easypost 7.4.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1818317cd00bce2eb87d53600db69d6360f3058f801b468145824588ccd8c3f7
4
- data.tar.gz: 5c84f10ef3bbb23b0b27373c6b52dcb5e9578cdf7caed6c1e73736561ad5afe8
3
+ metadata.gz: 0fea5a7b6c529207dce7950344ebfa7dacab20a5a03b89c20b9204f905226504
4
+ data.tar.gz: ccd5ee4596fbf4a4f3d52452a93984ed5774ab4b74d76e82c4b4fa8a77a8b836
5
5
  SHA512:
6
- metadata.gz: 16d6abe782e6607bad93751ec128b8ff536f5286e9311ecefce68eb3b7d5adba14f898ad813df6f2bd8b3a681a9b32a8daf15bad7258aa0cc21dd1540f2b7bd6
7
- data.tar.gz: b3bfe47a25eab2732c9cbf80034518c303e788921109f9e7c731e6aecfeeb254fca6d25bbd093d92ec377106c75792d7c372226e16a883d8e78c3ed49428b871
6
+ metadata.gz: 6a28525b29aed5376549c00422989c6d200d0db98085d0b414f311395c02c8b49ad8bd053d7f10ce02bc2ef2c0d39ecb9b627b2e24062d9c53e33db8033b0251
7
+ data.tar.gz: 3192c31ca964081536029824c38b5c7d942893a7fb798118495bfec3e616da789950befd5b201f372892af6ef53376408a6c8b965bbf30098b9e5e217c0772de
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v7.6.0 (2026-02-25)
4
+
5
+ - Adds generic `make_api_call` function
6
+
7
+ ## v7.5.0 (2026-02-20)
8
+
9
+ - Adds the following functions:
10
+ - `fedex_registration.register_address`
11
+ - `fedex_registration.request_pin`
12
+ - `fedex_registration.validate_pin`
13
+ - `fedex_registration.submit_invoice`
14
+
3
15
  ## v7.4.0 (2026-02-02)
4
16
 
5
17
  - Adds the following functions usable by child and referral customer users:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.4.0
1
+ 7.6.0
@@ -49,6 +49,7 @@ class EasyPost::Client
49
49
  EasyPost::Services::Embeddable,
50
50
  EasyPost::Services::EndShipper,
51
51
  EasyPost::Services::Event,
52
+ EasyPost::Services::FedexRegistration,
52
53
  EasyPost::Services::Insurance,
53
54
  EasyPost::Services::Luma,
54
55
  EasyPost::Services::Order,
@@ -143,6 +144,22 @@ class EasyPost::Client
143
144
  EasyPost::Hooks.unsubscribe_all(:response)
144
145
  end
145
146
 
147
+ # Make an API call to the EasyPost API
148
+ #
149
+ # This public, generic interface is useful for making arbitrary API calls to the EasyPost API that
150
+ # are not yet supported by the client library's services. When possible, the service for your use case
151
+ # should be used instead as it provides a more convenient and higher-level interface depending on the endpoint.
152
+ #
153
+ # @param method [Symbol] the HTTP Verb (get, post, put, patch, delete, etc.)
154
+ # @param endpoint [String] URI path of the resource
155
+ # @param params [Object] (nil) object to be used as the request parameters
156
+ # @return [EasyPost::Models::EasyPostObject] EasyPost object parsed from the response body
157
+ def make_api_call(method, endpoint, params = nil)
158
+ response = make_request(method, endpoint, params)
159
+
160
+ EasyPost::InternalUtilities::Json.convert_json_to_object(response)
161
+ end
162
+
146
163
  private
147
164
 
148
165
  def http_config
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ class EasyPost::Services::FedexRegistration < EasyPost::Services::Service
6
+ # Register the billing address for a FedEx account.
7
+ def register_address(fedex_account_number, params = {})
8
+ wrapped_params = wrap_address_validation(params)
9
+ endpoint = "fedex_registrations/#{fedex_account_number}/address"
10
+
11
+ response = @client.make_request(:post, endpoint, wrapped_params)
12
+
13
+ EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::EasyPostObject)
14
+ end
15
+
16
+ # Request a PIN for FedEx account verification.
17
+ def request_pin(fedex_account_number, pin_method_option)
18
+ wrapped_params = {
19
+ pin_method: {
20
+ option: pin_method_option,
21
+ },
22
+ }
23
+ endpoint = "fedex_registrations/#{fedex_account_number}/pin"
24
+
25
+ response = @client.make_request(:post, endpoint, wrapped_params)
26
+
27
+ EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::EasyPostObject)
28
+ end
29
+
30
+ # Validate the PIN entered by the user for FedEx account verification.
31
+ def validate_pin(fedex_account_number, params = {})
32
+ wrapped_params = wrap_pin_validation(params)
33
+ endpoint = "fedex_registrations/#{fedex_account_number}/pin/validate"
34
+
35
+ response = @client.make_request(:post, endpoint, wrapped_params)
36
+
37
+ EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::EasyPostObject)
38
+ end
39
+
40
+ # Submit invoice information to complete FedEx account registration.
41
+ def submit_invoice(fedex_account_number, params = {})
42
+ wrapped_params = wrap_invoice_validation(params)
43
+ endpoint = "fedex_registrations/#{fedex_account_number}/invoice"
44
+
45
+ response = @client.make_request(:post, endpoint, wrapped_params)
46
+
47
+ EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::EasyPostObject)
48
+ end
49
+
50
+ private
51
+
52
+ # Wraps address validation parameters and ensures the "name" field exists.
53
+ # If not present, generates a UUID (with hyphens removed) as the name.
54
+ def wrap_address_validation(params)
55
+ wrapped_params = {}
56
+
57
+ if params.key?(:address_validation)
58
+ address_validation = params[:address_validation].dup
59
+ ensure_name_field(address_validation)
60
+ wrapped_params[:address_validation] = address_validation
61
+ end
62
+
63
+ wrapped_params[:easypost_details] = params[:easypost_details] if params.key?(:easypost_details)
64
+
65
+ wrapped_params
66
+ end
67
+
68
+ # Wraps PIN validation parameters and ensures the "name" field exists.
69
+ # If not present, generates a UUID (with hyphens removed) as the name.
70
+ def wrap_pin_validation(params)
71
+ wrapped_params = {}
72
+
73
+ if params.key?(:pin_validation)
74
+ pin_validation = params[:pin_validation].dup
75
+ ensure_name_field(pin_validation)
76
+ wrapped_params[:pin_validation] = pin_validation
77
+ end
78
+
79
+ wrapped_params[:easypost_details] = params[:easypost_details] if params.key?(:easypost_details)
80
+
81
+ wrapped_params
82
+ end
83
+
84
+ # Wraps invoice validation parameters and ensures the "name" field exists.
85
+ # If not present, generates a UUID (with hyphens removed) as the name.
86
+ def wrap_invoice_validation(params)
87
+ wrapped_params = {}
88
+
89
+ if params.key?(:invoice_validation)
90
+ invoice_validation = params[:invoice_validation].dup
91
+ ensure_name_field(invoice_validation)
92
+ wrapped_params[:invoice_validation] = invoice_validation
93
+ end
94
+
95
+ wrapped_params[:easypost_details] = params[:easypost_details] if params.key?(:easypost_details)
96
+
97
+ wrapped_params
98
+ end
99
+
100
+ # Ensures the "name" field exists in the provided hash.
101
+ # If not present, generates a UUID (with hyphens removed) as the name.
102
+ # This follows the pattern used in the web UI implementation.
103
+ def ensure_name_field(hash)
104
+ return if hash.key?(:name) && !hash[:name].nil?
105
+
106
+ uuid = SecureRandom.uuid.delete('-')
107
+ hash[:name] = uuid
108
+ end
109
+ end
@@ -21,6 +21,7 @@ require_relative 'services/customs_item'
21
21
  require_relative 'services/embeddable'
22
22
  require_relative 'services/end_shipper'
23
23
  require_relative 'services/event'
24
+ require_relative 'services/fedex_registration'
24
25
  require_relative 'services/insurance'
25
26
  require_relative 'services/luma'
26
27
  require_relative 'services/order'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.4.0
4
+ version: 7.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - EasyPost Developers
@@ -356,6 +356,7 @@ files:
356
356
  - lib/easypost/services/embeddable.rb
357
357
  - lib/easypost/services/end_shipper.rb
358
358
  - lib/easypost/services/event.rb
359
+ - lib/easypost/services/fedex_registration.rb
359
360
  - lib/easypost/services/insurance.rb
360
361
  - lib/easypost/services/luma.rb
361
362
  - lib/easypost/services/order.rb