@sollinked/sdk
Advanced tools
Comparing version 1.2.4 to 1.3.0
@@ -10,1 +10,2 @@ import { Content, ContentCreateParams, ContentPayParams, ContentUpdateParams } from "./types"; | ||
export declare const get: (username: string, slug: string, auth: OptionalAuthCallParams) => Promise<string | Content>; | ||
export declare const getLatest: () => Promise<string | Content[]>; |
@@ -65,1 +65,16 @@ import axios from '../Services/axios.js'; | ||
}; | ||
export const getLatest = async () => { | ||
try { | ||
let res = await axios.get(`/content`); | ||
if (!res.data.success) { | ||
return res.data.message ?? "Error"; | ||
} | ||
if (!res.data.data) { | ||
return "Empty"; | ||
} | ||
return res.data.data; | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; |
@@ -17,4 +17,25 @@ import { AuthCallParams } from "../../types"; | ||
updated_at: string; | ||
paymentlink_id?: string; | ||
contentPasses?: ContentPass[]; | ||
}; | ||
export type LatestContent = { | ||
id: number; | ||
user_id: number; | ||
content_pass_ids: number[]; | ||
content: string; | ||
title: string; | ||
slug: string; | ||
description: string; | ||
value_usd: number; | ||
is_free: boolean; | ||
status: ContentStatus; | ||
deleted_at?: string; | ||
updated_at: string; | ||
paymentlink_id?: string; | ||
contentPasses?: ContentPass[]; | ||
user?: { | ||
username: string; | ||
display_name: string; | ||
}; | ||
}; | ||
export interface ContentCreateParams extends AuthCallParams { | ||
@@ -21,0 +42,0 @@ content_pass_ids: number[]; |
@@ -10,2 +10,3 @@ import { AuthCallParams } from "../../types"; | ||
cnft_count: number; | ||
paymentlink_id?: string; | ||
}; | ||
@@ -12,0 +13,0 @@ export type ContentCNFT = { |
@@ -1,4 +0,5 @@ | ||
import { ClaimAllMailParams, ClaimSpecificMailParams, NewMailParams, OnMailPaymentParams, UpdateMailTierParams } from "./types"; | ||
import { ApiResult } from "../../types"; | ||
export declare const get: () => Promise<void>; | ||
import { ClaimAllMailParams, ClaimSpecificMailParams, MailPaymentResponse, NewMailParams, OnMailPaymentParams, ThreadMail, UpdateMailTierParams } from "./types"; | ||
import { ApiResult, AuthCallParams } from "../../types"; | ||
export declare const getThreads: (username: string, params: AuthCallParams) => Promise<string | import("axios").AxiosResponse<ApiResult<ThreadMail[]>, any>>; | ||
export declare const getThread: (id: number, params: AuthCallParams) => Promise<string | import("axios").AxiosResponse<ApiResult<ThreadMail>, any>>; | ||
export declare const setTiers: (id: number, params: UpdateMailTierParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
@@ -11,2 +12,3 @@ export declare const claim: (id: number, params: ClaimSpecificMailParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
}>, any>>; | ||
export declare const getPaymentDetails: (mailId: number) => Promise<string | import("axios").AxiosResponse<ApiResult<MailPaymentResponse>, any>>; | ||
export declare const onMailPayment: (toUsername: string, params: OnMailPaymentParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; |
import axios from '../Services/axios.js'; | ||
export const get = async () => { | ||
export const getThreads = async (username, params) => { | ||
try { | ||
return await axios.post(`/mail/threads/${username}`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const getThread = async (id, params) => { | ||
try { | ||
return await axios.post(`/mail/thread/${id}`, params); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const setTiers = async (id, params) => { | ||
@@ -36,2 +50,10 @@ try { | ||
}; | ||
export const getPaymentDetails = async (mailId) => { | ||
try { | ||
return await axios.get(`/mail/payment/${mailId}`); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const onMailPayment = async (toUsername, params) => { | ||
@@ -38,0 +60,0 @@ try { |
@@ -22,3 +22,29 @@ import { AuthCallParams } from "../../types"; | ||
expiry_date?: string; | ||
claim_balance_verify_count: number; | ||
subject?: string; | ||
is_from_site: boolean; | ||
from_user_id?: number; | ||
message?: string; | ||
reply_message?: string; | ||
responded_at?: string; | ||
}; | ||
export type ThreadMail = { | ||
id: number; | ||
created_at: string; | ||
responded_at?: string; | ||
subject?: string; | ||
message?: string; | ||
reply_message?: string; | ||
value_usd?: number; | ||
tiplink_url?: string; | ||
tiplink_public_key: string; | ||
is_processed: boolean; | ||
}; | ||
export type MailPaymentResponse = { | ||
tiplink_public_key: string; | ||
is_processed: boolean; | ||
tiers: MailTier[]; | ||
username: string; | ||
display_name?: string; | ||
}; | ||
export type GetMailParams = { | ||
@@ -37,4 +63,5 @@ type: "claimed" | "unclaimed" | "expired" | "pending_deposit" | "pending_response" | "claimable" | "all"; | ||
} | ||
export interface NewMailParams { | ||
replyToEmail: string; | ||
export interface NewMailParams extends AuthCallParams { | ||
subject: string; | ||
emailMessage: string; | ||
} | ||
@@ -41,0 +68,0 @@ export interface OnMailPaymentParams { |
@@ -65,2 +65,5 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
}, [cookies, auth]); | ||
const clear = useCallback(() => { | ||
setUser(DEFAULT_USER); | ||
}, []); | ||
const me = useCallback(async (customSignature) => { | ||
@@ -248,4 +251,46 @@ let sigToVerify = customSignature ?? signature; | ||
}, [user, signature, auth, me]); | ||
const getEmails = useCallback(async (username) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
throw new UninitializedError(); | ||
} | ||
let { address, message } = auth; | ||
let res = await mail.getThreads(username, { address, message, signature }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
return res.data.data; | ||
}, [user, signature, auth]); | ||
const getEmailThread = useCallback(async (mailId) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
throw new UninitializedError(); | ||
} | ||
let { address, message } = auth; | ||
let res = await mail.getThread(mailId, { address, message, signature }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
return res.data.data; | ||
}, [user, signature, auth]); | ||
const getEmailPaymentDetails = useCallback(async (mailId) => { | ||
let res = await mail.getPaymentDetails(mailId); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
return res.data.data; | ||
}, []); | ||
const newMail = useCallback(async (toUsername, params) => { | ||
let res = await mail.newMail(toUsername, params); | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
throw new UninitializedError(); | ||
} | ||
let { address, message } = auth; | ||
let res = await mail.newMail(toUsername, { address, message, signature, ...params }); | ||
if (typeof res === 'string') { | ||
@@ -255,3 +300,3 @@ return res; | ||
return res.data.data; | ||
}, []); | ||
}, [user, signature, auth]); | ||
const onMailPayment = useCallback(async (toUsername, params) => { | ||
@@ -290,3 +335,2 @@ let res = await mail.onMailPayment(toUsername, params); | ||
if (!id) { | ||
console.log('creating new list'); | ||
let res = await newMailingList(false); | ||
@@ -510,2 +554,5 @@ if (typeof res === 'string') { | ||
}, [user, auth, signature]); | ||
const getLatestContent = useCallback(async () => { | ||
return await content.getLatest(); | ||
}, []); | ||
const createContentPass = useCallback(async (params) => { | ||
@@ -691,2 +738,6 @@ if (!user) { | ||
} | ||
let sigToVerify = customSignature ?? signature; | ||
if (!sigToVerify) { | ||
return; | ||
} | ||
setIsVerifying(true); | ||
@@ -700,3 +751,3 @@ let res = await me(customSignature); | ||
return res; | ||
}, [auth, createAccount, me]); | ||
}, [auth, createAccount, signature, me]); | ||
return (_jsx(SollinkedContext.Provider, { value: { | ||
@@ -710,2 +761,3 @@ user, | ||
me, | ||
clear, | ||
meContentPasses: meContentPasses, | ||
@@ -721,2 +773,5 @@ create: createAccount, | ||
mail: { | ||
get: getEmails, | ||
getThread: getEmailThread, | ||
getPaymentDetails: getEmailPaymentDetails, | ||
setTiers: setMailTiers, | ||
@@ -748,2 +803,3 @@ claim: claimMail, | ||
get: getContent, | ||
getLatest: getLatestContent, | ||
pay: payContent, | ||
@@ -750,0 +806,0 @@ }, |
@@ -7,3 +7,3 @@ import { ReactNode } from "react"; | ||
import { AxiosResponse } from "axios"; | ||
import { MailTier, NewMailParams, OnMailPaymentParams } from "./src/Mail/types"; | ||
import { MailPaymentResponse, MailTier, NewMailParams, OnMailPaymentParams, ThreadMail } from "./src/Mail/types"; | ||
import { BroadcastParams, DraftParams, MailingList, MailingListBroadcast, ResendBroadcastParams, UpdateMailingListPriceListParams } from "./src/MailingList/types"; | ||
@@ -43,2 +43,3 @@ import { Content, ContentCreateParams, ContentPayParams, ContentUpdateParams } from "./src/Content/types"; | ||
me: (customSignature?: string) => Promise<User | undefined>; | ||
clear: () => void; | ||
meContentPasses: () => Promise<string | ContentCNFT[] | undefined>; | ||
@@ -54,6 +55,9 @@ create: (username: string) => Promise<User | undefined>; | ||
mail?: { | ||
get: (username: string) => Promise<string | ThreadMail[] | undefined>; | ||
getThread: (mailId: number) => Promise<string | ThreadMail | undefined>; | ||
getPaymentDetails: (mailId: number) => Promise<string | MailPaymentResponse | undefined>; | ||
setTiers: (tiers: MailTier[]) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
claim: (id: number, claimToAddress?: string) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
claimAll: (claimToAddress?: string) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
new: (toUsername: string, params: NewMailParams) => Promise<string | { | ||
new: (toUsername: string, params: Omit<NewMailParams, keyof AuthCallParams>) => Promise<string | { | ||
mailId: number; | ||
@@ -87,2 +91,3 @@ depositTo: string; | ||
get: (username: string, slug: string) => Promise<string | Content>; | ||
getLatest: () => Promise<string | Content[]>; | ||
pay: (id: number, params: Omit<ContentPayParams, keyof AuthCallParams>) => Promise<string | AxiosResponse<ApiResult<Content>, any> | undefined>; | ||
@@ -89,0 +94,0 @@ }; |
{ | ||
"name": "@sollinked/sdk", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "SDK for Sollinked", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -86,2 +86,22 @@ import { Content, ContentCreateParams, ContentPayParams, ContentUpdateParams } from "./types" | ||
} | ||
} | ||
// displays the latest published contents | ||
export const getLatest = async() => { | ||
try { | ||
let res = await axios.get<ApiResult<Content[]>>(`/content`); | ||
if(!res.data.success) { | ||
return res.data.message ?? "Error"; | ||
} | ||
if(!res.data.data) { | ||
return "Empty"; | ||
} | ||
return res.data.data; | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} |
import { AuthCallParams } from "../../types"; | ||
import { PublicUser } from "../Account/types"; | ||
import { ContentPass } from "../ContentPass/types"; | ||
@@ -19,2 +20,3 @@ | ||
updated_at: string; | ||
paymentlink_id?: string; | ||
@@ -25,2 +27,25 @@ // generated | ||
export type LatestContent = { | ||
id: number; | ||
user_id: number; | ||
content_pass_ids: number[]; | ||
content: string; | ||
title: string; | ||
slug: string; | ||
description: string; | ||
value_usd: number; | ||
is_free: boolean; | ||
status: ContentStatus; | ||
deleted_at?: string; | ||
updated_at: string; | ||
paymentlink_id?: string; | ||
// generated | ||
contentPasses?: ContentPass[]; | ||
user?: { | ||
username: string; | ||
display_name: string; | ||
}; | ||
} | ||
export interface ContentCreateParams extends AuthCallParams { | ||
@@ -27,0 +52,0 @@ content_pass_ids: number[]; |
@@ -10,3 +10,4 @@ import { AuthCallParams } from "../../types"; | ||
value_usd: number; // price per pass | ||
cnft_count: number; // how many miinted | ||
cnft_count: number; // how many minted | ||
paymentlink_id?: string; | ||
} | ||
@@ -13,0 +14,0 @@ |
@@ -1,11 +0,28 @@ | ||
import { ClaimAllMailParams, ClaimSpecificMailParams, NewMailParams, OnMailPaymentParams, UpdateMailTierParams } from "./types" | ||
import { ClaimAllMailParams, ClaimSpecificMailParams, MailPaymentResponse, NewMailParams, OnMailPaymentParams, ThreadMail, UpdateMailTierParams } from "./types" | ||
import axios from '../Services/axios.js'; | ||
import { ApiResult } from "../../types"; | ||
import { ApiResult, AuthCallParams } from "../../types"; | ||
// get mails | ||
// unused | ||
export const get = async() => { | ||
export const getThreads = async(username: string, params: AuthCallParams) => { | ||
try { | ||
return await axios.post<ApiResult<ThreadMail[]>>(`/mail/threads/${username}`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
// claim all responded mails | ||
export const getThread = async(id: number, params: AuthCallParams) => { | ||
try { | ||
return await axios.post<ApiResult<ThreadMail>>(`/mail/thread/${id}`, params); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
// set tiers | ||
@@ -58,2 +75,14 @@ export const setTiers = async(id: number, params: UpdateMailTierParams) => { | ||
} | ||
//retrives payment details for the email | ||
export const getPaymentDetails = async(mailId: number) => { | ||
try { | ||
return await axios.get<ApiResult<MailPaymentResponse>>(`/mail/payment/${mailId}`); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
// second step of new mail | ||
@@ -60,0 +89,0 @@ export const onMailPayment = async(toUsername: string, params: OnMailPaymentParams) => { |
@@ -24,4 +24,32 @@ import { AuthCallParams } from "../../types"; | ||
expiry_date?: string; | ||
claim_balance_verify_count: number; | ||
subject?: string; | ||
is_from_site: boolean; | ||
from_user_id?: number; | ||
message?: string; | ||
reply_message?: string; | ||
responded_at?: string; | ||
} | ||
export type ThreadMail = { | ||
id: number; | ||
created_at: string; | ||
responded_at?: string; | ||
subject?: string; | ||
message?: string; // in html | ||
reply_message?: string; // in html | ||
value_usd?: number; | ||
tiplink_url?: string; // will have value if the mail expired | ||
tiplink_public_key: string; | ||
is_processed: boolean; | ||
} | ||
export type MailPaymentResponse = { | ||
tiplink_public_key: string; | ||
is_processed: boolean; | ||
tiers: MailTier[]; | ||
username: string; | ||
display_name?: string; | ||
} | ||
export type GetMailParams = { | ||
@@ -42,4 +70,5 @@ type: "claimed" | "unclaimed" | "expired" | "pending_deposit" | "pending_response" | "claimable" | "all"; | ||
export interface NewMailParams { | ||
replyToEmail: string; | ||
export interface NewMailParams extends AuthCallParams { | ||
subject: string; | ||
emailMessage: string; | ||
} | ||
@@ -46,0 +75,0 @@ export interface OnMailPaymentParams { |
@@ -7,3 +7,3 @@ import { ReactNode } from "react"; | ||
import { AxiosResponse } from "axios"; | ||
import { MailTier, NewMailParams, OnMailPaymentParams } from "./src/Mail/types"; | ||
import { MailPaymentResponse, MailTier, NewMailParams, OnMailPaymentParams, ThreadMail } from "./src/Mail/types"; | ||
import { BroadcastParams, DraftParams, MailingList, MailingListBroadcast, ResendBroadcastParams, UpdateMailingListPriceListParams } from "./src/MailingList/types"; | ||
@@ -48,2 +48,3 @@ import { Content, ContentCreateParams, ContentPayParams, ContentUpdateParams } from "./src/Content/types"; | ||
me: (customSignature?: string) => Promise<User | undefined>; | ||
clear: () => void; | ||
meContentPasses: () => Promise<string | ContentCNFT[] | undefined>; | ||
@@ -59,6 +60,9 @@ create: (username: string) => Promise<User | undefined>; | ||
mail?: { | ||
get: (username: string) => Promise<string | ThreadMail[] | undefined>; | ||
getThread: (mailId: number) => Promise<string | ThreadMail | undefined>; | ||
getPaymentDetails: (mailId: number) => Promise<string | MailPaymentResponse | undefined>; | ||
setTiers: (tiers: MailTier[]) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
claim: (id: number, claimToAddress?: string) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
claimAll: (claimToAddress?: string) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
new: (toUsername: string, params: NewMailParams) => Promise<string | { | ||
new: (toUsername: string, params: Omit<NewMailParams, keyof AuthCallParams>) => Promise<string | { | ||
mailId: number; | ||
@@ -92,2 +96,3 @@ depositTo: string; | ||
get: (username: string, slug: string) => Promise<string | Content>; | ||
getLatest: () => Promise<string | Content[]>; | ||
pay: (id: number, params: Omit<ContentPayParams, keyof AuthCallParams>) => Promise<string | AxiosResponse<ApiResult<Content>, any> | undefined>; | ||
@@ -94,0 +99,0 @@ }, |
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
169175
4463