diff --git a/examples/apis/cardtoken/create/main.go b/examples/apis/cardtoken/create/main.go index 61e9baf9..09455a06 100644 --- a/examples/apis/cardtoken/create/main.go +++ b/examples/apis/cardtoken/create/main.go @@ -25,8 +25,8 @@ func main() { ExpirationMonth: "11", ExpirationYear: "2025", SecurityCode: "123", - Cardholder: &cardtoken.Cardholder{ - Identification: &cardtoken.Identification{ + Cardholder: &cardtoken.CardholderRequest{ + Identification: &cardtoken.IdentificationRequest{ Type: "CPF", Number: "{{CPF_NUMBER}}", }, diff --git a/examples/apis/preapproval/search/main.go b/examples/apis/preapproval/search/main.go index c0a8bf62..ca9b2849 100644 --- a/examples/apis/preapproval/search/main.go +++ b/examples/apis/preapproval/search/main.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "github.com/mercadopago/sdk-go/pkg/config" "github.com/mercadopago/sdk-go/pkg/preapproval" ) @@ -17,8 +18,8 @@ func main() { client := preapproval.NewClient(cfg) filters := preapproval.SearchRequest{ - Limit: "10", - Offset: "10", + Limit: 10, + Offset: 10, Filters: map[string]string{ "payer_id": "123123123", }, diff --git a/pkg/cardtoken/client_test.go b/pkg/cardtoken/client_test.go index 817e6983..f033e698 100644 --- a/pkg/cardtoken/client_test.go +++ b/pkg/cardtoken/client_test.go @@ -120,7 +120,7 @@ func mockCardToken() *Response { } } -func parseDate(s string) *time.Time { +func parseDate(s string) time.Time { d, _ := time.Parse(time.RFC3339, s) - return &d + return d } diff --git a/pkg/cardtoken/request.go b/pkg/cardtoken/request.go index 0bf17a29..2e742884 100644 --- a/pkg/cardtoken/request.go +++ b/pkg/cardtoken/request.go @@ -1,7 +1,7 @@ package cardtoken type Request struct { - Cardholder *Cardholder `json:"cardholder,omitempty"` + Cardholder *CardholderRequest `json:"cardholder,omitempty"` SiteID string `json:"site_id,omitempty"` CardNumber string `json:"card_number,omitempty"` @@ -10,13 +10,13 @@ type Request struct { SecurityCode string `json:"security_code,omitempty"` } -type Cardholder struct { - Identification *Identification `json:"identification,omitempty"` +type CardholderRequest struct { + Identification *IdentificationRequest `json:"identification,omitempty"` Name string `json:"name,omitempty"` } -type Identification struct { +type IdentificationRequest struct { Number string `json:"number,omitempty"` Type string `json:"type,omitempty"` } diff --git a/pkg/cardtoken/response.go b/pkg/cardtoken/response.go index 46f164b3..48f38c48 100644 --- a/pkg/cardtoken/response.go +++ b/pkg/cardtoken/response.go @@ -3,22 +3,22 @@ package cardtoken import "time" type Response struct { - DateCreated *time.Time `json:"date_created"` - DateLastUpdated *time.Time `json:"date_last_updated"` - DateDue *time.Time `json:"date_due"` Cardholder CardholderResponse `json:"cardholder"` + DateCreated time.Time `json:"date_created"` + DateLastUpdated time.Time `json:"date_last_updated"` + DateDue time.Time `json:"date_due"` ID string `json:"id"` FirstSixDigits string `json:"first_six_digits"` LastFourDigits string `json:"last_four_digits"` Status string `json:"status"` - LuhnValidation bool `json:"luhn_validation"` - LiveMode bool `json:"live_mode"` - RequireEsc bool `json:"require_esc"` ExpirationMonth int `json:"expiration_month"` ExpirationYear int `json:"expiration_year"` CardNumberLength int `json:"card_number_length"` SecurityCodeLength int `json:"security_code_length"` + LuhnValidation bool `json:"luhn_validation"` + LiveMode bool `json:"live_mode"` + RequireEsc bool `json:"require_esc"` } type CardholderResponse struct { diff --git a/pkg/customer/request.go b/pkg/customer/request.go index 4db72eac..86dada98 100644 --- a/pkg/customer/request.go +++ b/pkg/customer/request.go @@ -4,10 +4,10 @@ import "time" // Request represents a request for creating a customer. type Request struct { - DateRegistered *time.Time `json:"date_registered,omitempty"` - Address *AddressResponse `json:"address,omitempty"` + Address *AddressRequest `json:"address,omitempty"` Identification *IdentificationRequest `json:"identification,omitempty"` Phone *PhoneRequest `json:"phone,omitempty"` + DateRegistered *time.Time `json:"date_registered,omitempty"` DefaultAddress string `json:"default_address,omitempty"` DefaultCard string `json:"default_card,omitempty"` diff --git a/pkg/customer/response.go b/pkg/customer/response.go index e0d2eab9..683d18f6 100644 --- a/pkg/customer/response.go +++ b/pkg/customer/response.go @@ -4,12 +4,12 @@ import "time" // Response represents a customer. type Response struct { - DateRegistered *time.Time `json:"date_registered"` - DateCreated *time.Time `json:"date_created"` - DateLastUpdated *time.Time `json:"date_last_updated"` Phone PhoneResponse `json:"phone"` Identification IdentificationResponse `json:"identification"` Address AddressResponse `json:"address"` + DateRegistered time.Time `json:"date_registered"` + DateCreated time.Time `json:"date_created"` + DateLastUpdated time.Time `json:"date_last_updated"` Cards []CardResponse `json:"cards"` Addresses []CompleteAddressResponse `json:"addresses"` @@ -43,12 +43,12 @@ type AddressResponse struct { // CardResponse represents a response for a card. type CardResponse struct { - DateCreated *time.Time `json:"date_created"` - DateLastUpdated *time.Time `json:"date_last_updated"` Cardholder CardholderResponse `json:"cardholder"` Issuer IssuerResponse `json:"issuer"` PaymentMethod PaymentMethodResponse `json:"payment_method"` SecurityCode SecurityCodeResponse `json:"security_code"` + DateCreated time.Time `json:"date_created"` + DateLastUpdated time.Time `json:"date_last_updated"` ID string `json:"id"` CustomerID string `json:"customer_id"` @@ -74,8 +74,8 @@ type IdentificationResponse struct { // IssuerResponse represents a response for an issuer. type IssuerResponse struct { - ID int `json:"id"` Name string `json:"name"` + ID int `json:"id"` } // PaymentMethodResponse represents a response for a payment method. @@ -89,17 +89,17 @@ type PaymentMethodResponse struct { // SecurityCodeResponse represents a response for a security code. type SecurityCodeResponse struct { - Length int `json:"length"` CardLocation string `json:"card_location"` + Length int `json:"length"` } // CompleteAddressResponse represents a response for a complete address. type CompleteAddressResponse struct { - DateCreated *time.Time `json:"date_created"` City CityResponse `json:"city"` State StateResponse `json:"state"` Country CountryResponse `json:"country"` Neighborhood NeighborhoodResponse `json:"neighborhood"` + DateCreated time.Time `json:"date_created"` ID string `json:"id"` StreetName string `json:"street_name"` diff --git a/pkg/customer/search_request.go b/pkg/customer/search_request.go index 3bf63815..70bc24ba 100644 --- a/pkg/customer/search_request.go +++ b/pkg/customer/search_request.go @@ -9,10 +9,9 @@ import ( // Filters field can receive a lot of parameters. For details, see: // https://www.mercadopago.com/developers/en/reference/customers/_customers_search/get. type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/customer/search_response.go b/pkg/customer/search_response.go index f87719dd..cbbea0aa 100644 --- a/pkg/customer/search_response.go +++ b/pkg/customer/search_response.go @@ -2,8 +2,8 @@ package customer // SearchResponse represents the response from the search endpoint. type SearchResponse struct { - Results []Response `json:"results"` Paging PagingResponse `json:"paging"` + Results []Response `json:"results"` } // PagingResponse represents the paging information within SearchResponse. diff --git a/pkg/customercard/client_test.go b/pkg/customercard/client_test.go index f4d7fa96..f7ba9e5d 100644 --- a/pkg/customercard/client_test.go +++ b/pkg/customercard/client_test.go @@ -112,7 +112,7 @@ func TestCreate(t *testing.T) { Thumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", SecureThumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", }, - SecurityCode: SecurityCode{ + SecurityCode: SecurityCodeResponse{ Length: 3, CardLocation: "back", }, @@ -230,7 +230,7 @@ func TestUpdate(t *testing.T) { Thumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", SecureThumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", }, - SecurityCode: SecurityCode{ + SecurityCode: SecurityCodeResponse{ Length: 3, CardLocation: "back", }, @@ -345,7 +345,7 @@ func TestGet(t *testing.T) { Thumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", SecureThumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", }, - SecurityCode: SecurityCode{ + SecurityCode: SecurityCodeResponse{ Length: 3, CardLocation: "back", }, @@ -460,7 +460,7 @@ func TestDelete(t *testing.T) { Thumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", SecureThumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", }, - SecurityCode: SecurityCode{ + SecurityCode: SecurityCodeResponse{ Length: 3, CardLocation: "back", }, @@ -574,7 +574,7 @@ func TestList(t *testing.T) { Thumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", SecureThumbnail: "https://http2.mlstatic.com/storage/logos-api-admin/0daa1670-5c81-11ec-ae75-df2bef173be2-xl@2x.png", }, - SecurityCode: SecurityCode{ + SecurityCode: SecurityCodeResponse{ Length: 3, CardLocation: "back", }, @@ -602,7 +602,7 @@ func TestList(t *testing.T) { } } -func parseDate(s string) *time.Time { +func parseDate(s string) time.Time { d, _ := time.Parse(time.RFC3339, s) - return &d + return d } diff --git a/pkg/customercard/response.go b/pkg/customercard/response.go index de1697df..963a7f0b 100644 --- a/pkg/customercard/response.go +++ b/pkg/customercard/response.go @@ -4,13 +4,13 @@ import "time" // Response represents a customer card. type Response struct { - DateCreated *time.Time `json:"date_created"` - DateLastUpdated *time.Time `json:"date_last_updated"` Issuer IssuerResponse `json:"issuer"` Cardholder CardholderResponse `json:"cardholder"` AdditionalInfo AdditionalInfoResponse `json:"additional_info"` PaymentMethod PaymentMethodResponse `json:"payment_method"` - SecurityCode SecurityCode `json:"security_code"` + SecurityCode SecurityCodeResponse `json:"security_code"` + DateCreated time.Time `json:"date_created"` + DateLastUpdated time.Time `json:"date_last_updated"` ID string `json:"id"` CustomerID string `json:"customer_id"` @@ -45,8 +45,8 @@ type IdentificationResponse struct { // IssuerResponse represents the card issuer code. type IssuerResponse struct { - ID int `json:"id"` Name string `json:"name"` + ID int `json:"id"` } // PaymentMethodResponse represents the card's payment method. @@ -59,7 +59,7 @@ type PaymentMethodResponse struct { } // SecurityCode represents the card's security code. -type SecurityCode struct { - Length int `json:"length"` +type SecurityCodeResponse struct { CardLocation string `json:"card_location"` + Length int `json:"length"` } diff --git a/pkg/invoice/client_test.go b/pkg/invoice/client_test.go index 3aa9f2f2..7fca89a5 100644 --- a/pkg/invoice/client_test.go +++ b/pkg/invoice/client_test.go @@ -228,7 +228,7 @@ func TestSearch(t *testing.T) { } } -func parseDate(s string) *time.Time { +func parseDate(s string) time.Time { d, _ := time.Parse(time.RFC3339, s) - return &d + return d } diff --git a/pkg/invoice/response.go b/pkg/invoice/response.go index e64b6286..6d71bf02 100644 --- a/pkg/invoice/response.go +++ b/pkg/invoice/response.go @@ -4,11 +4,11 @@ import "time" // Response is the response from the Invoice API. type Response struct { - DateCreated *time.Time `json:"date_created"` - DebitDate *time.Time `json:"debit_date"` - LastModified *time.Time `json:"last_modified"` - NextRetryDate *time.Time `json:"next_retry_date"` Payment PaymentResponse `json:"payment"` + DateCreated time.Time `json:"date_created"` + DebitDate time.Time `json:"debit_date"` + LastModified time.Time `json:"last_modified"` + NextRetryDate time.Time `json:"next_retry_date"` CurrencyID string `json:"currency_id"` ExternalReference string `json:"external_reference"` @@ -18,9 +18,9 @@ type Response struct { Status string `json:"status"` Summarized string `json:"summarized"` Type string `json:"type"` + TransactionAmount float64 `json:"transaction_amount"` ID int `json:"id"` RetryAttempt int `json:"retry_attempt"` - TransactionAmount float64 `json:"transaction_amount"` } // PaymentResponse contains information about payment. diff --git a/pkg/invoice/search_request.go b/pkg/invoice/search_request.go index 28469640..310dc33f 100644 --- a/pkg/invoice/search_request.go +++ b/pkg/invoice/search_request.go @@ -7,10 +7,9 @@ import ( // SearchRequest is the helper structure to build search request. type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/merchantorder/client_test.go b/pkg/merchantorder/client_test.go index 7b7b08dd..ba1a0c4b 100644 --- a/pkg/merchantorder/client_test.go +++ b/pkg/merchantorder/client_test.go @@ -338,8 +338,8 @@ func buildResponseMock() *Response { Nickname: "TEST_USER_658045679", }, Marketplace: "NONE", - DateCreated: &dateCreated, - LastUpdated: &lastUpdate, + DateCreated: dateCreated, + LastUpdated: lastUpdate, TotalAmount: 10, SiteID: "MLB", Items: []ItemResponse{ diff --git a/pkg/merchantorder/request.go b/pkg/merchantorder/request.go index f52d9fb4..892cdd1b 100644 --- a/pkg/merchantorder/request.go +++ b/pkg/merchantorder/request.go @@ -31,8 +31,8 @@ type ItemRequest struct { PictureURL string `json:"picture_url,omitempty"` CategoryID string `json:"category_id,omitempty"` CurrencyID string `json:"currency_id,omitempty"` - Quantity int `json:"quantity,omitempty"` UnitPrice float64 `json:"unit_price,omitempty"` + Quantity int `json:"quantity,omitempty"` } // CollectorRequest represents seller information. diff --git a/pkg/merchantorder/response.go b/pkg/merchantorder/response.go index 965737ec..9c97af10 100644 --- a/pkg/merchantorder/response.go +++ b/pkg/merchantorder/response.go @@ -6,10 +6,10 @@ import ( // Response represents a merchant order resource. type Response struct { - DateCreated *time.Time `json:"date_created"` - LastUpdated *time.Time `json:"last_updated"` Payer PayerResponse `json:"payer"` Collector CollectorResponse `json:"collector"` + DateCreated time.Time `json:"date_created"` + LastUpdated time.Time `json:"last_updated"` Items []ItemResponse `json:"items"` Shipments []ShipmentResponse `json:"shipments"` Payments []PaymentResponse `json:"payments"` @@ -24,12 +24,12 @@ type Response struct { Marketplace string `json:"marketplace"` SponsorID string `json:"sponsor_id"` OrderStatus string `json:"order_status"` - ID int64 `json:"id"` - Cancelled bool `json:"cancelled"` PaidAmount float64 `json:"paid_amount"` RefundedAmount float64 `json:"refunded_amount"` ShippingCost float64 `json:"shipping_cost"` TotalAmount float64 `json:"total_amount"` + ID int64 `json:"id"` + Cancelled bool `json:"cancelled"` } // PayerResponse represents buyer information. @@ -46,19 +46,19 @@ type CollectorResponse struct { // PaymentResponse represents payment information. type PaymentResponse struct { - DateApproved *time.Time `json:"date_approved"` - DateCreated *time.Time `json:"date_created"` - LastModified *time.Time `json:"last_modified"` + DateApproved time.Time `json:"date_approved"` + DateCreated time.Time `json:"date_created"` + LastModified time.Time `json:"last_modified"` Status string `json:"status"` StatusDetails string `json:"status_details"` OperationType string `json:"operation_type"` CurrencyID string `json:"currency_id"` - ID int64 `json:"id"` TransactionAmount float64 `json:"transaction_amount"` TotalPaidAmount float64 `json:"total_paid_amount"` ShippingCost float64 `json:"shipping_cost"` AmountRefunded float64 `json:"amount_refunded"` + ID int64 `json:"id"` } // ItemResponse represents item information. @@ -69,28 +69,28 @@ type ItemResponse struct { PictureURL string `json:"picture_url"` CurrencyID string `json:"currency_id"` CategoryID string `json:"category_id"` - Quantity int `json:"quantity"` UnitPrice float64 `json:"unit_price"` + Quantity int `json:"quantity"` } // ShipmentResponse represents shipment information. type ShipmentResponse struct { - DateCreated *time.Time `json:"date_created"` - LastModified *time.Time `json:"last_modified"` - DateFirstPrinted *time.Time `json:"date_first_printed"` ReceiverAddress ReceiverAddressResponse `json:"receiver_address"` ShippingOption ShippingOptionResponse `json:"shipping_option"` - - ShippingType string `json:"shipping_type"` - ShippingMode string `json:"shipping_mode"` - PickingType string `json:"picking_type"` - Status string `json:"status"` - ShippingSubstatus string `json:"shipping_substatus"` - ServiceID string `json:"service_id"` - ID int64 `json:"id"` - SenderID int64 `json:"sender_id"` - ReceiverID int64 `json:"receiver_id"` - Items []map[string]interface{} `json:"items"` + DateCreated time.Time `json:"date_created"` + LastModified time.Time `json:"last_modified"` + DateFirstPrinted time.Time `json:"date_first_printed"` + + ShippingType string `json:"shipping_type"` + ShippingMode string `json:"shipping_mode"` + PickingType string `json:"picking_type"` + Status string `json:"status"` + ShippingSubstatus string `json:"shipping_substatus"` + ServiceID string `json:"service_id"` + ID int64 `json:"id"` + SenderID int64 `json:"sender_id"` + ReceiverID int64 `json:"receiver_id"` + Items []map[string]any `json:"items"` } // ReceiverAddressResponse represents receiver address information. @@ -120,10 +120,10 @@ type ShippingOptionResponse struct { Name string `json:"name"` CurrencyID string `json:"currency_id"` - ID int64 `json:"id"` - ShippingMethodID int64 `json:"shipping_method_id"` Cost float64 `json:"cost"` ListCost float64 `json:"list_cost"` + ID int64 `json:"id"` + ShippingMethodID int64 `json:"shipping_method_id"` } // ReceiverAddressCityResponse represents city information. @@ -146,7 +146,7 @@ type ReceiverAddressCountryResponse struct { // ShippingEstimatedDeliveryResponse represents estimated delivery information. type ShippingEstimatedDeliveryResponse struct { - Date *time.Time `json:"date"` + Date time.Time `json:"date"` TimeFrom string `json:"time_from"` TimeTo string `json:"time_to"` diff --git a/pkg/merchantorder/search_request.go b/pkg/merchantorder/search_request.go index f20f9571..4644a81d 100644 --- a/pkg/merchantorder/search_request.go +++ b/pkg/merchantorder/search_request.go @@ -9,10 +9,9 @@ import ( // Filters field can receive a lot of paramaters. For details, see: // https://www.mercadopago.com/developers/en/reference/merchant_orders/_merchant_orders_search/get. type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/merchantorder/update_request.go b/pkg/merchantorder/update_request.go index 47e50c83..11b46acf 100644 --- a/pkg/merchantorder/update_request.go +++ b/pkg/merchantorder/update_request.go @@ -22,22 +22,22 @@ type UpdateRequest struct { // ShipmentRequest represents shipment information. type ShipmentRequest struct { + ReceiverAddress *ReceiverAddressRequest `json:"receiver_address,omitempty"` + ShippingOption *ShippingOptionRequest `json:"shipping_option,omitempty"` DateCreated *time.Time `json:"date_created,omitempty"` LastModified *time.Time `json:"last_modified,omitempty"` DateFirstPrinted *time.Time `json:"date_first_printed,omitempty"` - ReceiverAddress *ReceiverAddressRequest `json:"receiver_address,omitempty"` - ShippingOption *ShippingOptionRequest `json:"shipping_option,omitempty"` - ShippingType string `json:"shipping_type,omitempty"` - ShippingMode string `json:"shipping_mode,omitempty"` - PickingType string `json:"picking_type,omitempty"` - Status string `json:"status,omitempty"` - ShippingSubstatus string `json:"shipping_substatus,omitempty"` - ServiceID string `json:"service_id,omitempty"` - ID int64 `json:"id,omitempty"` - SenderID int64 `json:"sender_id,omitempty"` - ReceiverID int64 `json:"receiver_id,omitempty"` - Items []map[string]interface{} `json:"items,omitempty"` + ShippingType string `json:"shipping_type,omitempty"` + ShippingMode string `json:"shipping_mode,omitempty"` + PickingType string `json:"picking_type,omitempty"` + Status string `json:"status,omitempty"` + ShippingSubstatus string `json:"shipping_substatus,omitempty"` + ServiceID string `json:"service_id,omitempty"` + ID int64 `json:"id,omitempty"` + SenderID int64 `json:"sender_id,omitempty"` + ReceiverID int64 `json:"receiver_id,omitempty"` + Items []map[string]any `json:"items,omitempty"` } // ReceiverAddressRequest represents receiver address information. @@ -67,10 +67,10 @@ type ShippingOptionRequest struct { Name string `json:"name,omitempty"` CurrencyID string `json:"currency_id,omitempty"` - ShippingMethodID int64 `json:"shipping_method_id,omitempty"` - ID int64 `json:"id,omitempty"` Cost float64 `json:"cost,omitempty"` ListCost float64 `json:"list_cost,omitempty"` + ShippingMethodID int64 `json:"shipping_method_id,omitempty"` + ID int64 `json:"id,omitempty"` } // ReceiverAddressCityRequest represents city information. diff --git a/pkg/oauth/response.go b/pkg/oauth/response.go index a86ae257..50306ce2 100644 --- a/pkg/oauth/response.go +++ b/pkg/oauth/response.go @@ -7,6 +7,6 @@ type Response struct { RefreshToken string `json:"refresh_token"` PublicKey string `json:"public_key"` TokenType string `json:"token_type"` - LiveMode bool `json:"live_mode"` ExpiresIn int64 `json:"expires_in"` + LiveMode bool `json:"live_mode"` } diff --git a/pkg/payment/request.go b/pkg/payment/request.go index 501989c9..cfba1aca 100644 --- a/pkg/payment/request.go +++ b/pkg/payment/request.go @@ -6,7 +6,6 @@ import ( // Request represents a request for creating or updating a payment. type Request struct { - DateOfExpiration *time.Time `json:"date_of_expiration,omitempty"` AdditionalInfo *AdditionalInfoRequest `json:"additional_info,omitempty"` MerchantServices *MerchantServicesRequest `json:"merchant_services,omitempty"` Order *OrderRequest `json:"order,omitempty"` @@ -14,6 +13,7 @@ type Request struct { TransactionDetails *TransactionDetailsRequest `json:"transaction_details,omitempty"` PointOfInteraction *PointOfInteractionRequest `json:"point_of_interaction,omitempty"` PaymentMethod *PaymentMethodRequest `json:"payment_method,omitempty"` + DateOfExpiration *time.Time `json:"date_of_expiration,omitempty"` Taxes []TaxRequest `json:"taxes,omitempty"` CallbackURL string `json:"callback_url,omitempty"` @@ -29,16 +29,16 @@ type Request struct { PaymentMethodOptionID string `json:"payment_method_option_id,omitempty"` StatementDescriptor string `json:"statement_descriptor,omitempty"` ThreeDSecureMode string `json:"three_d_secure_mode,omitempty"` + ApplicationFee float64 `json:"application_fee,omitempty"` + CouponAmount float64 `json:"coupon_amount,omitempty"` + NetAmount float64 `json:"net_amount,omitempty"` + TransactionAmount float64 `json:"transaction_amount,omitempty"` Installments int `json:"installments,omitempty"` CampaignID int64 `json:"campaign_id,omitempty"` DifferentialPricingID int64 `json:"differential_pricing_id,omitempty"` SponsorID int64 `json:"sponsor_id,omitempty"` BinaryMode bool `json:"binary_mode,omitempty"` Capture bool `json:"capture,omitempty"` - ApplicationFee float64 `json:"application_fee,omitempty"` - CouponAmount float64 `json:"coupon_amount,omitempty"` - NetAmount float64 `json:"net_amount,omitempty"` - TransactionAmount float64 `json:"transaction_amount,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` } @@ -54,10 +54,10 @@ type AdditionalInfoRequest struct { // AdditionalInfoPayerRequest represents payer information request within AdditionalInfoPayerRequest. type AdditionalInfoPayerRequest struct { - RegistrationDate *time.Time `json:"registration_date,omitempty"` - LastPurchase *time.Time `json:"last_purchase,omitempty"` Phone *AdditionalInfoPayerPhoneRequest `json:"phone,omitempty"` Address *AdditionalInfoPayerAddressRequest `json:"address,omitempty"` + RegistrationDate *time.Time `json:"registration_date,omitempty"` + LastPurchase *time.Time `json:"last_purchase,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` @@ -108,16 +108,16 @@ type AdditionalInfoBarcodeRequest struct { // ItemRequest represents an item request within AdditionalInfoRequest. type ItemRequest struct { - EventDate *time.Time `json:"event_date,omitempty"` CategoryDescriptor *CategoryDescriptorRequest `json:"category_descriptor,omitempty"` + EventDate *time.Time `json:"event_date,omitempty"` ID string `json:"id,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` PictureURL string `json:"picture_url,omitempty"` CategoryID string `json:"category_id,omitempty"` - Quantity int64 `json:"quantity,omitempty"` UnitPrice float64 `json:"unit_price,omitempty"` + Quantity int64 `json:"quantity,omitempty"` Warranty bool `json:"warranty,omitempty"` } diff --git a/pkg/payment/response.go b/pkg/payment/response.go index 29389d64..f0c84e6d 100644 --- a/pkg/payment/response.go +++ b/pkg/payment/response.go @@ -6,11 +6,6 @@ import ( // Response is the response from the Payments API. type Response struct { - DateCreated *time.Time `json:"date_created"` - DateApproved *time.Time `json:"date_approved"` - DateLastUpdated *time.Time `json:"date_last_updated"` - DateOfExpiration *time.Time `json:"date_of_expiration"` - MoneyReleaseDate *time.Time `json:"money_release_date"` Payer PayerResponse `json:"payer"` AdditionalInfo AdditionalInfoResponse `json:"additional_info"` Order OrderResponse `json:"order"` @@ -19,6 +14,11 @@ type Response struct { PointOfInteraction PointOfInteractionResponse `json:"point_of_interaction"` PaymentMethod PaymentMethodResponse `json:"payment_method"` ThreeDSInfo ThreeDSInfoResponse `json:"three_ds_info"` + DateCreated time.Time `json:"date_created"` + DateApproved time.Time `json:"date_approved"` + DateLastUpdated time.Time `json:"date_last_updated"` + DateOfExpiration time.Time `json:"date_of_expiration"` + MoneyReleaseDate time.Time `json:"money_release_date"` FeeDetails []FeeDetailResponse `json:"fee_details"` Taxes []TaxResponse `json:"taxes"` Refunds []RefundResponse `json:"refunds"` @@ -52,16 +52,16 @@ type Response struct { CallForAuthorizeID string `json:"call_for_authorize_id"` StatementDescriptor string `json:"statement_descriptor"` MoneyReleaseStatus string `json:"money_release_status"` - Installments int `json:"installments"` - ID int64 `json:"id"` - SponsorID int64 `json:"sponsor_id"` - CollectorID int64 `json:"collector_id"` TransactionAmount float64 `json:"transaction_amount"` TransactionAmountRefunded float64 `json:"transaction_amount_refunded"` CouponAmount float64 `json:"coupon_amount"` TaxesAmount float64 `json:"taxes_amount"` ShippingAmount float64 `json:"shipping_amount"` NetAmount float64 `json:"net_amount"` + Installments int `json:"installments"` + ID int64 `json:"id"` + SponsorID int64 `json:"sponsor_id"` + CollectorID int64 `json:"collector_id"` LiveMode bool `json:"live_mode"` Captured bool `json:"captured"` BinaryMode bool `json:"binary_mode"` @@ -109,9 +109,9 @@ type ItemResponse struct { // AdditionalInfoPayerResponse represents payer's additional information. type AdditionalInfoPayerResponse struct { - RegistrationDate *time.Time `json:"registration_date"` Phone PhoneResponse `json:"phone"` Address AddressResponse `json:"address"` + RegistrationDate time.Time `json:"registration_date"` FirstName string `json:"first_name"` LastName string `json:"last_name"` @@ -172,9 +172,9 @@ type TransactionDetailsResponse struct { // CardResponse represents card information. type CardResponse struct { - DateCreated *time.Time `json:"date_created"` - DateLastUpdated *time.Time `json:"date_last_updated"` Cardholder CardholderResponse `json:"cardholder"` + DateCreated time.Time `json:"date_created"` + DateLastUpdated time.Time `json:"date_last_updated"` ID string `json:"id"` LastFourDigits string `json:"last_four_digits"` @@ -285,7 +285,7 @@ type RulesResponse struct { // DiscountResponse represents payment discount information. type DiscountResponse struct { - LimitDate *time.Time `json:"limit_date"` + LimitDate time.Time `json:"limit_date"` Type string `json:"type"` Value float64 `json:"value"` @@ -318,17 +318,17 @@ type TaxResponse struct { // RefundResponse represents refund information. type RefundResponse struct { - DateCreated *time.Time `json:"date_created"` Source SourceResponse `json:"source"` + DateCreated time.Time `json:"date_created"` Status string `json:"status"` RefundMode string `json:"refund_mode"` Reason string `json:"reason"` UniqueSequenceNumber string `json:"unique_sequence_number"` - ID int64 `json:"id"` - PaymentID int64 `json:"payment_id"` Amount float64 `json:"amount"` AdjustmentAmount float64 `json:"adjustment_amount"` + ID int64 `json:"id"` + PaymentID int64 `json:"payment_id"` } // SourceResponse represents source information. diff --git a/pkg/payment/search_request.go b/pkg/payment/search_request.go index 8c3f133e..1cd4a751 100644 --- a/pkg/payment/search_request.go +++ b/pkg/payment/search_request.go @@ -9,10 +9,9 @@ import ( // Filters field can receive a lot of paramaters. For details, see: // https://www.mercadopago.com/developers/en/reference/payments/_payments_search/get. type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/payment/search_response.go b/pkg/payment/search_response.go index 0cdcaff2..0e740df5 100644 --- a/pkg/payment/search_response.go +++ b/pkg/payment/search_response.go @@ -2,8 +2,8 @@ package payment // SearchResponse represents the response from the search endpoint. type SearchResponse struct { - Results []Response `json:"results"` Paging PagingResponse `json:"paging"` + Results []Response `json:"results"` } // PagingResponse represents the paging information within SearchResponse. diff --git a/pkg/payment/update_request.go b/pkg/payment/update_request.go index 3c6cdf8a..97acaafa 100644 --- a/pkg/payment/update_request.go +++ b/pkg/payment/update_request.go @@ -8,5 +8,5 @@ type CancelRequest struct { // CaptureRequest represents a payment capture request. type CaptureRequest struct { TransactionAmount float64 `json:"transaction_amount,omitempty"` - Capture bool `json:"capture"` + Capture bool `json:"capture,omitempty"` } diff --git a/pkg/paymentmethod/response.go b/pkg/paymentmethod/response.go index 6e806364..6afc17f1 100644 --- a/pkg/paymentmethod/response.go +++ b/pkg/paymentmethod/response.go @@ -11,18 +11,18 @@ type Response struct { SecureThumbnail string `json:"secure_thumbnail"` Thumbnail string `json:"thumbnail"` DeferredCapture string `json:"deferred_capture"` - AdditionalInfoNeeded []string `json:"additional_info_needed"` - ProcessingModes []string `json:"processing_modes"` - AccreditationTime int64 `json:"accreditation_time"` MinAllowedAmount float64 `json:"min_allowed_amount"` MaxAllowedAmount float64 `json:"max_allowed_amount"` + AccreditationTime int64 `json:"accreditation_time"` + AdditionalInfoNeeded []string `json:"additional_info_needed"` + ProcessingModes []string `json:"processing_modes"` } // SettingsResponse represents payment method settings. type SettingsResponse struct { - Bin *SettingsBinResponse `json:"bin"` - CardNumber *SettingsCardNumberResponse `json:"card_number"` - SecurityCode *SettingsSecurityCodeResponse `json:"security_code"` + Bin SettingsBinResponse `json:"bin"` + CardNumber SettingsCardNumberResponse `json:"card_number"` + SecurityCode SettingsSecurityCodeResponse `json:"security_code"` } // SettingsBinResponse represents BIN (Bank Identification Number) settings. @@ -34,15 +34,15 @@ type SettingsBinResponse struct { // SettingsCardNumberResponse represents card number settings. type SettingsCardNumberResponse struct { - Length int `json:"length"` Validation string `json:"validation"` + Length int `json:"length"` } // SettingsSecurityCodeResponse represents security code settings. type SettingsSecurityCodeResponse struct { Mode string `json:"mode"` - Length int `json:"length"` CardLocation string `json:"card_location"` + Length int `json:"length"` } // FinancialInstitutionResponse represents financial institution settings. diff --git a/pkg/point/client_test.go b/pkg/point/client_test.go index 21409965..0a773b14 100644 --- a/pkg/point/client_test.go +++ b/pkg/point/client_test.go @@ -359,7 +359,7 @@ func TestListDevices(t *testing.T) { ctx: context.Background(), }, want: &DevicesResponse{ - Devices: []Device{ + Devices: []DeviceResponse{ { ID: "PAX_A910__SMARTPOS1234345545", PosID: 47792476, @@ -368,7 +368,7 @@ func TestListDevices(t *testing.T) { OperatingMode: "PDV", }, }, - Paging: Paging{ + Paging: PagingResponse{ Total: 1, Offset: 0, Limit: 50, diff --git a/pkg/point/request.go b/pkg/point/request.go index 7c2ab293..4ad8b0db 100644 --- a/pkg/point/request.go +++ b/pkg/point/request.go @@ -4,21 +4,21 @@ type CreateRequest struct { AdditionalInfo *AdditionalInfoRequest `json:"additional_info"` Payment *PaymentRequest `json:"payment"` - Amount int `json:"amount"` Description string `json:"description"` + Amount int `json:"amount"` } type AdditionalInfoRequest struct { - PrintOnTerminal bool `json:"print_on_terminal,omitempty"` ExternalReference string `json:"external_reference,omitempty"` TicketNumber string `json:"ticket_number,omitempty"` + PrintOnTerminal bool `json:"print_on_terminal,omitempty"` } type PaymentRequest struct { - ID int64 `json:"id,omitempty"` - Installments int `json:"installments,omitempty"` Type string `json:"type,omitempty"` InstallmentsCost string `json:"installments_cost,omitempty"` + ID int64 `json:"id,omitempty"` + Installments int `json:"installments,omitempty"` } type UpdateDeviceOperatingModeRequest struct { diff --git a/pkg/point/response.go b/pkg/point/response.go index 83beb28b..adeca2ba 100644 --- a/pkg/point/response.go +++ b/pkg/point/response.go @@ -4,25 +4,25 @@ type Response struct { Payment PaymentResponse `json:"payment"` AdditionalInfo AdditionalInfoResponse `json:"additional_info"` - Amount int `json:"amount"` ID string `json:"id"` Description string `json:"description"` State string `json:"state"` DeviceID string `json:"device_id"` + Amount int `json:"amount"` } type AdditionalInfoResponse struct { - PrintOnTerminal bool `json:"print_on_terminal"` ExternalReference string `json:"external_reference"` TicketNumber string `json:"ticket_number"` + PrintOnTerminal bool `json:"print_on_terminal"` } type PaymentResponse struct { - ID int64 `json:"id"` - Installments int `json:"installments"` Type string `json:"type"` InstallmentsCost string `json:"installments_cost"` VoucherType string `json:"voucher_type"` + ID int64 `json:"id"` + Installments int `json:"installments"` } type CancelResponse struct { @@ -30,19 +30,19 @@ type CancelResponse struct { } type DevicesResponse struct { - Devices []Device `json:"devices"` - Paging Paging `json:"paging"` + Paging PagingResponse `json:"paging"` + Devices []DeviceResponse `json:"devices"` } -type Device struct { - PosID int `json:"pos_id"` - StoreID int `json:"store_id"` +type DeviceResponse struct { ID string `json:"id"` ExternalPosID string `json:"external_pos_id"` OperatingMode string `json:"operating_mode"` + PosID int `json:"pos_id"` + StoreID int `json:"store_id"` } -type Paging struct { +type PagingResponse struct { Total int `json:"total"` Offset int `json:"offset"` Limit int `json:"limit"` diff --git a/pkg/preapproval/client_test.go b/pkg/preapproval/client_test.go index 884dfa47..b77cb8cd 100644 --- a/pkg/preapproval/client_test.go +++ b/pkg/preapproval/client_test.go @@ -3,9 +3,6 @@ package preapproval import ( "context" "fmt" - "github.com/google/uuid" - "github.com/mercadopago/sdk-go/pkg/config" - "github.com/mercadopago/sdk-go/pkg/internal/httpclient" "io" "net/http" "os" @@ -13,6 +10,10 @@ import ( "strings" "testing" "time" + + "github.com/google/uuid" + "github.com/mercadopago/sdk-go/pkg/config" + "github.com/mercadopago/sdk-go/pkg/internal/httpclient" ) var ( @@ -101,8 +102,6 @@ func TestCreate(t *testing.T) { ChargedQuantity: 0, PendingChargeQuantity: 0, ChargedAmount: 0, - LastChargedDate: nil, - LastChargedAmount: nil, }, NextPaymentDate: parseDate("2024-03-06T18:10:01.000-04:00"), PaymentMethodID: "", @@ -208,8 +207,6 @@ func TestGet(t *testing.T) { ChargedQuantity: 0, PendingChargeQuantity: 0, ChargedAmount: 0, - LastChargedDate: nil, - LastChargedAmount: nil, }, NextPaymentDate: parseDate("2024-03-06T18:10:01.000-04:00"), PaymentMethodID: "", @@ -428,8 +425,6 @@ func TestUpdate(t *testing.T) { PendingChargeQuantity: 0, ChargedAmount: 0, Semaphore: "", - LastChargedDate: nil, - LastChargedAmount: nil, }, NextPaymentDate: parseDate("2024-03-06T18:10:01.000-04:00"), PaymentMethodID: "", @@ -458,7 +453,7 @@ func TestUpdate(t *testing.T) { } } -func parseDate(s string) *time.Time { +func parseDate(s string) time.Time { d, _ := time.Parse(time.RFC3339, s) - return &d + return d } diff --git a/pkg/preapproval/request.go b/pkg/preapproval/request.go index b11acf3b..3da0a861 100644 --- a/pkg/preapproval/request.go +++ b/pkg/preapproval/request.go @@ -18,9 +18,9 @@ type Request struct { // AutoRecurringRequest represents the recurrence settings. type AutoRecurringRequest struct { + FreeTrial *FreeTrialRequest `json:"free_trial,omitempty"` StartDate *time.Time `json:"start_date,omitempty"` EndDate *time.Time `json:"end_date,omitempty"` - FreeTrial *FreeTrialRequest `json:"free_trial,omitempty"` CurrencyID string `json:"currency_id,omitempty"` FrequencyType string `json:"frequency_type,omitempty"` diff --git a/pkg/preapproval/response.go b/pkg/preapproval/response.go index 3f8d471e..22c80b8a 100644 --- a/pkg/preapproval/response.go +++ b/pkg/preapproval/response.go @@ -6,9 +6,9 @@ import "time" type Response struct { AutoRecurring AutoRecurringResponse `json:"auto_recurring"` Summarized SummarizedResponse `json:"summarized"` - DateCreated *time.Time `json:"date_created"` - LastModified *time.Time `json:"last_modified"` - NextPaymentDate *time.Time `json:"next_payment_date"` + DateCreated time.Time `json:"date_created"` + LastModified time.Time `json:"last_modified"` + NextPaymentDate time.Time `json:"next_payment_date"` ID string `json:"id"` PayerEmail string `json:"payer_email"` @@ -21,25 +21,25 @@ type Response struct { FirstInvoiceOffset string `json:"first_invoice_offset"` BackURL string `json:"back_url"` PreapprovalPlanID string `json:"preapproval_plan_id"` + PayerFirstName string `json:"payer_first_name"` + PayerLastName string `json:"payer_last_name"` CardID int `json:"card_id"` Version int `json:"version"` PayerID int `json:"payer_id"` CollectorID int `json:"collector_id"` ApplicationID int `json:"application_id"` - PayerFirstName string `json:"payer_first_name"` - PayerLastName string `json:"payer_last_name"` } // AutoRecurringResponse represents the recurrence settings. type AutoRecurringResponse struct { FreeTrial FreeTrialResponse `json:"free_trial"` - StartDate *time.Time `json:"start_date"` - EndDate *time.Time `json:"end_date"` + StartDate time.Time `json:"start_date"` + EndDate time.Time `json:"end_date"` CurrencyID string `json:"currency_id"` FrequencyType string `json:"frequency_type"` - Frequency int `json:"frequency"` TransactionAmount float64 `json:"transaction_amount"` + Frequency int `json:"frequency"` } // FreeTrialResponse represents the free trial settings. @@ -51,13 +51,13 @@ type FreeTrialResponse struct { // SummarizedResponse contains summary information about invoices and subscription charges. type SummarizedResponse struct { - LastChargedDate *time.Time `json:"last_charged_date"` - LastChargedAmount *time.Time `json:"last_charged_amount"` + LastChargedDate time.Time `json:"last_charged_date"` + LastChargedAmount time.Time `json:"last_charged_amount"` + Semaphore string `json:"semaphore"` + PendingChargeAmount float64 `json:"pending_charge_amount"` + ChargedAmount float64 `json:"charged_amount"` Quotas int `json:"quotas"` PendingChargeQuantity int `json:"pending_charge_quantity"` ChargedQuantity int `json:"charged_quantity"` - PendingChargeAmount float64 `json:"pending_charge_amount"` - ChargedAmount float64 `json:"charged_amount"` - Semaphore string `json:"semaphore"` } diff --git a/pkg/preapproval/search_request.go b/pkg/preapproval/search_request.go index 473350de..7e0e66cb 100644 --- a/pkg/preapproval/search_request.go +++ b/pkg/preapproval/search_request.go @@ -9,10 +9,9 @@ import ( // Filters field can receive a lot of parameters. For details, see: // https://www.mercadopago.com/developers/en/reference/subscriptions/_preapproval_search/get type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/preapproval/search_response.go b/pkg/preapproval/search_response.go index 5549f9b8..8e0f72e0 100644 --- a/pkg/preapproval/search_response.go +++ b/pkg/preapproval/search_response.go @@ -2,8 +2,8 @@ package preapproval // SearchResponse represents the response from the search endpoint. type SearchResponse struct { - Results []Response `json:"results"` Paging PagingResponse `json:"paging"` + Results []Response `json:"results"` } // PagingResponse represents the paging information within SearchResponse. diff --git a/pkg/preapprovalplan/client_test.go b/pkg/preapprovalplan/client_test.go index 2cbec20d..b49b3cef 100644 --- a/pkg/preapprovalplan/client_test.go +++ b/pkg/preapprovalplan/client_test.go @@ -468,7 +468,7 @@ func TestSearch(t *testing.T) { } } -func parseDate(s string) *time.Time { +func parseDate(s string) time.Time { d, _ := time.Parse(time.RFC3339, s) - return &d + return d } diff --git a/pkg/preapprovalplan/response.go b/pkg/preapprovalplan/response.go index fc9a8987..338cd086 100644 --- a/pkg/preapprovalplan/response.go +++ b/pkg/preapprovalplan/response.go @@ -4,10 +4,10 @@ import "time" // Response represents the response from the pre-approval plan endpoint. type Response struct { - DateCreated *time.Time `json:"date_created"` - LastModified *time.Time `json:"last_modified"` AutoRecurring AutoRecurringResponse `json:"auto_recurring"` PaymentMethodsAllowed PaymentMethodsAllowedResponse `json:"payment_methods_allowed"` + DateCreated time.Time `json:"date_created"` + LastModified time.Time `json:"last_modified"` ID string `json:"id"` BackURL string `json:"back_url"` @@ -25,10 +25,10 @@ type AutoRecurringResponse struct { CurrencyID string `json:"currency_id"` FrequencyType string `json:"frequency_type"` + TransactionAmount float64 `json:"transaction_amount"` Frequency int `json:"frequency"` Repetitions int `json:"repetitions"` BillingDay int `json:"billing_day"` - TransactionAmount float64 `json:"transaction_amount"` BillingDayProportional bool `json:"billing_day_proportional"` } diff --git a/pkg/preapprovalplan/search_request.go b/pkg/preapprovalplan/search_request.go index 820987f7..5395e340 100644 --- a/pkg/preapprovalplan/search_request.go +++ b/pkg/preapprovalplan/search_request.go @@ -9,10 +9,9 @@ import ( // Filters field can receive a lot of parameters. For details, see: // https://www.mercadopago.com/developers/en/reference/subscriptions/_preapproval_plan_id/get type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/preapprovalplan/search_response.go b/pkg/preapprovalplan/search_response.go index b459f5e7..8a4bbbf5 100644 --- a/pkg/preapprovalplan/search_response.go +++ b/pkg/preapprovalplan/search_response.go @@ -2,8 +2,8 @@ package preapprovalplan // SearchResponse represents the response from the search endpoint. type SearchResponse struct { - Results []Response `json:"results"` Paging PagingResponse `json:"paging"` + Results []Response `json:"results"` } // PagingResponse represents the paging information within SearchResponse. diff --git a/pkg/preference/client_test.go b/pkg/preference/client_test.go index dae7cf82..47611f20 100644 --- a/pkg/preference/client_test.go +++ b/pkg/preference/client_test.go @@ -481,7 +481,7 @@ func TestSearch(t *testing.T) { } } -func parseDate(s string) *time.Time { +func parseDate(s string) time.Time { d, _ := time.Parse(time.RFC3339, s) - return &d + return d } diff --git a/pkg/preference/request.go b/pkg/preference/request.go index 75221173..8efc9614 100644 --- a/pkg/preference/request.go +++ b/pkg/preference/request.go @@ -6,31 +6,31 @@ import ( // PreferenceRequest contains parameters to create/update a preference. type Request struct { - DateOfExpiration *time.Time `json:"date_of_expiration,omitempty"` - ExpirationDateFrom *time.Time `json:"expiration_date_from,omitempty"` - ExpirationDateTo *time.Time `json:"expiration_date_to,omitempty"` BackUrls *PreferenceBackUrlsRequest `json:"back_urls,omitempty"` DifferentialPricing *PreferenceDifferentialPricingRequest `json:"differential_pricing,omitempty"` Payer *PreferencePayerRequest `json:"payer,omitempty"` PaymentMethods *PreferencePaymentMethodsRequest `json:"payment_methods,omitempty"` Shipments *PreferenceShipmentsRequest `json:"shipments,omitempty"` + DateOfExpiration *time.Time `json:"date_of_expiration,omitempty"` + ExpirationDateFrom *time.Time `json:"expiration_date_from,omitempty"` + ExpirationDateTo *time.Time `json:"expiration_date_to,omitempty"` Items []PreferenceItemRequest `json:"items,omitempty"` Taxes []PreferenceTaxRequest `json:"taxes,omitempty"` Tracks []PreferenceTrackRequest `json:"tracks,omitempty"` - AdditionalInfo string `json:"additional_info,omitempty"` - AutoReturn string `json:"auto_return,omitempty"` - ExternalReference string `json:"external_reference,omitempty"` - Marketplace string `json:"marketplace,omitempty"` - OperationType string `json:"operation_type,omitempty"` - NotificationUrl string `json:"notification_url,omitempty"` - Purpose string `json:"purpose,omitempty"` - StatementDescriptor string `json:"statement_descriptor,omitempty"` - BinaryMode bool `json:"binary_mode,omitempty"` - Expires bool `json:"expires,omitempty"` - MarketplaceFee float64 `json:"marketplace_fee,omitempty"` - ProcessingModes []string `json:"processing_modes,omitempty"` - Metadata map[string]interface{} `json:"metadata,omitempty"` + AdditionalInfo string `json:"additional_info,omitempty"` + AutoReturn string `json:"auto_return,omitempty"` + ExternalReference string `json:"external_reference,omitempty"` + Marketplace string `json:"marketplace,omitempty"` + OperationType string `json:"operation_type,omitempty"` + NotificationUrl string `json:"notification_url,omitempty"` + Purpose string `json:"purpose,omitempty"` + StatementDescriptor string `json:"statement_descriptor,omitempty"` + MarketplaceFee float64 `json:"marketplace_fee,omitempty"` + BinaryMode bool `json:"binary_mode,omitempty"` + Expires bool `json:"expires,omitempty"` + ProcessingModes []string `json:"processing_modes,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` } // PreferenceBackUrlsRequest contains callback URLs. @@ -53,16 +53,16 @@ type PreferenceItemRequest struct { PictureURL string `json:"picture_url,omitempty"` CategoryID string `json:"category_id,omitempty"` CurrencyID string `json:"currency_id,omitempty"` - Quantity int `json:"quantity,omitempty"` UnitPrice float64 `json:"unit_price,omitempty"` + Quantity int `json:"quantity,omitempty"` } // PreferencePayerRequest contains payer information in the preference. type PreferencePayerRequest struct { - DateCreated *time.Time `json:"date_created,omitempty"` Phone *PhoneRequest `json:"phone,omitempty"` Identification *IdentificationRequest `json:"identification,omitempty"` Address *AddressRequest `json:"address,omitempty"` + DateCreated *time.Time `json:"date_created,omitempty"` Name string `json:"name,omitempty"` Surname string `json:"surname,omitempty"` @@ -116,10 +116,10 @@ type PreferenceShipmentsRequest struct { Mode string `json:"mode,omitempty"` Dimensions string `json:"dimensions,omitempty"` DefaultShippingMethod string `json:"default_shipping_method,omitempty"` + Cost float64 `json:"cost,omitempty"` LocalPickup bool `json:"local_pickup,omitempty"` FreeShipping bool `json:"free_shipping,omitempty"` ExpressShipment bool `json:"express_shipment,omitempty"` - Cost float64 `json:"cost,omitempty"` } // PreferenceFreeMethodRequest contains information about free shipping methods in the preference. diff --git a/pkg/preference/response.go b/pkg/preference/response.go index c89bf19a..ae2a21dc 100644 --- a/pkg/preference/response.go +++ b/pkg/preference/response.go @@ -5,38 +5,38 @@ import ( ) type Response struct { - DateOfExpiration *time.Time `json:"date_of_expiration"` - ExpirationDateFrom *time.Time `json:"expiration_date_from"` - ExpirationDateTo *time.Time `json:"expiration_date_to"` - LastUpdated *time.Time `json:"last_updated"` - DateCreated *time.Time `json:"date_created"` Payer PreferencePayerResponse `json:"payer"` PaymentMethods PreferencePaymentMethodsResponse `json:"payment_methods"` BackURLS PreferenceBackUrlsResponse `json:"back_urls"` Shipments PreferenceShipmentsResponse `json:"shipments"` DifferentialPricing PreferenceDifferentialPricingResponse `json:"differential_pricing"` + DateOfExpiration time.Time `json:"date_of_expiration"` + ExpirationDateFrom time.Time `json:"expiration_date_from"` + ExpirationDateTo time.Time `json:"expiration_date_to"` + LastUpdated time.Time `json:"last_updated"` + DateCreated time.Time `json:"date_created"` Taxes []PreferenceTaxResponse `json:"taxes"` Tracks []PreferenceTrackResponse `json:"tracks"` Items []PreferenceItemResponse `json:"items"` - ID string `json:"id"` - ClientID string `json:"client_id"` - NotificationURL string `json:"notification_url"` - StatementDescriptor string `json:"statement_descriptor"` - Marketplace string `json:"marketplace"` - ExternalReference string `json:"external_reference"` - AdditionalInfo string `json:"additional_info"` - AutoReturn string `json:"auto_return"` - OperationType string `json:"operation_type"` - InitPoint string `json:"init_point"` - SandboxInitPoint string `json:"sandbox_init_point"` - SiteID string `json:"site_id"` - CollectorID int64 `json:"collector_id"` - Expires bool `json:"expires"` - BinaryMode bool `json:"binary_mode"` - MarketplaceFee float64 `json:"marketplace_fee"` - ProcessingModes []string `json:"processing_modes"` - Metadata map[string]interface{} `json:"metadata"` + ID string `json:"id"` + ClientID string `json:"client_id"` + NotificationURL string `json:"notification_url"` + StatementDescriptor string `json:"statement_descriptor"` + Marketplace string `json:"marketplace"` + ExternalReference string `json:"external_reference"` + AdditionalInfo string `json:"additional_info"` + AutoReturn string `json:"auto_return"` + OperationType string `json:"operation_type"` + InitPoint string `json:"init_point"` + SandboxInitPoint string `json:"sandbox_init_point"` + SiteID string `json:"site_id"` + MarketplaceFee float64 `json:"marketplace_fee"` + CollectorID int64 `json:"collector_id"` + Expires bool `json:"expires"` + BinaryMode bool `json:"binary_mode"` + ProcessingModes []string `json:"processing_modes"` + Metadata map[string]any `json:"metadata"` } // PreferenceItemResponse represents an item. @@ -47,8 +47,8 @@ type PreferenceItemResponse struct { CurrencyID string `json:"currency_id"` PictureURL string `json:"picture_url"` CategoryID string `json:"category_id"` - Quantity int `json:"quantity"` UnitPrice float64 `json:"unit_price"` + Quantity int `json:"quantity"` } // PreferencePayerResponse contains payer information in the preference. @@ -56,8 +56,8 @@ type PreferencePayerResponse struct { Phone PhoneResponse `json:"phone"` Identification IdentificationResponse `json:"identification"` Address AddressResponse `json:"address"` - DateCreated *time.Time `json:"date_created"` - LastPurchase *time.Time `json:"last_purchase"` + DateCreated time.Time `json:"date_created"` + LastPurchase time.Time `json:"last_purchase"` Name string `json:"name"` Surname string `json:"surname"` @@ -112,7 +112,7 @@ type PreferenceFreeMethodResponse struct { // PreferenceReceiverAddressResponse represents a sending address. type PreferenceReceiverAddressResponse struct { - AddressResponse + Address AddressResponse `json:"address"` CountryName string `json:"country_name"` StateName string `json:"state_name"` diff --git a/pkg/preference/search_request.go b/pkg/preference/search_request.go index 7673fe36..2d181d71 100644 --- a/pkg/preference/search_request.go +++ b/pkg/preference/search_request.go @@ -9,10 +9,9 @@ import ( // Filters field can receive a lot of paramaters. For details, see: // https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences_search/get. type SearchRequest struct { + Limit int + Offset int Filters map[string]string - - Limit int - Offset int } // GetParams creates map to build query parameters. Keys will be changed to lower case. diff --git a/pkg/preference/search_response.go b/pkg/preference/search_response.go index 499b79e1..818432db 100644 --- a/pkg/preference/search_response.go +++ b/pkg/preference/search_response.go @@ -4,10 +4,10 @@ import "time" // SearchResponse contains information about a preference for searching. type SearchResponse struct { - DateCreated *time.Time `json:"date_created"` - ExpirationDateFrom *time.Time `json:"expiration_date_from"` - ExpirationDateTo *time.Time `json:"expiration_date_to"` - LastUpdated *time.Time `json:"last_updated"` + DateCreated time.Time `json:"date_created"` + ExpirationDateFrom time.Time `json:"expiration_date_from"` + ExpirationDateTo time.Time `json:"expiration_date_to"` + LastUpdated time.Time `json:"last_updated"` ID string `json:"id"` ClientID string `json:"client_id"` diff --git a/pkg/refund/client_test.go b/pkg/refund/client_test.go index fe153c98..63893200 100644 --- a/pkg/refund/client_test.go +++ b/pkg/refund/client_test.go @@ -332,7 +332,7 @@ func buildResponseMock() *Response { ID: "7186040733", Type: "collector", }, - DateCreated: &d, + DateCreated: d, RefundMode: "standard", AdjustmentAmount: 0, } diff --git a/pkg/refund/response.go b/pkg/refund/response.go index f80cbd22..35259ba8 100644 --- a/pkg/refund/response.go +++ b/pkg/refund/response.go @@ -4,17 +4,17 @@ import "time" // Response is the response from the Refund's API. type Response struct { - DateCreated *time.Time `json:"date_created"` - Source Source `json:"source"` + Source Source `json:"source"` + DateCreated time.Time `json:"date_created"` Status string `json:"status"` RefundMode string `json:"refund_mode"` Reason string `json:"reason"` UniqueSequenceNumber string `json:"unique_sequence_number"` - ID int64 `json:"id"` - PaymentID int64 `json:"payment_id"` Amount float64 `json:"amount"` AdjustmentAmount float64 `json:"adjustment_amount"` + ID int64 `json:"id"` + PaymentID int64 `json:"payment_id"` } // Source represents the data to identify who originated the refund diff --git a/pkg/user/response.go b/pkg/user/response.go index fd013044..282f11c6 100644 --- a/pkg/user/response.go +++ b/pkg/user/response.go @@ -1,11 +1,11 @@ package user type Response struct { - ID int64 `json:"id"` Nickname string `json:"nickname"` FirstName string `json:"first_name"` LastName string `json:"last_name"` CountryID string `json:"country_id"` Email string `json:"email"` SiteID string `json:"site_id"` + ID int64 `json:"id"` } diff --git a/test/card_token.go b/test/card_token.go index 13520a22..d16cea8b 100644 --- a/test/card_token.go +++ b/test/card_token.go @@ -8,8 +8,8 @@ import ( func GenerateCardToken(ctx context.Context, client cardtoken.Client) (string, error) { req := cardtoken.Request{ - Cardholder: &cardtoken.Cardholder{ - Identification: &cardtoken.Identification{ + Cardholder: &cardtoken.CardholderRequest{ + Identification: &cardtoken.IdentificationRequest{ Number: "01234567890", Type: "CPF", }, diff --git a/test/integration/cardtoken/card_token_test.go b/test/integration/cardtoken/card_token_test.go index d9c79d10..24921805 100644 --- a/test/integration/cardtoken/card_token_test.go +++ b/test/integration/cardtoken/card_token_test.go @@ -24,8 +24,8 @@ func TestCardToken(t *testing.T) { ExpirationMonth: "11", ExpirationYear: "2025", SecurityCode: "123", - Cardholder: &cardtoken.Cardholder{ - Identification: &cardtoken.Identification{ + Cardholder: &cardtoken.CardholderRequest{ + Identification: &cardtoken.IdentificationRequest{ Type: "CPF", Number: "70383868084", },