easypost 7.4.0 → 7.5.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: c1c914f092b06f13332e656663b1650c734f8de6509ac8c45fd509900c7db938
4
+ data.tar.gz: b553d86880fe21e4619f8cb7982f720d9ca3ae646f23b66be5d569fae59fa8dc
5
5
  SHA512:
6
- metadata.gz: 16d6abe782e6607bad93751ec128b8ff536f5286e9311ecefce68eb3b7d5adba14f898ad813df6f2bd8b3a681a9b32a8daf15bad7258aa0cc21dd1540f2b7bd6
7
- data.tar.gz: b3bfe47a25eab2732c9cbf80034518c303e788921109f9e7c731e6aecfeeb254fca6d25bbd093d92ec377106c75792d7c372226e16a883d8e78c3ed49428b871
6
+ metadata.gz: 5678236ab51f3f63418917820b3ba92e67e7bbefe6cb8d4d312660925d3da8d9d8667ee204fdbffaecb2a283a4ce31433dcd4e92c715be3a69fc96ca77df67cf
7
+ data.tar.gz: 3e42754c66996261979f938cbed8b8472ce9f9ec8b50407621bbedbf43d3fc565bb6052998570a85509efb0eda981ce7fab80c8f1799c561149d6a7f5eeaf0f7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v7.5.0 (2026-02-20)
4
+
5
+ - Adds the following functions:
6
+ - `fedex_registration.register_address`
7
+ - `fedex_registration.request_pin`
8
+ - `fedex_registration.validate_pin`
9
+ - `fedex_registration.submit_invoice`
10
+
3
11
  ## v7.4.0 (2026-02-02)
4
12
 
5
13
  - Adds the following functions usable by child and referral customer users:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.4.0
1
+ 7.5.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,
@@ -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.5.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