forked from Kieran/snort
feat: ref codes
This commit is contained in:
parent
9e4a0542ea
commit
6f8e8eca0f
12
packages/app/src/External/SnortApi.ts
vendored
12
packages/app/src/External/SnortApi.ts
vendored
@ -78,6 +78,10 @@ export interface RelayDistance {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface RefCodeResponse {
|
||||
code: string
|
||||
}
|
||||
|
||||
export default class SnortApi {
|
||||
#url: string;
|
||||
#publisher?: EventPublisher;
|
||||
@ -99,8 +103,8 @@ export default class SnortApi {
|
||||
return this.#getJson<Array<string>>(`api/v1/twitter/follows-for-nostr?username=${encodeURIComponent(username)}`);
|
||||
}
|
||||
|
||||
createSubscription(type: number) {
|
||||
return this.#getJsonAuthd<InvoiceResponse>(`api/v1/subscription?type=${type}`, "PUT");
|
||||
createSubscription(type: number, refCode?: string) {
|
||||
return this.#getJsonAuthd<InvoiceResponse>(`api/v1/subscription?type=${type}&refCode=${refCode}`, "PUT");
|
||||
}
|
||||
|
||||
renewSubscription(id: string, months = 1) {
|
||||
@ -135,6 +139,10 @@ export default class SnortApi {
|
||||
return this.#getJson<Array<RelayDistance>>(`api/v1/relays?count=${count}`, "POST", { lat, lon });
|
||||
}
|
||||
|
||||
getRefCode() {
|
||||
return this.#getJsonAuthd<RefCodeResponse>("api/v1/referral", "GET");
|
||||
}
|
||||
|
||||
async #getJsonAuthd<T>(
|
||||
path: string,
|
||||
method?: "GET" | string,
|
||||
|
Loading…
Reference in New Issue
Block a user