Skip to content

Commit d801ca7

Browse files
committed
Release 0.0.2
1 parent c9f4f75 commit d801ca7

File tree

11 files changed

+168
-161
lines changed

11 files changed

+168
-161
lines changed

README.md

+30-7
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,31 @@ Instantiate and use the client with the following:
2323
import { ReferralExchangeClient } from "ogp-refx";
2424

2525
const client = new ReferralExchangeClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
26-
await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook({
27-
key: "value",
26+
await client.referrals.upsert({
27+
patient: {
28+
uin: "uin",
29+
name: "name",
30+
phoneNumber: "91234567",
31+
dob: "1990-01-01",
32+
gender: "Male",
33+
},
34+
offeringId: "offeringId",
35+
senderHciCode: "senderHciCode",
36+
senderInstitutionName: "senderInstitutionName",
37+
doctorMcr: "doctorMcr",
38+
doctorName: "doctorName",
39+
doctorEmail: "doctorEmail",
40+
doctorContactNumber: "doctorContactNumber",
41+
isSubsidised: {
42+
key: "value",
43+
},
44+
isUrgent: {
45+
key: "value",
46+
},
47+
isDraft: {
48+
key: "value",
49+
},
50+
formResponses: [{}],
2851
});
2952
```
3053

@@ -50,7 +73,7 @@ will be thrown.
5073
import { ReferralExchangeError } from "ogp-refx";
5174

5275
try {
53-
await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook(...);
76+
await client.referrals.upsert(...);
5477
} catch (err) {
5578
if (err instanceof ReferralExchangeError) {
5679
console.log(err.statusCode);
@@ -67,7 +90,7 @@ try {
6790
If you would like to send additional headers as part of the request, use the `headers` request option.
6891

6992
```typescript
70-
const response = await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook(..., {
93+
const response = await client.referrals.upsert(..., {
7194
headers: {
7295
'X-Custom-Header': 'custom value'
7396
}
@@ -89,7 +112,7 @@ A request is deemed retriable when any of the following HTTP status codes is ret
89112
Use the `maxRetries` request option to configure this behavior.
90113

91114
```typescript
92-
const response = await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook(..., {
115+
const response = await client.referrals.upsert(..., {
93116
maxRetries: 0 // override maxRetries at the request level
94117
});
95118
```
@@ -99,7 +122,7 @@ const response = await client.formSgWebhooksControllerHandleDoctorNotesFormWebho
99122
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
100123

101124
```typescript
102-
const response = await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook(..., {
125+
const response = await client.referrals.upsert(..., {
103126
timeoutInSeconds: 30 // override timeout to 30s
104127
});
105128
```
@@ -110,7 +133,7 @@ The SDK allows users to abort requests at any point by passing in an abort signa
110133

111134
```typescript
112135
const controller = new AbortController();
113-
const response = await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook(..., {
136+
const response = await client.referrals.upsert(..., {
114137
abortSignal: controller.signal
115138
});
116139
controller.abort(); // aborts the request

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ogp-refx",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"private": false,
55
"repository": "https://github.com/opengovsg/refer-ts-sdk",
66
"main": "./index.js",

reference.md

+48-52
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,5 @@
11
# Reference
22

3-
<details><summary><code>client.<a href="/src/Client.ts">formSgWebhooksControllerHandleDoctorNotesFormWebhook</a>(formId) -> void</code></summary>
4-
<dl>
5-
<dd>
6-
7-
#### 🔌 Usage
8-
9-
<dl>
10-
<dd>
11-
12-
<dl>
13-
<dd>
14-
15-
```typescript
16-
await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook({
17-
key: "value",
18-
});
19-
```
20-
21-
</dd>
22-
</dl>
23-
</dd>
24-
</dl>
25-
26-
#### ⚙️ Parameters
27-
28-
<dl>
29-
<dd>
30-
31-
<dl>
32-
<dd>
33-
34-
**formId:** `unknown`
35-
36-
</dd>
37-
</dl>
38-
39-
<dl>
40-
<dd>
41-
42-
**requestOptions:** `ReferralExchangeClient.RequestOptions`
43-
44-
</dd>
45-
</dl>
46-
</dd>
47-
</dl>
48-
49-
</dd>
50-
</dl>
51-
</details>
52-
53-
##
54-
553
## Eligibility
564

575
<details><summary><code>client.eligibility.<a href="/src/api/resources/eligibility/client/Client.ts">get</a>({ ...params }) -> ReferralExchange.EligibilityRes</code></summary>
@@ -796,6 +744,54 @@ await client.webhooks.handleSinghealthProfile();
796744
</dl>
797745
</details>
798746

747+
<details><summary><code>client.webhooks.<a href="/src/api/resources/webhooks/client/Client.ts">handleDoctorNotes</a>(formId) -> void</code></summary>
748+
<dl>
749+
<dd>
750+
751+
#### 🔌 Usage
752+
753+
<dl>
754+
<dd>
755+
756+
<dl>
757+
<dd>
758+
759+
```typescript
760+
await client.webhooks.handleDoctorNotes("formId");
761+
```
762+
763+
</dd>
764+
</dl>
765+
</dd>
766+
</dl>
767+
768+
#### ⚙️ Parameters
769+
770+
<dl>
771+
<dd>
772+
773+
<dl>
774+
<dd>
775+
776+
**formId:** `string`
777+
778+
</dd>
779+
</dl>
780+
781+
<dl>
782+
<dd>
783+
784+
**requestOptions:** `Webhooks.RequestOptions`
785+
786+
</dd>
787+
</dl>
788+
</dd>
789+
</dl>
790+
791+
</dd>
792+
</dl>
793+
</details>
794+
799795
## Health
800796

801797
<details><summary><code>client.health.<a href="/src/api/resources/health/client/Client.ts">check</a>() -> ReferralExchange.OkResponse</code></summary>

src/Client.ts

-70
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*/
44

55
import * as core from "./core";
6-
import urlJoin from "url-join";
7-
import * as errors from "./errors/index";
86
import { Eligibility } from "./api/resources/eligibility/client/Client";
97
import { Referrals } from "./api/resources/referrals/client/Client";
108
import { Offerings } from "./api/resources/offerings/client/Client";
@@ -64,72 +62,4 @@ export class ReferralExchangeClient {
6462
public get health(): Health {
6563
return (this._health ??= new Health(this._options));
6664
}
67-
68-
/**
69-
* @param {unknown} formId
70-
* @param {ReferralExchangeClient.RequestOptions} requestOptions - Request-specific configuration.
71-
*
72-
* @example
73-
* await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook({
74-
* "key": "value"
75-
* })
76-
*/
77-
public async formSgWebhooksControllerHandleDoctorNotesFormWebhook(
78-
formId: unknown,
79-
requestOptions?: ReferralExchangeClient.RequestOptions
80-
): Promise<void> {
81-
const _response = await (this._options.fetcher ?? core.fetcher)({
82-
url: urlJoin(
83-
await core.Supplier.get(this._options.environment),
84-
`api/v1/webhooks/formsg/form-submission/${encodeURIComponent(formId)}`
85-
),
86-
method: "POST",
87-
headers: {
88-
"X-Fern-Language": "JavaScript",
89-
"X-Fern-SDK-Name": "ogp-refx",
90-
"X-Fern-SDK-Version": "0.0.1",
91-
"User-Agent": "ogp-refx/0.0.1",
92-
"X-Fern-Runtime": core.RUNTIME.type,
93-
"X-Fern-Runtime-Version": core.RUNTIME.version,
94-
...(await this._getCustomAuthorizationHeaders()),
95-
...requestOptions?.headers,
96-
},
97-
contentType: "application/json",
98-
requestType: "json",
99-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
100-
maxRetries: requestOptions?.maxRetries,
101-
abortSignal: requestOptions?.abortSignal,
102-
});
103-
if (_response.ok) {
104-
return;
105-
}
106-
107-
if (_response.error.reason === "status-code") {
108-
throw new errors.ReferralExchangeError({
109-
statusCode: _response.error.statusCode,
110-
body: _response.error.body,
111-
});
112-
}
113-
114-
switch (_response.error.reason) {
115-
case "non-json":
116-
throw new errors.ReferralExchangeError({
117-
statusCode: _response.error.statusCode,
118-
body: _response.error.rawBody,
119-
});
120-
case "timeout":
121-
throw new errors.ReferralExchangeTimeoutError(
122-
"Timeout exceeded when calling POST /api/v1/webhooks/formsg/form-submission/{formId}."
123-
);
124-
case "unknown":
125-
throw new errors.ReferralExchangeError({
126-
message: _response.error.errorMessage,
127-
});
128-
}
129-
}
130-
131-
protected async _getCustomAuthorizationHeaders() {
132-
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
133-
return { Authorization: apiKeyValue };
134-
}
13565
}

src/api/resources/eligibility/client/Client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export class Eligibility {
5353
headers: {
5454
"X-Fern-Language": "JavaScript",
5555
"X-Fern-SDK-Name": "ogp-refx",
56-
"X-Fern-SDK-Version": "0.0.1",
57-
"User-Agent": "ogp-refx/0.0.1",
56+
"X-Fern-SDK-Version": "0.0.2",
57+
"User-Agent": "ogp-refx/0.0.2",
5858
"X-Fern-Runtime": core.RUNTIME.type,
5959
"X-Fern-Runtime-Version": core.RUNTIME.version,
6060
...(await this._getCustomAuthorizationHeaders()),

src/api/resources/health/client/Client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export class Health {
4242
headers: {
4343
"X-Fern-Language": "JavaScript",
4444
"X-Fern-SDK-Name": "ogp-refx",
45-
"X-Fern-SDK-Version": "0.0.1",
46-
"User-Agent": "ogp-refx/0.0.1",
45+
"X-Fern-SDK-Version": "0.0.2",
46+
"User-Agent": "ogp-refx/0.0.2",
4747
"X-Fern-Runtime": core.RUNTIME.type,
4848
"X-Fern-Runtime-Version": core.RUNTIME.version,
4949
...(await this._getCustomAuthorizationHeaders()),

src/api/resources/offerings/client/Client.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export class Offerings {
4242
headers: {
4343
"X-Fern-Language": "JavaScript",
4444
"X-Fern-SDK-Name": "ogp-refx",
45-
"X-Fern-SDK-Version": "0.0.1",
46-
"User-Agent": "ogp-refx/0.0.1",
45+
"X-Fern-SDK-Version": "0.0.2",
46+
"User-Agent": "ogp-refx/0.0.2",
4747
"X-Fern-Runtime": core.RUNTIME.type,
4848
"X-Fern-Runtime-Version": core.RUNTIME.version,
4949
...(await this._getCustomAuthorizationHeaders()),
@@ -101,8 +101,8 @@ export class Offerings {
101101
headers: {
102102
"X-Fern-Language": "JavaScript",
103103
"X-Fern-SDK-Name": "ogp-refx",
104-
"X-Fern-SDK-Version": "0.0.1",
105-
"User-Agent": "ogp-refx/0.0.1",
104+
"X-Fern-SDK-Version": "0.0.2",
105+
"User-Agent": "ogp-refx/0.0.2",
106106
"X-Fern-Runtime": core.RUNTIME.type,
107107
"X-Fern-Runtime-Version": core.RUNTIME.version,
108108
...(await this._getCustomAuthorizationHeaders()),
@@ -173,8 +173,8 @@ export class Offerings {
173173
headers: {
174174
"X-Fern-Language": "JavaScript",
175175
"X-Fern-SDK-Name": "ogp-refx",
176-
"X-Fern-SDK-Version": "0.0.1",
177-
"User-Agent": "ogp-refx/0.0.1",
176+
"X-Fern-SDK-Version": "0.0.2",
177+
"User-Agent": "ogp-refx/0.0.2",
178178
"X-Fern-Runtime": core.RUNTIME.type,
179179
"X-Fern-Runtime-Version": core.RUNTIME.version,
180180
...(await this._getCustomAuthorizationHeaders()),

src/api/resources/public/client/Client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export class Public {
5151
headers: {
5252
"X-Fern-Language": "JavaScript",
5353
"X-Fern-SDK-Name": "ogp-refx",
54-
"X-Fern-SDK-Version": "0.0.1",
55-
"User-Agent": "ogp-refx/0.0.1",
54+
"X-Fern-SDK-Version": "0.0.2",
55+
"User-Agent": "ogp-refx/0.0.2",
5656
"X-Fern-Runtime": core.RUNTIME.type,
5757
"X-Fern-Runtime-Version": core.RUNTIME.version,
5858
...(await this._getCustomAuthorizationHeaders()),

0 commit comments

Comments
 (0)