Skip to content

Commit a64d112

Browse files
committed
Release 0.0.7
1 parent 361c846 commit a64d112

28 files changed

+328
-73
lines changed

README.md

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

2525
const client = new ReferralExchangeClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
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: [{}],
26+
await client.apiHoldingControllerCreateNote("referralId", {
27+
authorHciCode: "authorHciCode",
5128
});
5229
```
5330

@@ -73,7 +50,7 @@ will be thrown.
7350
import { ReferralExchangeError } from "@opengovsg/refx-ts-sdk";
7451

7552
try {
76-
await client.referrals.upsert(...);
53+
await client.apiHoldingControllerCreateNote(...);
7754
} catch (err) {
7855
if (err instanceof ReferralExchangeError) {
7956
console.log(err.statusCode);
@@ -90,7 +67,7 @@ try {
9067
If you would like to send additional headers as part of the request, use the `headers` request option.
9168

9269
```typescript
93-
const response = await client.referrals.upsert(..., {
70+
const response = await client.apiHoldingControllerCreateNote(..., {
9471
headers: {
9572
'X-Custom-Header': 'custom value'
9673
}
@@ -112,7 +89,7 @@ A request is deemed retriable when any of the following HTTP status codes is ret
11289
Use the `maxRetries` request option to configure this behavior.
11390

11491
```typescript
115-
const response = await client.referrals.upsert(..., {
92+
const response = await client.apiHoldingControllerCreateNote(..., {
11693
maxRetries: 0 // override maxRetries at the request level
11794
});
11895
```
@@ -122,7 +99,7 @@ const response = await client.referrals.upsert(..., {
12299
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
123100

124101
```typescript
125-
const response = await client.referrals.upsert(..., {
102+
const response = await client.apiHoldingControllerCreateNote(..., {
126103
timeoutInSeconds: 30 // override timeout to 30s
127104
});
128105
```
@@ -133,7 +110,7 @@ The SDK allows users to abort requests at any point by passing in an abort signa
133110

134111
```typescript
135112
const controller = new AbortController();
136-
const response = await client.referrals.upsert(..., {
113+
const response = await client.apiHoldingControllerCreateNote(..., {
137114
abortSignal: controller.signal
138115
});
139116
controller.abort(); // aborts the request

package.json

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

reference.md

+68-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# Reference
22

3+
<details><summary><code>client.<a href="/src/Client.ts">apiHoldingControllerBackToDraftReferral</a>(referralId) -> ReferralExchange.ReferralDto</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.apiHoldingControllerBackToDraftReferral("referralId");
17+
```
18+
19+
</dd>
20+
</dl>
21+
</dd>
22+
</dl>
23+
24+
#### ⚙️ Parameters
25+
26+
<dl>
27+
<dd>
28+
29+
<dl>
30+
<dd>
31+
32+
**referralId:** `string`
33+
34+
</dd>
35+
</dl>
36+
37+
<dl>
38+
<dd>
39+
40+
**requestOptions:** `ReferralExchangeClient.RequestOptions`
41+
42+
</dd>
43+
</dl>
44+
</dd>
45+
</dl>
46+
47+
</dd>
48+
</dl>
49+
</details>
50+
51+
##
52+
353
## Eligibility
454

555
<details><summary><code>client.eligibility.<a href="/src/api/resources/eligibility/client/Client.ts">get</a>({ ...params }) -> ReferralExchange.EligibilityRes</code></summary>
@@ -178,7 +228,7 @@ await client.referrals.upsert({
178228
</dl>
179229
</details>
180230

181-
<details><summary><code>client.referrals.<a href="/src/api/resources/referrals/client/Client.ts">get</a>(referralId) -> ReferralExchange.FullReferralDto</code></summary>
231+
<details><summary><code>client.referrals.<a href="/src/api/resources/referrals/client/Client.ts">get</a>(referralId, { ...params }) -> ReferralExchange.FullReferralDto</code></summary>
182232
<dl>
183233
<dd>
184234

@@ -215,6 +265,14 @@ await client.referrals.get("referralId");
215265
<dl>
216266
<dd>
217267

268+
**request:** `ReferralExchange.ReferralsGetRequest`
269+
270+
</dd>
271+
</dl>
272+
273+
<dl>
274+
<dd>
275+
218276
**requestOptions:** `Referrals.RequestOptions`
219277

220278
</dd>
@@ -654,7 +712,7 @@ await client.offerings.listTimeslots("offeringId", {
654712

655713
## Public
656714

657-
<details><summary><code>client.public.<a href="/src/api/resources/public/client/Client.ts">getReferral</a>(referralId) -> ReferralExchange.PublicReferralDto[]</code></summary>
715+
<details><summary><code>client.public.<a href="/src/api/resources/public/client/Client.ts">getReferral</a>(referralId, { ...params }) -> ReferralExchange.PublicReferralDto[]</code></summary>
658716
<dl>
659717
<dd>
660718

@@ -691,6 +749,14 @@ await client.public.getReferral("referralId");
691749
<dl>
692750
<dd>
693751

752+
**request:** `ReferralExchange.PublicGetReferralRequest`
753+
754+
</dd>
755+
</dl>
756+
757+
<dl>
758+
<dd>
759+
694760
**requestOptions:** `Public.RequestOptions`
695761

696762
</dd>

src/Client.ts

+135
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*/
44

55
import * as core from "./core";
6+
import * as ReferralExchange from "./api/index";
7+
import urlJoin from "url-join";
8+
import * as errors from "./errors/index";
69
import { Eligibility } from "./api/resources/eligibility/client/Client";
710
import { Referrals } from "./api/resources/referrals/client/Client";
811
import { Offerings } from "./api/resources/offerings/client/Client";
@@ -62,4 +65,136 @@ export class ReferralExchangeClient {
6265
public get health(): Health {
6366
return (this._health ??= new Health(this._options));
6467
}
68+
69+
/**
70+
* @param {string} referralId
71+
* @param {ReferralExchange.CreateNoteReq} request
72+
* @param {ReferralExchangeClient.RequestOptions} requestOptions - Request-specific configuration.
73+
*
74+
* @example
75+
* await client.apiHoldingControllerCreateNote("referralId", {
76+
* authorHciCode: "authorHciCode"
77+
* })
78+
*/
79+
public async apiHoldingControllerCreateNote(
80+
referralId: string,
81+
request: ReferralExchange.CreateNoteReq,
82+
requestOptions?: ReferralExchangeClient.RequestOptions
83+
): Promise<ReferralExchange.NoteDto> {
84+
const _response = await (this._options.fetcher ?? core.fetcher)({
85+
url: urlJoin(
86+
await core.Supplier.get(this._options.environment),
87+
`api/v1/referrals/${encodeURIComponent(referralId)}/notes`
88+
),
89+
method: "POST",
90+
headers: {
91+
"X-Fern-Language": "JavaScript",
92+
"X-Fern-SDK-Name": "@opengovsg/refx-ts-sdk",
93+
"X-Fern-SDK-Version": "0.0.7",
94+
"User-Agent": "@opengovsg/refx-ts-sdk/0.0.7",
95+
"X-Fern-Runtime": core.RUNTIME.type,
96+
"X-Fern-Runtime-Version": core.RUNTIME.version,
97+
...(await this._getCustomAuthorizationHeaders()),
98+
...requestOptions?.headers,
99+
},
100+
contentType: "application/json",
101+
requestType: "json",
102+
body: request,
103+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
104+
maxRetries: requestOptions?.maxRetries,
105+
abortSignal: requestOptions?.abortSignal,
106+
});
107+
if (_response.ok) {
108+
return _response.body as ReferralExchange.NoteDto;
109+
}
110+
111+
if (_response.error.reason === "status-code") {
112+
throw new errors.ReferralExchangeError({
113+
statusCode: _response.error.statusCode,
114+
body: _response.error.body,
115+
});
116+
}
117+
118+
switch (_response.error.reason) {
119+
case "non-json":
120+
throw new errors.ReferralExchangeError({
121+
statusCode: _response.error.statusCode,
122+
body: _response.error.rawBody,
123+
});
124+
case "timeout":
125+
throw new errors.ReferralExchangeTimeoutError(
126+
"Timeout exceeded when calling POST /api/v1/referrals/{referralId}/notes."
127+
);
128+
case "unknown":
129+
throw new errors.ReferralExchangeError({
130+
message: _response.error.errorMessage,
131+
});
132+
}
133+
}
134+
135+
/**
136+
* @param {string} referralId
137+
* @param {ReferralExchangeClient.RequestOptions} requestOptions - Request-specific configuration.
138+
*
139+
* @example
140+
* await client.apiHoldingControllerBackToDraftReferral("referralId")
141+
*/
142+
public async apiHoldingControllerBackToDraftReferral(
143+
referralId: string,
144+
requestOptions?: ReferralExchangeClient.RequestOptions
145+
): Promise<ReferralExchange.ReferralDto> {
146+
const _response = await (this._options.fetcher ?? core.fetcher)({
147+
url: urlJoin(
148+
await core.Supplier.get(this._options.environment),
149+
`api/v1/referrals/${encodeURIComponent(referralId)}/back-to-draft`
150+
),
151+
method: "POST",
152+
headers: {
153+
"X-Fern-Language": "JavaScript",
154+
"X-Fern-SDK-Name": "@opengovsg/refx-ts-sdk",
155+
"X-Fern-SDK-Version": "0.0.7",
156+
"User-Agent": "@opengovsg/refx-ts-sdk/0.0.7",
157+
"X-Fern-Runtime": core.RUNTIME.type,
158+
"X-Fern-Runtime-Version": core.RUNTIME.version,
159+
...(await this._getCustomAuthorizationHeaders()),
160+
...requestOptions?.headers,
161+
},
162+
contentType: "application/json",
163+
requestType: "json",
164+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
165+
maxRetries: requestOptions?.maxRetries,
166+
abortSignal: requestOptions?.abortSignal,
167+
});
168+
if (_response.ok) {
169+
return _response.body as ReferralExchange.ReferralDto;
170+
}
171+
172+
if (_response.error.reason === "status-code") {
173+
throw new errors.ReferralExchangeError({
174+
statusCode: _response.error.statusCode,
175+
body: _response.error.body,
176+
});
177+
}
178+
179+
switch (_response.error.reason) {
180+
case "non-json":
181+
throw new errors.ReferralExchangeError({
182+
statusCode: _response.error.statusCode,
183+
body: _response.error.rawBody,
184+
});
185+
case "timeout":
186+
throw new errors.ReferralExchangeTimeoutError(
187+
"Timeout exceeded when calling POST /api/v1/referrals/{referralId}/back-to-draft."
188+
);
189+
case "unknown":
190+
throw new errors.ReferralExchangeError({
191+
message: _response.error.errorMessage,
192+
});
193+
}
194+
}
195+
196+
protected async _getCustomAuthorizationHeaders() {
197+
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
198+
return { Authorization: apiKeyValue };
199+
}
65200
}

src/api/client/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./requests";
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
/**
6+
* @example
7+
* {
8+
* authorHciCode: "authorHciCode"
9+
* }
10+
*/
11+
export interface CreateNoteReq {
12+
/** Note content - plaintext. */
13+
content?: string;
14+
/** Author HCI code. Must be already tied by your system. */
15+
authorHciCode: string;
16+
}

src/api/client/requests/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { type CreateNoteReq } from "./CreateNoteReq";

src/api/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./resources";
22
export * from "./types";
33
export * from "./errors";
4+
export * from "./client";

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": "@opengovsg/refx-ts-sdk",
56-
"X-Fern-SDK-Version": "2024.10.3",
57-
"User-Agent": "@opengovsg/refx-ts-sdk/2024.10.3",
56+
"X-Fern-SDK-Version": "0.0.7",
57+
"User-Agent": "@opengovsg/refx-ts-sdk/0.0.7",
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": "@opengovsg/refx-ts-sdk",
45-
"X-Fern-SDK-Version": "2024.10.3",
46-
"User-Agent": "@opengovsg/refx-ts-sdk/2024.10.3",
45+
"X-Fern-SDK-Version": "0.0.7",
46+
"User-Agent": "@opengovsg/refx-ts-sdk/0.0.7",
4747
"X-Fern-Runtime": core.RUNTIME.type,
4848
"X-Fern-Runtime-Version": core.RUNTIME.version,
4949
...(await this._getCustomAuthorizationHeaders()),

src/api/resources/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * as health from "./health";
88
export * from "./eligibility/client/requests";
99
export * from "./referrals/client/requests";
1010
export * from "./offerings/client/requests";
11+
export * from "./public/client/requests";

0 commit comments

Comments
 (0)