1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/fetchers/ownership_fetcher.js
Brett Sun 7014514654 Use UrlResolver to resolve api urls based on white labelling rather than updating ApiUrl's export
Keeping an export constant is more predictable and less surprising for
most people.
2016-06-14 17:58:00 +02:00

69 lines
2.0 KiB
JavaScript

'use strict';
import requests from '../utils/requests';
// FIXME: fix query string usage
let OwnershipFetcher = {
/**
* Fetch the default, public contract of a user from the API.
*/
fetchContract(loanee) {
return requests.get('blob_contracts', { loanee });
},
/**
* Fetch the contracts of the logged-in user from the API.
*/
fetchContractList(isActive, isPublic, issuer) {
let queryParams = {
isActive,
isPublic,
issuer
};
return requests.get('ownership_contract_list', queryParams);
},
/**
* Create a contractagreement between the logged-in user and the email from the API with contract.
*/
createContractAgreement(signee, contractObj) {
return requests.post('ownership_contract_agreements', { body: {signee: signee, contract: contractObj.id }});
},
/**
* Fetch the contractagreement between the logged-in user and the email from the API.
*/
fetchContractAgreementList(issuer, accepted, pending) {
let queryParams = {
issuer,
accepted,
pending
};
return requests.get('ownership_contract_agreements', queryParams);
},
confirmContractAgreement(contractAgreement) {
return requests.put('ownership_contract_agreements_confirm', {contract_agreement_id: contractAgreement.id});
},
denyContractAgreement(contractAgreement) {
return requests.put('ownership_contract_agreements_deny', {contract_agreement_id: contractAgreement.id});
},
fetchLoanPieceRequestList() {
return requests.get('ownership_loans_pieces_request');
},
changeContract(contractObj) {
return requests.put('ownership_contract', { body: contractObj, contract_id: contractObj.id });
},
deleteContract(contractObjId) {
return requests.delete('ownership_contract', {contract_id: contractObjId});
}
};
export default OwnershipFetcher;