1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/ocean/Order.ts

72 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-10-16 14:56:18 +02:00
import Keeper from "../keeper/Keeper"
2018-10-02 10:06:26 +02:00
import Logger from "../utils/Logger"
2018-10-16 14:56:18 +02:00
import Asset from "./Asset"
2018-10-09 10:55:53 +02:00
import OceanBase from "./OceanBase"
2018-10-16 14:56:18 +02:00
import Account from "./Account"
2018-10-09 10:55:53 +02:00
export default class Order extends OceanBase {
2018-10-16 14:56:18 +02:00
private paid: boolean
private status: number
private accessUrl: string
private accessId: string
2018-10-10 11:02:00 +02:00
2018-10-16 14:56:18 +02:00
constructor(private asset: Asset, private timeout: number,
private pubkey: string, private key: any) {
super()
}
2018-10-16 14:56:18 +02:00
public setAccessUrl(url: string) {
this.accessUrl = url
}
2018-10-16 14:56:18 +02:00
public getAccessUrl() {
return this.accessUrl
}
2018-10-16 14:56:18 +02:00
public setStatus(status: number) {
this.status = status
}
2018-10-16 14:56:18 +02:00
public setAccessId(accessId: string) {
Logger.log("accessId", accessId)
this.accessId = accessId
}
2018-10-16 14:56:18 +02:00
public getStatus() {
return this.status
}
2018-10-16 14:56:18 +02:00
public setPaid(paid: boolean) {
this.paid = paid
}
2018-10-16 14:56:18 +02:00
public getPaid() {
return this.paid
}
2018-10-16 14:56:18 +02:00
public getAsset() {
return this.asset
}
2018-10-16 14:56:18 +02:00
public getPubkey() {
return this.pubkey
}
2018-10-16 14:56:18 +02:00
public getTimeout() {
return this.timeout
}
2018-10-16 14:56:18 +02:00
public getKey() {
return this.key
}
2018-10-16 14:56:18 +02:00
public async pay(account: Account) {
const {market} = await Keeper.getInstance()
// send payment
Logger.log("Sending payment: ", this.getId(), this.accessId,
this.asset.publisher.getId(), this.asset.price, this.timeout)
return market.payOrder(this, account.getId())
}
}