Skip to content

Commit

Permalink
chore: regenerate api clients to include deliveryconfig (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
smeijer authored Oct 15, 2024
1 parent 76666a9 commit 535534f
Show file tree
Hide file tree
Showing 16 changed files with 532 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-dingos-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@magicbell/project-client': minor
---

add deliveryconfig endpoints
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# CategoryDeliveryPlan

**Properties**

| Name | Type | Required | Description |
| :------- | :----------------------------- | :------- | :---------- |
| category | string || |
| channels | CategoryDeliveryPlanChannels[] || |
| disabled | boolean || |

# CategoryDeliveryPlanChannels

**Properties**

| Name | Type | Required | Description |
| :------ | :--------------- | :------- | :---------- |
| channel | ChannelsChannel2 || |
| delay | number || |
| if | string || |

# ChannelsChannel2

**Properties**

| Name | Type | Required | Description |
| :--------- | :----- | :------- | :------------ |
| INAPP | string || "in_app" |
| SLACK | string || "slack" |
| WEBPUSH | string || "web_push" |
| MOBILEPUSH | string || "mobile_push" |
| TEAMS | string || "teams" |
| EMAIL | string || "email" |
31 changes: 31 additions & 0 deletions packages/project-client/documentation/models/DeliveryPlan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# DeliveryPlan

**Properties**

| Name | Type | Required | Description |
| :------- | :--------------------- | :------- | :---------- |
| channels | DeliveryPlanChannels[] || |

# DeliveryPlanChannels

**Properties**

| Name | Type | Required | Description |
| :------ | :--------------- | :------- | :---------- |
| channel | ChannelsChannel1 || |
| delay | number || |
| if | string || |

# ChannelsChannel1

**Properties**

| Name | Type | Required | Description |
| :--------- | :----- | :------- | :------------ |
| INAPP | string || "in_app" |
| SLACK | string || "slack" |
| WEBPUSH | string || "web_push" |
| MOBILEPUSH | string || "mobile_push" |
| TEAMS | string || "teams" |
| EMAIL | string || "email" |
| SMS | string || "sms" |
116 changes: 116 additions & 0 deletions packages/project-client/documentation/services/ChannelsService.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ A list of all methods in the `ChannelsService` service. Click on the method name

| Methods | Description |
| :---------------------------------------------------------------- | :---------- |
| [getProjectDeliveryconfig](#getprojectdeliveryconfig) | |
| [saveProjectDeliveryconfig](#saveprojectdeliveryconfig) | |
| [saveCategoriesDeliveryconfig](#savecategoriesdeliveryconfig) | |
| [getMobilePushApnsUserTokens](#getmobilepushapnsusertokens) | |
| [getMobilePushApnsUserToken](#getmobilepushapnsusertoken) | |
| [discardMobilePushApnsUserToken](#discardmobilepushapnsusertoken) | |
Expand All @@ -23,6 +26,119 @@ A list of all methods in the `ChannelsService` service. Click on the method name
| [getWebPushUserToken](#getwebpushusertoken) | |
| [discardWebPushUserToken](#discardwebpushusertoken) | |

## getProjectDeliveryconfig

- HTTP Method: `GET`
- Endpoint: `/channels/deliveryconfig`

**Return Type**

`DeliveryPlan`

**Example Usage Code Snippet**

```typescript
import { Client } from '@magicbell/project-client';

(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});

const { data } = await client.channels.getProjectDeliveryconfig();

console.log(data);
})();
```

## saveProjectDeliveryconfig

- HTTP Method: `PUT`
- Endpoint: `/channels/deliveryconfig`

**Parameters**

| Name | Type | Required | Description |
| :--- | :---------------------------------------- | :------- | :---------------- |
| body | [DeliveryPlan](../models/DeliveryPlan.md) || The request body. |

**Return Type**

`DeliveryPlan`

**Example Usage Code Snippet**

```typescript
import { Client, DeliveryPlan } from '@magicbell/project-client';

(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});

const channelsChannel1 = ChannelsChannel1.INAPP;

const deliveryPlanChannels: DeliveryPlanChannels = {
channel: channelsChannel1,
delay: 7,
if: 'if',
};

const deliveryPlan: DeliveryPlan = {
channels: [deliveryPlanChannels],
};

const { data } = await client.channels.saveProjectDeliveryconfig(input);

console.log(data);
})();
```

## saveCategoriesDeliveryconfig

- HTTP Method: `POST`
- Endpoint: `/channels/deliveryconfig/categories`

**Parameters**

| Name | Type | Required | Description |
| :--- | :-------------------------------------------------------- | :------- | :---------------- |
| body | [CategoryDeliveryPlan](../models/CategoryDeliveryPlan.md) || The request body. |

**Return Type**

`CategoryDeliveryPlan`

**Example Usage Code Snippet**

```typescript
import { CategoryDeliveryPlan, Client } from '@magicbell/project-client';

(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});

const channelsChannel2 = ChannelsChannel2.INAPP;

const categoryDeliveryPlanChannels: CategoryDeliveryPlanChannels = {
channel: channelsChannel2,
delay: 1,
if: 'if',
};

const categoryDeliveryPlan: CategoryDeliveryPlan = {
category: '62Lu',
channels: [categoryDeliveryPlanChannels],
disabled: true,
};

const { data } = await client.channels.saveCategoriesDeliveryconfig(input);

console.log(data);
})();
```

## getMobilePushApnsUserTokens

- HTTP Method: `GET`
Expand Down
16 changes: 8 additions & 8 deletions packages/project-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export * from './services/jwt/index.js';
export class Client {
public readonly broadcasts: BroadcastsService;

public readonly channels: ChannelsService;

public readonly integrations: IntegrationsService;

public readonly jwt: JwtService;

public readonly channels: ChannelsService;

constructor(public config: SdkConfig) {
const baseUrl = config.environment || config.baseUrl || Environment.DEFAULT;
this.config = {
Expand All @@ -28,39 +28,39 @@ export class Client {
};
this.broadcasts = new BroadcastsService(this.config);

this.channels = new ChannelsService(this.config);

this.integrations = new IntegrationsService(this.config);

this.jwt = new JwtService(this.config);

this.channels = new ChannelsService(this.config);
}

set baseUrl(baseUrl: string) {
this.broadcasts.baseUrl = baseUrl;
this.channels.baseUrl = baseUrl;
this.integrations.baseUrl = baseUrl;
this.jwt.baseUrl = baseUrl;
this.channels.baseUrl = baseUrl;
}

set environment(environment: Environment) {
this.broadcasts.baseUrl = environment;
this.channels.baseUrl = environment;
this.integrations.baseUrl = environment;
this.jwt.baseUrl = environment;
this.channels.baseUrl = environment;
}

set timeout(timeout: number) {
this.broadcasts.timeout = timeout;
this.channels.timeout = timeout;
this.integrations.timeout = timeout;
this.jwt.timeout = timeout;
this.channels.timeout = timeout;
}

set token(token: string) {
this.broadcasts.token = token;
this.channels.token = token;
this.integrations.token = token;
this.jwt.token = token;
this.channels.token = token;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export type { Broadcast } from './broadcast.js';
export type { BroadcastListResponse } from './broadcast-list-response.js';
export type { Category } from './category.js';
export type { Channels } from './channels.js';
export type { Email } from './email.js';
export type { InApp } from './in-app.js';
export type { Links } from './links.js';
export type { MobilePush } from './mobile-push.js';
export type { Overrides } from './overrides.js';
export type { OverridesChannels } from './overrides-channels.js';
export type { Providers } from './providers.js';
export type { Slack } from './slack.js';
export type { Sms } from './sms.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { webPush, webPushRequest, webPushResponse } from './web-push.js';
/**
* The shape of the model inside the application code - what the users use
*/
export const channels = z.lazy(() => {
export const overridesChannels = z.lazy(() => {
return z.object({
email: email.optional(),
inApp: inApp.optional(),
Expand All @@ -23,21 +23,21 @@ export const channels = z.lazy(() => {

/**
*
* @typedef {Channels} channels
* @typedef {OverridesChannels} overridesChannels
* @property {Email}
* @property {InApp}
* @property {MobilePush}
* @property {Slack}
* @property {Sms}
* @property {WebPush}
*/
export type Channels = z.infer<typeof channels>;
export type OverridesChannels = z.infer<typeof overridesChannels>;

/**
* The shape of the model mapping from the api schema into the application shape.
* Is equal to application shape if all property names match the api schema
*/
export const channelsResponse = z.lazy(() => {
export const overridesChannelsResponse = z.lazy(() => {
return z
.object({
email: emailResponse.optional(),
Expand All @@ -61,7 +61,7 @@ export const channelsResponse = z.lazy(() => {
* The shape of the model mapping from the application shape into the api schema.
* Is equal to application shape if all property names match the api schema
*/
export const channelsRequest = z.lazy(() => {
export const overridesChannelsRequest = z.lazy(() => {
return z
.object({
email: emailRequest.nullish(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { z } from 'zod';

import { channels, channelsRequest, channelsResponse } from './channels.js';
import { overridesChannels, overridesChannelsRequest, overridesChannelsResponse } from './overrides-channels.js';
import { providers, providersRequest, providersResponse } from './providers.js';

/**
* The shape of the model inside the application code - what the users use
*/
export const overrides = z.lazy(() => {
return z.object({
channels: channels.optional(),
channels: overridesChannels.optional(),
providers: providers.optional(),
});
});

/**
*
* @typedef {Overrides} overrides
* @property {Channels}
* @property {OverridesChannels}
* @property {Providers}
*/
export type Overrides = z.infer<typeof overrides>;
Expand All @@ -28,7 +28,7 @@ export type Overrides = z.infer<typeof overrides>;
export const overridesResponse = z.lazy(() => {
return z
.object({
channels: channelsResponse.optional(),
channels: overridesChannelsResponse.optional(),
providers: providersResponse.optional(),
})
.transform((data) => ({
Expand All @@ -42,8 +42,10 @@ export const overridesResponse = z.lazy(() => {
* Is equal to application shape if all property names match the api schema
*/
export const overridesRequest = z.lazy(() => {
return z.object({ channels: channelsRequest.nullish(), providers: providersRequest.nullish() }).transform((data) => ({
channels: data['channels'],
providers: data['providers'],
}));
return z
.object({ channels: overridesChannelsRequest.nullish(), providers: providersRequest.nullish() })
.transform((data) => ({
channels: data['channels'],
providers: data['providers'],
}));
});
Loading

0 comments on commit 535534f

Please sign in to comment.