2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-14 16:53:18 +02:00
|
|
|
import request from '../utils/request';
|
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
|
|
|
*/
|
2016-06-14 13:05:57 +02:00
|
|
|
fetchContract(loanee) {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('blob_contracts', {
|
|
|
|
query: { loanee }
|
|
|
|
});
|
2015-08-18 16:24:36 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch the contracts of the logged-in user from the API.
|
|
|
|
*/
|
2015-12-21 11:44:13 +01:00
|
|
|
fetchContractList(isActive, isPublic, issuer) {
|
2016-06-14 16:53:18 +02:00
|
|
|
const query = { isActive, isPublic, issuer };
|
|
|
|
|
|
|
|
return request('ownership_contract_list', { query });
|
2015-09-11 18:23:31 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a contractagreement between the logged-in user and the email from the API with contract.
|
|
|
|
*/
|
2015-12-21 11:44:13 +01:00
|
|
|
createContractAgreement(signee, contractObj) {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('ownership_contract_agreements', {
|
|
|
|
method: 'POST',
|
|
|
|
jsonBody: {
|
|
|
|
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) {
|
2016-06-14 16:53:18 +02:00
|
|
|
const query = { issuer, accepted, pending };
|
|
|
|
|
|
|
|
return request('ownership_contract_agreements', { query });
|
2015-09-10 20:20:42 +02:00
|
|
|
},
|
|
|
|
|
2015-12-21 11:44:13 +01:00
|
|
|
confirmContractAgreement(contractAgreement) {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('ownership_contract_agreements_confirm', {
|
|
|
|
method: 'PUT',
|
|
|
|
urlTemplateSpec: {
|
|
|
|
contractAgreementId: contractAgreement.id
|
|
|
|
}
|
|
|
|
});
|
2015-09-17 14:20:46 +02:00
|
|
|
},
|
|
|
|
|
2015-12-21 11:44:13 +01:00
|
|
|
denyContractAgreement(contractAgreement) {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('ownership_contract_agreements_deny', {
|
|
|
|
method: 'PUT',
|
|
|
|
urlTemplateSpec: {
|
|
|
|
contractAgreementId: contractAgreement.id
|
|
|
|
}
|
|
|
|
});
|
2015-09-17 14:20:46 +02:00
|
|
|
},
|
|
|
|
|
2015-12-21 11:44:13 +01:00
|
|
|
fetchLoanPieceRequestList() {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('ownership_loans_pieces_request');
|
2015-09-03 15:53:02 +02:00
|
|
|
},
|
|
|
|
|
2015-12-21 11:44:13 +01:00
|
|
|
changeContract(contractObj) {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('ownership_contract', {
|
|
|
|
method: 'PUT',
|
|
|
|
jsonBody: contractObj,
|
|
|
|
urlTemplateSpec: {
|
|
|
|
contractId: contractObj.id
|
|
|
|
}
|
|
|
|
});
|
2015-09-07 11:38:23 +02:00
|
|
|
},
|
|
|
|
|
2016-06-14 16:53:18 +02:00
|
|
|
deleteContract(contractId) {
|
|
|
|
return request('ownership_contract', {
|
|
|
|
method: 'DELETE',
|
|
|
|
urlTemplateSpec: { contractId }
|
|
|
|
});
|
2015-08-26 09:50:38 +02:00
|
|
|
}
|
2015-06-01 13:02:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default OwnershipFetcher;
|