Skip to content

Commit

Permalink
Release 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Dec 13, 2024
1 parent c9f4f75 commit d801ca7
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 161 deletions.
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,31 @@ Instantiate and use the client with the following:
import { ReferralExchangeClient } from "ogp-refx";

const client = new ReferralExchangeClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook({
key: "value",
await client.referrals.upsert({
patient: {
uin: "uin",
name: "name",
phoneNumber: "91234567",
dob: "1990-01-01",
gender: "Male",
},
offeringId: "offeringId",
senderHciCode: "senderHciCode",
senderInstitutionName: "senderInstitutionName",
doctorMcr: "doctorMcr",
doctorName: "doctorName",
doctorEmail: "doctorEmail",
doctorContactNumber: "doctorContactNumber",
isSubsidised: {
key: "value",
},
isUrgent: {
key: "value",
},
isDraft: {
key: "value",
},
formResponses: [{}],
});
```

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

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

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

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

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

```typescript
const controller = new AbortController();
const response = await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook(..., {
const response = await client.referrals.upsert(..., {
abortSignal: controller.signal
});
controller.abort(); // aborts the request
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ogp-refx",
"version": "0.0.1",
"version": "0.0.2",
"private": false,
"repository": "https://github.com/opengovsg/refer-ts-sdk",
"main": "./index.js",
Expand Down
100 changes: 48 additions & 52 deletions reference.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,5 @@
# Reference

<details><summary><code>client.<a href="/src/Client.ts">formSgWebhooksControllerHandleDoctorNotesFormWebhook</a>(formId) -> void</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```typescript
await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook({
key: "value",
});
```

</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**formId:** `unknown`

</dd>
</dl>

<dl>
<dd>

**requestOptions:** `ReferralExchangeClient.RequestOptions`

</dd>
</dl>
</dd>
</dl>

</dd>
</dl>
</details>

##

## Eligibility

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

<details><summary><code>client.webhooks.<a href="/src/api/resources/webhooks/client/Client.ts">handleDoctorNotes</a>(formId) -> void</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```typescript
await client.webhooks.handleDoctorNotes("formId");
```

</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**formId:** `string`

</dd>
</dl>

<dl>
<dd>

**requestOptions:** `Webhooks.RequestOptions`

</dd>
</dl>
</dd>
</dl>

</dd>
</dl>
</details>

## Health

<details><summary><code>client.health.<a href="/src/api/resources/health/client/Client.ts">check</a>() -> ReferralExchange.OkResponse</code></summary>
Expand Down
70 changes: 0 additions & 70 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/

import * as core from "./core";
import urlJoin from "url-join";
import * as errors from "./errors/index";
import { Eligibility } from "./api/resources/eligibility/client/Client";
import { Referrals } from "./api/resources/referrals/client/Client";
import { Offerings } from "./api/resources/offerings/client/Client";
Expand Down Expand Up @@ -64,72 +62,4 @@ export class ReferralExchangeClient {
public get health(): Health {
return (this._health ??= new Health(this._options));
}

/**
* @param {unknown} formId
* @param {ReferralExchangeClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @example
* await client.formSgWebhooksControllerHandleDoctorNotesFormWebhook({
* "key": "value"
* })
*/
public async formSgWebhooksControllerHandleDoctorNotesFormWebhook(
formId: unknown,
requestOptions?: ReferralExchangeClient.RequestOptions
): Promise<void> {
const _response = await (this._options.fetcher ?? core.fetcher)({
url: urlJoin(
await core.Supplier.get(this._options.environment),
`api/v1/webhooks/formsg/form-submission/${encodeURIComponent(formId)}`
),
method: "POST",
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return;
}

if (_response.error.reason === "status-code") {
throw new errors.ReferralExchangeError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}

switch (_response.error.reason) {
case "non-json":
throw new errors.ReferralExchangeError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.ReferralExchangeTimeoutError(
"Timeout exceeded when calling POST /api/v1/webhooks/formsg/form-submission/{formId}."
);
case "unknown":
throw new errors.ReferralExchangeError({
message: _response.error.errorMessage,
});
}
}

protected async _getCustomAuthorizationHeaders() {
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
return { Authorization: apiKeyValue };
}
}
4 changes: 2 additions & 2 deletions src/api/resources/eligibility/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export class Eligibility {
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-SDK-Version": "0.0.2",
"User-Agent": "ogp-refx/0.0.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand Down
4 changes: 2 additions & 2 deletions src/api/resources/health/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class Health {
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-SDK-Version": "0.0.2",
"User-Agent": "ogp-refx/0.0.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand Down
12 changes: 6 additions & 6 deletions src/api/resources/offerings/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class Offerings {
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-SDK-Version": "0.0.2",
"User-Agent": "ogp-refx/0.0.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand Down Expand Up @@ -101,8 +101,8 @@ export class Offerings {
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-SDK-Version": "0.0.2",
"User-Agent": "ogp-refx/0.0.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand Down Expand Up @@ -173,8 +173,8 @@ export class Offerings {
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-SDK-Version": "0.0.2",
"User-Agent": "ogp-refx/0.0.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand Down
4 changes: 2 additions & 2 deletions src/api/resources/public/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export class Public {
headers: {
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "ogp-refx",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "ogp-refx/0.0.1",
"X-Fern-SDK-Version": "0.0.2",
"User-Agent": "ogp-refx/0.0.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand Down
Loading

0 comments on commit d801ca7

Please sign in to comment.