2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-02 11:54:33 +02:00
|
|
|
import requests from '../utils/requests';
|
2015-06-01 13:02:53 +02:00
|
|
|
|
2015-07-15 14:48:51 +02:00
|
|
|
import ApiUrls from '../constants/api_urls';
|
2015-06-01 13:02:53 +02:00
|
|
|
|
|
|
|
let OwnershipFetcher = {
|
|
|
|
/**
|
2015-08-28 16:18:10 +02:00
|
|
|
* Fetch the default, public contract of a user from the API.
|
2015-06-01 13:02:53 +02:00
|
|
|
*/
|
2015-08-28 16:18:10 +02:00
|
|
|
fetchContract(email) {
|
2015-08-31 17:29:43 +02:00
|
|
|
return requests.get(ApiUrls.blob_contracts + '?loanee=' + email);
|
2015-08-18 16:24:36 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch the contracts of the logged-in user from the API.
|
|
|
|
*/
|
2015-09-11 18:23:31 +02:00
|
|
|
fetchContractList(isActive, isPublic, issuer){
|
|
|
|
let queryParams = {
|
|
|
|
isActive,
|
|
|
|
isPublic,
|
|
|
|
issuer
|
|
|
|
};
|
|
|
|
return requests.get(ApiUrls.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(ApiUrls.ownership_contract_agreements, { body: {signee: signee, contract: contractObj.id }});
|
2015-08-26 09:50:38 +02:00
|
|
|
},
|
2015-08-18 16:24:36 +02:00
|
|
|
|
2015-09-10 20:20:42 +02:00
|
|
|
/**
|
|
|
|
* 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(ApiUrls.ownership_contract_agreements, queryParams);
|
|
|
|
},
|
|
|
|
|
2015-08-26 09:50:38 +02:00
|
|
|
fetchLoanPieceRequestList(){
|
|
|
|
return requests.get(ApiUrls.ownership_loans_pieces_request);
|
2015-09-03 15:53:02 +02:00
|
|
|
},
|
|
|
|
|
2015-09-16 09:47:22 +02:00
|
|
|
changeContract(contractObj){
|
2015-09-08 13:08:49 +02:00
|
|
|
return requests.put(ApiUrls.ownership_contract, { body: contractObj, contract_id: contractObj.id });
|
2015-09-07 11:38:23 +02:00
|
|
|
},
|
|
|
|
|
2015-09-07 15:43:44 +02:00
|
|
|
deleteContract(contractObjId){
|
2015-09-08 11:53:09 +02:00
|
|
|
return requests.delete(ApiUrls.ownership_contract, {contract_id: contractObjId});
|
2015-08-26 09:50:38 +02:00
|
|
|
}
|
2015-06-01 13:02:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default OwnershipFetcher;
|