Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Dec 14, 2023
1 parent 5fd5d50 commit 279c5db
Show file tree
Hide file tree
Showing 67 changed files with 1,120 additions and 187 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/courier",
"version": "6.0.1",
"version": "6.0.2",
"private": false,
"repository": "https://github.com/trycourier/courier-node",
"main": "./index.js",
Expand All @@ -12,13 +12,15 @@
},
"dependencies": {
"url-join": "4.0.1",
"@types/url-join": "4.0.1",
"axios": "0.27.2",
"form-data": "4.0.0",
"node-fetch": "2.7.0",
"qs": "6.11.2",
"@types/qs": "6.9.8",
"js-base64": "3.7.2"
},
"devDependencies": {
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4"
Expand Down
13 changes: 10 additions & 3 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Brands } from "./api/resources/brands/client/Client";
import { Bulk } from "./api/resources/bulk/client/Client";
import { Lists } from "./api/resources/lists/client/Client";
import { Messages } from "./api/resources/messages/client/Client";
import { Notifications } from "./api/resources/notifications/client/Client";
import { Profiles } from "./api/resources/profiles/client/Client";
import { Templates } from "./api/resources/templates/client/Client";
import { Tenants } from "./api/resources/tenants/client/Client";
Expand All @@ -25,7 +26,7 @@ import { UserPreferences } from "./api/resources/userPreferences/client/Client";
export declare namespace CourierClient {
interface Options {
environment?: core.Supplier<environments.CourierEnvironment | string>;
authorizationToken: core.Supplier<core.BearerToken | undefined>;
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
}

interface RequestOptions {
Expand All @@ -40,7 +41,7 @@ export declare namespace CourierClient {
}

export class CourierClient {
constructor(protected readonly _options: CourierClient.Options) {}
constructor(protected readonly _options: CourierClient.Options = {}) {}

/**
* Use the send API to send a message to one or more recipients.
Expand All @@ -59,7 +60,7 @@ export class CourierClient {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
"Idempotency-Key": requestOptions?.idempotencyKey != null ? requestOptions?.idempotencyKey : undefined,
"X-Idempotency-Expiration":
requestOptions?.idempotencyExpiry != null
Expand Down Expand Up @@ -145,6 +146,12 @@ export class CourierClient {
return (this._messages ??= new Messages(this._options));
}

protected _notifications: Notifications | undefined;

public get notifications(): Notifications {
return (this._notifications ??= new Notifications(this._options));
}

protected _profiles: Profiles | undefined;

public get profiles(): Profiles {
Expand Down
14 changes: 7 additions & 7 deletions src/api/resources/audiences/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as errors from "../../../../errors";
export declare namespace Audiences {
interface Options {
environment?: core.Supplier<environments.CourierEnvironment | string>;
authorizationToken: core.Supplier<core.BearerToken | undefined>;
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
}

interface RequestOptions {
Expand All @@ -21,7 +21,7 @@ export declare namespace Audiences {
}

export class Audiences {
constructor(protected readonly _options: Audiences.Options) {}
constructor(protected readonly _options: Audiences.Options = {}) {}

/**
* Returns the specified audience by id.
Expand All @@ -37,7 +37,7 @@ export class Audiences {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -87,7 +87,7 @@ export class Audiences {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
body: request,
Expand Down Expand Up @@ -134,7 +134,7 @@ export class Audiences {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -191,7 +191,7 @@ export class Audiences {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down Expand Up @@ -253,7 +253,7 @@ export class Audiences {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down
8 changes: 4 additions & 4 deletions src/api/resources/auditEvents/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as errors from "../../../../errors";
export declare namespace AuditEvents {
interface Options {
environment?: core.Supplier<environments.CourierEnvironment | string>;
authorizationToken: core.Supplier<core.BearerToken | undefined>;
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
}

interface RequestOptions {
Expand All @@ -21,7 +21,7 @@ export declare namespace AuditEvents {
}

export class AuditEvents {
constructor(protected readonly _options: AuditEvents.Options) {}
constructor(protected readonly _options: AuditEvents.Options = {}) {}

/**
* Fetch the list of audit events
Expand All @@ -46,7 +46,7 @@ export class AuditEvents {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down Expand Up @@ -93,7 +93,7 @@ export class AuditEvents {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down
6 changes: 3 additions & 3 deletions src/api/resources/authTokens/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as errors from "../../../../errors";
export declare namespace AuthTokens {
interface Options {
environment?: core.Supplier<environments.CourierEnvironment | string>;
authorizationToken: core.Supplier<core.BearerToken | undefined>;
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
}

interface RequestOptions {
Expand All @@ -26,7 +26,7 @@ export declare namespace AuthTokens {
}

export class AuthTokens {
constructor(protected readonly _options: AuthTokens.Options) {}
constructor(protected readonly _options: AuthTokens.Options = {}) {}

/**
* Returns a new access token.
Expand All @@ -45,7 +45,7 @@ export class AuthTokens {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
"Idempotency-Key": requestOptions?.idempotencyKey != null ? requestOptions?.idempotencyKey : undefined,
"X-Idempotency-Expiration":
requestOptions?.idempotencyExpiry != null
Expand Down
16 changes: 9 additions & 7 deletions src/api/resources/automations/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as Courier from "../../..";
import urlJoin from "url-join";
import * as errors from "../../../../errors";
import * as Courier from "../../..";

export declare namespace Automations {
interface Options {
environment?: core.Supplier<environments.CourierEnvironment | string>;
authorizationToken: core.Supplier<core.BearerToken | undefined>;
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
}

interface RequestOptions {
Expand All @@ -26,15 +26,16 @@ export declare namespace Automations {
}

export class Automations {
constructor(protected readonly _options: Automations.Options) {}
constructor(protected readonly _options: Automations.Options = {}) {}

/**
* Invoke an automation run from an automation template.
*/
public async invokeAutomationTemplate(
templateId: string,
request: Courier.AutomationInvokeParams,
requestOptions?: Automations.IdempotentRequestOptions
): Promise<void> {
): Promise<Courier.AutomationInvokeResponse> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.CourierEnvironment.Production,
Expand All @@ -45,19 +46,20 @@ export class Automations {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
"Idempotency-Key": requestOptions?.idempotencyKey != null ? requestOptions?.idempotencyKey : undefined,
"X-Idempotency-Expiration":
requestOptions?.idempotencyExpiry != null
? requestOptions?.idempotencyExpiry.toString()
: undefined,
},
contentType: "application/json",
body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return;
return _response.body as Courier.AutomationInvokeResponse;
}

if (_response.error.reason === "status-code") {
Expand Down Expand Up @@ -99,7 +101,7 @@ export class Automations {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
"Idempotency-Key": requestOptions?.idempotencyKey != null ? requestOptions?.idempotencyKey : undefined,
"X-Idempotency-Expiration":
requestOptions?.idempotencyExpiry != null
Expand Down
63 changes: 57 additions & 6 deletions src/api/resources/brands/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as errors from "../../../../errors";
export declare namespace Brands {
interface Options {
environment?: core.Supplier<environments.CourierEnvironment | string>;
authorizationToken: core.Supplier<core.BearerToken | undefined>;
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
}

interface RequestOptions {
Expand All @@ -26,7 +26,7 @@ export declare namespace Brands {
}

export class Brands {
constructor(protected readonly _options: Brands.Options) {}
constructor(protected readonly _options: Brands.Options = {}) {}

/**
* @throws {@link Courier.BadRequestError}
Expand All @@ -47,7 +47,7 @@ export class Brands {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
"Idempotency-Key": requestOptions?.idempotencyKey != null ? requestOptions?.idempotencyKey : undefined,
"X-Idempotency-Expiration":
requestOptions?.idempotencyExpiry != null
Expand Down Expand Up @@ -108,7 +108,7 @@ export class Brands {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -163,7 +163,7 @@ export class Brands {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down Expand Up @@ -211,7 +211,7 @@ export class Brands {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.1",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -248,6 +248,57 @@ export class Brands {
}
}

/**
* Replace an existing brand with the supplied values.
*/
public async replace(
brandId: string,
request: Courier.BrandUpdateParameters,
requestOptions?: Brands.RequestOptions
): Promise<Courier.Brand> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.CourierEnvironment.Production,
`/brands/${brandId}`
),
method: "PUT",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@trycourier/courier",
"X-Fern-SDK-Version": "6.0.2",
},
contentType: "application/json",
body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return _response.body as Courier.Brand;
}

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

switch (_response.error.reason) {
case "non-json":
throw new errors.CourierError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.CourierTimeoutError();
case "unknown":
throw new errors.CourierError({
message: _response.error.errorMessage,
});
}
}

protected async _getAuthorizationHeader() {
const bearer = (await core.Supplier.get(this._options.authorizationToken)) ?? process.env["COURIER_AUTH_TOKEN"];
if (bearer == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/

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

export interface BrandPutParameters {
id: string;
export interface BrandUpdateParameters {
/** The name of the brand. */
name: string;
settings: Courier.BrandSettings;
settings?: Courier.BrandSettings;
snippets?: Courier.BrandSnippets;
}
1 change: 1 addition & 0 deletions src/api/resources/brands/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { ListBrandsRequest } from "./ListBrandsRequest";
export { BrandUpdateParameters } from "./BrandUpdateParameters";

0 comments on commit 279c5db

Please sign in to comment.