solidus_easypost 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +6 -0
- data/.github/stale.yml +4 -4
- data/.github_changelog_generator +2 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +12 -47
- data/CHANGELOG.md +113 -0
- data/LICENSE +1 -1
- data/README.md +111 -21
- data/app/controllers/spree/admin/postage_labels_controller.rb +20 -0
- data/app/decorators/models/solidus_easypost/spree/carton_decorator.rb +38 -0
- data/app/decorators/models/solidus_easypost/spree/shipment_decorator.rb +18 -23
- data/app/models/solidus_easypost/parcel_dimension.rb +34 -0
- data/app/models/solidus_easypost/return_authorization.rb +2 -13
- data/app/overrides/spree/admin/orders/_shipment/add_postage_label.html.erb.deface +10 -0
- data/bin/rails +0 -1
- data/bin/rails-engine +0 -2
- data/bin/rails-sandbox +1 -2
- data/bin/sandbox +2 -0
- data/config/initializers/webhooks.rb +7 -0
- data/config/locales/en.yml +7 -4
- data/config/routes.rb +5 -1
- data/db/migrate/20201025110912_add_tracker_id_to_cartons.rb +6 -0
- data/lib/generators/solidus_easypost/install/install_generator.rb +7 -1
- data/lib/generators/solidus_easypost/install/templates/initializer.rb +26 -0
- data/lib/solidus_easypost/address_builder.rb +45 -0
- data/lib/solidus_easypost/calculator/base_dimension_calculator.rb +28 -0
- data/lib/solidus_easypost/calculator/weight_dimension_calculator.rb +22 -0
- data/lib/solidus_easypost/configuration.rb +25 -2
- data/lib/solidus_easypost/errors/unknown_partial_resource_error.rb +11 -0
- data/lib/solidus_easypost/estimator.rb +37 -0
- data/lib/solidus_easypost/parcel_builder.rb +27 -0
- data/lib/solidus_easypost/shipment_builder.rb +32 -0
- data/lib/solidus_easypost/shipping_method_selector.rb +17 -0
- data/lib/solidus_easypost/shipping_rate_calculator.rb +9 -0
- data/lib/solidus_easypost/testing_support/factories/address_factory.rb +10 -0
- data/lib/solidus_easypost/testing_support/factories/product_factory.rb +7 -0
- data/lib/solidus_easypost/testing_support/factories/shipment_factory.rb +30 -0
- data/lib/solidus_easypost/testing_support/factories/shipping_method_factory.rb +8 -0
- data/lib/solidus_easypost/testing_support/factories/stock_location_factory.rb +10 -0
- data/lib/solidus_easypost/testing_support/factories/variant_factory.rb +7 -0
- data/lib/solidus_easypost/testing_support/factories.rb +3 -0
- data/lib/solidus_easypost/tracker_webhook_handler.rb +14 -0
- data/lib/solidus_easypost/version.rb +1 -1
- data/lib/solidus_easypost.rb +11 -0
- data/solidus_easypost.gemspec +8 -5
- data/spec/cassettes/{Spree_Address/_easypost_address/is_an_EasyPost_Address_object.yml → address_builder/from_address.yml} +19 -23
- data/spec/cassettes/{Spree_StockLocation/_easypost_address/is_an_EasyPost_Address_object.yml → address_builder/from_stock_location.yml} +19 -23
- data/spec/cassettes/{Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_front_end_visible/has_the_correct_costs.yml → estimator.yml} +0 -0
- data/spec/cassettes/integration/checkout.yml +377 -0
- data/spec/cassettes/integration/order_shipping/with_purchase_labels.yml +373 -0
- data/spec/cassettes/integration/order_shipping/without_purchase_labels.yml +251 -0
- data/spec/cassettes/{Spree_Stock_Package/_easypost_parcel/is_an_EasyPost_Parcel_object.yml → parcel_builder/from_package.yml} +17 -22
- data/spec/cassettes/{Spree_Stock_Package/_easypost_parcel/has_the_correct_attributes.yml → parcel_builder/from_return_authorization.yml} +17 -22
- data/spec/cassettes/postage_labels/show.yml +72 -0
- data/spec/cassettes/return_authorization.yml +310 -0
- data/spec/cassettes/{Spree_Stock_Package/_easypost_shipment/is_an_EasyPost_Shipment_object.yml → shipment_builder/from_package.yml} +74 -92
- data/spec/cassettes/{Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/create_no_new_shipping_methods.yml → shipment_builder/from_return_authorization.yml} +77 -95
- data/spec/cassettes/shipment_builder/from_shipment.yml +250 -0
- data/spec/controllers/spree/admin/postage_labels_controller_spec.rb +18 -0
- data/spec/features/admin/postage_labels_spec.rb +18 -0
- data/spec/integration/checkout_spec.rb +45 -0
- data/spec/integration/order_shipping_spec.rb +33 -0
- data/spec/models/solidus_easypost/parcel_dimension_spec.rb +80 -0
- data/spec/models/solidus_easypost/return_authorization_spec.rb +7 -40
- data/spec/models/spree/carton_spec.rb +57 -0
- data/spec/models/spree/shipment_spec.rb +48 -59
- data/spec/models/spree/shipping_rate_spec.rb +14 -7
- data/spec/solidus_easypost/address_builder_spec.rb +17 -0
- data/spec/solidus_easypost/calculator/weight_dimension_calculator_spec.rb +39 -0
- data/spec/solidus_easypost/estimator_spec.rb +52 -0
- data/spec/solidus_easypost/parcel_builder_spec.rb +113 -0
- data/spec/solidus_easypost/shipment_builder_spec.rb +28 -0
- data/spec/solidus_easypost/shipping_method_selector_spec.rb +33 -0
- data/spec/solidus_easypost/shipping_rate_calculator_spec.rb +12 -0
- data/spec/solidus_easypost/tracker_webhook_handler_spec.rb +58 -0
- data/spec/spec_helper.rb +11 -7
- data/spec/support/easypost.rb +3 -1
- data/spec/support/helpers/api_stubs.rb +40 -0
- data/spec/support/helpers/configuration.rb +28 -0
- data/spec/support/helpers/shipping_methods.rb +26 -0
- data/spec/support/solidus.rb +1 -0
- data/spec/support/vcr.rb +1 -0
- metadata +118 -85
- data/app/decorators/models/solidus_easypost/spree/address_decorator.rb +0 -30
- data/app/decorators/models/solidus_easypost/spree/stock/estimator_decorator.rb +0 -15
- data/app/decorators/models/solidus_easypost/spree/stock/package_decorator.rb +0 -27
- data/app/decorators/models/solidus_easypost/spree/stock_location_decorator.rb +0 -26
- data/app/models/solidus_easypost/estimator.rb +0 -51
- data/lib/solidus_easypost/factories.rb +0 -24
- data/spec/cassettes/SolidusEasypost_ReturnAuthorization/_easypost_shipment/is_an_EasyPost_Shipment_object.yml +0 -271
- data/spec/cassettes/SolidusEasypost_ReturnAuthorization/_return_label/has_the_correct_fields.yml +0 -336
- data/spec/cassettes/SolidusEasypost_ReturnAuthorization/_return_label/is_an_EasyPost_PackageLabel_object.yml +0 -336
- data/spec/cassettes/Spree_Address/_easypost_address/has_the_correct_attributes.yml +0 -69
- data/spec/cassettes/Spree_Order/_refresh_shipment_rates/can_get_rates_from_easy_post.yml +0 -271
- data/spec/cassettes/Spree_Order/_refresh_shipment_rates/create_shipping_methods_for_the_rates.yml +0 -269
- data/spec/cassettes/Spree_Shipment/_buys_a_shipping_rate_after_transitioning_to_ship.yml +0 -403
- data/spec/cassettes/Spree_Shipment/_easypost_shipment/when_it_is_a_new_shipment/behaves_like_an_easypost_shipment/is_an_EasyPost_Shipment_object.yml +0 -271
- data/spec/cassettes/Spree_Shipment/_easypost_shipment/when_it_is_a_new_shipment/calls_the_api.yml +0 -200
- data/spec/cassettes/Spree_Shipment/_easypost_shipment/when_it_is_an_existing_shipment/behaves_like_an_easypost_shipment/is_an_EasyPost_Shipment_object.yml +0 -334
- data/spec/cassettes/Spree_Shipment/_easypost_shipment/when_it_is_an_existing_shipment/loads_the_existing_shipment.yml +0 -271
- data/spec/cassettes/Spree_StockLocation/_easypost_address/has_the_correct_attributes.yml +0 -69
- data/spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_dont_exist/creates_new_shipping_methods.yml +0 -269
- data/spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_dont_exist/is_empty.yml +0 -269
- data/spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_front_end_visible/has_the_correct_names.yml +0 -269
- data/spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_not_front_end_visible/is_empty.yml +0 -269
- data/spec/cassettes/Spree_Stock_Package/_easypost_shipment/calls_the_api.yml +0 -200
- data/spec/factories/spree_modification.rb +0 -25
- data/spec/models/spree/address_spec.rb +0 -31
- data/spec/models/spree/order_spec.rb +0 -31
- data/spec/models/spree/stock/estimator_spec.rb +0 -80
- data/spec/models/spree/stock/package_spec.rb +0 -35
- data/spec/models/spree/stock_location_spec.rb +0 -31
- data/spec/support/shipping_method_helpers.rb +0 -43
@@ -0,0 +1,33 @@
|
|
1
|
+
RSpec.describe SolidusEasypost::ShippingMethodSelector do
|
2
|
+
describe '#shipping_method_for' do
|
3
|
+
context 'when a shipping method for the given carrier and service exists' do
|
4
|
+
it 'returns the existing shipping method' do
|
5
|
+
shipping_method = create(:shipping_method, carrier: 'USPS', service_level: 'Express')
|
6
|
+
easypost_rate = EasyPost::Rate.construct_from('carrier' => 'USPS', 'service' => 'Express')
|
7
|
+
|
8
|
+
selector = described_class.new
|
9
|
+
selected_shipping_method = selector.shipping_method_for(easypost_rate)
|
10
|
+
|
11
|
+
expect(selected_shipping_method).to eq(shipping_method)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when a shipping method for the given carrier and service does not exist' do
|
16
|
+
it 'creates a new shipping method' do
|
17
|
+
shipping_category = create(:shipping_category)
|
18
|
+
easypost_rate = EasyPost::Rate.construct_from('carrier' => 'USPS', 'service' => 'Express')
|
19
|
+
|
20
|
+
selector = described_class.new
|
21
|
+
selected_shipping_method = selector.shipping_method_for(easypost_rate)
|
22
|
+
|
23
|
+
expect(selected_shipping_method).to have_attributes(
|
24
|
+
name: 'USPS Express',
|
25
|
+
carrier: 'USPS',
|
26
|
+
service_level: 'Express',
|
27
|
+
shipping_categories: [shipping_category],
|
28
|
+
available_to_users: false,
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
RSpec.describe SolidusEasypost::ShippingRateCalculator do
|
2
|
+
describe '#compute' do
|
3
|
+
it 'returns the amount on the EasyPost rate' do
|
4
|
+
easypost_rate = EasyPost::Rate.construct_from('rate' => 25.0)
|
5
|
+
|
6
|
+
calculator = described_class.new
|
7
|
+
computed_rate = calculator.compute(easypost_rate)
|
8
|
+
|
9
|
+
expect(computed_rate).to eq(25.0)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
RSpec.describe SolidusEasypost::TrackerWebhookHandler do
|
2
|
+
describe '.call' do
|
3
|
+
context 'when the event is not tracker.updated' do
|
4
|
+
it 'does not process the event' do
|
5
|
+
stub_const('Spree::Event', class_spy(Spree::Event))
|
6
|
+
create(:carton, easy_post_tracker_id: 'trk_test')
|
7
|
+
|
8
|
+
payload = {
|
9
|
+
'description' => 'tracker.created',
|
10
|
+
'result' => {
|
11
|
+
'id' => 'trk_test',
|
12
|
+
},
|
13
|
+
}
|
14
|
+
described_class.call(payload)
|
15
|
+
|
16
|
+
expect(Spree::Event).not_to have_received(:fire)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when the tracker was not registered in Solidus' do
|
21
|
+
it 'does not process the event' do
|
22
|
+
stub_const('Spree::Event', class_spy(Spree::Event))
|
23
|
+
create(:carton, easy_post_tracker_id: 'trk_test')
|
24
|
+
|
25
|
+
payload = {
|
26
|
+
'description' => 'tracker.updated',
|
27
|
+
'result' => {
|
28
|
+
'id' => 'trk_test1',
|
29
|
+
},
|
30
|
+
}
|
31
|
+
described_class.call(payload)
|
32
|
+
|
33
|
+
expect(Spree::Event).not_to have_received(:fire)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the event is a tracker update for a registered tracker' do
|
38
|
+
it 'forwards the event via the event bus' do
|
39
|
+
stub_const('Spree::Event', class_spy(Spree::Event))
|
40
|
+
carton = create(:carton, easy_post_tracker_id: 'trk_test')
|
41
|
+
|
42
|
+
payload = {
|
43
|
+
'description' => 'tracker.updated',
|
44
|
+
'result' => {
|
45
|
+
'id' => 'trk_test',
|
46
|
+
},
|
47
|
+
}
|
48
|
+
described_class.call(payload)
|
49
|
+
|
50
|
+
expect(Spree::Event).to have_received(:fire).with(
|
51
|
+
'solidus_easypost.tracker.updated',
|
52
|
+
carton: carton,
|
53
|
+
payload: payload,
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,22 +6,26 @@ ENV['RAILS_ENV'] = 'test'
|
|
6
6
|
# Run Coverage report
|
7
7
|
require 'solidus_dev_support/rspec/coverage'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# Create the dummy app if it's still missing.
|
10
|
+
dummy_env = "#{__dir__}/dummy/config/environment.rb"
|
11
|
+
system 'bin/rake extension:test_app' unless File.exist? dummy_env
|
12
|
+
require dummy_env
|
13
13
|
|
14
14
|
# Requires factories and other useful helpers defined in spree_core.
|
15
15
|
require 'solidus_dev_support/rspec/feature_helper'
|
16
16
|
|
17
17
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
18
18
|
# in spec/support/ and its subdirectories.
|
19
|
-
Dir[
|
19
|
+
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
|
20
20
|
|
21
|
-
# Requires factories defined in lib/solidus_easypost/factories.rb
|
22
|
-
require 'solidus_easypost/factories'
|
21
|
+
# Requires factories defined in lib/solidus_easypost/testing_support/factories.rb
|
22
|
+
require 'solidus_easypost/testing_support/factories'
|
23
23
|
|
24
24
|
RSpec.configure do |config|
|
25
25
|
config.infer_spec_type_from_file_location!
|
26
26
|
config.use_transactional_fixtures = false
|
27
|
+
|
28
|
+
if Spree.solidus_gem_version < Gem::Version.new('2.11')
|
29
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
|
30
|
+
end
|
27
31
|
end
|
data/spec/support/easypost.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module SolidusEasypost
|
2
|
+
module TestHelpers
|
3
|
+
module ApiStubs
|
4
|
+
def stub_easypost_shipment
|
5
|
+
EasyPost::Shipment.class_eval do
|
6
|
+
def rates; end
|
7
|
+
|
8
|
+
def tracking_code; end
|
9
|
+
end
|
10
|
+
|
11
|
+
easypost_shipment = instance_spy(
|
12
|
+
EasyPost::Shipment,
|
13
|
+
id: SecureRandom.hex,
|
14
|
+
tracking_code: SecureRandom.hex,
|
15
|
+
rates: Array.new(3) { stub_easypost_rate },
|
16
|
+
)
|
17
|
+
|
18
|
+
allow(EasyPost::Shipment).to receive(:retrieve)
|
19
|
+
.with(easypost_shipment.id)
|
20
|
+
.and_return(easypost_shipment)
|
21
|
+
|
22
|
+
easypost_shipment
|
23
|
+
end
|
24
|
+
|
25
|
+
def stub_easypost_rate
|
26
|
+
easypost_rate = instance_spy(EasyPost::Rate, id: SecureRandom.hex)
|
27
|
+
|
28
|
+
allow(EasyPost::Shipment).to receive(:retrieve)
|
29
|
+
.with(easypost_rate.id)
|
30
|
+
.and_return(easypost_rate)
|
31
|
+
|
32
|
+
easypost_rate
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.include SolidusEasypost::TestHelpers::ApiStubs
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module SolidusEasypost
|
2
|
+
module TestHelpers
|
3
|
+
module Configuration
|
4
|
+
def stub_easypost_config(values)
|
5
|
+
allow(SolidusEasypost.configuration).to receive_messages(values)
|
6
|
+
end
|
7
|
+
|
8
|
+
def use_easypost_estimator
|
9
|
+
stock_configuration = ::Spree::Core::StockConfiguration.new.tap do |stock_config|
|
10
|
+
stock_config.estimator_class = 'SolidusEasypost::Estimator'
|
11
|
+
end
|
12
|
+
|
13
|
+
if ::Spree.solidus_gem_version >= Gem::Version.new('2.9.0')
|
14
|
+
stub_spree_preferences(stock: stock_configuration)
|
15
|
+
else
|
16
|
+
# rubocop:disable RSpec/AnyInstance
|
17
|
+
allow_any_instance_of(::Spree::AppConfiguration).to receive(:stock)
|
18
|
+
.and_return(stock_configuration)
|
19
|
+
# rubocop:enable RSpec/AnyInstance
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.configure do |config|
|
27
|
+
config.include SolidusEasypost::TestHelpers::Configuration
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SolidusEasypost
|
2
|
+
module TestHelpers
|
3
|
+
module ShippingMethods
|
4
|
+
def create_easypost_shipping_methods
|
5
|
+
[
|
6
|
+
%w[USPS Express],
|
7
|
+
%w[USPS First],
|
8
|
+
%w[USPS ParcelSelect],
|
9
|
+
%w[USPS Priority],
|
10
|
+
].each do |(carrier, service_level)|
|
11
|
+
create(
|
12
|
+
:shipping_method,
|
13
|
+
name: "#{carrier} #{service_level}",
|
14
|
+
carrier: carrier,
|
15
|
+
service_level: service_level,
|
16
|
+
available_to_users: true,
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.include SolidusEasypost::TestHelpers::ShippingMethods
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'spree/testing_support/order_walkthrough'
|
data/spec/support/vcr.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_easypost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan Deere
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: deface
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: easypost
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +47,7 @@ dependencies:
|
|
33
47
|
version: 2.0.0
|
34
48
|
- - "<"
|
35
49
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
50
|
+
version: '4'
|
37
51
|
type: :runtime
|
38
52
|
prerelease: false
|
39
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +57,7 @@ dependencies:
|
|
43
57
|
version: 2.0.0
|
44
58
|
- - "<"
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
60
|
+
version: '4'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: solidus_support
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,16 +76,16 @@ dependencies:
|
|
62
76
|
name: solidus_dev_support
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
|
-
- - "
|
79
|
+
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
81
|
+
version: '2.1'
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
|
-
- - "
|
86
|
+
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
88
|
+
version: '2.1'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: vcr
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +114,7 @@ dependencies:
|
|
100
114
|
- - ">="
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '0'
|
103
|
-
description:
|
117
|
+
description:
|
104
118
|
email: brendan@stembolt.com
|
105
119
|
executables: []
|
106
120
|
extensions: []
|
@@ -109,22 +123,23 @@ files:
|
|
109
123
|
- ".circleci/config.yml"
|
110
124
|
- ".gem_release.yml"
|
111
125
|
- ".github/stale.yml"
|
126
|
+
- ".github_changelog_generator"
|
112
127
|
- ".gitignore"
|
113
128
|
- ".rspec"
|
114
129
|
- ".rubocop.yml"
|
115
130
|
- ".rubocop_todo.yml"
|
131
|
+
- CHANGELOG.md
|
116
132
|
- Gemfile
|
117
133
|
- LICENSE
|
118
134
|
- README.md
|
119
135
|
- Rakefile
|
120
|
-
- app/
|
136
|
+
- app/controllers/spree/admin/postage_labels_controller.rb
|
137
|
+
- app/decorators/models/solidus_easypost/spree/carton_decorator.rb
|
121
138
|
- app/decorators/models/solidus_easypost/spree/shipment_decorator.rb
|
122
139
|
- app/decorators/models/solidus_easypost/spree/shipping_rate_decorator.rb
|
123
|
-
- app/
|
124
|
-
- app/decorators/models/solidus_easypost/spree/stock/package_decorator.rb
|
125
|
-
- app/decorators/models/solidus_easypost/spree/stock_location_decorator.rb
|
126
|
-
- app/models/solidus_easypost/estimator.rb
|
140
|
+
- app/models/solidus_easypost/parcel_dimension.rb
|
127
141
|
- app/models/solidus_easypost/return_authorization.rb
|
142
|
+
- app/overrides/spree/admin/orders/_shipment/add_postage_label.html.erb.deface
|
128
143
|
- bin/console
|
129
144
|
- bin/rails
|
130
145
|
- bin/rails-engine
|
@@ -132,68 +147,86 @@ files:
|
|
132
147
|
- bin/rake
|
133
148
|
- bin/sandbox
|
134
149
|
- bin/setup
|
150
|
+
- config/initializers/webhooks.rb
|
135
151
|
- config/locales/en.yml
|
136
152
|
- config/routes.rb
|
137
153
|
- db/migrate/20140515024440_add_easy_post_fields_to_shipping_rate.rb
|
154
|
+
- db/migrate/20201025110912_add_tracker_id_to_cartons.rb
|
138
155
|
- lib/generators/solidus_easypost/install/install_generator.rb
|
156
|
+
- lib/generators/solidus_easypost/install/templates/initializer.rb
|
139
157
|
- lib/solidus_easypost.rb
|
158
|
+
- lib/solidus_easypost/address_builder.rb
|
159
|
+
- lib/solidus_easypost/calculator/base_dimension_calculator.rb
|
160
|
+
- lib/solidus_easypost/calculator/weight_dimension_calculator.rb
|
140
161
|
- lib/solidus_easypost/configuration.rb
|
141
162
|
- lib/solidus_easypost/engine.rb
|
142
|
-
- lib/solidus_easypost/
|
163
|
+
- lib/solidus_easypost/errors/unknown_partial_resource_error.rb
|
164
|
+
- lib/solidus_easypost/estimator.rb
|
165
|
+
- lib/solidus_easypost/parcel_builder.rb
|
166
|
+
- lib/solidus_easypost/shipment_builder.rb
|
167
|
+
- lib/solidus_easypost/shipping_method_selector.rb
|
168
|
+
- lib/solidus_easypost/shipping_rate_calculator.rb
|
169
|
+
- lib/solidus_easypost/testing_support/factories.rb
|
170
|
+
- lib/solidus_easypost/testing_support/factories/address_factory.rb
|
171
|
+
- lib/solidus_easypost/testing_support/factories/product_factory.rb
|
172
|
+
- lib/solidus_easypost/testing_support/factories/shipment_factory.rb
|
173
|
+
- lib/solidus_easypost/testing_support/factories/shipping_method_factory.rb
|
174
|
+
- lib/solidus_easypost/testing_support/factories/stock_location_factory.rb
|
175
|
+
- lib/solidus_easypost/testing_support/factories/variant_factory.rb
|
176
|
+
- lib/solidus_easypost/tracker_webhook_handler.rb
|
143
177
|
- lib/solidus_easypost/version.rb
|
144
178
|
- solidus_easypost.gemspec
|
145
|
-
- spec/cassettes/
|
146
|
-
- spec/cassettes/
|
147
|
-
- spec/cassettes/
|
148
|
-
- spec/cassettes/
|
149
|
-
- spec/cassettes/
|
150
|
-
- spec/cassettes/
|
151
|
-
- spec/cassettes/
|
152
|
-
- spec/cassettes/
|
153
|
-
- spec/cassettes/
|
154
|
-
- spec/cassettes/
|
155
|
-
- spec/cassettes/
|
156
|
-
- spec/cassettes/
|
157
|
-
- spec/cassettes/
|
158
|
-
- spec/
|
159
|
-
- spec/
|
160
|
-
- spec/
|
161
|
-
- spec/
|
162
|
-
- spec/
|
163
|
-
- spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_front_end_visible/has_the_correct_names.yml
|
164
|
-
- spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_not_front_end_visible/is_empty.yml
|
165
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_parcel/has_the_correct_attributes.yml
|
166
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_parcel/is_an_EasyPost_Parcel_object.yml
|
167
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_shipment/calls_the_api.yml
|
168
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_shipment/is_an_EasyPost_Shipment_object.yml
|
169
|
-
- spec/factories/spree_modification.rb
|
179
|
+
- spec/cassettes/address_builder/from_address.yml
|
180
|
+
- spec/cassettes/address_builder/from_stock_location.yml
|
181
|
+
- spec/cassettes/estimator.yml
|
182
|
+
- spec/cassettes/integration/checkout.yml
|
183
|
+
- spec/cassettes/integration/order_shipping/with_purchase_labels.yml
|
184
|
+
- spec/cassettes/integration/order_shipping/without_purchase_labels.yml
|
185
|
+
- spec/cassettes/parcel_builder/from_package.yml
|
186
|
+
- spec/cassettes/parcel_builder/from_return_authorization.yml
|
187
|
+
- spec/cassettes/postage_labels/show.yml
|
188
|
+
- spec/cassettes/return_authorization.yml
|
189
|
+
- spec/cassettes/shipment_builder/from_package.yml
|
190
|
+
- spec/cassettes/shipment_builder/from_return_authorization.yml
|
191
|
+
- spec/cassettes/shipment_builder/from_shipment.yml
|
192
|
+
- spec/controllers/spree/admin/postage_labels_controller_spec.rb
|
193
|
+
- spec/features/admin/postage_labels_spec.rb
|
194
|
+
- spec/integration/checkout_spec.rb
|
195
|
+
- spec/integration/order_shipping_spec.rb
|
196
|
+
- spec/models/solidus_easypost/parcel_dimension_spec.rb
|
170
197
|
- spec/models/solidus_easypost/return_authorization_spec.rb
|
171
|
-
- spec/models/spree/
|
172
|
-
- spec/models/spree/order_spec.rb
|
198
|
+
- spec/models/spree/carton_spec.rb
|
173
199
|
- spec/models/spree/shipment_spec.rb
|
174
200
|
- spec/models/spree/shipping_rate_spec.rb
|
175
|
-
- spec/
|
176
|
-
- spec/
|
177
|
-
- spec/
|
201
|
+
- spec/solidus_easypost/address_builder_spec.rb
|
202
|
+
- spec/solidus_easypost/calculator/weight_dimension_calculator_spec.rb
|
203
|
+
- spec/solidus_easypost/estimator_spec.rb
|
204
|
+
- spec/solidus_easypost/parcel_builder_spec.rb
|
205
|
+
- spec/solidus_easypost/shipment_builder_spec.rb
|
206
|
+
- spec/solidus_easypost/shipping_method_selector_spec.rb
|
207
|
+
- spec/solidus_easypost/shipping_rate_calculator_spec.rb
|
208
|
+
- spec/solidus_easypost/tracker_webhook_handler_spec.rb
|
178
209
|
- spec/solidus_easypost_spec.rb
|
179
210
|
- spec/spec_helper.rb
|
180
211
|
- spec/support/easypost.rb
|
181
212
|
- spec/support/factory_bot.rb
|
182
|
-
- spec/support/
|
213
|
+
- spec/support/helpers/api_stubs.rb
|
214
|
+
- spec/support/helpers/configuration.rb
|
215
|
+
- spec/support/helpers/shipping_methods.rb
|
216
|
+
- spec/support/solidus.rb
|
183
217
|
- spec/support/vcr.rb
|
184
218
|
homepage: https://github.com/solidusio-contrib/solidus_easypost
|
185
219
|
licenses:
|
186
220
|
- BSD-3-Clause
|
187
221
|
metadata:
|
188
|
-
|
189
|
-
|
190
|
-
post_install_message:
|
222
|
+
rubygems_mfa_required: 'true'
|
223
|
+
post_install_message:
|
191
224
|
rdoc_options: []
|
192
225
|
require_paths:
|
193
226
|
- lib
|
194
227
|
required_ruby_version: !ruby/object:Gem::Requirement
|
195
228
|
requirements:
|
196
|
-
- - "
|
229
|
+
- - ">="
|
197
230
|
- !ruby/object:Gem::Version
|
198
231
|
version: '2.5'
|
199
232
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -202,47 +235,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
235
|
- !ruby/object:Gem::Version
|
203
236
|
version: '0'
|
204
237
|
requirements: []
|
205
|
-
rubygems_version: 3.
|
206
|
-
signing_key:
|
238
|
+
rubygems_version: 3.1.2
|
239
|
+
signing_key:
|
207
240
|
specification_version: 4
|
208
|
-
summary:
|
241
|
+
summary: EasyPost integration for Solidus stores.
|
209
242
|
test_files:
|
210
|
-
- spec/cassettes/
|
211
|
-
- spec/cassettes/
|
212
|
-
- spec/cassettes/
|
213
|
-
- spec/cassettes/
|
214
|
-
- spec/cassettes/
|
215
|
-
- spec/cassettes/
|
216
|
-
- spec/cassettes/
|
217
|
-
- spec/cassettes/
|
218
|
-
- spec/cassettes/
|
219
|
-
- spec/cassettes/
|
220
|
-
- spec/cassettes/
|
221
|
-
- spec/cassettes/
|
222
|
-
- spec/cassettes/
|
223
|
-
- spec/
|
224
|
-
- spec/
|
225
|
-
- spec/
|
226
|
-
- spec/
|
227
|
-
- spec/
|
228
|
-
- spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_front_end_visible/has_the_correct_names.yml
|
229
|
-
- spec/cassettes/Spree_Stock_Estimator/_shipping_rates/when_rates_are_found/when_shipping_methods_exist/when_shipping_methods_are_not_front_end_visible/is_empty.yml
|
230
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_parcel/has_the_correct_attributes.yml
|
231
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_parcel/is_an_EasyPost_Parcel_object.yml
|
232
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_shipment/calls_the_api.yml
|
233
|
-
- spec/cassettes/Spree_Stock_Package/_easypost_shipment/is_an_EasyPost_Shipment_object.yml
|
234
|
-
- spec/factories/spree_modification.rb
|
243
|
+
- spec/cassettes/address_builder/from_address.yml
|
244
|
+
- spec/cassettes/address_builder/from_stock_location.yml
|
245
|
+
- spec/cassettes/estimator.yml
|
246
|
+
- spec/cassettes/integration/checkout.yml
|
247
|
+
- spec/cassettes/integration/order_shipping/with_purchase_labels.yml
|
248
|
+
- spec/cassettes/integration/order_shipping/without_purchase_labels.yml
|
249
|
+
- spec/cassettes/parcel_builder/from_package.yml
|
250
|
+
- spec/cassettes/parcel_builder/from_return_authorization.yml
|
251
|
+
- spec/cassettes/postage_labels/show.yml
|
252
|
+
- spec/cassettes/return_authorization.yml
|
253
|
+
- spec/cassettes/shipment_builder/from_package.yml
|
254
|
+
- spec/cassettes/shipment_builder/from_return_authorization.yml
|
255
|
+
- spec/cassettes/shipment_builder/from_shipment.yml
|
256
|
+
- spec/controllers/spree/admin/postage_labels_controller_spec.rb
|
257
|
+
- spec/features/admin/postage_labels_spec.rb
|
258
|
+
- spec/integration/checkout_spec.rb
|
259
|
+
- spec/integration/order_shipping_spec.rb
|
260
|
+
- spec/models/solidus_easypost/parcel_dimension_spec.rb
|
235
261
|
- spec/models/solidus_easypost/return_authorization_spec.rb
|
236
|
-
- spec/models/spree/
|
237
|
-
- spec/models/spree/order_spec.rb
|
262
|
+
- spec/models/spree/carton_spec.rb
|
238
263
|
- spec/models/spree/shipment_spec.rb
|
239
264
|
- spec/models/spree/shipping_rate_spec.rb
|
240
|
-
- spec/
|
241
|
-
- spec/
|
242
|
-
- spec/
|
265
|
+
- spec/solidus_easypost/address_builder_spec.rb
|
266
|
+
- spec/solidus_easypost/calculator/weight_dimension_calculator_spec.rb
|
267
|
+
- spec/solidus_easypost/estimator_spec.rb
|
268
|
+
- spec/solidus_easypost/parcel_builder_spec.rb
|
269
|
+
- spec/solidus_easypost/shipment_builder_spec.rb
|
270
|
+
- spec/solidus_easypost/shipping_method_selector_spec.rb
|
271
|
+
- spec/solidus_easypost/shipping_rate_calculator_spec.rb
|
272
|
+
- spec/solidus_easypost/tracker_webhook_handler_spec.rb
|
243
273
|
- spec/solidus_easypost_spec.rb
|
244
274
|
- spec/spec_helper.rb
|
245
275
|
- spec/support/easypost.rb
|
246
276
|
- spec/support/factory_bot.rb
|
247
|
-
- spec/support/
|
277
|
+
- spec/support/helpers/api_stubs.rb
|
278
|
+
- spec/support/helpers/configuration.rb
|
279
|
+
- spec/support/helpers/shipping_methods.rb
|
280
|
+
- spec/support/solidus.rb
|
248
281
|
- spec/support/vcr.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidusEasypost
|
4
|
-
module Spree
|
5
|
-
module AddressDecorator
|
6
|
-
def easypost_address
|
7
|
-
attributes = {
|
8
|
-
street1: address1,
|
9
|
-
street2: address2,
|
10
|
-
city: city,
|
11
|
-
zip: zipcode,
|
12
|
-
phone: phone
|
13
|
-
}
|
14
|
-
|
15
|
-
attributes[:company] = company if respond_to?(:company)
|
16
|
-
attributes[:name] = if respond_to?(:name)
|
17
|
-
name
|
18
|
-
elsif respond_to?(:full_name)
|
19
|
-
full_name
|
20
|
-
end
|
21
|
-
attributes[:state] = state ? state.abbr : state_name
|
22
|
-
attributes[:country] = country&.iso
|
23
|
-
|
24
|
-
::EasyPost::Address.create attributes
|
25
|
-
end
|
26
|
-
|
27
|
-
::Spree::Address.prepend self
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidusEasypost
|
4
|
-
module Spree
|
5
|
-
module Stock
|
6
|
-
module EstimatorDecorator
|
7
|
-
def shipping_rates(package, frontend_only = true)
|
8
|
-
SolidusEasypost::Estimator.new.shipping_rates(package, frontend_only)
|
9
|
-
end
|
10
|
-
|
11
|
-
::Spree::Stock::Estimator.prepend self
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidusEasypost
|
4
|
-
module Spree
|
5
|
-
module Stock
|
6
|
-
module PackageDecorator
|
7
|
-
def easypost_parcel
|
8
|
-
total_weight = contents.sum do |item|
|
9
|
-
item.quantity * item.variant.weight
|
10
|
-
end
|
11
|
-
|
12
|
-
::EasyPost::Parcel.create weight: total_weight
|
13
|
-
end
|
14
|
-
|
15
|
-
def easypost_shipment
|
16
|
-
::EasyPost::Shipment.create(
|
17
|
-
to_address: order.ship_address.easypost_address,
|
18
|
-
from_address: stock_location.easypost_address,
|
19
|
-
parcel: easypost_parcel
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
::Spree::Stock::Package.prepend self
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|