@sollinked/sdk
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -1,3 +0,3 @@ | ||
import { BroadcastParams, CreateMailingListParams, MailingList, RetryBroadcastParams, UpdateMailingListPriceListParams } from "./types"; | ||
import { ApiResult } from "../../types"; | ||
import { BroadcastParams, CreateMailingListParams, DraftParams, MailingList, MailingListBroadcast, RetryBroadcastParams, UpdateMailingListPriceListParams } from "./types"; | ||
import { ApiResult, AuthCallParams } from "../../types"; | ||
export declare const create: (params: CreateMailingListParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
@@ -7,2 +7,7 @@ export declare const updateTiers: (params: UpdateMailingListPriceListParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const retry: (id: number, params: RetryBroadcastParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const saveDraft: (params: DraftParams) => Promise<string | import("axios").AxiosResponse<ApiResult<number>, any>>; | ||
export declare const updateDraft: (id: number, params: DraftParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const testDraft: (id: number, params: AuthCallParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const broadcastDraft: (id: number, params: BroadcastParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const getDraft: (id: number, params: AuthCallParams) => Promise<string | import("axios").AxiosResponse<ApiResult<MailingListBroadcast>, any>>; | ||
export declare const get: (username: string) => Promise<string | { | ||
@@ -9,0 +14,0 @@ list: MailingList | undefined; |
@@ -34,2 +34,42 @@ import axios from '../Services/axios.js'; | ||
}; | ||
export const saveDraft = async (params) => { | ||
try { | ||
return await axios.post(`/mailingList/saveDraft`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const updateDraft = async (id, params) => { | ||
try { | ||
return await axios.post(`/mailingList/updateDraft/${id}`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const testDraft = async (id, params) => { | ||
try { | ||
return await axios.post(`/mailingList/testDraft/${id}`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const broadcastDraft = async (id, params) => { | ||
try { | ||
return await axios.post(`/mailingList/broadcastDraft/${id}`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const getDraft = async (id, params) => { | ||
try { | ||
return await axios.post(`/mailingList/draft/${id}`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const get = async (username) => { | ||
@@ -36,0 +76,0 @@ try { |
@@ -43,2 +43,5 @@ import { AuthCallParams } from "../../types"; | ||
is_executing: boolean; | ||
is_draft: boolean; | ||
updated_at: string; | ||
tier_ids?: number[]; | ||
success_count: number; | ||
@@ -48,2 +51,3 @@ total_count: number; | ||
export interface CreateMailingListParams extends AuthCallParams { | ||
tier_ids?: number[]; | ||
} | ||
@@ -60,1 +64,6 @@ export interface UpdateMailingListPriceListParams extends AuthCallParams { | ||
} | ||
export interface DraftParams extends AuthCallParams { | ||
title: string; | ||
content: string; | ||
tier_ids?: number[]; | ||
} |
@@ -289,2 +289,75 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
}, [user, auth, signature, me]); | ||
const saveBroadcastDraft = useCallback(async (params) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
} | ||
let { address, message } = auth; | ||
let res = await mailingList.saveDraft({ address, message, signature, ...params }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
await me(); | ||
return res; | ||
}, [user, auth, signature, me]); | ||
const updateBroadcastDraft = useCallback(async (id, params) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
} | ||
let { address, message } = auth; | ||
let res = await mailingList.updateDraft(id, { address, message, signature, ...params }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
await me(); | ||
return res; | ||
}, [user, auth, signature, me]); | ||
const testBroadcastDraft = useCallback(async (id, params) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
} | ||
let { address, message } = auth; | ||
let res = await mailingList.testDraft(id, { address, message, signature, ...params }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
return res; | ||
}, [user, auth, signature]); | ||
const broadcastDraft = useCallback(async (id, params) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
} | ||
let { address, message } = auth; | ||
let res = await mailingList.broadcastDraft(id, { address, message, signature, ...params }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
await me(); | ||
return res; | ||
}, [user, auth, signature, me]); | ||
const getBroadcastDraft = useCallback(async (id) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
} | ||
let { address, message } = auth; | ||
let res = await mailingList.getDraft(id, { address, message, signature }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
return res; | ||
}, [user, auth, signature]); | ||
const getUserMailingList = useCallback(async (username) => { | ||
@@ -465,2 +538,7 @@ return await mailingList.get(username); | ||
broadcast: newBroadcast, | ||
saveDraft: saveBroadcastDraft, | ||
updateDraft: updateBroadcastDraft, | ||
testDraft: testBroadcastDraft, | ||
broadcastDraft: broadcastDraft, | ||
getDraft: getBroadcastDraft, | ||
}, | ||
@@ -467,0 +545,0 @@ calendar: { |
@@ -8,3 +8,3 @@ import { ReactNode } from "react"; | ||
import { MailTier, NewMailParams, OnMailPaymentParams } from "./src/Mail/types"; | ||
import { BroadcastParams, MailingList, UpdateMailingListPriceListParams } from "./src/MailingList/types"; | ||
import { BroadcastParams, DraftParams, MailingList, MailingListBroadcast, UpdateMailingListPriceListParams } from "./src/MailingList/types"; | ||
export type ApiResult<T> = { | ||
@@ -66,2 +66,7 @@ success: boolean; | ||
broadcast: (params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
saveDraft: (params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<number>, any> | undefined>; | ||
updateDraft: (id: number, params: Omit<DraftParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
testDraft: (id: number, params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
broadcastDraft: (id: number, params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
getDraft: (id: number) => Promise<string | AxiosResponse<ApiResult<MailingListBroadcast>, any> | undefined>; | ||
}; | ||
@@ -68,0 +73,0 @@ calendar?: { |
{ | ||
"name": "@sollinked/sdk", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "SDK for Sollinked", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -1,4 +0,4 @@ | ||
import { BroadcastParams, CreateMailingListParams, MailingList, RetryBroadcastParams, UpdateMailingListPriceListParams } from "./types" | ||
import { BroadcastParams, CreateMailingListParams, DraftParams, MailingList, MailingListBroadcast, RetryBroadcastParams, UpdateMailingListPriceListParams } from "./types" | ||
import axios from '../Services/axios.js'; | ||
import { ApiResult } from "../../types"; | ||
import { ApiResult, AuthCallParams } from "../../types"; | ||
@@ -49,2 +49,51 @@ | ||
export const saveDraft = async(params: DraftParams) => { | ||
try { | ||
return await axios.post<ApiResult<number>>(`/mailingList/saveDraft`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
export const updateDraft = async(id: number, params: DraftParams) => { | ||
try { | ||
return await axios.post<ApiResult<undefined>>(`/mailingList/updateDraft/${id}`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
export const testDraft = async(id: number, params: AuthCallParams) => { | ||
try { | ||
return await axios.post<ApiResult<undefined>>(`/mailingList/testDraft/${id}`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
export const broadcastDraft = async(id: number, params: BroadcastParams) => { | ||
try { | ||
return await axios.post<ApiResult<undefined>>(`/mailingList/broadcastDraft/${id}`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
export const getDraft = async(id: number, params: AuthCallParams) => { | ||
try { | ||
return await axios.post<ApiResult<MailingListBroadcast>>(`/mailingList/draft/${id}`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
// get user | ||
@@ -51,0 +100,0 @@ export const get = async(username: string) => { |
@@ -51,2 +51,5 @@ import { AuthCallParams } from "../../types"; | ||
is_executing: boolean; | ||
is_draft: boolean; | ||
updated_at: string; | ||
tier_ids?: number[]; | ||
success_count: number; | ||
@@ -57,3 +60,3 @@ total_count: number; | ||
export interface CreateMailingListParams extends AuthCallParams { | ||
tier_ids?: number[]; | ||
} | ||
@@ -73,2 +76,8 @@ | ||
} | ||
export interface DraftParams extends AuthCallParams { | ||
title: string; | ||
content: string; | ||
tier_ids?: number[]; | ||
} |
@@ -8,3 +8,3 @@ import { ReactNode } from "react"; | ||
import { MailTier, NewMailParams, OnMailPaymentParams } from "./src/Mail/types"; | ||
import { BroadcastParams, MailingList, UpdateMailingListPriceListParams } from "./src/MailingList/types"; | ||
import { BroadcastParams, DraftParams, MailingList, MailingListBroadcast, UpdateMailingListPriceListParams } from "./src/MailingList/types"; | ||
@@ -71,2 +71,7 @@ export type ApiResult<T> = { | ||
broadcast: (params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
saveDraft: (params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<number>, any> | undefined>; | ||
updateDraft: (id: number, params: Omit<DraftParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
testDraft: (id: number, params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
broadcastDraft: (id: number, params: Omit<BroadcastParams, "address" | "message" | "signature">) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
getDraft: (id: number) => Promise<string | AxiosResponse<ApiResult<MailingListBroadcast>, any> | undefined>; | ||
} | ||
@@ -73,0 +78,0 @@ calendar?: { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123655
3232