From 83a85cb20e176ae8873929963e1ece9408254e5b Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 20 Jun 2023 09:48:23 -0600 Subject: [PATCH 1/2] fix: customs_info wrapping for customs_items --- CHANGELOG.md | 4 ++ VERSION | 2 +- lib/easypost/http_client.rb | 5 +- lib/easypost/services/customs_info.rb | 4 +- ...tomsInfo_create_creates_a_customs_info.yml | 27 +++++----- ...Info_retrieve_retrieves_a_customs_info.yml | 51 ++++++++++--------- spec/customs_info_spec.rb | 1 + 7 files changed, 53 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a3d1e51..73999c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v5.0.1 (2023-06-20) + +- Fixes a bug where the params of a `customs_info` on create weren't wrapped properly which led to an empty set of `customs_items` + ## v5.0.0 (2023-06-06) See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-4x-to-50) for more details. diff --git a/VERSION b/VERSION index 0062ac97..6b244dcd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.0 +5.0.1 diff --git a/lib/easypost/http_client.rb b/lib/easypost/http_client.rb index 04bde724..091b6a61 100644 --- a/lib/easypost/http_client.rb +++ b/lib/easypost/http_client.rb @@ -43,7 +43,10 @@ def default_request_execute(method, uri, headers, open_timeout, read_timeout, bo # Attempt to make the request and return the response. Net::HTTP.start( uri.host, - uri.port, use_ssl: true, read_timeout: read_timeout, open_timeout: open_timeout, + uri.port, + use_ssl: true, + read_timeout: read_timeout, + open_timeout: open_timeout, ) do |http| http.request(request) end diff --git a/lib/easypost/services/customs_info.rb b/lib/easypost/services/customs_info.rb index c95e9b5f..eb783dcc 100644 --- a/lib/easypost/services/customs_info.rb +++ b/lib/easypost/services/customs_info.rb @@ -5,7 +5,9 @@ class EasyPost::Services::CustomsInfo < EasyPost::Services::Service # Create a CustomsInfo object def create(params) - @client.make_request(:post, 'customs_infos', MODEL_CLASS, params) + wrapped_params = { customs_info: params } + + @client.make_request(:post, 'customs_infos', MODEL_CLASS, wrapped_params) end # Retrieve a CustomsInfo object diff --git a/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_create_creates_a_customs_info.yml b/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_create_creates_a_customs_info.yml index 4b44da0a..747783c1 100644 --- a/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_create_creates_a_customs_info.yml +++ b/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_create_creates_a_customs_info.yml @@ -5,9 +5,9 @@ http_interactions: uri: https://api.easypost.com/v2/customs_infos body: encoding: UTF-8 - string: '{"eel_pfc":"NOEEI 30.37(a)","customs_certify":true,"customs_signer":"Steve + string: '{"customs_info":{"eel_pfc":"NOEEI 30.37(a)","customs_certify":true,"customs_signer":"Steve Brule","contents_type":"merchandise","contents_explanation":"","restriction_type":"none","non_delivery_option":"return","customs_items":[{"description":"Sweet - shirts","quantity":2,"weight":11,"value":23.25,"hs_tariff_number":"654321","origin_country":"US"}]}' + shirts","quantity":2,"weight":11,"value":23.25,"hs_tariff_number":"654321","origin_country":"US"}]}}' headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -37,7 +37,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - a4ae9a0564652d8fe0dc931d0006d8eb + - b135b6106491c99be786a80500112e0f Cache-Control: - private, no-cache, no-store Pragma: @@ -45,30 +45,31 @@ http_interactions: Expires: - '0' Location: - - "/api/v2/customs_infos/cstinfo_9258abe696a84fd6a4c54ff9469ed0c9" + - "/api/v2/customs_infos/cstinfo_937a03cece6a4c53a9b1de43b6389500" Content-Type: - application/json; charset=utf-8 Etag: - - W/"865cec3ef3f102900a188837fd3a8c64" + - W/"74de73c3351fc117bafb061079700cf9" X-Runtime: - - '0.045289' + - '0.035774' Transfer-Encoding: - chunked X-Node: - - bigweb12nuq + - bigweb4nuq X-Version-Label: - - easypost-202305171925-180fff930b-master + - easypost-202306162038-54b6e7ec52-master X-Backend: - easypost X-Proxied: - extlb4wdc 5ab12a3ed2 - - intlb1wdc a29e4ad05c - - intlb2nuq a29e4ad05c + - intlb2nuq 255dce5529 + - intlb2wdc 255dce5529 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"cstinfo_9258abe696a84fd6a4c54ff9469ed0c9","object":"CustomsInfo","created_at":"2023-05-17T19:39:59Z","updated_at":"2023-05-17T19:39:59Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve - Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[]}' - recorded_at: Wed, 17 May 2023 19:39:59 GMT + string: '{"id":"cstinfo_937a03cece6a4c53a9b1de43b6389500","object":"CustomsInfo","created_at":"2023-06-20T15:45:31Z","updated_at":"2023-06-20T15:45:31Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve + Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_c84a2c83a15d467d9a92277c8fbe87fd","object":"CustomsItem","created_at":"2023-06-20T15:45:31Z","updated_at":"2023-06-20T15:45:31Z","description":"Sweet + shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]}' + recorded_at: Tue, 20 Jun 2023 15:45:29 GMT recorded_with: VCR 6.1.0 diff --git a/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_retrieve_retrieves_a_customs_info.yml b/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_retrieve_retrieves_a_customs_info.yml index 5331ca52..33ab3462 100644 --- a/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_retrieve_retrieves_a_customs_info.yml +++ b/spec/cassettes/customs_info/EasyPost_Services_CustomsInfo_retrieve_retrieves_a_customs_info.yml @@ -5,9 +5,9 @@ http_interactions: uri: https://api.easypost.com/v2/customs_infos body: encoding: UTF-8 - string: '{"eel_pfc":"NOEEI 30.37(a)","customs_certify":true,"customs_signer":"Steve + string: '{"customs_info":{"eel_pfc":"NOEEI 30.37(a)","customs_certify":true,"customs_signer":"Steve Brule","contents_type":"merchandise","contents_explanation":"","restriction_type":"none","non_delivery_option":"return","customs_items":[{"description":"Sweet - shirts","quantity":2,"weight":11,"value":23.25,"hs_tariff_number":"654321","origin_country":"US"}]}' + shirts","quantity":2,"weight":11,"value":23.25,"hs_tariff_number":"654321","origin_country":"US"}]}}' headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -37,7 +37,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - a4ae9a0464652d8fe0dc931e0006d908 + - b135b60b6491c99ce786ab1400112e55 Cache-Control: - private, no-cache, no-store Pragma: @@ -45,35 +45,36 @@ http_interactions: Expires: - '0' Location: - - "/api/v2/customs_infos/cstinfo_3e88629556bb41d0befac0a915e22548" + - "/api/v2/customs_infos/cstinfo_7d46b13bfe1c40329950c47b3c986586" Content-Type: - application/json; charset=utf-8 Etag: - - W/"18d88a8e33548bfc1fd561e5cad4304c" + - W/"febd4a4c15d4b7c586b80e7d12abce8f" X-Runtime: - - '0.039659' + - '0.036426' Transfer-Encoding: - chunked X-Node: - - bigweb1nuq + - bigweb6nuq X-Version-Label: - - easypost-202305171925-180fff930b-master + - easypost-202306162038-54b6e7ec52-master X-Backend: - easypost X-Proxied: - extlb4wdc 5ab12a3ed2 - - intlb1nuq a29e4ad05c - - intlb2wdc a29e4ad05c + - intlb1nuq 255dce5529 + - intlb1wdc 255dce5529 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"cstinfo_3e88629556bb41d0befac0a915e22548","object":"CustomsInfo","created_at":"2023-05-17T19:39:59Z","updated_at":"2023-05-17T19:39:59Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve - Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[]}' - recorded_at: Wed, 17 May 2023 19:39:59 GMT + string: '{"id":"cstinfo_7d46b13bfe1c40329950c47b3c986586","object":"CustomsInfo","created_at":"2023-06-20T15:45:32Z","updated_at":"2023-06-20T15:45:32Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve + Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_c61705f937f24c1a8b1e8f00e3079373","object":"CustomsItem","created_at":"2023-06-20T15:45:32Z","updated_at":"2023-06-20T15:45:32Z","description":"Sweet + shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]}' + recorded_at: Tue, 20 Jun 2023 15:45:30 GMT - request: method: get - uri: https://api.easypost.com/v2/customs_infos/cstinfo_3e88629556bb41d0befac0a915e22548 + uri: https://api.easypost.com/v2/customs_infos/cstinfo_7d46b13bfe1c40329950c47b3c986586 body: encoding: US-ASCII string: '' @@ -106,7 +107,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - a4ae9a0964652d90e0dc931f0006d91c + - a6f079cf6491c99ce786ab150016c8da Cache-Control: - private, no-cache, no-store Pragma: @@ -116,26 +117,26 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Etag: - - W/"18d88a8e33548bfc1fd561e5cad4304c" + - W/"febd4a4c15d4b7c586b80e7d12abce8f" X-Runtime: - - '0.018159' + - '0.020902' Transfer-Encoding: - chunked X-Node: - - bigweb6nuq + - bigweb9nuq X-Version-Label: - - easypost-202305171805-88442329bc-master + - easypost-202306162038-54b6e7ec52-master X-Backend: - easypost X-Proxied: - - extlb4wdc 5ab12a3ed2 - - intlb1nuq a29e4ad05c - - intlb2wdc a29e4ad05c + - extlb1nuq 5ab12a3ed2 + - intlb1nuq 255dce5529 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"cstinfo_3e88629556bb41d0befac0a915e22548","object":"CustomsInfo","created_at":"2023-05-17T19:39:59Z","updated_at":"2023-05-17T19:39:59Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve - Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[]}' - recorded_at: Wed, 17 May 2023 19:40:00 GMT + string: '{"id":"cstinfo_7d46b13bfe1c40329950c47b3c986586","object":"CustomsInfo","created_at":"2023-06-20T15:45:32Z","updated_at":"2023-06-20T15:45:32Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve + Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_c61705f937f24c1a8b1e8f00e3079373","object":"CustomsItem","created_at":"2023-06-20T15:45:32Z","updated_at":"2023-06-20T15:45:32Z","description":"Sweet + shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]}' + recorded_at: Tue, 20 Jun 2023 15:45:30 GMT recorded_with: VCR 6.1.0 diff --git a/spec/customs_info_spec.rb b/spec/customs_info_spec.rb index 9e5c5b68..2844918a 100644 --- a/spec/customs_info_spec.rb +++ b/spec/customs_info_spec.rb @@ -10,6 +10,7 @@ customs_info = client.customs_info.create(Fixture.basic_customs_info) expect(customs_info).to be_an_instance_of(EasyPost::Models::CustomsInfo) + expect(customs_info.customs_items).to all(be_an_instance_of(EasyPost::Models::CustomsItem)) expect(customs_info.id).to match('cstinfo_') expect(customs_info.eel_pfc).to eq('NOEEI 30.37(a)') end From 1bd1c7aebb867bf40e401578dae05971a6f3536b Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 20 Jun 2023 09:53:13 -0600 Subject: [PATCH 2/2] fix: lint --- lib/easypost/http_client.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/easypost/http_client.rb b/lib/easypost/http_client.rb index 091b6a61..bea3d752 100644 --- a/lib/easypost/http_client.rb +++ b/lib/easypost/http_client.rb @@ -43,9 +43,9 @@ def default_request_execute(method, uri, headers, open_timeout, read_timeout, bo # Attempt to make the request and return the response. Net::HTTP.start( uri.host, - uri.port, - use_ssl: true, - read_timeout: read_timeout, + uri.port, + use_ssl: true, + read_timeout: read_timeout, open_timeout: open_timeout, ) do |http| http.request(request)