1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/brizo/Brizo.ts
Sebastian Gerske 8ab5f7408b remove logging
2018-12-07 17:19:16 +01:00

51 lines
1.4 KiB
TypeScript

import Config from "../models/Config"
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
const apiPath = "/api/v1/brizo/services"
export default class Brizo {
private url: string
constructor(config: Config) {
this.url = config.brizoUri
}
public getPurchaseEndpoint() {
return `${this.url}${apiPath}/access/purchase?`
}
public getConsumeEndpoint(pubKey: string, serviceId: string, url: string) {
return `${this.url}${apiPath}/consume?pubKey=${pubKey}&serviceId=${serviceId}&url=${url}`
}
public getComputeEndpoint(pubKey: string, serviceId: string, algo: string, container: string) {
// tslint:disable-next-line
return `${this.url}${apiPath}/compute?pubKey=${pubKey}&serviceId=${serviceId}&algo=${algo}&container=${container}"`
}
public async initializeServiceAgreement(
did: string,
serviceAgreementId: string,
serviceDefinitionId: string,
signature: string,
consumerAddress: string): Promise<any> {
const args = {
did,
serviceAgreementId,
serviceDefinitionId,
signature,
consumerAddress,
}
return WebServiceConnectorProvider
.getConnector()
.post(
`${this.url}${apiPath}/access/initialize`,
decodeURI(JSON.stringify(args)),
)
}
}