@meowinc/meow-sdk 0.0.3 → 0.0.5
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/mail/auth/create-mailbox.d.ts +6 -0
- package/dist/mail/auth/create-mailbox.js +11 -0
- package/dist/mail/auth/index.d.ts +7 -0
- package/dist/mail/auth/index.js +14 -0
- package/dist/mail/auth/my.d.ts +9 -0
- package/dist/mail/auth/my.js +11 -0
- package/dist/mail/email/deleteEmailById.d.ts +3 -0
- package/dist/mail/email/deleteEmailById.js +11 -0
- package/dist/mail/email/getEmailById.d.ts +6 -0
- package/dist/mail/email/getEmailById.js +11 -0
- package/dist/mail/email/index.d.ts +9 -0
- package/dist/mail/email/index.js +22 -0
- package/dist/mail/email/sendMessage.d.ts +3 -0
- package/dist/mail/email/sendMessage.js +16 -0
- package/dist/mail/email/setReadStatus.d.ts +3 -0
- package/dist/mail/email/setReadStatus.js +12 -0
- package/dist/mail/index.d.ts +5 -0
- package/dist/mail/index.js +4 -0
- package/dist/mail/types.d.ts +18 -0
- package/dist/mail/types.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AccountClient } from "./account";
|
|
2
2
|
import type { AuthorizationProvider } from "./auth-provider";
|
|
3
|
+
import { MailClient } from "./mail";
|
|
3
4
|
import type { UndefinedString } from "./types";
|
|
4
5
|
export { AuthorizationProvider } from "./auth-provider";
|
|
5
6
|
export { UndefinedString };
|
|
6
7
|
export { AccessToken } from "./token";
|
|
7
8
|
export declare class MeowSdkClient<T extends AuthorizationProvider> {
|
|
8
9
|
readonly account: AccountClient;
|
|
10
|
+
readonly mail: MailClient;
|
|
9
11
|
private readonly authProvider;
|
|
10
12
|
protected constructor(authProvider: T);
|
|
11
13
|
isAuthorizationExist(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AccountClient } from "./account";
|
|
2
|
+
import { MailClient } from "./mail";
|
|
2
3
|
export { AccessToken } from "./token";
|
|
3
4
|
export class MeowSdkClient {
|
|
4
5
|
account;
|
|
6
|
+
mail;
|
|
5
7
|
authProvider;
|
|
6
8
|
constructor(authProvider) {
|
|
7
9
|
this.authProvider = authProvider;
|
|
8
10
|
this.account = new AccountClient(authProvider);
|
|
11
|
+
this.mail = new MailClient(authProvider);
|
|
9
12
|
}
|
|
10
13
|
isAuthorizationExist() {
|
|
11
14
|
return (this.authProvider.getAccessToken() != undefined ||
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../../auth-provider";
|
|
2
|
+
import { MeowResult } from "../../types";
|
|
3
|
+
export interface Response {
|
|
4
|
+
created_id: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function request(authorizationProvider: AuthorizationProvider): Promise<MeowResult<Response>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withAuthorization(authorizationProvider)
|
|
7
|
+
.withMethodPost()
|
|
8
|
+
.withUrl(`${MAIL_API}/v1/auth/create-mail-box`)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../../auth-provider";
|
|
2
|
+
export declare class AuthRequests {
|
|
3
|
+
private authorizationProvider;
|
|
4
|
+
constructor(authorizationProvider: AuthorizationProvider);
|
|
5
|
+
getMyMailbox(): Promise<import("../../types").MeowResult<import("./my").Response>>;
|
|
6
|
+
createMailbox(): Promise<import("../../types").MeowResult<import("./create-mailbox").Response>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { request as myRequest } from "./my";
|
|
2
|
+
import { request as createMailbox } from "./create-mailbox";
|
|
3
|
+
export class AuthRequests {
|
|
4
|
+
authorizationProvider;
|
|
5
|
+
constructor(authorizationProvider) {
|
|
6
|
+
this.authorizationProvider = authorizationProvider;
|
|
7
|
+
}
|
|
8
|
+
async getMyMailbox() {
|
|
9
|
+
return await myRequest(this.authorizationProvider);
|
|
10
|
+
}
|
|
11
|
+
async createMailbox() {
|
|
12
|
+
return await createMailbox(this.authorizationProvider);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../../auth-provider";
|
|
2
|
+
import { MeowResult } from "../../types";
|
|
3
|
+
export interface Response {
|
|
4
|
+
mailbox: {
|
|
5
|
+
address: string;
|
|
6
|
+
id: 1;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function request(authProvider: AuthorizationProvider): Promise<MeowResult<Response>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(authProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodGet()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/auth/my`)
|
|
8
|
+
.withAuthorization(authProvider)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(id, authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodDelete()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/email/${id}`)
|
|
8
|
+
.withAuthorization(authorizationProvider)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../../auth-provider";
|
|
2
|
+
import { MeowResult } from "../../types";
|
|
3
|
+
import { EmailModel } from "../types";
|
|
4
|
+
type Response = EmailModel;
|
|
5
|
+
export declare function request(id: number, authorizationProvider: AuthorizationProvider): Promise<MeowResult<Response>>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(id, authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodGet()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/email/${id}`)
|
|
8
|
+
.withAuthorization(authorizationProvider)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../../auth-provider";
|
|
2
|
+
export declare class EmailRequests {
|
|
3
|
+
private authorizationProvider;
|
|
4
|
+
constructor(authorizationProvider: AuthorizationProvider);
|
|
5
|
+
getEmailById(id: number): Promise<import("../../types").MeowResult<import("../types").EmailModel>>;
|
|
6
|
+
deleteEmailById(id: number): Promise<import("../../types").MeowResult<void>>;
|
|
7
|
+
sendEmail(to: string, subject: string, content: string): Promise<import("../../types").MeowResult<void>>;
|
|
8
|
+
setReadStatus(id: number, isRead: boolean): Promise<import("../../types").MeowResult<void>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { request as getEmailById } from "./getEmailById";
|
|
2
|
+
import { request as deleteEmailById } from "./deleteEmailById";
|
|
3
|
+
import { request as sendEmail } from "./sendMessage";
|
|
4
|
+
import { request as setReadStatus } from "./setReadStatus";
|
|
5
|
+
export class EmailRequests {
|
|
6
|
+
authorizationProvider;
|
|
7
|
+
constructor(authorizationProvider) {
|
|
8
|
+
this.authorizationProvider = authorizationProvider;
|
|
9
|
+
}
|
|
10
|
+
async getEmailById(id) {
|
|
11
|
+
return await getEmailById(id, this.authorizationProvider);
|
|
12
|
+
}
|
|
13
|
+
async deleteEmailById(id) {
|
|
14
|
+
return await deleteEmailById(id, this.authorizationProvider);
|
|
15
|
+
}
|
|
16
|
+
async sendEmail(to, subject, content) {
|
|
17
|
+
return await sendEmail(to, subject, content, this.authorizationProvider);
|
|
18
|
+
}
|
|
19
|
+
async setReadStatus(id, isRead) {
|
|
20
|
+
return await setReadStatus(id, isRead, this.authorizationProvider);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(to, subject, content, authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodPost()
|
|
7
|
+
.withAuthorization(authorizationProvider)
|
|
8
|
+
.withUrl(`${MAIL_API}/v1/email/send-message`)
|
|
9
|
+
.withJsonBody({
|
|
10
|
+
to,
|
|
11
|
+
subject,
|
|
12
|
+
content,
|
|
13
|
+
})
|
|
14
|
+
.send()
|
|
15
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(id, isRead, authorizationProvider) {
|
|
5
|
+
return new HttpClient()
|
|
6
|
+
.withMethodPut()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/email/my/set-read`)
|
|
8
|
+
.withAuthorization(authorizationProvider)
|
|
9
|
+
.withJsonBody({ mailId: id, isRead })
|
|
10
|
+
.send()
|
|
11
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type MailboxType = "External" | "Default" | "TechnicalAlert" | "DmarcRecordReceiver";
|
|
2
|
+
export interface EmailModel {
|
|
3
|
+
content: string;
|
|
4
|
+
dateTime: number;
|
|
5
|
+
from: {
|
|
6
|
+
id: number;
|
|
7
|
+
mailbox: string;
|
|
8
|
+
type: MailboxType;
|
|
9
|
+
};
|
|
10
|
+
id: number;
|
|
11
|
+
isRead: boolean;
|
|
12
|
+
subject: string;
|
|
13
|
+
to: {
|
|
14
|
+
id: number;
|
|
15
|
+
mailbox: string;
|
|
16
|
+
type: MailboxType;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|