Skip to content

Commit

Permalink
feat: add some missed methods and update environments
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed Feb 29, 2024
1 parent 51a6233 commit c5ba41b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
20 changes: 18 additions & 2 deletions src/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnvironmentName, EnvironmentInfo> = {
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',
},
}
32 changes: 25 additions & 7 deletions src/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -87,7 +86,7 @@ export class Payments {
return response.json()
}

public async createWebservice({
public async createService({
subscriptionDid,
name,
description,
Expand Down Expand Up @@ -159,7 +158,6 @@ export class Payments {
apiDescription,
curation,
}
console.log(body)
const options = {
method: 'POST',
headers: {
Expand All @@ -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) {
Expand All @@ -178,7 +176,7 @@ export class Payments {
return response.json()
}

public async createDataset({
public async createFile({
subscriptionDid,
assetType,
name,
Expand Down Expand Up @@ -253,7 +251,6 @@ export class Payments {
maxCreditsToCharge,
curation,
}
console.log(body)
const options = {
method: 'POST',
headers: {
Expand All @@ -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) {
Expand All @@ -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()
}

}

0 comments on commit c5ba41b

Please sign in to comment.