easypost 7.6.0 → 7.8.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: 0fea5a7b6c529207dce7950344ebfa7dacab20a5a03b89c20b9204f905226504
4
- data.tar.gz: ccd5ee4596fbf4a4f3d52452a93984ed5774ab4b74d76e82c4b4fa8a77a8b836
3
+ metadata.gz: 6d0911a839a9eb760f7148f421495219aba256e66bd9b22dc1c6cb4792500b37
4
+ data.tar.gz: 8cb391d0d0dd9335559945652e7a7b09288dec30d91bc0f34fb71153941d58ed
5
5
  SHA512:
6
- metadata.gz: 6a28525b29aed5376549c00422989c6d200d0db98085d0b414f311395c02c8b49ad8bd053d7f10ce02bc2ef2c0d39ecb9b627b2e24062d9c53e33db8033b0251
7
- data.tar.gz: 3192c31ca964081536029824c38b5c7d942893a7fb798118495bfec3e616da789950befd5b201f372892af6ef53376408a6c8b965bbf30098b9e5e217c0772de
6
+ metadata.gz: 2a9e30899933af0ec0c15e54cc56f8330486156dae96005dbcbf30dca6e65f41e9b907c60953ee589e8dcc7638cb286df0914822bada22c4079ceed871f08ced
7
+ data.tar.gz: f51929d62280e9f95da2d59df30e73391b8a502571f7df8a870c9ee95d5bc83bb124a385c6ce33cb439de67beef5c9aaac686cba29e5143d16aa2c9405a4b666
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  run-tests:
11
- runs-on: ubuntu-latest
11
+ runs-on: ubuntu-24.04
12
12
  strategy:
13
13
  matrix:
14
14
  rubyversion: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0']
@@ -24,14 +24,13 @@ jobs:
24
24
  run: just install
25
25
  - name: run tests
26
26
  run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just test
27
- - name: Coveralls
27
+ - name: Coverage
28
28
  if: github.ref == 'refs/heads/master'
29
- uses: coverallsapp/github-action@master
29
+ uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
30
30
  with:
31
- github-token: ${{ secrets.GITHUB_TOKEN }}
32
- path-to-lcov: './coverage/lcov/easypost-ruby.lcov'
31
+ token: ${{ secrets.CODECOV_TOKEN }}
33
32
  lint:
34
- runs-on: ubuntu-latest
33
+ runs-on: ubuntu-24.04
35
34
  steps:
36
35
  - uses: actions/checkout@v6
37
36
  - uses: extractions/setup-just@v3
@@ -48,7 +47,7 @@ jobs:
48
47
  run: just lint
49
48
  docs:
50
49
  if: github.ref == 'refs/heads/master'
51
- runs-on: ubuntu-latest
50
+ runs-on: ubuntu-24.04
52
51
  steps:
53
52
  - uses: actions/checkout@v6
54
53
  - uses: extractions/setup-just@v3
@@ -7,7 +7,7 @@ on:
7
7
 
8
8
  jobs:
9
9
  release:
10
- runs-on: ubuntu-latest
10
+ runs-on: ubuntu-24.04
11
11
  steps:
12
12
  - uses: actions/checkout@v6
13
13
  - uses: extractions/setup-just@v3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v7.8.0 (2026-10-27)
4
+
5
+ - Removes the deprecated, unusable `add_credit_card` function
6
+ - Stripe has disabled the ability to pass plain credit card details over the wire and now requires using [Stripe.js/Elements/Checkout](https://support.stripe.com/questions/card-tokenization-restrictions-using-publishable-keys). Follow the [Decentralized (EasyPost-Manage Billing) Guide](https://docs.easypost.com/guides/get-started-with-forge/easypost-managed-billing-guide#referralcustomer-billing-management) for more details on the new flow to use.
7
+ - Makes `referral_customer.retrieve_easypost_stripe_api_key` public to help facilitate adding credit cards using Stripe.js
8
+ - Adds support for `FedexDefaultAccount`, `GofoWalletAccount`, `UpsDapAccount`, `UniUniWalletAccount`, and `VehoWalletAccount` by properly routing carrier-account create requests to the `/carrier_accounts/open` endpoint.
9
+
10
+ ## v7.7.0 (2026-06-25)
11
+
12
+ - Adds `params` to `request_pin` ensuring users can pass `easypost_details` to the call
13
+
3
14
  ## v7.6.0 (2026-02-25)
4
15
 
5
16
  - Adds generic `make_api_call` function
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # EasyPost Ruby Client Library
2
2
 
3
3
  [![Build Status](https://github.com/EasyPost/easypost-ruby/workflows/CI/badge.svg)](https://github.com/EasyPost/easypost-ruby/actions?query=workflow%3ACI)
4
- [![Coverage Status](https://coveralls.io/repos/github/EasyPost/easypost-ruby/badge.svg?branch=master)](https://coveralls.io/github/EasyPost/easypost-ruby?branch=master)
4
+ [![codecov](https://codecov.io/gh/EasyPost/easypost-ruby/graph/badge.svg?token=NuKtbPVJMX)](https://codecov.io/gh/EasyPost/easypost-ruby)
5
5
  [![Gem Version](https://badge.fury.io/rb/easypost.svg)](https://badge.fury.io/rb/easypost)
6
6
 
7
7
  EasyPost, the simple shipping solution. You can sign up for an account at <https://easypost.com>.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.6.0
1
+ 7.8.0
@@ -1,26 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class EasyPost::Services::CarrierAccount < EasyPost::Services::Service
4
- CUSTOM_WORKFLOW_CARRIER_TYPES = %w[FedexAccount FedexSmartpostAccount].freeze
5
- CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = %w[
6
- AmazonShippingAccount UpsAccount UpsMailInnovationsAccount
7
- UpsSurepostAccount UspsShipAccount
8
- ].freeze
4
+ CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES = {
5
+ 'carrier_accounts/open' => %w[
6
+ FedexDefaultAccount
7
+ GofoWalletAccount
8
+ UpsDapAccount
9
+ UniUniWalletAccount
10
+ VehoWalletAccount
11
+ ].freeze,
12
+ 'carrier_accounts/register' => %w[
13
+ FedexAccount
14
+ FedexSmartpostAccount
15
+ ].freeze,
16
+ 'carrier_accounts/register_oauth' => %w[
17
+ AmazonShippingAccount
18
+ UpsAccount
19
+ UpsMailInnovationsAccount
20
+ UpsSurepostAccount
21
+ UspsShipAccount
22
+ ].freeze,
23
+ }.freeze
9
24
  MODEL_CLASS = EasyPost::Models::CarrierAccount # :nodoc:
10
25
 
11
26
  # Create a carrier account
12
27
  def create(params = {})
13
28
  carrier_account_type = params[:type]
14
- wrapped_params = { select_top_layer_key(carrier_account_type).to_sym => params }
29
+ create_url = select_carrier_account_creation_endpoint(carrier_account_type)
30
+ wrapped_params = { select_top_layer_key(create_url).to_sym => params }
15
31
 
16
- # For UPS and FedEx the endpoint is different
17
- create_url = if CUSTOM_WORKFLOW_CARRIER_TYPES.include?(carrier_account_type)
18
- 'carrier_accounts/register'
19
- elsif CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type)
20
- 'carrier_accounts/register_oauth'
21
- else
22
- 'carrier_accounts'
23
- end
24
32
  response = @client.make_request(:post, create_url, wrapped_params)
25
33
 
26
34
  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
@@ -57,12 +65,21 @@ class EasyPost::Services::CarrierAccount < EasyPost::Services::Service
57
65
 
58
66
  private
59
67
 
60
- # Select the top-layer key for the carrier account creation/update request based on the carrier type.
61
- def select_top_layer_key(carrier_account_type)
62
- if CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type)
68
+ # Select the top-layer key for the carrier account creation/update request based on the create endpoint.
69
+ def select_top_layer_key(create_url)
70
+ if create_url == 'carrier_accounts/register_oauth'
63
71
  'carrier_account_oauth_registrations'
64
72
  else
65
73
  'carrier_account'
66
74
  end
67
75
  end
76
+
77
+ # Determines which API endpoint to use for the creation call.
78
+ def select_carrier_account_creation_endpoint(carrier_account_type)
79
+ CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES.each do |endpoint, carrier_account_types|
80
+ return endpoint if carrier_account_types.include?(carrier_account_type)
81
+ end
82
+
83
+ 'carrier_accounts'
84
+ end
68
85
  end
@@ -14,11 +14,10 @@ class EasyPost::Services::FedexRegistration < EasyPost::Services::Service
14
14
  end
15
15
 
16
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
- },
17
+ def request_pin(fedex_account_number, pin_method_option, params = {})
18
+ wrapped_params = wrap_pin_validation(params)
19
+ wrapped_params[:pin_method] = {
20
+ option: pin_method_option,
22
21
  }
23
22
  endpoint = "fedex_registrations/#{fedex_account_number}/pin"
24
23
 
@@ -40,25 +40,6 @@ class EasyPost::Services::ReferralCustomer < EasyPost::Services::Service
40
40
  all(params)
41
41
  end
42
42
 
43
- # Add a credit card to EasyPost for a ReferralCustomer without needing a Stripe account. This function requires the ReferralCustomer User's API key.
44
- def add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary')
45
- easypost_stripe_api_key = retrieve_easypost_stripe_api_key
46
-
47
- begin
48
- stripe_credit_card_token = create_stripe_token(
49
- number,
50
- expiration_month,
51
- expiration_year,
52
- cvc,
53
- easypost_stripe_api_key,
54
- )
55
- rescue StandardError
56
- raise EasyPost::Errors::ExternalApiError.new(EasyPost::Constants::STRIPE_CARD_CREATE_FAILED)
57
- end
58
-
59
- create_easypost_credit_card(referral_api_key, stripe_credit_card_token, priority)
60
- end
61
-
62
43
  # Add a credit card to EasyPost for a ReferralCustomer with a payment method ID from Stripe. This function requires the ReferralCustomer User's API key.
63
44
  def add_credit_card_from_stripe(referral_api_key, payment_method_id, priority = 'primary')
64
45
  params = {
@@ -94,61 +75,9 @@ class EasyPost::Services::ReferralCustomer < EasyPost::Services::Service
94
75
  EasyPost::InternalUtilities::Json.convert_json_to_object(response)
95
76
  end
96
77
 
97
- private
98
-
99
78
  # Retrieve EasyPost's Stripe public API key.
100
79
  def retrieve_easypost_stripe_api_key
101
80
  response = @client.make_request(:get, 'partners/stripe_public_key', nil, 'beta')
102
81
  response['public_key']
103
82
  end
104
-
105
- # Get credit card token from Stripe.
106
- def create_stripe_token(number, expiration_month, expiration_year,
107
- cvc, easypost_stripe_token)
108
- headers = {
109
- # This Stripe endpoint only accepts URL form encoded bodies.
110
- Authorization: "Bearer #{easypost_stripe_token}",
111
- 'Content-type': 'application/x-www-form-urlencoded',
112
- }
113
-
114
- credit_card_hash = {
115
- card: {
116
- number: number,
117
- exp_month: expiration_month,
118
- exp_year: expiration_year,
119
- cvc: cvc,
120
- },
121
- }
122
-
123
- form_encoded_params = EasyPost::InternalUtilities.form_encode_params(credit_card_hash)
124
-
125
- uri = URI.parse('https://api.stripe.com/v1/tokens')
126
- http = Net::HTTP.new(uri.host, uri.port)
127
- http.use_ssl = true
128
- request = Net::HTTP::Post.new(uri.request_uri, headers)
129
- query = URI.encode_www_form(form_encoded_params)
130
-
131
- response = http.request(request, query)
132
- response_json = JSON.parse(response.body)
133
- response_json['id']
134
- end
135
-
136
- # Submit Stripe credit card token to EasyPost.
137
- def create_easypost_credit_card(referral_api_key, stripe_object_id, priority = 'primary')
138
- wrapped_params = {
139
- credit_card: {
140
- stripe_object_id: stripe_object_id,
141
- priority: priority,
142
- },
143
- }
144
- referral_client = EasyPost::Client.new(api_key: referral_api_key)
145
- response = referral_client.make_request(
146
- :post,
147
- 'credit_cards',
148
- wrapped_params,
149
- 'beta',
150
- )
151
-
152
- EasyPost::InternalUtilities::Json.convert_json_to_object(response)
153
- end
154
83
  end
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.6.0
4
+ version: 7.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - EasyPost Developers