From 6f8e8eca0fd06a42e1e955599658d345e168f29e Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 30 Nov 2023 16:37:42 +0000 Subject: [PATCH] feat: ref codes --- packages/app/src/External/SnortApi.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/app/src/External/SnortApi.ts b/packages/app/src/External/SnortApi.ts index ee451d3e..a56081d8 100644 --- a/packages/app/src/External/SnortApi.ts +++ b/packages/app/src/External/SnortApi.ts @@ -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>(`api/v1/twitter/follows-for-nostr?username=${encodeURIComponent(username)}`); } - createSubscription(type: number) { - return this.#getJsonAuthd(`api/v1/subscription?type=${type}`, "PUT"); + createSubscription(type: number, refCode?: string) { + return this.#getJsonAuthd(`api/v1/subscription?type=${type}&refCode=${refCode}`, "PUT"); } renewSubscription(id: string, months = 1) { @@ -135,6 +139,10 @@ export default class SnortApi { return this.#getJson>(`api/v1/relays?count=${count}`, "POST", { lat, lon }); } + getRefCode() { + return this.#getJsonAuthd("api/v1/referral", "GET"); + } + async #getJsonAuthd( path: string, method?: "GET" | string,