From c5ba41b479573bac70b887dc9498e46d10c9ce8c Mon Sep 17 00:00:00 2001 From: enrique Date: Thu, 29 Feb 2024 12:42:00 +0100 Subject: [PATCH] feat: add some missed methods and update environments --- src/environments.ts | 20 ++++++++++++++++++-- src/payments.ts | 32 +++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/environments.ts b/src/environments.ts index ece41b0..5d06474 100644 --- a/src/environments.ts +++ b/src/environments.ts @@ -3,11 +3,27 @@ export interface EnvironmentInfo { backend: string } -export type EnvironmentName = 'staging' +export type EnvironmentName = 'appStaging' | 'appTesting' | 'appArbitrum' | 'appGnosis' | 'appMatic' export const Environments: Record = { - staging: { + appStaging: { frontend: 'https://staging.nevermined.app', backend: 'https://one-backend.staging.nevermined.app', }, + appTesting: { + frontend: 'https://testing.nevermined.app', + backend: 'https://one-backend.testing.nevermined.app', + }, + appArbitrum: { + frontend: 'https://nevermined.app', + backend: 'https://one-backend.arbitrum.nevermined.app', + }, + appGnosis: { + frontend: 'https://gnosis.nevermined.app', + backend: 'https://one-backend.gnosis.nevermined.app', + }, + appMatic: { + frontend: 'https://matic.nevermined.app', + backend: 'https://one-backend.matic.nevermined.app', + }, } diff --git a/src/payments.ts b/src/payments.ts index ca3b5e5..fa8caf2 100644 --- a/src/payments.ts +++ b/src/payments.ts @@ -24,7 +24,6 @@ export class Payments { const sessionKey = url.searchParams.get('sessionKey') if (sessionKey) { this.sessionKey = sessionKey - console.log('sessionKey:', sessionKey) url.searchParams.delete('sessionKey') history.replaceState(history.state, '', url.toString()) } @@ -87,7 +86,7 @@ export class Payments { return response.json() } - public async createWebservice({ + public async createService({ subscriptionDid, name, description, @@ -159,7 +158,6 @@ export class Payments { apiDescription, curation, } - console.log(body) const options = { method: 'POST', headers: { @@ -168,7 +166,7 @@ export class Payments { }, body: JSON.stringify(body), } - const url = new URL('/api/v1/payments/webservice', this.environment.backend) + const url = new URL('/api/v1/payments/service', this.environment.backend) const response = await fetch(url, options) if (!response.ok) { @@ -178,7 +176,7 @@ export class Payments { return response.json() } - public async createDataset({ + public async createFile({ subscriptionDid, assetType, name, @@ -253,7 +251,6 @@ export class Payments { maxCreditsToCharge, curation, } - console.log(body) const options = { method: 'POST', headers: { @@ -262,7 +259,7 @@ export class Payments { }, body: JSON.stringify(body), } - const url = new URL('/api/v1/payments/dataset', this.environment.backend) + const url = new URL('/api/v1/payments/file', this.environment.backend) const response = await fetch(url, options) if (!response.ok) { @@ -271,4 +268,25 @@ export class Payments { return response.json() } + + public getSubscriptionDetails(did: string) { + const url = new URL(`/en/subscription/${did}`, this.environment.frontend) + window.location.href = url.toString() + } + + public getServiceDetails(did: string) { + const url = new URL(`/en/webservice/${did}`, this.environment.frontend) + window.location.href = url.toString() + } + + public getFileDetails(did: string) { + const url = new URL(`/en/file/${did}`, this.environment.frontend) + window.location.href = url.toString() + } + + public checkoutSubscription(did: string) { + const url = new URL(`/en/subscription/checkout/${did}`, this.environment.frontend) + window.location.href = url.toString() + } + }