2018-11-09 10:43:29 +01:00
|
|
|
import Config from "../models/Config"
|
2018-11-19 12:16:11 +01:00
|
|
|
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
|
2018-11-09 10:43:29 +01:00
|
|
|
|
|
|
|
export default class Brizo {
|
|
|
|
private url: string
|
|
|
|
|
|
|
|
constructor(config: Config) {
|
|
|
|
|
|
|
|
this.url = config.brizoUri
|
|
|
|
}
|
|
|
|
|
|
|
|
public getPurchaseEndpoint() {
|
|
|
|
return `${this.url}/api/v1/brizo/services/access/purchase?`
|
|
|
|
}
|
|
|
|
|
2018-11-09 11:16:22 +01:00
|
|
|
public getConsumeEndpoint(pubKey: string, serviceId: string, url: string) {
|
2018-11-09 10:43:29 +01:00
|
|
|
return `${this.url}/api/v1/brizo/services/consume?pubKey=${pubKey}&serviceId=${serviceId}&url=${url}`
|
|
|
|
}
|
2018-11-09 11:16:22 +01:00
|
|
|
|
|
|
|
public getComputeEndpoint(pubKey: string, serviceId: string, algo: string, container: string) {
|
|
|
|
// tslint:disable-next-line
|
|
|
|
return `${this.url}/api/v1/brizo/services/compute?pubKey=${pubKey}&serviceId=${serviceId}&algo=${algo}&container=${container}"`
|
|
|
|
}
|
2018-11-19 12:16:11 +01:00
|
|
|
|
|
|
|
public async initializeServiceAgreement(did: string, serviceAgreementId: string, serviceDefinitionId: string,
|
|
|
|
signature: string, consumerPublicKey: string): Promise<any> {
|
|
|
|
|
|
|
|
return WebServiceConnectorProvider.getConnector().post(
|
|
|
|
`${this.url}/api/v1/brizo/services/access/initialize`,
|
|
|
|
{
|
|
|
|
did,
|
|
|
|
serviceAgreementId,
|
|
|
|
serviceDefinitionId,
|
|
|
|
signature,
|
|
|
|
consumerPublicKey,
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
2018-11-09 10:43:29 +01:00
|
|
|
}
|