From 8dcafc02dd45c8c083438cc1ef3a3e4963ff327c Mon Sep 17 00:00:00 2001 From: Andres Hernandez Date: Fri, 9 Sep 2022 16:11:11 -0500 Subject: [PATCH 1/4] BillPayments done and tested --- cuenca/resources/bill_payments.py | 37 +++++- cuenca/resources/users.py | 12 +- requirements.txt | 2 +- .../cassettes/test_create_bill_payment.yaml | 108 ++++++++++++++++++ tests/resources/test_bill_payments.py | 16 +++ 5 files changed, 164 insertions(+), 11 deletions(-) create mode 100644 tests/resources/cassettes/test_create_bill_payment.yaml diff --git a/cuenca/resources/bill_payments.py b/cuenca/resources/bill_payments.py index af95e366..e0ba0943 100644 --- a/cuenca/resources/bill_payments.py +++ b/cuenca/resources/bill_payments.py @@ -1,19 +1,48 @@ -from typing import ClassVar, cast +from typing import ClassVar, Optional, cast -from cuenca_validations.types import BillPaymentQuery +from cuenca_validations.types import BillPaymentQuery, ServiceProviderFieldType, BillPaymentRequest -from .base import Transaction +from .base import Creatable, Transaction from .resources import retrieve_uri from .service_providers import ServiceProvider -class BillPayment(Transaction): +class BillPayment(Transaction, Creatable): _resource: ClassVar = 'bill_payments' _query_params: ClassVar = BillPaymentQuery account_number: str provider_uri: str + @classmethod + def create( + cls, + account_number: str, + amount: int, + provider_id: str, + field_type: ServiceProviderFieldType, + accountholder_name: Optional[str] = None, + user_id: Optional[str] = None, + ) -> 'BillPayment': + """ + :param account_number: account id to be paid + :param amount: needs to be in centavos (not pesos) + :param provider_id: ServiceProvider.id + :param field_type: payment type you choose + :param accountholder_name: needed for some services + :param user_id: Source user to take the funds + :return: BillPayment object + """ + req = BillPaymentRequest( + account_number=account_number, + amount=amount, + provider_id=provider_id, + field_type=field_type, + accountholder_name=accountholder_name, + user_id=user_id, + ) + return cast('BillPayment', cls._create(**req.dict())) + @property def provider(self) -> ServiceProvider: provider = cast(ServiceProvider, retrieve_uri(self.provider_uri)) diff --git a/cuenca/resources/users.py b/cuenca/resources/users.py index 4ca1de75..5a1fea29 100644 --- a/cuenca/resources/users.py +++ b/cuenca/resources/users.py @@ -4,10 +4,10 @@ from clabe import Clabe from cuenca_validations.types import ( Address, - AddressUpdateRequest, + #AddressUpdateRequest, Beneficiary, KYCFile, - KYCFileUpdateRequest, + #KYCFileUpdateRequest, PhoneNumber, TOSAgreement, TOSRequest, @@ -132,11 +132,11 @@ def update( phone_number: Optional[PhoneNumber] = None, email_address: Optional[str] = None, profession: Optional[str] = None, - address: Optional[AddressUpdateRequest] = None, + address: Optional[Address] = None, beneficiaries: Optional[List[Beneficiary]] = None, - govt_id: Optional[KYCFileUpdateRequest] = None, - proof_of_address: Optional[KYCFileUpdateRequest] = None, - proof_of_life: Optional[KYCFileUpdateRequest] = None, + govt_id: Optional[KYCFile] = None, + proof_of_address: Optional[KYCFile] = None, + proof_of_life: Optional[KYCFile] = None, terms_of_service: Optional[TOSRequest] = None, verification_id: Optional[str] = None, status: Optional[UserStatus] = None, diff --git a/requirements.txt b/requirements.txt index 312ea418..54d91055 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.27.1 -cuenca-validations==0.10.28 +cuenca-validations==0.11.2.dev1 dataclasses>=0.7;python_version<"3.7" diff --git a/tests/resources/cassettes/test_create_bill_payment.yaml b/tests/resources/cassettes/test_create_bill_payment.yaml new file mode 100644 index 00000000..c62908cb --- /dev/null +++ b/tests/resources/cassettes/test_create_bill_payment.yaml @@ -0,0 +1,108 @@ +interactions: +- request: + body: '{"amount": 1000, "field_type": "barcode", "account_number": "000000000000000000000000000000", + "provider_id": "SP01", "user_id": "US01"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - DUMMY + Connection: + - keep-alive + Content-Length: + - '175' + Content-Type: + - application/json + User-Agent: + - cuenca-python/0.14.1 + X-Cuenca-Api-Version: + - '2020-03-19' + method: POST + uri: https://sandbox.cuenca.com/bill_payments + response: + body: + string: '{"id":"ST01","created_at":"2022-09-09T21:08:11.115509","user_id":"US01","amount":1000,"status":"submitted","descriptor":"Pago + de Servicio","account_number":"000000000000000000000000000000","accountholder_name":null,"provider_uri":"/service_providers/SP01","field_type_id":"SP4qT51xTBPypWCNSBAuREL9","platform_id":"PTAW9CNmJSQ_O8piz-y1NyeA"}' + headers: + Connection: + - keep-alive + Content-Length: + - '400' + Content-Type: + - application/json + Date: + - Fri, 09 Sep 2022 21:08:11 GMT + X-Amzn-Trace-Id: + - Root=1-631bab3a-2cc747337a2b962347561ca6;Sampled=0 + X-Request-Time: + - 'value: 0.774' + x-amz-apigw-id: + - YNexNGdYCYcFVKQ= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '400' + x-amzn-Remapped-Date: + - Fri, 09 Sep 2022 21:08:11 GMT + x-amzn-Remapped-Server: + - nginx/1.22.0 + x-amzn-Remapped-x-amzn-RequestId: + - d9916014-0da1-46d5-9df7-f0a37b3dff21 + x-amzn-RequestId: + - 6f46f9a0-1f1e-4cbf-9243-4ede2417576b + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - DUMMY + Connection: + - keep-alive + User-Agent: + - cuenca-python/0.14.1 + X-Cuenca-Api-Version: + - '2020-03-19' + method: GET + uri: https://sandbox.cuenca.com/service_providers/SP01 + response: + body: + string: '{"id":"SP01","created_at":"2019-07-15T23:21:48.020000","name":"CFE","provider_key":"electricity_cfe","categories":["electricity"],"field_types":[{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000000000000000000000","topup_amounts":[],"type":"barcode"},{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000","topup_amounts":[],"type":"account_number"}]}' + headers: + Connection: + - keep-alive + Content-Length: + - '417' + Content-Type: + - application/json + Date: + - Fri, 09 Sep 2022 21:08:12 GMT + X-Amzn-Trace-Id: + - Root=1-631bab3b-744d7bf5658ed04767b13ed9;Sampled=0 + X-Request-Time: + - 'value: 0.301' + x-amz-apigw-id: + - YNexYHYviYcFY2w= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '417' + x-amzn-Remapped-Date: + - Fri, 09 Sep 2022 21:08:12 GMT + x-amzn-Remapped-Server: + - nginx/1.22.0 + x-amzn-Remapped-x-amzn-RequestId: + - 2c115c13-b55f-4aed-bb08-974c9af67e8a + x-amzn-RequestId: + - ca5657f0-deae-4909-be5b-1a632cf20408 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/resources/test_bill_payments.py b/tests/resources/test_bill_payments.py index 5dce5cd1..7a8f6860 100644 --- a/tests/resources/test_bill_payments.py +++ b/tests/resources/test_bill_payments.py @@ -1,5 +1,6 @@ import pytest +from cuenca_validations.types import BillPaymentRequest from cuenca.resources import BillPayment @@ -11,3 +12,18 @@ def test_bill_payment(): # It should always have a provider provider = bill_payment.provider assert provider is not None + +@pytest.mark.vcr +def test_create_bill_payment(): + bill_payment_request = BillPaymentRequest( + account_number='000000000000000000000000000000', + amount='1000', + provider_id='SP01', + field_type='barcode', + user_id='US01' + ) + bill_payment = BillPayment.create(**bill_payment_request.dict()) + assert bill_payment.id + assert bill_payment.amount == bill_payment_request.amount + assert bill_payment.account_number == bill_payment_request.account_number + assert bill_payment.provider.id == bill_payment_request.provider_id From b834d2a75477aea6b0277a7c30661bc994c0209e Mon Sep 17 00:00:00 2001 From: Andres Hernandez Date: Fri, 9 Sep 2022 16:13:29 -0500 Subject: [PATCH 2/4] lint --- cuenca/resources/bill_payments.py | 6 +++++- cuenca/resources/users.py | 2 -- tests/resources/test_bill_payments.py | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cuenca/resources/bill_payments.py b/cuenca/resources/bill_payments.py index e0ba0943..7d52314e 100644 --- a/cuenca/resources/bill_payments.py +++ b/cuenca/resources/bill_payments.py @@ -1,6 +1,10 @@ from typing import ClassVar, Optional, cast -from cuenca_validations.types import BillPaymentQuery, ServiceProviderFieldType, BillPaymentRequest +from cuenca_validations.types import ( + BillPaymentQuery, + BillPaymentRequest, + ServiceProviderFieldType, +) from .base import Creatable, Transaction from .resources import retrieve_uri diff --git a/cuenca/resources/users.py b/cuenca/resources/users.py index 5a1fea29..be5130e6 100644 --- a/cuenca/resources/users.py +++ b/cuenca/resources/users.py @@ -4,10 +4,8 @@ from clabe import Clabe from cuenca_validations.types import ( Address, - #AddressUpdateRequest, Beneficiary, KYCFile, - #KYCFileUpdateRequest, PhoneNumber, TOSAgreement, TOSRequest, diff --git a/tests/resources/test_bill_payments.py b/tests/resources/test_bill_payments.py index 7a8f6860..1fd0567b 100644 --- a/tests/resources/test_bill_payments.py +++ b/tests/resources/test_bill_payments.py @@ -1,6 +1,6 @@ import pytest - from cuenca_validations.types import BillPaymentRequest + from cuenca.resources import BillPayment @@ -13,6 +13,7 @@ def test_bill_payment(): provider = bill_payment.provider assert provider is not None + @pytest.mark.vcr def test_create_bill_payment(): bill_payment_request = BillPaymentRequest( @@ -20,7 +21,7 @@ def test_create_bill_payment(): amount='1000', provider_id='SP01', field_type='barcode', - user_id='US01' + user_id='US01', ) bill_payment = BillPayment.create(**bill_payment_request.dict()) assert bill_payment.id From 77cdbdb6e87020a0cb93429ef02d7fa4a4e1b7d3 Mon Sep 17 00:00:00 2001 From: Andres Hernandez Date: Sun, 11 Sep 2022 21:36:57 -0500 Subject: [PATCH 3/4] reviews done --- cuenca/resources/bill_payments.py | 2 +- cuenca/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cuenca/resources/bill_payments.py b/cuenca/resources/bill_payments.py index 7d52314e..15674728 100644 --- a/cuenca/resources/bill_payments.py +++ b/cuenca/resources/bill_payments.py @@ -29,7 +29,7 @@ def create( user_id: Optional[str] = None, ) -> 'BillPayment': """ - :param account_number: account id to be paid + :param account_number: account number to be paid :param amount: needs to be in centavos (not pesos) :param provider_id: ServiceProvider.id :param field_type: payment type you choose diff --git a/cuenca/version.py b/cuenca/version.py index 0c21cb75..eef242d1 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '0.14.1' +__version__ = '0.14.2' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' From e431112c4308ec8bab5308ab70a9e96219c16ecb Mon Sep 17 00:00:00 2001 From: Andres Hernandez Date: Mon, 12 Sep 2022 12:46:48 -0500 Subject: [PATCH 4/4] ServiceProvider and BillPayments done and tested with fields --- cuenca/resources/service_providers.py | 6 +- requirements.txt | 2 +- .../cassettes/test_bill_payment.yaml | 70 +++++++++++-------- .../cassettes/test_create_bill_payment.yaml | 48 ++++++------- .../cassettes/test_service_provider.yaml | 34 +++++---- tests/resources/test_bill_payments.py | 2 +- tests/resources/test_service_providers.py | 10 ++- 7 files changed, 98 insertions(+), 74 deletions(-) diff --git a/cuenca/resources/service_providers.py b/cuenca/resources/service_providers.py index 9935ed63..0977cfe1 100644 --- a/cuenca/resources/service_providers.py +++ b/cuenca/resources/service_providers.py @@ -1,6 +1,9 @@ from typing import ClassVar, List -from cuenca_validations.types import ServiceProviderCategory +from cuenca_validations.types import ( + ServiceProviderCategory, + ServiceProviderField, +) from .base import Queryable, Retrievable @@ -11,3 +14,4 @@ class ServiceProvider(Retrievable, Queryable): name: str provider_key: str categories: List[ServiceProviderCategory] + fields: List[ServiceProviderField] diff --git a/requirements.txt b/requirements.txt index 54d91055..2aa0df34 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.27.1 -cuenca-validations==0.11.2.dev1 +cuenca-validations==0.11.2.dev2 dataclasses>=0.7;python_version<"3.7" diff --git a/tests/resources/cassettes/test_bill_payment.yaml b/tests/resources/cassettes/test_bill_payment.yaml index d08a3a0c..509ade55 100644 --- a/tests/resources/cassettes/test_bill_payment.yaml +++ b/tests/resources/cassettes/test_bill_payment.yaml @@ -11,38 +11,42 @@ interactions: Connection: - keep-alive User-Agent: - - cuenca-python/0.3.3 + - cuenca-python/0.14.2 X-Cuenca-Api-Version: - '2020-03-19' method: GET uri: https://sandbox.cuenca.com/bill_payments/ST01 response: body: - string: '{"id":"ST01","created_at":"2020-10-05T01:12:46.973000","user_id":"US01","amount":10000,"status":"succeeded","descriptor":"Pago - de servicio","account_number":"(111) 111-1111","provider_uri":"/service_providers/SP01"}' + string: '{"id":"ST01","created_at":"2022-09-09T21:08:11.115000","user_id":"US01","amount":1000,"status":"failed","descriptor":"Pago + de Servicio","account_number":"000000000000000000000000000000","accountholder_name":null,"provider_uri":"/service_providers/SP01","field_id":null,"platform_id":"PT01"}' headers: Connection: - keep-alive Content-Length: - - '224' + - '370' Content-Type: - application/json Date: - - Mon, 05 Oct 2020 23:56:54 GMT - Via: - - 1.1 72c5987cf6b5170991873937a6e36b80.cloudfront.net (CloudFront) - X-Amz-Cf-Id: - - vPUPB8XgktMziooNHnjTbP2v-wiXIZsW134XChHmw-lw885pV52hpw== - X-Amz-Cf-Pop: - - DFW50-C1 + - Mon, 12 Sep 2022 17:28:11 GMT X-Amzn-Trace-Id: - - Root=1-5f7bb2c5-250155e014a2927a6d49f7f5;Sampled=0 - X-Cache: - - Miss from cloudfront + - Root=1-631f6c2a-2730a57538a7cde575f11fcf;Sampled=0 + X-Request-Time: + - 'value: 0.648' x-amz-apigw-id: - - T9je0FM4IAMF5NQ= + - YW3WpG2CCYcFTMw= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '370' + x-amzn-Remapped-Date: + - Mon, 12 Sep 2022 17:28:11 GMT + x-amzn-Remapped-Server: + - nginx/1.22.0 + x-amzn-Remapped-x-amzn-RequestId: + - 297a93e0-26cd-4b05-a609-6f16fb9584ac x-amzn-RequestId: - - 199a3e85-25c7-40b1-81e6-c45f2d81820b + - e3e87aaf-cb0f-4064-9814-77aa97e395df status: code: 200 message: OK @@ -58,37 +62,41 @@ interactions: Connection: - keep-alive User-Agent: - - cuenca-python/0.3.3 + - cuenca-python/0.14.2 X-Cuenca-Api-Version: - '2020-03-19' method: GET uri: https://sandbox.cuenca.com/service_providers/SP01 response: body: - string: '{"id":"SP01","created_at":"2020-10-05T00:00:48.020000","name":"Telcel","provider_key":"topup_telcel","categories":["mobile_telephone_prepaid"]}' + string: '{"id":"SP01","created_at":"2019-07-15T23:21:48.020000","name":"CFE","provider_key":"electricity_cfe","categories":["electricity"],"fields":[{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000000000000000000000","topup_amounts":[],"type":"barcode"},{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000","topup_amounts":[],"type":"account_number"}]}' headers: Connection: - keep-alive Content-Length: - - '163' + - '412' Content-Type: - application/json Date: - - Mon, 05 Oct 2020 23:56:55 GMT - Via: - - 1.1 72c5987cf6b5170991873937a6e36b80.cloudfront.net (CloudFront) - X-Amz-Cf-Id: - - A9UIKYCnUwTC067I5RCn2e5D9A4wUWy-yeDFT3BMoUqVIzmX5RXaRw== - X-Amz-Cf-Pop: - - DFW50-C1 + - Mon, 12 Sep 2022 17:28:11 GMT X-Amzn-Trace-Id: - - Root=1-5f7bb2c7-36ea3a3623a06c615355e8a7;Sampled=0 - X-Cache: - - Miss from cloudfront + - Root=1-631f6c2b-1f9b9aa63ad8b9080ad1aa8b;Sampled=0 + X-Request-Time: + - 'value: 0.326' x-amz-apigw-id: - - T9jfMHpcoAMF14Q= + - YW3WyE9JCYcFj4w= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '412' + x-amzn-Remapped-Date: + - Mon, 12 Sep 2022 17:28:11 GMT + x-amzn-Remapped-Server: + - nginx/1.22.0 + x-amzn-Remapped-x-amzn-RequestId: + - 71c5252e-89c9-45bf-905e-b0ea0048f8bd x-amzn-RequestId: - - bacb6a7e-6fcc-4645-bd55-5d0dfc08f4e2 + - 37186823-58eb-4675-a61c-8ac1eb394ce9 status: code: 200 message: OK diff --git a/tests/resources/cassettes/test_create_bill_payment.yaml b/tests/resources/cassettes/test_create_bill_payment.yaml index c62908cb..ad345e41 100644 --- a/tests/resources/cassettes/test_create_bill_payment.yaml +++ b/tests/resources/cassettes/test_create_bill_payment.yaml @@ -1,7 +1,7 @@ interactions: - request: body: '{"amount": 1000, "field_type": "barcode", "account_number": "000000000000000000000000000000", - "provider_id": "SP01", "user_id": "US01"}' + "provider_id": "SP01", "user_id": "USMGZJ4vEYQ5SplZR5lcX5bg"}' headers: Accept: - '*/*' @@ -16,42 +16,42 @@ interactions: Content-Type: - application/json User-Agent: - - cuenca-python/0.14.1 + - cuenca-python/0.14.2 X-Cuenca-Api-Version: - '2020-03-19' method: POST uri: https://sandbox.cuenca.com/bill_payments response: body: - string: '{"id":"ST01","created_at":"2022-09-09T21:08:11.115509","user_id":"US01","amount":1000,"status":"submitted","descriptor":"Pago - de Servicio","account_number":"000000000000000000000000000000","accountholder_name":null,"provider_uri":"/service_providers/SP01","field_type_id":"SP4qT51xTBPypWCNSBAuREL9","platform_id":"PTAW9CNmJSQ_O8piz-y1NyeA"}' + string: '{"id":"STGjSUx0_9Rym_ElZbn8gW5g","created_at":"2022-09-12T17:41:18.036250","user_id":"USMGZJ4vEYQ5SplZR5lcX5bg","amount":1000,"status":"submitted","descriptor":"Pago + de Servicio a CFE","account_number":"000000000000000000000000000000","accountholder_name":null,"provider_uri":"/service_providers/SP01","field_id":"SP4qT51xTBPypWCNSBAuREL9","platform_id":"PTAW9CNmJSQ_O8piz-y1NyeA"}' headers: Connection: - keep-alive Content-Length: - - '400' + - '401' Content-Type: - application/json Date: - - Fri, 09 Sep 2022 21:08:11 GMT + - Mon, 12 Sep 2022 17:41:18 GMT X-Amzn-Trace-Id: - - Root=1-631bab3a-2cc747337a2b962347561ca6;Sampled=0 + - Root=1-631f6f3b-2a07ba063f555dae2e758be4;Sampled=0 X-Request-Time: - - 'value: 0.774' + - 'value: 3.277' x-amz-apigw-id: - - YNexNGdYCYcFVKQ= + - YW5RSFYpCYcFbhg= x-amzn-Remapped-Connection: - keep-alive x-amzn-Remapped-Content-Length: - - '400' + - '401' x-amzn-Remapped-Date: - - Fri, 09 Sep 2022 21:08:11 GMT + - Mon, 12 Sep 2022 17:41:18 GMT x-amzn-Remapped-Server: - nginx/1.22.0 x-amzn-Remapped-x-amzn-RequestId: - - d9916014-0da1-46d5-9df7-f0a37b3dff21 + - d9e85c4b-f6d2-4909-80d9-f848720a12ec x-amzn-RequestId: - - 6f46f9a0-1f1e-4cbf-9243-4ede2417576b + - fa9f577b-2d7f-4f42-8d51-2889420af5cd status: code: 201 message: Created @@ -67,41 +67,41 @@ interactions: Connection: - keep-alive User-Agent: - - cuenca-python/0.14.1 + - cuenca-python/0.14.2 X-Cuenca-Api-Version: - '2020-03-19' method: GET uri: https://sandbox.cuenca.com/service_providers/SP01 response: body: - string: '{"id":"SP01","created_at":"2019-07-15T23:21:48.020000","name":"CFE","provider_key":"electricity_cfe","categories":["electricity"],"field_types":[{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000000000000000000000","topup_amounts":[],"type":"barcode"},{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000","topup_amounts":[],"type":"account_number"}]}' + string: '{"id":"SP01","created_at":"2019-07-15T23:21:48.020000","name":"CFE","provider_key":"electricity_cfe","categories":["electricity"],"fields":[{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000000000000000000000","topup_amounts":[],"type":"barcode"},{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000","topup_amounts":[],"type":"account_number"}]}' headers: Connection: - keep-alive Content-Length: - - '417' + - '412' Content-Type: - application/json Date: - - Fri, 09 Sep 2022 21:08:12 GMT + - Mon, 12 Sep 2022 17:41:18 GMT X-Amzn-Trace-Id: - - Root=1-631bab3b-744d7bf5658ed04767b13ed9;Sampled=0 + - Root=1-631f6f3e-2b6d8b2936fcb61e07a9ccd7;Sampled=0 X-Request-Time: - - 'value: 0.301' + - 'value: 0.344' x-amz-apigw-id: - - YNexYHYviYcFY2w= + - YW5RzGr9CYcFzmg= x-amzn-Remapped-Connection: - keep-alive x-amzn-Remapped-Content-Length: - - '417' + - '412' x-amzn-Remapped-Date: - - Fri, 09 Sep 2022 21:08:12 GMT + - Mon, 12 Sep 2022 17:41:18 GMT x-amzn-Remapped-Server: - nginx/1.22.0 x-amzn-Remapped-x-amzn-RequestId: - - 2c115c13-b55f-4aed-bb08-974c9af67e8a + - d45822cf-13eb-467b-82ba-f31af89f6bf5 x-amzn-RequestId: - - ca5657f0-deae-4909-be5b-1a632cf20408 + - 6071e186-dad0-421a-b301-1c4f371123b5 status: code: 200 message: OK diff --git a/tests/resources/cassettes/test_service_provider.yaml b/tests/resources/cassettes/test_service_provider.yaml index 85d8ad78..4a602915 100644 --- a/tests/resources/cassettes/test_service_provider.yaml +++ b/tests/resources/cassettes/test_service_provider.yaml @@ -11,37 +11,41 @@ interactions: Connection: - keep-alive User-Agent: - - cuenca-python/0.3.3 + - cuenca-python/0.14.2 X-Cuenca-Api-Version: - '2020-03-19' method: GET uri: https://sandbox.cuenca.com/service_providers/SP01 response: body: - string: '{"id":"SP01","created_at":"2020-10-05T00:00:48.020000","name":"Telcel","provider_key":"topup_telcel","categories":["mobile_telephone_prepaid"]}' + string: '{"id":"SP01","created_at":"2019-07-15T23:21:48.020000","name":"CFE","provider_key":"electricity_cfe","categories":["electricity"],"fields":[{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000000000000000000000","topup_amounts":[],"type":"barcode"},{"is_active":true,"requires_accountholder_name":false,"mask":"000000000000","topup_amounts":[],"type":"account_number"}]}' headers: Connection: - keep-alive Content-Length: - - '143' + - '412' Content-Type: - application/json Date: - - Mon, 05 Oct 2020 23:57:35 GMT - Via: - - 1.1 efcb172d06d66d2afa4eb747b3b88605.cloudfront.net (CloudFront) - X-Amz-Cf-Id: - - iWGW67QhiyoL-aZIypsTLH6C5bvPqRCgV_g44Fi0P4vOx333rMny_Q== - X-Amz-Cf-Pop: - - DFW50-C1 + - Mon, 12 Sep 2022 17:04:32 GMT X-Amzn-Trace-Id: - - Root=1-5f7bb2ef-0ce8f8fa299012df0c8a8103;Sampled=0 - X-Cache: - - Miss from cloudfront + - Root=1-631f669d-21de2ba7666426d91dcb9880;Sampled=0 + X-Request-Time: + - 'value: 2.924' x-amz-apigw-id: - - T9jlZE16IAMFybg= + - YWz4sFA4iYcFpWA= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '412' + x-amzn-Remapped-Date: + - Mon, 12 Sep 2022 17:04:32 GMT + x-amzn-Remapped-Server: + - nginx/1.22.0 + x-amzn-Remapped-x-amzn-RequestId: + - 69191bbf-d841-4d7f-90aa-7d8e9e2585bd x-amzn-RequestId: - - 55e6aec9-7e04-4158-a418-478cc49101d4 + - 4d1ea458-d9d5-47ec-893c-4b747cba50ef status: code: 200 message: OK diff --git a/tests/resources/test_bill_payments.py b/tests/resources/test_bill_payments.py index 1fd0567b..67e8d2fe 100644 --- a/tests/resources/test_bill_payments.py +++ b/tests/resources/test_bill_payments.py @@ -18,7 +18,7 @@ def test_bill_payment(): def test_create_bill_payment(): bill_payment_request = BillPaymentRequest( account_number='000000000000000000000000000000', - amount='1000', + amount=1000, provider_id='SP01', field_type='barcode', user_id='US01', diff --git a/tests/resources/test_service_providers.py b/tests/resources/test_service_providers.py index ffe925be..564c83b5 100644 --- a/tests/resources/test_service_providers.py +++ b/tests/resources/test_service_providers.py @@ -1,5 +1,8 @@ import pytest -from cuenca_validations.types import ServiceProviderCategory +from cuenca_validations.types import ( + ServiceProviderCategory, + ServiceProviderFieldType, +) from cuenca.resources import ServiceProvider @@ -14,3 +17,8 @@ def test_service_provider(): categories = service_provider.categories values = set(category.value for category in ServiceProviderCategory) assert all(category in values for category in categories) + + # Check that all fields are in the FieldType Enum + fields = service_provider.fields + values = set(field.value for field in ServiceProviderFieldType) + assert all(field.type in values for field in fields)