diff --git a/src/main/java/conekta/io/client/impl/CustomersClient.java b/src/main/java/conekta/io/client/impl/CustomersClient.java index 81e8ac9..0da78da 100644 --- a/src/main/java/conekta/io/client/impl/CustomersClient.java +++ b/src/main/java/conekta/io/client/impl/CustomersClient.java @@ -8,6 +8,7 @@ import conekta.io.error.ConektaErrorResponse; import conekta.io.model.PaginatedConektaObject; import conekta.io.model.impl.Customer; +import conekta.io.model.request.CustomerReq; import conekta.io.model.submodel.Event; import conekta.io.model.submodel.PaymentSource; @@ -21,8 +22,8 @@ public class CustomersClient extends ConektaRequestor { * @param customer The customer to be created. * @return The created ConektaResponse. */ - public ConektaResponse createCustomer(Customer customer){ - HttpResponse customerResponse = doRequest(customer, Constants.CUSTOMERS_PATH, Constants.POST); + public ConektaResponse createCustomer(CustomerReq customerReq) { + HttpResponse customerResponse = doRequest(customerReq, Constants.CUSTOMERS_PATH, Constants.POST); return ConektaResponse.builder() .response(customerResponse) .statusCode(customerResponse.statusCode()) @@ -37,7 +38,7 @@ public ConektaResponse createCustomer(Customer customer){ * @param customerId The id of the customer to be retrieved. * @return The retrieved ConektaResponse. */ - public ConektaResponse retrieveCustomer(String customerId){ + public ConektaResponse retrieveCustomer(String customerId) { HttpResponse customerResponse = doRequest(null, Constants.CUSTOMERS_PATH + Constants.SLASH + customerId, Constants.GET); return ConektaResponse.builder() .response(customerResponse) @@ -49,12 +50,13 @@ public ConektaResponse retrieveCustomer(String customerId){ /** * Retrieves all customers paginated in Conekta. + * * @param next The next page of the customers to be retrieved. * If null, the first page will be retrieved. * If not null, the next page will be retrieved. * @return The retrieved ConektaResponse>. */ - public ConektaResponse> getCustomers(String next){ + public ConektaResponse> getCustomers(String next) { HttpResponse customersResponse = doRequest(null, Constants.CUSTOMERS_PATH + (next != null ? Constants.NEXT + next : ""), Constants.GET); return ConektaResponse.>builder() .response(customersResponse) @@ -71,7 +73,7 @@ public ConektaResponse> getCustomers(String nex * @param customer The customer to be updated. * @return The updated ConektaResponse. */ - public ConektaResponse updateCustomer(String customerId, Customer customer){ + public ConektaResponse updateCustomer(String customerId, Customer customer) { HttpResponse customerResponse = doRequest(customer, Constants.CUSTOMERS_PATH + Constants.SLASH + customerId, Constants.PUT); return ConektaResponse.builder() .response(customerResponse) @@ -87,7 +89,7 @@ public ConektaResponse updateCustomer(String customerId, Customer cust * @param customerId The id of the customer to be deleted. * @return The deleted ConektaResponse. */ - public ConektaResponse deleteCustomer(String customerId){ + public ConektaResponse deleteCustomer(String customerId) { HttpResponse customerResponse = doRequest(null, Constants.CUSTOMERS_PATH + Constants.SLASH + customerId, Constants.DELETE); return ConektaResponse.builder() .response(customerResponse) diff --git a/src/main/java/conekta/io/client/impl/OrdersClient.java b/src/main/java/conekta/io/client/impl/OrdersClient.java index 16bd45a..4ec128c 100644 --- a/src/main/java/conekta/io/client/impl/OrdersClient.java +++ b/src/main/java/conekta/io/client/impl/OrdersClient.java @@ -7,9 +7,9 @@ import conekta.io.config.Constants; import conekta.io.error.ConektaErrorResponse; import conekta.io.model.PaginatedConektaObject; +import conekta.io.model.impl.Order; import conekta.io.model.request.OrderRefundReq; import conekta.io.model.request.OrderReq; -import conekta.io.model.response.Order; import conekta.io.model.submodel.Charge; import conekta.io.utils.Utils; diff --git a/src/main/java/conekta/io/model/impl/Customer.java b/src/main/java/conekta/io/model/impl/Customer.java index 1b1bd0d..3dd8bed 100644 --- a/src/main/java/conekta/io/model/impl/Customer.java +++ b/src/main/java/conekta/io/model/impl/Customer.java @@ -1,7 +1,10 @@ package conekta.io.model.impl; import conekta.io.model.ConektaObject; +import conekta.io.model.PaginatedConektaObject; import conekta.io.model.submodel.AntifraudInfo; +import conekta.io.model.submodel.PaymentSource; +import conekta.io.model.submodel.ShippingContact; import lombok.Data; @Data @@ -17,8 +20,8 @@ public class Customer extends ConektaObject { private String customReference; private AntifraudInfo antifraudInfo; private String defaultPaymentSourceId; - private Object paymentSources; - private Object shippingContacts; - //TODO REVISAR CON UN EXPERTO URGENTE + private PaginatedConektaObject paymentSources; + private PaginatedConektaObject shippingContacts; + private Subscription subscription; private Boolean deleted; } diff --git a/src/main/java/conekta/io/model/response/Order.java b/src/main/java/conekta/io/model/impl/Order.java similarity index 94% rename from src/main/java/conekta/io/model/response/Order.java rename to src/main/java/conekta/io/model/impl/Order.java index e0df7da..8831439 100644 --- a/src/main/java/conekta/io/model/response/Order.java +++ b/src/main/java/conekta/io/model/impl/Order.java @@ -1,8 +1,7 @@ -package conekta.io.model.response; +package conekta.io.model.impl; import conekta.io.model.ConektaObject; import conekta.io.model.PaginatedConektaObject; -import conekta.io.model.impl.Customer; import conekta.io.model.submodel.*; import lombok.Data; diff --git a/src/main/java/conekta/io/model/impl/Subscription.java b/src/main/java/conekta/io/model/impl/Subscription.java index 799f010..9f4ca9e 100644 --- a/src/main/java/conekta/io/model/impl/Subscription.java +++ b/src/main/java/conekta/io/model/impl/Subscription.java @@ -1,6 +1,18 @@ package conekta.io.model.impl; import conekta.io.model.ConektaObject; +import lombok.Data; +@Data public class Subscription extends ConektaObject { + + private String status; + private String chargeId; + private String createAt; + private Long subscriptionStart; + private Long billingCycleStart; + private Long billingCycleEnd; + private String planId; + private String customerId; + private String cardId; } diff --git a/src/main/java/conekta/io/model/request/CustomerReq.java b/src/main/java/conekta/io/model/request/CustomerReq.java index 4a39b8c..5242795 100644 --- a/src/main/java/conekta/io/model/request/CustomerReq.java +++ b/src/main/java/conekta/io/model/request/CustomerReq.java @@ -1,6 +1,7 @@ package conekta.io.model.request; import conekta.io.model.ConektaObject; +import conekta.io.model.submodel.PaymentSource; import conekta.io.model.submodel.ShippingContact; import lombok.Data; @@ -8,11 +9,13 @@ @Data public class CustomerReq extends ConektaObject { + private String customerId; private String name; private String phone; private String email; - private List paymentSources; + private List paymentSources; private Boolean corporate; private String defaultPaymentSourceID; private List shippingContacts; + private Boolean deleted; } diff --git a/src/main/java/conekta/io/model/request/PaymentSourceCreateReq.java b/src/main/java/conekta/io/model/request/PaymentSourceCreateReq.java deleted file mode 100644 index 7f33977..0000000 --- a/src/main/java/conekta/io/model/request/PaymentSourceCreateReq.java +++ /dev/null @@ -1,14 +0,0 @@ -package conekta.io.model.request; - -import conekta.io.model.ConektaObject; -import lombok.Data; - -import java.math.BigDecimal; - -@Data -public class PaymentSourceCreateReq extends ConektaObject { - private String tokenId; - private String paymentType; - private BigDecimal expiresAt; - private CardReq card; -} diff --git a/src/main/java/conekta/io/model/request/CardReq.java b/src/main/java/conekta/io/model/submodel/Card.java similarity index 65% rename from src/main/java/conekta/io/model/request/CardReq.java rename to src/main/java/conekta/io/model/submodel/Card.java index e1b1cfb..cdf154b 100644 --- a/src/main/java/conekta/io/model/request/CardReq.java +++ b/src/main/java/conekta/io/model/submodel/Card.java @@ -1,10 +1,11 @@ -package conekta.io.model.request; +package conekta.io.model.submodel; import conekta.io.model.ConektaObject; +import conekta.io.model.request.TokenAddressReq; import lombok.Data; @Data -public class CardReq extends ConektaObject { +public class Card extends ConektaObject { private String number; private String name; private String expYear; diff --git a/src/main/java/conekta/io/model/submodel/PaymentSource.java b/src/main/java/conekta/io/model/submodel/PaymentSource.java index c6bf9a9..799117d 100644 --- a/src/main/java/conekta/io/model/submodel/PaymentSource.java +++ b/src/main/java/conekta/io/model/submodel/PaymentSource.java @@ -3,6 +3,8 @@ import conekta.io.model.ConektaObject; import lombok.Data; +import java.math.BigDecimal; + @Data public class PaymentSource extends ConektaObject { private String type; @@ -18,4 +20,7 @@ public class PaymentSource extends ConektaObject { private String parentId; private Boolean isDefault; private Boolean visibleOnCheckout; + private String paymentType; + private BigDecimal expiresAt; + private Card card; } diff --git a/src/test/java/conekta/io/CustomersClientTest.java b/src/test/java/conekta/io/CustomersClientTest.java index 945e549..a73d69e 100644 --- a/src/test/java/conekta/io/CustomersClientTest.java +++ b/src/test/java/conekta/io/CustomersClientTest.java @@ -7,6 +7,7 @@ import conekta.io.error.ConektaErrorResponse; import conekta.io.model.PaginatedConektaObject; import conekta.io.model.impl.Customer; +import conekta.io.model.request.CustomerReq; import conekta.io.model.submodel.Event; import conekta.io.model.submodel.PaymentSource; import okhttp3.mockwebserver.MockWebServer; @@ -34,17 +35,20 @@ void generateAuthenticator() { @Test void createCustomer() throws URISyntaxException, IOException { + // Arrange String customerJson = Utils.readFile("clients/customer.json"); - Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, Customer.class); + String customerResponseJson = Utils.readFile("clients/customerCreateResponse.json"); + CustomerReq customerReq = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, CustomerReq.class); + Customer customerResponse = ConektaObjectMapper.getInstance().stringJsonToObject(customerResponseJson, Customer.class); - Utils.buildMockServer(this.mockWebServer, customerJson, 201); + Utils.buildMockServer(this.mockWebServer, customerResponseJson, 201); // Act - ConektaResponse customerConektaResponse = customersClient.createCustomer(cus); + ConektaResponse customerConektaResponse = customersClient.createCustomer(customerReq); // Assert - Assertions.assertEquals(customerConektaResponse.getData(), cus); + Assertions.assertEquals(customerConektaResponse.getData(), customerResponse); Assertions.assertEquals(201, customerConektaResponse.getStatusCode()); } @@ -53,7 +57,7 @@ void createCustomerWithError() throws URISyntaxException, IOException { // Arrange String customerJson = Utils.readFile("clients/customerWithNoMail.json"); String errorJson = Utils.readFile("clients/errorMail.json"); - Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, Customer.class); + CustomerReq cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, CustomerReq.class); ConektaErrorResponse error = ConektaObjectMapper.getInstance().stringJsonToObject(errorJson, ConektaErrorResponse.class); Utils.buildMockServer(this.mockWebServer, errorJson, 404); @@ -69,7 +73,7 @@ void createCustomerWithError() throws URISyntaxException, IOException { @Test void retrieveCustomer() throws IOException, URISyntaxException { // Arrange - String customerJson = Utils.readFile("clients/customer.json"); + String customerJson = Utils.readFile("clients/customerResponse.json"); Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, Customer.class); Utils.buildMockServer(this.mockWebServer, customerJson, 200); @@ -83,8 +87,8 @@ void retrieveCustomer() throws IOException, URISyntaxException { @Test void getCustomers() throws IOException, URISyntaxException { - String customerJson = Utils.readFile("clients/customer.json"); - Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, Customer.class); + String customerListJson = Utils.readFile("clients/customerListResponse.json"); + Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerListJson, Customer.class); PaginatedConektaObject paginatedConektaObject = new PaginatedConektaObject<>(); paginatedConektaObject.setData(List.of(cus)); String s = ConektaObjectMapper.getInstance().conektaObjectToString(paginatedConektaObject); @@ -102,7 +106,7 @@ void getCustomers() throws IOException, URISyntaxException { void updateCustomer() throws IOException, URISyntaxException { String customerJson = Utils.readFile("clients/customer.json"); String customerJsonModified = Utils.readFile("clients/customerModified.json"); - Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, Customer.class); + CustomerReq cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, CustomerReq.class); Customer cusModified = ConektaObjectMapper.getInstance().stringJsonToObject(customerJsonModified, Customer.class); Utils.buildMockServer(this.mockWebServer, customerJsonModified, 200); @@ -114,13 +118,12 @@ void updateCustomer() throws IOException, URISyntaxException { Assertions.assertEquals(customerConektaResponse.getData(), cusModified); Assertions.assertNotEquals(cus, customerConektaResponse.getData()); Assertions.assertNotEquals(cus, cusModified); - } @Test void deleteCustomer() throws IOException, URISyntaxException { // Arrange - String customerJson = Utils.readFile("clients/customer.json"); + String customerJson = Utils.readFile("clients/customerDeleteResponse.json"); Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerJson, Customer.class); cus.setDeleted(true); String deletedJson = ConektaObjectMapper.getInstance().conektaObjectToString(cus); @@ -134,6 +137,23 @@ void deleteCustomer() throws IOException, URISyntaxException { Assertions.assertEquals(customerConektaResponse.getData(), cus); } + @Test + void deleteCustomerFail() throws IOException, URISyntaxException { + // Arrange + String customerDeleteFailResponseJson = Utils.readFile("clients/customerDeleteFailResponse.json"); + Customer cus = ConektaObjectMapper.getInstance().stringJsonToObject(customerDeleteFailResponseJson, Customer.class); + cus.setDeleted(true); + String deletedJson = ConektaObjectMapper.getInstance().conektaObjectToString(cus); + + Utils.buildMockServer(this.mockWebServer, deletedJson, 404); + + // Act + ConektaResponse customerConektaResponse = customersClient.deleteCustomer("1"); + + // Assert + Assertions.assertEquals(customerConektaResponse.getData(), cus); + } + @Test void getCustomerEvents() throws IOException, URISyntaxException { // Arrange diff --git a/src/test/java/conekta/io/OrdersClientTest.java b/src/test/java/conekta/io/OrdersClientTest.java index 60dd1f1..df236b4 100644 --- a/src/test/java/conekta/io/OrdersClientTest.java +++ b/src/test/java/conekta/io/OrdersClientTest.java @@ -6,9 +6,9 @@ import conekta.io.config.ConektaObjectMapper; import conekta.io.error.ConektaError; import conekta.io.model.PaginatedConektaObject; +import conekta.io.model.impl.Order; import conekta.io.model.request.OrderRefundReq; import conekta.io.model.request.OrderReq; -import conekta.io.model.response.Order; import conekta.io.model.submodel.Charge; import okhttp3.mockwebserver.MockWebServer; import org.junit.jupiter.api.Assertions; diff --git a/src/test/resources/clients/customerCreateResponse.json b/src/test/resources/clients/customerCreateResponse.json new file mode 100644 index 0000000..e1341df --- /dev/null +++ b/src/test/resources/clients/customerCreateResponse.json @@ -0,0 +1,67 @@ +{ + "livemode": false, + "name": "Jhon Doe", + "email": "test@test.com", + "phone": "+5215555555555", + "default_shipping_contact_id": "ship_cont_2sTTpLxTSUnV63Eeb", + "id": "cus_2sTTpLxTSUnV63Eec", + "object": "customer", + "created_at": 1662473589, + "corporate": true, + "custom_reference": "", + "antifraud_info": { + "first_paid_at": 1485151007, + "account_created_at": 1484040996 + }, + "default_payment_source_id": "src_2sTTpLxTSUnV63Eeg", + "payment_sources": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "id": "src_2sTTpLxTSUnV63Eeg", + "object": "payment_source", + "type": "card", + "created_at": 1662473590, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "09", + "exp_year": "23", + "brand": "visa", + "name": "Jorge Lopez", + "parent_id": "cus_2sTTpLxTSUnV63Eec", + "default": true, + "visible_on_checkout": false + } + ] + }, + "shipping_contacts": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "receiver": "Marvin Fuller", + "phone": "+5215555555555", + "between_streets": "Morelos Campeche", + "address": { + "street1": "Nuevo Leon 4", + "street2": "fake street", + "city": "Ciudad de Mexico", + "state": "Ciudad de Mexico", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "06100" + }, + "id": "ship_cont_2sTTpLxTSUnV63Eeb", + "object": "shipping_contact", + "created_at": 1662473589, + "parent_id": "cus_2sTTpLxTSUnV63Eec", + "default": true + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/clients/customerDeleteFailResponse.json b/src/test/resources/clients/customerDeleteFailResponse.json new file mode 100644 index 0000000..f0a3eb1 --- /dev/null +++ b/src/test/resources/clients/customerDeleteFailResponse.json @@ -0,0 +1,12 @@ +{ + "details": [ + { + "debug_message": "The object customer \"cus_2sTTpLxTSUnV63Eec\" could not be found.", + "message": "El recurso no ha sido encontrado.", + "code": "conekta.errors.resource_not_found.entity" + } + ], + "object": "error", + "type": "resource_not_found_error", + "log_id": "63176fdf9e9c3150da5e44fd" +} \ No newline at end of file diff --git a/src/test/resources/clients/customerDeleteResponse.json b/src/test/resources/clients/customerDeleteResponse.json new file mode 100644 index 0000000..d14904d --- /dev/null +++ b/src/test/resources/clients/customerDeleteResponse.json @@ -0,0 +1,68 @@ +{ + "livemode": false, + "name": "Jhon Doe", + "email": "test@test.com", + "phone": "+5215555555555", + "default_shipping_contact_id": "ship_cont_2sTTpLxTSUnV63Eeb", + "id": "cus_2sTTpLxTSUnV63Eec", + "object": "customer", + "created_at": 1662473589, + "corporate": true, + "custom_reference": "", + "antifraud_info": { + "first_paid_at": 1485151007, + "account_created_at": 1484040996 + }, + "default_payment_source_id": "src_2sTTpLxTSUnV63Eeg", + "payment_sources": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "id": "src_2sTTpLxTSUnV63Eeg", + "object": "payment_source", + "type": "card", + "created_at": 1662473590, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "09", + "exp_year": "23", + "brand": "visa", + "name": "Jorge Lopez", + "parent_id": "cus_2sTTpLxTSUnV63Eec", + "default": true, + "visible_on_checkout": false + } + ] + }, + "shipping_contacts": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "receiver": "Marvin Fuller", + "phone": "+5215555555555", + "between_streets": "Morelos Campeche", + "address": { + "street1": "Nuevo Leon 4", + "street2": "fake street", + "city": "Ciudad de Mexico", + "state": "Ciudad de Mexico", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "06100" + }, + "id": "ship_cont_2sTTpLxTSUnV63Eeb", + "object": "shipping_contact", + "created_at": 1662473589, + "parent_id": "cus_2sTTpLxTSUnV63Eec", + "default": true + } + ] + }, + "deleted": true +} \ No newline at end of file diff --git a/src/test/resources/clients/customerListResponse.json b/src/test/resources/clients/customerListResponse.json new file mode 100644 index 0000000..8046378 --- /dev/null +++ b/src/test/resources/clients/customerListResponse.json @@ -0,0 +1,142 @@ +{ + "next_page_url": "https://apipp.conekta.io/customers?next=cus_2s6cgqbzZBg9rr8PQ", + "has_more": true, + "total": 385, + "object": "list", + "data": [ + { + "livemode": false, + "name": "Jhon Doe", + "email": "test@test.com", + "phone": "+5215555555555", + "default_shipping_contact_id": "ship_cont_2sTTpLxTSUnV63Eeb", + "id": "cus_2sTTpLxTSUnV63Eec", + "object": "customer", + "created_at": 1662473589, + "corporate": true, + "custom_reference": "", + "antifraud_info": { + "first_paid_at": 1485151007, + "account_created_at": 1484040996 + }, + "default_payment_source_id": "src_2sTTpLxTSUnV63Eeg", + "payment_sources": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "id": "src_2sTTpLxTSUnV63Eeg", + "object": "payment_source", + "type": "card", + "created_at": 1662473590, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "09", + "exp_year": "23", + "brand": "visa", + "name": "Jorge Lopez", + "parent_id": "cus_2sTTpLxTSUnV63Eec", + "default": true, + "visible_on_checkout": false + } + ] + }, + "shipping_contacts": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "receiver": "Marvin Fuller", + "phone": "+5215555555555", + "between_streets": "Morelos Campeche", + "address": { + "street1": "Nuevo Leon 4", + "street2": "fake street", + "city": "Ciudad de Mexico", + "state": "Ciudad de Mexico", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "06100" + }, + "id": "ship_cont_2sTTpLxTSUnV63Eeb", + "object": "shipping_contact", + "created_at": 1662473589, + "parent_id": "cus_2sTTpLxTSUnV63Eec", + "default": true + } + ] + } + }, + { + "livemode": false, + "name": "Jhon Doe", + "email": "test@test.com", + "phone": "+5215555555555", + "default_shipping_contact_id": "ship_cont_2sM1HXz92ykiYoCui", + "id": "cus_2sM1HXz92ykiYoCuj", + "object": "customer", + "created_at": 1660766987, + "corporate": true, + "custom_reference": "", + "antifraud_info": { + "first_paid_at": 1485151007, + "account_created_at": 1484040996 + }, + "default_payment_source_id": "src_2sM1HXz92ykiYoCuo", + "payment_sources": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "id": "src_2sM1HXz92ykiYoCuo", + "object": "payment_source", + "type": "card", + "created_at": 1660766987, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "08", + "exp_year": "23", + "brand": "visa", + "name": "Jorge Lopez", + "parent_id": "cus_2sM1HXz92ykiYoCuj", + "default": true, + "visible_on_checkout": false + } + ] + }, + "shipping_contacts": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "receiver": "Marvin Fuller", + "phone": "+5215555555555", + "between_streets": "Morelos Campeche", + "address": { + "street1": "Nuevo Leon 4", + "street2": "fake street", + "city": "Ciudad de Mexico", + "state": "Ciudad de Mexico", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "06100" + }, + "id": "ship_cont_2sM1HXz92ykiYoCui", + "object": "shipping_contact", + "created_at": 1660766987, + "parent_id": "cus_2sM1HXz92ykiYoCuj", + "default": true + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/test/resources/clients/customerModified.json b/src/test/resources/clients/customerModified.json index a36d399..dc1b067 100644 --- a/src/test/resources/clients/customerModified.json +++ b/src/test/resources/clients/customerModified.json @@ -1,32 +1,67 @@ { + "livemode": false, "name": "Jhon Doe", - "email": "test@ctest.com", - "phone": "+52144444444", + "email": "test@test.com", + "phone": "+5215555555555", + "default_shipping_contact_id": "ship_cont_2sM1HXz92ykiYoCui", + "id": "cus_2sM1HXz92ykiYoCuj", + "object": "customer", + "created_at": 1660766987, "corporate": true, + "custom_reference": "", "antifraud_info": { - "account_created_at": 1484040996, - "first_paid_at": 1485151007 + "first_paid_at": 1485151007, + "account_created_at": 1484040996 }, - "payment_sources": [ - { - "token_id": "tok_test_visa_4242", - "type": "card" - } - ], - "shipping_contacts": [ - { - "phone": "+5215555555555", - "receiver": "Marvin Fuller", - "between_streets": "Morelos Campeche", - "address": { - "street1": "Nuevo Leon 4", - "street2": "fake street", - "city": "Ciudad de Mexico", - "state": "Ciudad de Mexico", - "country": "MX", - "postal_code": "06100", - "residential": true + "default_payment_source_id": "src_2sM1HXz92ykiYoCuo", + "payment_sources": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "id": "src_2sM1HXz92ykiYoCuo", + "object": "payment_source", + "type": "card", + "created_at": 1660766987, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "08", + "exp_year": "23", + "brand": "visa", + "name": "Jorge Lopez", + "parent_id": "cus_2sM1HXz92ykiYoCuj", + "default": true, + "visible_on_checkout": false } - } - ] + ] + }, + "shipping_contacts": { + "object": "list", + "has_more": false, + "total": 1, + "data": [ + { + "receiver": "Marvin Fuller", + "phone": "+5215555555555", + "between_streets": "Morelos Campeche", + "address": { + "street1": "Nuevo Leon 4", + "street2": "fake street", + "city": "Ciudad de Mexico", + "state": "Ciudad de Mexico", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "06100" + }, + "id": "ship_cont_2sM1HXz92ykiYoCui", + "object": "shipping_contact", + "created_at": 1660766987, + "parent_id": "cus_2sM1HXz92ykiYoCuj", + "default": true + } + ] + } } \ No newline at end of file diff --git a/src/test/resources/clients/customerResponse.json b/src/test/resources/clients/customerResponse.json new file mode 100644 index 0000000..9c00339 --- /dev/null +++ b/src/test/resources/clients/customerResponse.json @@ -0,0 +1,208 @@ +{ + "livemode": false, + "name": "Jhon Doe", + "email": "test@test.com", + "phone": "+5215555555555", + "default_shipping_contact_id": "ship_cont_2rYuZoAh4cSWMpjP2", + "subscription": { + "id": "sub_2sM1EZpuw1MkG1dEU", + "status": "active", + "object": "subscription", + "charge_id": "62fd4a226cd84c621b06a8f3", + "created_at": 1660766754, + "subscription_start": 1660766754, + "billing_cycle_start": 1660766744, + "billing_cycle_end": 1663445144, + "trial_end": 1660766754, + "plan_id": "extra-plan", + "last_billing_cycle_order_id": "ord_2sM1EZpuw1MkG1dEa", + "customer_id": "cus_2rYuZoAh4cSWMpjP3", + "card_id": "src_2rYuZoAh4cSWMpjP7" + }, + "id": "cus_2rYuZoAh4cSWMpjP3", + "object": "customer", + "created_at": 1648583824, + "corporate": true, + "custom_reference": "", + "antifraud_info": { + "first_paid_at": 1485151007, + "account_created_at": 1484040996 + }, + "default_payment_source_id": "src_2rYuZoAh4cSWMpjP7", + "payment_sources": { + "next_page_url": "https://apipp.conekta.io/customers/cus_2rYuZoAh4cSWMpjP3/payment_sources?next=src_2s7GEemaHFAEHYNZJ&limit=5", + "object": "list", + "has_more": true, + "total": 9, + "data": [ + { + "id": "src_2sMczNBeEwd6NBd5P", + "object": "payment_source", + "type": "card", + "created_at": 1660929677, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "12", + "exp_year": "25", + "brand": "visa", + "name": "TEST", + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false, + "visible_on_checkout": false + }, + { + "id": "src_2sM1CX7KtRy87foUd", + "object": "payment_source", + "type": "card", + "created_at": 1660766593, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "12", + "exp_year": "25", + "brand": "visa", + "name": "TEST", + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false, + "visible_on_checkout": false + }, + { + "id": "src_2sLgmTn78YZ4ZKt5v", + "object": "payment_source", + "type": "card", + "created_at": 1660682605, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "12", + "exp_year": "25", + "brand": "visa", + "name": "TEST", + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false, + "visible_on_checkout": false + }, + { + "id": "src_2sB7Dh31tGuUL3ZrP", + "object": "payment_source", + "type": "card", + "created_at": 1658151177, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "12", + "exp_year": "25", + "brand": "visa", + "name": "TEST", + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false, + "visible_on_checkout": false + }, + { + "id": "src_2s7GEemaHFAEHYNZJ", + "object": "payment_source", + "type": "card", + "created_at": 1657135123, + "last4": "4242", + "bin": "424242", + "card_type": "credit", + "exp_month": "12", + "exp_year": "25", + "brand": "visa", + "name": "TEST", + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false, + "visible_on_checkout": false + } + ] + }, + "shipping_contacts": { + "next_page_url": "https://apipp.conekta.io/customers/cus_2rYuZoAh4cSWMpjP3/shipping_contacts?next=ship_cont_2sMM6xaEa78TCYQpb&limit=5", + "object": "list", + "has_more": true, + "total": 41, + "data": [ + { + "receiver": "Monse Torres", + "phone": "5556581111", + "address": { + "street1": "Av. Jardín", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "02970" + }, + "id": "ship_cont_2sPcpsbA8fyJ1Z1YX", + "object": "shipping_contact", + "created_at": 1661457501, + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false + }, + { + "receiver": "Monse Torres", + "phone": "5556581111", + "address": { + "street1": "Av. Jardín", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "02970" + }, + "id": "ship_cont_2sMcyyJF6mAyyp3tJ", + "object": "shipping_contact", + "created_at": 1660929646, + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false + }, + { + "receiver": "Monse Torres", + "phone": "5556581111", + "address": { + "street1": "Av. Jardín", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "02970" + }, + "id": "ship_cont_2sMbjx4CKFfsFq8EQ", + "object": "shipping_contact", + "created_at": 1660923988, + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false + }, + { + "receiver": "Monse Torres", + "phone": "5556581111", + "address": { + "street1": "Av. Jardín", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "02970" + }, + "id": "ship_cont_2sMbfbZzF5A1PUAgD", + "object": "shipping_contact", + "created_at": 1660923646, + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false + }, + { + "receiver": "Monse Torres", + "phone": "5556581111", + "address": { + "street1": "Av. Jardín", + "country": "mx", + "residential": true, + "object": "shipping_address", + "postal_code": "02970" + }, + "id": "ship_cont_2sMM6xaEa78TCYQpb", + "object": "shipping_contact", + "created_at": 1660857289, + "parent_id": "cus_2rYuZoAh4cSWMpjP3", + "default": false + } + ] + } +} \ No newline at end of file