-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commissions with related transactions (#65)
* tests comissions * fix test * fix entry model * fix relatedtransaction * commission end * change version valid * fix entry model * fix Commission * use mapper in commission * update version * fix end * change id * rebase and change version cuenca-validations
- Loading branch information
Keryc Diaz
authored
Oct 13, 2020
1 parent
8cdb4c7
commit 8885032
Showing
9 changed files
with
470 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
from typing import ClassVar, Optional | ||
from typing import ClassVar, Optional, cast | ||
|
||
from cuenca_validations.types import ( | ||
CommissionType, | ||
EntryType, | ||
RelatedTransaction, | ||
) | ||
from pydantic.dataclasses import dataclass | ||
|
||
from cuenca import resources | ||
|
||
from .base import Transaction | ||
from .resources import retrieve_uri | ||
|
||
mapper = {CommissionType.cash_deposit: EntryType.credit} | ||
|
||
|
||
@dataclass | ||
class Commission(Transaction): | ||
_resource: ClassVar = 'commissions' | ||
|
||
related_transaction_uri: Optional[str] | ||
type: CommissionType | ||
related_transaction_uri: Optional[RelatedTransaction] | ||
|
||
@property # type: ignore | ||
def related_transaction(self): | ||
rt = self.related_transaction_uri | ||
if not rt: | ||
return None | ||
resource = getattr(resources, rt.get_model()) | ||
return cast(resource, retrieve_uri(rt)) if resource else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
__version__ = '0.3.2' | ||
__version__ = '0.3.4' | ||
CLIENT_VERSION = __version__ | ||
API_VERSION = '2020-03-19' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
requests==2.24.0 | ||
cuenca-validations==0.5.7 | ||
cuenca-validations==0.6.2 | ||
dataclasses>=0.7;python_version<"3.7" | ||
aws-requests-auth==0.4.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- DUMMY | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- cuenca-python/0.3.2 | ||
X-Cuenca-Api-Version: | ||
- '2020-03-19' | ||
x-amz-content-sha256: | ||
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||
x-amz-date: | ||
- 20201001T182731Z | ||
method: GET | ||
uri: https://sandbox.cuenca.com/commissions/COXXX | ||
response: | ||
body: | ||
string: '{"id":"COXXX","created_at":"2020-09-24T00:29:34.830000","user_id":"US2qz3mrAomlP8LWG106tILW","amount":25000,"status":"created","descriptor":"Comisi\u00f3n | ||
(card_request)", "type": "cash_deposit","related_transaction_uri":null}' | ||
headers: | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '220' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Thu, 01 Oct 2020 18:27:35 GMT | ||
Via: | ||
- 1.1 73f86570b09a38dfaa856857b5578e7e.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- vytdtvve_zN6caN21ZDTayVxVQ2-d1rDKmoG02Ut1V04G2SOrxtzfg== | ||
X-Amz-Cf-Pop: | ||
- DFW55-C1 | ||
X-Amzn-Trace-Id: | ||
- Root=1-5f761f95-7f1856a72145666d5107c55e;Sampled=0 | ||
X-Cache: | ||
- Miss from cloudfront | ||
x-amz-apigw-id: | ||
- TvnfVGIEIAMFa_Q= | ||
x-amzn-RequestId: | ||
- ab9b3780-d7c6-4628-98cf-5553b3de80a1 | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
104 changes: 104 additions & 0 deletions
104
tests/resources/cassettes/test_commission_retrieve_witw_cash_deposit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- DUMMY | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- cuenca-python/0.3.2 | ||
X-Cuenca-Api-Version: | ||
- '2020-03-19' | ||
x-amz-content-sha256: | ||
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||
x-amz-date: | ||
- 20201001T185704Z | ||
method: GET | ||
uri: https://sandbox.cuenca.com/commissions/COXXX | ||
response: | ||
body: | ||
string: '{"id":"COXXX","created_at":"2020-09-30T19:38:33.361000","user_id":"USXXX","amount":1000,"status":"succeeded","descriptor":"Comisi\u00f3n | ||
(cash_deposit)", "type": "cash_deposit","related_transaction_uri":"/deposits/CDXXX"}' | ||
headers: | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '254' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Thu, 01 Oct 2020 18:57:04 GMT | ||
Via: | ||
- 1.1 73f86570b09a38dfaa856857b5578e7e.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- qhDyaKeW0Ocibu9DAsgRAOGZDLKAh4Ch8h7bgUOzErlF2enEXVrNLw== | ||
X-Amz-Cf-Pop: | ||
- DFW55-C1 | ||
X-Amzn-Trace-Id: | ||
- Root=1-5f762680-5dbf128e0175d0637dc90d9b;Sampled=0 | ||
X-Cache: | ||
- Miss from cloudfront | ||
x-amz-apigw-id: | ||
- Tvr0KGBuoAMFvDw= | ||
x-amzn-RequestId: | ||
- f2476afc-8fb5-491f-ad79-2f365e55797d | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- DUMMY | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- cuenca-python/0.3.2 | ||
X-Cuenca-Api-Version: | ||
- '2020-03-19' | ||
x-amz-content-sha256: | ||
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||
x-amz-date: | ||
- 20201001T185705Z | ||
method: GET | ||
uri: https://sandbox.cuenca.com/deposits/CDXXX | ||
response: | ||
body: | ||
string: '{"id":"CDXXX","created_at":"2020-09-30T19:38:29.234000","user_id":"USXXX","amount":2002,"status":"succeeded","descriptor":"Deposito | ||
v\u00eda paynet auth 648695","source_uri":null,"network":"cash","tracking_key":null}' | ||
headers: | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '254' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Thu, 01 Oct 2020 18:57:05 GMT | ||
Via: | ||
- 1.1 73f86570b09a38dfaa856857b5578e7e.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- zWYNKGEjQ8P0PF_azgGX01euUv3Jl0T4dejiLXjDJdvQ4_FvG81F2A== | ||
X-Amz-Cf-Pop: | ||
- DFW55-C1 | ||
X-Amzn-Trace-Id: | ||
- Root=1-5f762681-2c39d73d0760e8f37ffbe378;Sampled=0 | ||
X-Cache: | ||
- Miss from cloudfront | ||
x-amz-apigw-id: | ||
- Tvr0OFKJIAMFYng= | ||
x-amzn-RequestId: | ||
- 1e7a83a6-88a1-443d-a175-1f35152b6cda | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
104 changes: 104 additions & 0 deletions
104
tests/resources/cassettes/test_commission_retrieve_witw_cash_transfer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- DUMMY | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- cuenca-python/0.3.2 | ||
X-Cuenca-Api-Version: | ||
- '2020-03-19' | ||
x-amz-content-sha256: | ||
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||
x-amz-date: | ||
- 20201001T185704Z | ||
method: GET | ||
uri: https://sandbox.cuenca.com/commissions/COXXX | ||
response: | ||
body: | ||
string: '{"id":"COXXX","created_at":"2020-09-30T19:38:33.361000","user_id":"USXXX","amount":1000,"status":"succeeded","descriptor":"Comisi\u00f3n | ||
(cash_transfer)", "type": "cash_deposit","related_transaction_uri":"/transfers/SP5XXX"}' | ||
headers: | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '254' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Thu, 01 Oct 2020 18:57:04 GMT | ||
Via: | ||
- 1.1 73f86570b09a38dfaa856857b5578e7e.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- qhDyaKeW0Ocibu9DAsgRAOGZDLKAh4Ch8h7bgUOzErlF2enEXVrNLw== | ||
X-Amz-Cf-Pop: | ||
- DFW55-C1 | ||
X-Amzn-Trace-Id: | ||
- Root=1-5f762680-5dbf128e0175d0637dc90d9b;Sampled=0 | ||
X-Cache: | ||
- Miss from cloudfront | ||
x-amz-apigw-id: | ||
- Tvr0KGBuoAMFvDw= | ||
x-amzn-RequestId: | ||
- f2476afc-8fb5-491f-ad79-2f365e55797d | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- DUMMY | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- cuenca-python/0.3.2 | ||
X-Cuenca-Api-Version: | ||
- '2020-03-19' | ||
x-amz-content-sha256: | ||
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||
x-amz-date: | ||
- 20201001T185705Z | ||
method: GET | ||
uri: https://sandbox.cuenca.com/transfers/SP5XXX | ||
response: | ||
body: | ||
string: '{"id":"SP5XXX","created_at":"2020-05-08T23:12:25.042000","updated_at":"2020-05-08T23:12:28.854000","account_number":"646180157013244941","recipient_name":"test | ||
85d91ea6-76b6-49ab-913b-0481e8df7379","amount":8888,"descriptor":"lambda","idempotency_key":"b2bf01cb-da5f-4a42-9462-23078b81b6ea","status":"failed","network":"spei","destination_uri":null,"tracking_key":null,"user_id":"USXXX"}' | ||
headers: | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '254' | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Thu, 01 Oct 2020 18:57:05 GMT | ||
Via: | ||
- 1.1 73f86570b09a38dfaa856857b5578e7e.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- zWYNKGEjQ8P0PF_azgGX01euUv3Jl0T4dejiLXjDJdvQ4_FvG81F2A== | ||
X-Amz-Cf-Pop: | ||
- DFW55-C1 | ||
X-Amzn-Trace-Id: | ||
- Root=1-5f762681-2c39d73d0760e8f37ffbe378;Sampled=0 | ||
X-Cache: | ||
- Miss from cloudfront | ||
x-amz-apigw-id: | ||
- Tvr0OFKJIAMFYng= | ||
x-amzn-RequestId: | ||
- 1e7a83a6-88a1-443d-a175-1f35152b6cda | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
Oops, something went wrong.