Skip to content

Commit

Permalink
Release 0.0.41
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Feb 2, 2023
1 parent afc3a18 commit 0e8a7bc
Show file tree
Hide file tree
Showing 65 changed files with 207 additions and 255 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ravenapp/raven",
"version": "0.0.40",
"version": "0.0.41",
"repository": "https://github.com/ravenappdev/raven-node",
"files": [
"dist",
Expand Down
146 changes: 112 additions & 34 deletions src/Client.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,131 @@
/**
* This file auto-generated by Fern from our API Definition.
* This file was auto-generated by Fern from our API Definition.
*/

import * as environments from "./environments";
import * as core from "./core";
import { Client as DeviceClient } from "./resources/device/client/Client";
import { Client as EventClient } from "./resources/event/client/Client";
import { Client as UserClient } from "./resources/user/client/Client";
import { RavenApi } from ".";
import { RavenApi } from "@ravenapp/raven";
import urlJoin from "url-join";
import * as serializers from "./serialization";
import * as errors from "./errors";
import { Client as DeviceClient } from "./api/resources/device/client/Client";
import { Client as UserClient } from "./api/resources/user/client/Client";

export declare namespace RavenApiClient {
interface Options {
environment?: environments.Environment | string;
auth?: {
authorization?: core.Supplier<string>;
};
}
interface Options {
environment?: environments.RavenApiEnvironment | string;
authorization?: core.Supplier<string>;
}
}

export class RavenApiClient {
constructor(private readonly options: RavenApiClient.Options) {}
constructor(private readonly options: RavenApiClient.Options) {}

#device: DeviceClient | undefined;
/**
* This endpoint allows you to send messages
* @throws {RavenApi.EventNotFoundError}
*/
public async send(appId: RavenApi.AppId, request: RavenApi.SendEventRequest): Promise<RavenApi.SendEventResponse> {
const { idempotencyKey, ..._body } = request;
const _response = await core.fetcher({
url: urlJoin(
this.options.environment ?? environments.RavenApiEnvironment.Prod,
`/v1/apps/${appId}/events/send`
),
method: "POST",
headers: {
"Idempotency-Key": idempotencyKey,
Authorization: await core.Supplier.get(this.options.authorization),
},
body: await serializers.SendEventRequest.json(_body),
});
if (_response.ok) {
return await serializers.SendEventResponse.parse(_response.body as serializers.SendEventResponse.Raw);
}

public get device(): DeviceClient {
return (this.#device ??= new DeviceClient(this.options));
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 404:
throw new RavenApi.EventNotFoundError(
await serializers.EventNotFoundErrorBody.parse(
_response.error.body as serializers.EventNotFoundErrorBody.Raw
)
);
default:
throw new errors.RavenApiError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

#event: EventClient | undefined;
switch (_response.error.reason) {
case "non-json":
throw new errors.RavenApiError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.RavenApiTimeoutError();
case "unknown":
throw new errors.RavenApiError({
message: _response.error.errorMessage,
});
}
}

public get event(): EventClient {
return (this.#event ??= new EventClient(this.options));
}
public async sendBulk(
appId: RavenApi.AppId,
request: RavenApi.BulkSendEventRequest
): Promise<RavenApi.SendEventResponse> {
const { idempotencyKey, ..._body } = request;
const _response = await core.fetcher({
url: urlJoin(
this.options.environment ?? environments.RavenApiEnvironment.Prod,
`/v1/apps/${appId}/events/bulk_send`
),
method: "POST",
headers: {
"Idempotency-Key": idempotencyKey,
Authorization: await core.Supplier.get(this.options.authorization),
},
body: await serializers.BulkSendEventRequest.json(_body),
});
if (_response.ok) {
return await serializers.SendEventResponse.parse(_response.body as serializers.SendEventResponse.Raw);
}

public async send(
request: RavenApi.event.send.Request
): Promise<RavenApi.event.send.Response> {
return this.event.send(request);
}
if (_response.error.reason === "status-code") {
throw new errors.RavenApiError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}

public async sendBulk(
request: RavenApi.event.sendBulk.Request
): Promise<RavenApi.event.sendBulk.Response> {
return this.event.sendBulk(request);
}
switch (_response.error.reason) {
case "non-json":
throw new errors.RavenApiError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.RavenApiTimeoutError();
case "unknown":
throw new errors.RavenApiError({
message: _response.error.errorMessage,
});
}
}

#user: UserClient | undefined;
#device: DeviceClient | undefined;

public get user(): UserClient {
return (this.#user ??= new UserClient(this.options));
}
public get device(): DeviceClient {
return (this.#device ??= new DeviceClient(this.options));
}

#user: UserClient | undefined;

public get user(): UserClient {
return (this.#user ??= new UserClient(this.options));
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";
import * as errors from "../../errors";
import { RavenApi } from "@ravenapp/raven";

export class EventNotFoundError extends errors.RavenApiError {
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export * from "./resources";
export * from "./types";
export * from "./errors";
export * from "./client";
117 changes: 0 additions & 117 deletions src/api/resources/event/client/Client.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/api/resources/event/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/api/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
export * as device from "./device";
export * from "./device/types";
export * as event from "./event";
export * from "./event/types";
export * as ids from "./ids";
export * from "./ids/types";
export * as user from "./user";
export * from "./user/types";
export * from "./event/errors";
export * from "./event/client/requests";
export * from "./user/client/requests";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../../..";
import * as serializers from "../..";
import { RavenApi } from "@ravenapp/raven";
import * as core from "../../../../../core";
import * as core from "../../../core";

export const BulkSendEventRequest: core.serialization.Schema<
serializers.BulkSendEventRequest.Raw,
Omit<RavenApi.BulkSendEventRequest, "idempotencyKey">
> = core.serialization.object({
event: core.serialization.string(),
batch: core.serialization.list(core.serialization.lazyObject(async () => (await import("../../../..")).BatchEvent)),
batch: core.serialization.list(core.serialization.lazyObject(async () => (await import("../..")).BatchEvent)),
});

export declare namespace BulkSendEventRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../../..";
import * as serializers from "../..";
import { RavenApi } from "@ravenapp/raven";
import * as core from "../../../../../core";
import * as core from "../../../core";

export const SendEventRequest: core.serialization.Schema<
serializers.SendEventRequest.Raw,
Omit<RavenApi.SendEventRequest, "idempotencyKey">
> = core.serialization.object({
event: core.serialization.string(),
data: core.serialization.record(core.serialization.string(), core.serialization.unknown()),
user: core.serialization.lazyObject(async () => (await import("../../../..")).User).optional(),
user: core.serialization.lazyObject(async () => (await import("../..")).User).optional(),
scheduleAt: core.serialization.number().optional(),
override: core.serialization.lazyObject(async () => (await import("../../../..")).EventOverride).optional(),
override: core.serialization.lazyObject(async () => (await import("../..")).EventOverride).optional(),
});

export declare namespace SendEventRequest {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/serialization/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from "./resources";
export * from "./types";
export * from "./client";
2 changes: 0 additions & 2 deletions src/serialization/resources/event/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/serialization/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
export * as device from "./device";
export * from "./device/types";
export * as event from "./event";
export * from "./event/types";
export * as ids from "./ids";
export * from "./ids/types";
export * as user from "./user";
export * from "./user/types";
export * from "./event/client/requests";
export * from "./user/client/requests";
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../..";
import * as serializers from "..";
import { RavenApi } from "@ravenapp/raven";
import * as core from "../../../../core";
import * as core from "../../core";

export const Attachment: core.serialization.ObjectSchema<serializers.Attachment.Raw, RavenApi.Attachment> =
core.serialization.object({
Expand Down
Loading

0 comments on commit 0e8a7bc

Please sign in to comment.