shred-api-client 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import Environment from "../model/Env";
2
+ import { Approve, Project, ProjectAPISchema, ProjectCreation, Query, SendToApproval } from "../model/Project.schema";
3
+ import Context from "../model/Context";
4
+ declare class ProjectAPI implements ProjectAPISchema {
5
+ private env;
6
+ private clientHTTP;
7
+ constructor(env: Environment);
8
+ find(context: Context, projectId: string): Promise<Project>;
9
+ create(context: Context, createData: ProjectCreation): Promise<Project>;
10
+ review(ctx: Context, pId: string, revision: string): Promise<boolean>;
11
+ cancel(ctx: Context, projectId: string): Promise<boolean>;
12
+ list(context: Context, query: Query): Promise<Project[]>;
13
+ deny(ctx: Context, pId: string, denyFB: string): Promise<boolean>;
14
+ unschedule(context: Context, projectId: string): Promise<boolean>;
15
+ start(context: Context, projectId: string): Promise<boolean>;
16
+ approve(ctx: Context, pId: string, approve: Approve): Promise<boolean>;
17
+ sendToApproval(context: Context, projectId: string, approval: SendToApproval): Promise<boolean>;
18
+ }
19
+ export default ProjectAPI;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const HTTPClient_1 = __importDefault(require("../util/HTTPClient"));
7
+ const Project_schema_1 = require("../model/Project.schema");
8
+ class ProjectAPI {
9
+ constructor(env) {
10
+ this.env = env;
11
+ this.clientHTTP = new HTTPClient_1.default();
12
+ }
13
+ async find(context, projectId) {
14
+ const endpointData = Project_schema_1.ProjectEndpoints.FindOne;
15
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
16
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, context);
17
+ return data;
18
+ }
19
+ async create(context, createData) {
20
+ const endpointData = Project_schema_1.ProjectEndpoints.CreateProject;
21
+ const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, createData, context);
22
+ return data;
23
+ }
24
+ async review(ctx, pId, revision) {
25
+ const endpointData = Project_schema_1.ProjectEndpoints.Review;
26
+ const endpoint = endpointData.uri.replace(":projectId", pId);
27
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, { revision }, ctx);
28
+ return data.success;
29
+ }
30
+ async cancel(ctx, projectId) {
31
+ const endpointData = Project_schema_1.ProjectEndpoints.Cancel;
32
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
33
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, ctx);
34
+ return data.success;
35
+ }
36
+ async list(context, query) {
37
+ const endpointData = Project_schema_1.ProjectEndpoints.List;
38
+ const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, query, context);
39
+ return data;
40
+ }
41
+ async deny(ctx, pId, denyFB) {
42
+ const endpointData = Project_schema_1.ProjectEndpoints.Deny;
43
+ const endpoint = endpointData.uri.replace(":projectId", pId);
44
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, { denyFeedback: denyFB }, ctx);
45
+ return data.success;
46
+ }
47
+ async unschedule(context, projectId) {
48
+ const endpointData = Project_schema_1.ProjectEndpoints.Unschedule;
49
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
50
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, context);
51
+ return data.success;
52
+ }
53
+ async start(context, projectId) {
54
+ const endpointData = Project_schema_1.ProjectEndpoints.StartEdition;
55
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
56
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, context);
57
+ return data.success;
58
+ }
59
+ async approve(ctx, pId, approve) {
60
+ const endpointData = Project_schema_1.ProjectEndpoints.Approve;
61
+ const endpoint = endpointData.uri.replace(":projectId", pId);
62
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, approve, ctx);
63
+ return data.success;
64
+ }
65
+ async sendToApproval(context, projectId, approval) {
66
+ const endpointData = Project_schema_1.ProjectEndpoints.SendToApproval;
67
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
68
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, approval, context);
69
+ return data.success;
70
+ }
71
+ }
72
+ exports.default = ProjectAPI;
@@ -0,0 +1,10 @@
1
+ import Environment from "../model/Env";
2
+ import { PushNotificationSchema, PushNotification } from "../model/PushNotification.schema";
3
+ import Context from "../src/model/Context";
4
+ declare class PushNotificationAPI implements PushNotificationSchema {
5
+ private env;
6
+ private clientHTTP;
7
+ constructor(env: Environment);
8
+ push(ctx: Context, notification: PushNotification): Promise<boolean>;
9
+ }
10
+ export default PushNotificationAPI;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const HTTPClient_1 = __importDefault(require("../util/HTTPClient"));
7
+ const PushNotification_schema_1 = require("../model/PushNotification.schema");
8
+ class PushNotificationAPI {
9
+ constructor(env) {
10
+ this.env = env;
11
+ this.clientHTTP = new HTTPClient_1.default();
12
+ }
13
+ async push(ctx, notification) {
14
+ const endpointInfo = PushNotification_schema_1.PushNotificationEndpoints.Push;
15
+ const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, notification, ctx);
16
+ return data.success;
17
+ }
18
+ }
19
+ exports.default = PushNotificationAPI;
@@ -8,7 +8,8 @@ declare class UserAPI implements UserAPISchema {
8
8
  sendValidationCode(email: string): Promise<boolean>;
9
9
  confirmCode(email: string, code: number): Promise<boolean>;
10
10
  isEmailAvaliable(email: string): Promise<boolean>;
11
- update(context: Context, update: Update): Promise<boolean>;
11
+ update(context: Context, update: Partial<Update>): Promise<boolean>;
12
+ setup(context: Context): Promise<boolean>;
12
13
  authenticate(context: Context, system: System): Promise<string>;
13
14
  createUser(email: string, name: string, password: string, passwordConfirmation: string, profession: string | null, invitationCode: string | null): Promise<any>;
14
15
  getUserInfo(context: Context): Promise<User>;
@@ -30,6 +30,11 @@ class UserAPI {
30
30
  const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}`, endpointData.method, Object.assign({}, update), context);
31
31
  return data.isValid;
32
32
  }
33
+ async setup(context) {
34
+ const endpointData = User_schema_1.UserEndpoints.Setup;
35
+ const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}`, endpointData.method, null, context);
36
+ return data.success;
37
+ }
33
38
  async authenticate(context, system) {
34
39
  const endpointData = User_schema_1.UserEndpoints.Authenticate;
35
40
  const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}`, endpointData.method, { system }, context);
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ShredAPI } from "./model/Api";
2
2
  import { Role } from "./model/User.schema";
3
+ import { Status as ProjectStatus } from "./model/Project.schema";
3
4
  import Exceptions from "./model/exceptions/";
4
5
  export { Role };
5
6
  export { Exceptions };
7
+ export { ProjectStatus };
6
8
  export default ShredAPI;
7
9
  export * from "./namespace";
package/dist/index.js CHANGED
@@ -17,10 +17,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Exceptions = exports.Role = void 0;
20
+ exports.ProjectStatus = exports.Exceptions = exports.Role = void 0;
21
21
  const Api_1 = require("./model/Api");
22
22
  const User_schema_1 = require("./model/User.schema");
23
23
  Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return User_schema_1.Role; } });
24
+ const Project_schema_1 = require("./model/Project.schema");
25
+ Object.defineProperty(exports, "ProjectStatus", { enumerable: true, get: function () { return Project_schema_1.Status; } });
24
26
  const exceptions_1 = __importDefault(require("./model/exceptions/"));
25
27
  exports.Exceptions = exceptions_1.default;
26
28
  exports.default = Api_1.ShredAPI;
@@ -1,16 +1,18 @@
1
1
  import Environment from "./Env";
2
2
  import { PromptAPISchema } from "./Prompt.schema";
3
- import { SMSAPISchema } from "./SMS.schema";
3
+ import { PushNotificationSchema } from "./PushNotification.schema";
4
4
  import { SubscriptionAPISchema } from "./Subscription.schema";
5
5
  import { UserAPISchema } from "./User.schema";
6
6
  import { EmailAPISchema } from "./Email.schema";
7
7
  import { TenantAPISchema } from "./Tenant.schema";
8
+ import { ProjectAPISchema } from "./Project.schema";
8
9
  export declare class ShredAPI {
9
10
  user: UserAPISchema;
10
11
  subscription: SubscriptionAPISchema;
11
12
  prompt: PromptAPISchema;
12
- sms: SMSAPISchema;
13
+ pushNotification: PushNotificationSchema;
13
14
  email: EmailAPISchema;
14
15
  tenant: TenantAPISchema;
16
+ project: ProjectAPISchema;
15
17
  constructor(env: Environment);
16
18
  }
package/dist/model/Api.js CHANGED
@@ -4,20 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ShredAPI = void 0;
7
- const SMS_api_1 = __importDefault(require("../api/SMS.api"));
7
+ const PushNotification_api_1 = __importDefault(require("../api/PushNotification.api"));
8
8
  const Prompt_api_1 = __importDefault(require("../api/Prompt.api"));
9
9
  const Subscription_api_1 = __importDefault(require("../api/Subscription.api"));
10
10
  const Tenant_api_1 = __importDefault(require("../api/Tenant.api"));
11
11
  const User_api_1 = __importDefault(require("../api/User.api"));
12
12
  const Email_api_1 = __importDefault(require("../api/Email.api"));
13
+ const Project_api_1 = __importDefault(require("../api/Project.api"));
13
14
  class ShredAPI {
14
15
  constructor(env) {
15
16
  this.user = new User_api_1.default(env);
16
17
  this.prompt = new Prompt_api_1.default(env);
17
18
  this.subscription = new Subscription_api_1.default(env);
18
- this.sms = new SMS_api_1.default(env);
19
+ this.pushNotification = new PushNotification_api_1.default(env);
19
20
  this.email = new Email_api_1.default(env);
20
21
  this.tenant = new Tenant_api_1.default(env);
22
+ this.project = new Project_api_1.default(env);
21
23
  }
22
24
  }
23
25
  exports.ShredAPI = ShredAPI;
@@ -0,0 +1,12 @@
1
+ type Asset = {
2
+ duration?: number;
3
+ fileName: string;
4
+ extension: string;
5
+ mimeType: string;
6
+ fileSize: number;
7
+ thumbnailUrl: string;
8
+ assetUrl: string;
9
+ uploadTime: number;
10
+ id?: string;
11
+ };
12
+ export { Asset };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,123 @@
1
+ import { Asset } from "./Asset.schema";
2
+ import Context from "./Context";
3
+ export type ProjectCreation = Pick<Project, "title" | "instructions" | "captionStyle" | "assets">;
4
+ export type SendToApproval = {
5
+ video: string;
6
+ thumbnail: string;
7
+ captionSuggestion: string;
8
+ };
9
+ export type Approve = {
10
+ scheduleTime?: number;
11
+ captionSuggestion: string;
12
+ };
13
+ export type Query = {
14
+ startDate: string;
15
+ endDate: string;
16
+ timeZone?: string;
17
+ };
18
+ interface ProjectAPISchema {
19
+ find: (context: Context, projectId: string) => Promise<Project>;
20
+ create: (context: Context, data: ProjectCreation) => Promise<Project>;
21
+ review: (context: Context, projectId: string, revision: string) => Promise<boolean>;
22
+ cancel: (context: Context, projectId: string) => Promise<boolean>;
23
+ list: (context: Context, query: Query) => Promise<Project[]>;
24
+ start: (context: Context, projectId: string) => Promise<boolean>;
25
+ sendToApproval: (context: Context, projectId: string, data: SendToApproval) => Promise<boolean>;
26
+ approve: (context: Context, projectId: string, data: Approve) => Promise<boolean>;
27
+ deny: (context: Context, projectId: string, denyFeedback: string) => Promise<boolean>;
28
+ unschedule: (context: Context, projectId: string) => Promise<boolean>;
29
+ }
30
+ declare const ProjectEndpoints: {
31
+ List: {
32
+ uri: string;
33
+ method: string;
34
+ };
35
+ CreateProject: {
36
+ uri: string;
37
+ method: string;
38
+ };
39
+ FindOne: {
40
+ uri: string;
41
+ method: string;
42
+ };
43
+ Review: {
44
+ uri: string;
45
+ method: string;
46
+ };
47
+ Cancel: {
48
+ uri: string;
49
+ method: string;
50
+ };
51
+ StartEdition: {
52
+ uri: string;
53
+ method: string;
54
+ };
55
+ SendToApproval: {
56
+ uri: string;
57
+ method: string;
58
+ };
59
+ Approve: {
60
+ uri: string;
61
+ method: string;
62
+ };
63
+ Unschedule: {
64
+ uri: string;
65
+ method: string;
66
+ };
67
+ Deny: {
68
+ uri: string;
69
+ method: string;
70
+ };
71
+ };
72
+ export declare enum Status {
73
+ SUBMITTED = 0,
74
+ EDITING = 1,
75
+ COMPLETED = 2,
76
+ WAITING_APPROVE = 3,
77
+ DENIED = 4,
78
+ REVISIONING = 5,
79
+ CANCELLED = 6,
80
+ SCHEDULED = 7
81
+ }
82
+ declare enum CaptionStyle {
83
+ ONE_LINE = 1,
84
+ ONE_LINE_EMOJIS = 2,
85
+ TWO_LINES_EMOJIS = 3,
86
+ HOME_HIGHLIGHT = 4
87
+ }
88
+ type DenyFeedback = {
89
+ timestamp: number;
90
+ feedback: string;
91
+ resolved: boolean;
92
+ };
93
+ type Project = {
94
+ id: string | null;
95
+ title: string;
96
+ instructions: string;
97
+ submitMonth: string;
98
+ status: Status;
99
+ captionStyle: CaptionStyle;
100
+ finalVideoId?: string;
101
+ canRevision: boolean;
102
+ thumbnailUrl?: string;
103
+ revision?: string;
104
+ modified?: number;
105
+ captionSuggestion?: string;
106
+ editorId: string;
107
+ userId: string;
108
+ assets?: Asset[];
109
+ denyFeedback?: DenyFeedback[];
110
+ approvedBy?: string;
111
+ approveTimestamp?: number;
112
+ expirationTimestamp?: number;
113
+ sentToApproveTimestamp?: number;
114
+ submitTimestamp: number;
115
+ editTimestamp?: number;
116
+ completeTimestamp?: number;
117
+ revisedAt?: number;
118
+ isFreeProject?: boolean;
119
+ scheduledAt?: number;
120
+ scheduledTime?: number;
121
+ tenantId?: string;
122
+ };
123
+ export { Project, ProjectAPISchema, ProjectEndpoints };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectEndpoints = exports.Status = void 0;
4
+ const ProjectEndpoints = {
5
+ List: {
6
+ uri: "/projects/list",
7
+ method: "GET",
8
+ },
9
+ CreateProject: {
10
+ uri: "/projects/create",
11
+ method: "POST",
12
+ },
13
+ FindOne: {
14
+ uri: `/projects/:projectId/`,
15
+ method: "POST",
16
+ },
17
+ Review: {
18
+ uri: "/projects/:projectId/review/",
19
+ method: "POST",
20
+ },
21
+ Cancel: {
22
+ uri: "/projects/:projectId/cancel/",
23
+ method: "DELETE",
24
+ },
25
+ StartEdition: {
26
+ uri: "/projects/:projectId/start/",
27
+ method: "PUT",
28
+ },
29
+ SendToApproval: {
30
+ uri: "/projects/:projectId/sendToApproval/",
31
+ method: "PUT",
32
+ },
33
+ Approve: {
34
+ uri: "/projects/:projectId/approve/",
35
+ method: "POST",
36
+ },
37
+ Unschedule: {
38
+ uri: "/projects/:projectId/unschedule/",
39
+ method: "POST",
40
+ },
41
+ Deny: {
42
+ uri: "/projects/:projectId/deny/",
43
+ method: "POST",
44
+ },
45
+ };
46
+ exports.ProjectEndpoints = ProjectEndpoints;
47
+ var Status;
48
+ (function (Status) {
49
+ Status[Status["SUBMITTED"] = 0] = "SUBMITTED";
50
+ Status[Status["EDITING"] = 1] = "EDITING";
51
+ Status[Status["COMPLETED"] = 2] = "COMPLETED";
52
+ Status[Status["WAITING_APPROVE"] = 3] = "WAITING_APPROVE";
53
+ Status[Status["DENIED"] = 4] = "DENIED";
54
+ Status[Status["REVISIONING"] = 5] = "REVISIONING";
55
+ Status[Status["CANCELLED"] = 6] = "CANCELLED";
56
+ Status[Status["SCHEDULED"] = 7] = "SCHEDULED";
57
+ })(Status || (exports.Status = Status = {}));
58
+ var CaptionStyle;
59
+ (function (CaptionStyle) {
60
+ CaptionStyle[CaptionStyle["ONE_LINE"] = 1] = "ONE_LINE";
61
+ CaptionStyle[CaptionStyle["ONE_LINE_EMOJIS"] = 2] = "ONE_LINE_EMOJIS";
62
+ CaptionStyle[CaptionStyle["TWO_LINES_EMOJIS"] = 3] = "TWO_LINES_EMOJIS";
63
+ CaptionStyle[CaptionStyle["HOME_HIGHLIGHT"] = 4] = "HOME_HIGHLIGHT";
64
+ })(CaptionStyle || (CaptionStyle = {}));
@@ -0,0 +1,17 @@
1
+ import Context from "./Context";
2
+ interface PushNotificationSchema {
3
+ push: (context: Context, notification: PushNotification) => Promise<boolean>;
4
+ }
5
+ declare const PushNotificationEndpoints: {
6
+ Push: {
7
+ uri: string;
8
+ method: string;
9
+ };
10
+ };
11
+ type PushNotification = {
12
+ title: string;
13
+ body: string;
14
+ userToken: string;
15
+ metadata: any;
16
+ };
17
+ export { PushNotificationSchema, PushNotificationEndpoints, PushNotification };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PushNotificationEndpoints = void 0;
4
+ const PushNotificationEndpoints = {
5
+ Push: {
6
+ uri: "/notifications/push/",
7
+ method: "POST",
8
+ },
9
+ };
10
+ exports.PushNotificationEndpoints = PushNotificationEndpoints;
@@ -6,7 +6,8 @@ interface UserAPISchema {
6
6
  sendValidationCode: (email: string) => Promise<boolean>;
7
7
  confirmCode: (email: string, code: number) => Promise<boolean>;
8
8
  authenticate: (context: Context, system: System) => Promise<string>;
9
- update: (context: Context, update: Update) => Promise<boolean>;
9
+ update: (context: Context, update: Partial<Update>) => Promise<boolean>;
10
+ setup: (context: Context) => Promise<boolean>;
10
11
  createUser: (email: string, name: string, password: string, passwordConfirmation: string, profession: string | null, invitationCode: string | null) => Promise<User>;
11
12
  }
12
13
  declare const UserEndpoints: {
@@ -42,6 +43,10 @@ declare const UserEndpoints: {
42
43
  uri: string;
43
44
  method: string;
44
45
  };
46
+ Setup: {
47
+ uri: string;
48
+ method: string;
49
+ };
45
50
  };
46
51
  declare enum Role {
47
52
  USER = "User",
@@ -34,6 +34,10 @@ const UserEndpoints = {
34
34
  uri: "/accounts/user/update",
35
35
  method: "PUT",
36
36
  },
37
+ Setup: {
38
+ uri: "/accounts/user/setup/",
39
+ method: "POST",
40
+ },
37
41
  };
38
42
  exports.UserEndpoints = UserEndpoints;
39
43
  var Role;
@@ -1,6 +1,8 @@
1
1
  import { Product as TProduct, Subscription as TSubscription } from "./model/Subscription.schema";
2
2
  import { System as TSystem, User as TUser, Role as TRole } from "./model/User.schema";
3
3
  import { Email as TEmail } from "./model/Email.schema";
4
+ import { Asset as TAsset } from "./model/Asset.schema";
5
+ import { Project as TProject } from "./model/Project.schema";
4
6
  import { Tenant as TTenant } from "./model/Tenant.schema";
5
7
  import { Prompt as TPrompt, Script as TScript, Category as TCategory } from "./model/Prompt.schema";
6
8
  export declare namespace Permissions {
@@ -13,6 +15,8 @@ export declare namespace Shred {
13
15
  type User = TUser;
14
16
  type Email = TEmail;
15
17
  type System = TSystem;
18
+ type Project = TProject;
19
+ type Asset = TAsset;
16
20
  namespace PromptTypes {
17
21
  type Prompt = TPrompt;
18
22
  type Script = TScript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,12 +0,0 @@
1
- import Environment from "../model/Env";
2
- import { SMSAPISchema } from "../model/SMS.schema";
3
- import Context from "../src/model/Context";
4
- declare class SMSAPI implements SMSAPISchema {
5
- private env;
6
- private clientHTTP;
7
- constructor(env: Environment);
8
- sendSMS(content: string, ctx: Context): Promise<boolean>;
9
- verify(phone: string, code: number): Promise<boolean>;
10
- sendVerifyCode(phone: string, friendlyName?: string | undefined): Promise<boolean>;
11
- }
12
- export default SMSAPI;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const HTTPClient_1 = __importDefault(require("../util/HTTPClient"));
7
- const SMS_schema_1 = require("../model/SMS.schema");
8
- class SMSAPI {
9
- constructor(env) {
10
- this.env = env;
11
- this.clientHTTP = new HTTPClient_1.default();
12
- }
13
- async sendSMS(content, ctx) {
14
- const endpointInfo = SMS_schema_1.SMSEndpoints.SendSMS;
15
- const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, { content }, ctx);
16
- return data.success;
17
- }
18
- async verify(phone, code) {
19
- const endpointInfo = SMS_schema_1.SMSEndpoints.VerifyCode;
20
- const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, { phone, code });
21
- return data.success;
22
- }
23
- async sendVerifyCode(phone, friendlyName) {
24
- const endpointInfo = SMS_schema_1.SMSEndpoints.SendVerifyCode;
25
- const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, { phone, friendlyName });
26
- return data;
27
- }
28
- }
29
- exports.default = SMSAPI;
@@ -1,21 +0,0 @@
1
- import Context from "./Context";
2
- interface SMSAPISchema {
3
- sendSMS: (content: string, context: Context) => Promise<boolean>;
4
- sendVerifyCode: (phone: string, friendlyName?: string) => Promise<boolean>;
5
- verify: (phone: string, number: number) => Promise<boolean>;
6
- }
7
- declare const SMSEndpoints: {
8
- SendVerifyCode: {
9
- uri: string;
10
- method: string;
11
- };
12
- VerifyCode: {
13
- uri: string;
14
- method: string;
15
- };
16
- SendSMS: {
17
- uri: string;
18
- method: string;
19
- };
20
- };
21
- export { SMSAPISchema, SMSEndpoints };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SMSEndpoints = void 0;
4
- const SMSEndpoints = {
5
- SendVerifyCode: {
6
- uri: "/sms/public/verify/send",
7
- method: "POST",
8
- },
9
- VerifyCode: {
10
- uri: "/sms/public/verify",
11
- method: "POST",
12
- },
13
- SendSMS: {
14
- uri: "/sms/message/send",
15
- method: "POST",
16
- },
17
- };
18
- exports.SMSEndpoints = SMSEndpoints;