Skip to content

Commit

Permalink
(feat): update with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] authored May 22, 2024
1 parent cda1f60 commit ab552a4
Show file tree
Hide file tree
Showing 260 changed files with 2,787 additions and 715 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- name: Compile
run: yarn && yarn build

test:
runs-on: ubuntu-latest

Expand All @@ -27,13 +27,13 @@ jobs:
uses: actions/setup-node@v3

- name: Compile
run: yarn && yarn test
run: yarn && yarn test

publish:
needs: [ compile, test ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand Down
11 changes: 1 addition & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
node_modules
.DS_Store
/dist
/Client.d.ts
/Client.js
/environments.d.ts
/environments.js
/index.d.ts
/index.js
/api
/core
/errors
/dist
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
src
tests
.gitignore
.github
.fernignore
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
/** @type {import('jest').Config} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
};
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "@trycourier/courier",
"version": "v6.1.1",
"version": "v6.1.2",
"private": false,
"repository": "https://github.com/trycourier/courier-node",
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"format": "prettier --write 'src/**/*.ts'",
"format": "prettier . --write --ignore-unknown",
"build": "tsc",
"prepack": "cp -rv dist/. .",
"test": "jest"
},
"dependencies": {
"url-join": "4.0.1",
"form-data": "4.0.0",
"formdata-node": "^6.0.3",
"node-fetch": "2.7.0",
"qs": "6.11.2",
"js-base64": "3.7.2"
Expand All @@ -22,11 +23,12 @@
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"jest": "^29.7.0",
"@types/jest": "^29.5.5",
"ts-jest": "^29.1.1",
"jest": "29.7.0",
"@types/jest": "29.5.5",
"ts-jest": "29.1.1",
"jest-environment-jsdom": "29.7.0",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4"
}
}
}
48 changes: 39 additions & 9 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import * as environments from "./environments";
import * as core from "./core";
import * as Courier from "./api";
import * as Courier from "./api/index";
import urlJoin from "url-join";
import * as errors from "./errors";
import * as errors from "./errors/index";
import { Audiences } from "./api/resources/audiences/client/Client";
import { AuditEvents } from "./api/resources/auditEvents/client/Client";
import { AuthTokens } from "./api/resources/authTokens/client/Client";
Expand Down Expand Up @@ -36,7 +36,7 @@ export declare namespace CourierClient {

interface IdempotentRequestOptions extends RequestOptions {
idempotencyKey?: string | undefined;
idempotencyExpiry?: number | undefined;
idempotencyExpiry?: string | undefined;
}
}

Expand All @@ -45,6 +45,35 @@ export class CourierClient {

/**
* Use the send API to send a message to one or more recipients.
*
* @param {Courier.SendMessageRequest} request
* @param {CourierClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
*
* @example
* await courier.send({
* message: {
* content: {},
* data: {
* "string": {
* "key": "value"
* }
* },
* brand_id: "string",
* channels: {
* "string": {}
* },
* context: {},
* metadata: {},
* providers: {
* "string": {}
* },
* routing: {},
* timeout: {},
* delay: {},
* expiry: {},
* to: {}
* }
* })
*/
public async send(
request: Courier.SendMessageRequest,
Expand All @@ -60,12 +89,12 @@ export class CourierClient {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "v6.1.1",
"X-Fern-SDK-Version": "v6.1.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
"Idempotency-Key": requestOptions?.idempotencyKey != null ? requestOptions?.idempotencyKey : undefined,
"X-Idempotency-Expiration":
requestOptions?.idempotencyExpiry != null
? requestOptions?.idempotencyExpiry.toString()
: undefined,
requestOptions?.idempotencyExpiry != null ? requestOptions?.idempotencyExpiry : undefined,
},
contentType: "application/json",
body: request,
Expand Down Expand Up @@ -182,8 +211,9 @@ export class CourierClient {
return (this._users ??= new Users(this._options));
}

protected async _getAuthorizationHeader() {
const bearer = (await core.Supplier.get(this._options.authorizationToken)) ?? process.env["COURIER_AUTH_TOKEN"];
protected async _getAuthorizationHeader(): Promise<string> {
const bearer =
(await core.Supplier.get(this._options.authorizationToken)) ?? process?.env["COURIER_AUTH_TOKEN"];
if (bearer == null) {
throw new errors.CourierError({
message: "Please specify COURIER_AUTH_TOKEN when instantiating the client.",
Expand Down
29 changes: 28 additions & 1 deletion src/api/client/requests/SendMessageRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,35 @@
* This file was auto-generated by Fern from our API Definition.
*/

import * as Courier from "../..";
import * as Courier from "../../index";

/**
* @example
* {
* message: {
* content: {},
* data: {
* "string": {
* "key": "value"
* }
* },
* brand_id: "string",
* channels: {
* "string": {}
* },
* context: {},
* metadata: {},
* providers: {
* "string": {}
* },
* routing: {},
* timeout: {},
* delay: {},
* expiry: {},
* to: {}
* }
* }
*/
export interface SendMessageRequest {
/** Defines the message to be delivered */
message: Courier.Message;
Expand Down
2 changes: 1 addition & 1 deletion src/api/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { SendMessageRequest } from "./SendMessageRequest";
export { type SendMessageRequest } from "./SendMessageRequest";
Loading

0 comments on commit ab552a4

Please # to comment.