solidus_easypost 1.0.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +41 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/stale.yml +17 -0
  5. data/.github_changelog_generator +2 -0
  6. data/.gitignore +21 -0
  7. data/.rspec +2 -0
  8. data/.rubocop.yml +7 -0
  9. data/.rubocop_todo.yml +36 -0
  10. data/CHANGELOG.md +113 -0
  11. data/Gemfile +33 -0
  12. data/LICENSE +26 -0
  13. data/README.md +194 -0
  14. data/Rakefile +6 -0
  15. data/app/controllers/spree/admin/postage_labels_controller.rb +20 -0
  16. data/app/decorators/models/solidus_easypost/spree/carton_decorator.rb +38 -0
  17. data/app/decorators/models/solidus_easypost/spree/shipment_decorator.rb +47 -0
  18. data/app/decorators/models/solidus_easypost/spree/shipping_rate_decorator.rb +13 -0
  19. data/app/models/solidus_easypost/parcel_dimension.rb +34 -0
  20. data/app/models/solidus_easypost/return_authorization.rb +27 -0
  21. data/app/overrides/spree/admin/orders/_shipment/add_postage_label.html.erb.deface +10 -0
  22. data/bin/console +17 -0
  23. data/bin/rails +7 -0
  24. data/bin/rails-engine +13 -0
  25. data/bin/rails-sandbox +16 -0
  26. data/bin/rake +7 -0
  27. data/bin/sandbox +86 -0
  28. data/bin/setup +8 -0
  29. data/config/initializers/webhooks.rb +7 -0
  30. data/config/locales/en.yml +8 -0
  31. data/config/routes.rb +9 -0
  32. data/db/migrate/20140515024440_add_easy_post_fields_to_shipping_rate.rb +9 -0
  33. data/db/migrate/20201025110912_add_tracker_id_to_cartons.rb +6 -0
  34. data/lib/generators/solidus_easypost/install/install_generator.rb +28 -0
  35. data/lib/generators/solidus_easypost/install/templates/initializer.rb +26 -0
  36. data/lib/solidus_easypost/address_builder.rb +45 -0
  37. data/lib/solidus_easypost/calculator/base_dimension_calculator.rb +28 -0
  38. data/lib/solidus_easypost/calculator/weight_dimension_calculator.rb +22 -0
  39. data/lib/solidus_easypost/configuration.rb +34 -0
  40. data/lib/solidus_easypost/engine.rb +19 -0
  41. data/lib/solidus_easypost/errors/unknown_partial_resource_error.rb +11 -0
  42. data/lib/solidus_easypost/estimator.rb +37 -0
  43. data/lib/solidus_easypost/parcel_builder.rb +27 -0
  44. data/lib/solidus_easypost/shipment_builder.rb +32 -0
  45. data/lib/solidus_easypost/shipping_method_selector.rb +17 -0
  46. data/lib/solidus_easypost/shipping_rate_calculator.rb +9 -0
  47. data/lib/solidus_easypost/testing_support/factories/address_factory.rb +10 -0
  48. data/lib/solidus_easypost/testing_support/factories/product_factory.rb +7 -0
  49. data/lib/solidus_easypost/testing_support/factories/shipment_factory.rb +30 -0
  50. data/lib/solidus_easypost/testing_support/factories/shipping_method_factory.rb +8 -0
  51. data/lib/solidus_easypost/testing_support/factories/stock_location_factory.rb +10 -0
  52. data/lib/solidus_easypost/testing_support/factories/variant_factory.rb +7 -0
  53. data/lib/solidus_easypost/testing_support/factories.rb +3 -0
  54. data/lib/solidus_easypost/tracker_webhook_handler.rb +14 -0
  55. data/lib/solidus_easypost/version.rb +5 -0
  56. data/lib/solidus_easypost.rb +32 -0
  57. data/solidus_easypost.gemspec +41 -0
  58. data/spec/cassettes/address_builder/from_address.yml +65 -0
  59. data/spec/cassettes/address_builder/from_stock_location.yml +65 -0
  60. data/spec/cassettes/estimator.yml +269 -0
  61. data/spec/cassettes/integration/checkout.yml +377 -0
  62. data/spec/cassettes/integration/order_shipping/with_purchase_labels.yml +373 -0
  63. data/spec/cassettes/integration/order_shipping/without_purchase_labels.yml +251 -0
  64. data/spec/cassettes/parcel_builder/from_package.yml +63 -0
  65. data/spec/cassettes/parcel_builder/from_return_authorization.yml +63 -0
  66. data/spec/cassettes/postage_labels/show.yml +72 -0
  67. data/spec/cassettes/return_authorization.yml +310 -0
  68. data/spec/cassettes/shipment_builder/from_package.yml +251 -0
  69. data/spec/cassettes/shipment_builder/from_return_authorization.yml +251 -0
  70. data/spec/cassettes/shipment_builder/from_shipment.yml +250 -0
  71. data/spec/controllers/spree/admin/postage_labels_controller_spec.rb +18 -0
  72. data/spec/features/admin/postage_labels_spec.rb +18 -0
  73. data/spec/integration/checkout_spec.rb +45 -0
  74. data/spec/integration/order_shipping_spec.rb +33 -0
  75. data/spec/models/solidus_easypost/parcel_dimension_spec.rb +80 -0
  76. data/spec/models/solidus_easypost/return_authorization_spec.rb +17 -0
  77. data/spec/models/spree/carton_spec.rb +57 -0
  78. data/spec/models/spree/shipment_spec.rb +69 -0
  79. data/spec/models/spree/shipping_rate_spec.rb +23 -0
  80. data/spec/solidus_easypost/address_builder_spec.rb +17 -0
  81. data/spec/solidus_easypost/calculator/weight_dimension_calculator_spec.rb +39 -0
  82. data/spec/solidus_easypost/estimator_spec.rb +52 -0
  83. data/spec/solidus_easypost/parcel_builder_spec.rb +113 -0
  84. data/spec/solidus_easypost/shipment_builder_spec.rb +28 -0
  85. data/spec/solidus_easypost/shipping_method_selector_spec.rb +33 -0
  86. data/spec/solidus_easypost/shipping_rate_calculator_spec.rb +12 -0
  87. data/spec/solidus_easypost/tracker_webhook_handler_spec.rb +58 -0
  88. data/spec/solidus_easypost_spec.rb +19 -0
  89. data/spec/spec_helper.rb +31 -0
  90. data/spec/support/easypost.rb +5 -0
  91. data/spec/support/factory_bot.rb +3 -0
  92. data/spec/support/helpers/api_stubs.rb +40 -0
  93. data/spec/support/helpers/configuration.rb +28 -0
  94. data/spec/support/helpers/shipping_methods.rb +26 -0
  95. data/spec/support/solidus.rb +1 -0
  96. data/spec/support/vcr.rb +12 -0
  97. metadata +170 -142
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a26dc932c698059bd4388ff49714aa3c73237428
4
- data.tar.gz: d04a475b17469a183cd4bea7cff09d24f63b3d65
2
+ SHA256:
3
+ metadata.gz: 0d54d7ac2a6876f5b69df700919019c7ef094bb58e146139ff8ec93a9da754a0
4
+ data.tar.gz: 4e75d5636a2fb85d1277dd4fe6ffc2e2a61c616ed0688ba247dc72c218dabf8a
5
5
  SHA512:
6
- metadata.gz: 68b7eb575bdffce10647d57a95af4eda916598e02c60cd5d60fd741dcb3d85e3e7d88aa10d3cd75eba8405753a194ff2a051fdcd8455ae4c171e42abf91592d8
7
- data.tar.gz: 62238a7110f277acd9df7672f7f208360e3d1ed9e53d2c572e9471f34c5734f58d9fb81e669610f2c58b7255834c34e3ea16f07bcfc65a7cc5e80d06e9b9c493
6
+ metadata.gz: 62e2e3f86ccbab5feab3550b7e32c3e168169b11790663a629dc56a34ede6b2bd6cbe63c4e5459b3af62c084f9686f58c02e05faac10c418836bfe2e00433dc8
7
+ data.tar.gz: adf8d14742ea4da96c3b4950b9db43b46b61fd279528a8f5610a2061ff7a03aa6a8ca610775862004784cef06af1e0a49c2e667d0c47b188a487ed76c5b3f912
@@ -0,0 +1,41 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
9
+
10
+ jobs:
11
+ run-specs-with-postgres:
12
+ executor: solidusio_extensions/postgres
13
+ steps:
14
+ - solidusio_extensions/run-tests
15
+ run-specs-with-mysql:
16
+ executor: solidusio_extensions/mysql
17
+ steps:
18
+ - solidusio_extensions/run-tests
19
+ lint-code:
20
+ executor: solidusio_extensions/sqlite-memory
21
+ steps:
22
+ - solidusio_extensions/lint-code
23
+
24
+ workflows:
25
+ "Run specs on supported Solidus versions":
26
+ jobs:
27
+ - run-specs-with-postgres
28
+ - run-specs-with-mysql
29
+ - lint-code
30
+
31
+ "Weekly run specs against master":
32
+ triggers:
33
+ - schedule:
34
+ cron: "0 0 * * 4" # every Thursday
35
+ filters:
36
+ branches:
37
+ only:
38
+ - master
39
+ jobs:
40
+ - run-specs-with-postgres
41
+ - run-specs-with-mysql
data/.gem_release.yml ADDED
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_easypost/version.rb'
4
+ message: Bump SolidusEasypost to %{version}
5
+ tag: true
data/.github/stale.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: false
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: stale
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It might be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
16
+ spec/examples.txt
17
+ /sandbox
18
+ .rvmrc
19
+ .ruby-version
20
+ .ruby-gemset
21
+ .bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - solidus_dev_support/rubocop
5
+
6
+ AllCops:
7
+ NewCops: enable
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,36 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-09-23 14:11:08 UTC using RuboCop version 0.91.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ RSpec/DescribeClass:
11
+ Exclude:
12
+ - 'spec/features/**/*'
13
+ - 'spec/integration/order_shipping_spec.rb'
14
+
15
+ # Offense count: 3
16
+ RSpec/MultipleExpectations:
17
+ Max: 3
18
+
19
+ # Offense count: 4
20
+ # Configuration parameters: EnforcedStyle.
21
+ # SupportedStyles: scientific, engineering, integral
22
+ Style/ExponentialNotation:
23
+ Exclude:
24
+ - 'spec/integration/checkout_spec.rb'
25
+
26
+ # Offense count: 1
27
+ Style/OptionalBooleanParameter:
28
+ Exclude:
29
+ - 'lib/solidus_easypost/estimator.rb'
30
+
31
+ # Offense count: 3
32
+ # Cop supports --auto-correct.
33
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
34
+ # URISchemes: http, https
35
+ Layout/LineLength:
36
+ Max: 137
data/CHANGELOG.md ADDED
@@ -0,0 +1,113 @@
1
+ # Changelog
2
+
3
+ ## [v3.0.0](https://github.com/solidusio-contrib/solidus_easypost/tree/v3.0.0) (2022-01-05)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_easypost/compare/v2.0.0...v3.0.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Dependabot can't resolve your Ruby dependency files [\#92](https://github.com/solidusio-contrib/solidus_easypost/issues/92)
10
+ - Prepare Solidus Easypost for Solidus 3.0 [\#88](https://github.com/solidusio-contrib/solidus_easypost/issues/88)
11
+ - Dependabot can't resolve your Ruby dependency files [\#77](https://github.com/solidusio-contrib/solidus_easypost/issues/77)
12
+ - Dependabot can't resolve your Ruby dependency files [\#76](https://github.com/solidusio-contrib/solidus_easypost/issues/76)
13
+ - README is incompatible with latest rubygems release [\#73](https://github.com/solidusio-contrib/solidus_easypost/issues/73)
14
+ - Unable to Handle Refunds Out of the Box [\#58](https://github.com/solidusio-contrib/solidus_easypost/issues/58)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - fix new cops [\#102](https://github.com/solidusio-contrib/solidus_easypost/pull/102) ([ccarruitero](https://github.com/ccarruitero))
19
+ - fix webhooks handler setup and allow customize [\#100](https://github.com/solidusio-contrib/solidus_easypost/pull/100) ([ccarruitero](https://github.com/ccarruitero))
20
+ - relax ruby version to support ruby 3.0 [\#99](https://github.com/solidusio-contrib/solidus_easypost/pull/99) ([ccarruitero](https://github.com/ccarruitero))
21
+ - Add custom parcel dimension calculator class [\#98](https://github.com/solidusio-contrib/solidus_easypost/pull/98) ([vassalloandrea](https://github.com/vassalloandrea))
22
+ - Update gemspec to allow Solidus 3 [\#94](https://github.com/solidusio-contrib/solidus_easypost/pull/94) ([vassalloandrea](https://github.com/vassalloandrea))
23
+ - Prepare extension for solidus 3.0 [\#89](https://github.com/solidusio-contrib/solidus_easypost/pull/89) ([ccarruitero](https://github.com/ccarruitero))
24
+ - Allow tracking packages via EasyPost [\#87](https://github.com/solidusio-contrib/solidus_easypost/pull/87) ([aldesantis](https://github.com/aldesantis))
25
+ - Upgrade extension to latest defaults [\#86](https://github.com/solidusio-contrib/solidus_easypost/pull/86) ([aldesantis](https://github.com/aldesantis))
26
+ - Allow admins to download postage labels [\#84](https://github.com/solidusio-contrib/solidus_easypost/pull/84) ([aldesantis](https://github.com/aldesantis))
27
+ - Update extension with latest solidus\_dev\_support defaults [\#82](https://github.com/solidusio-contrib/solidus_easypost/pull/82) ([aldesantis](https://github.com/aldesantis))
28
+ - Streamline and reorganize tests for better reliability [\#81](https://github.com/solidusio-contrib/solidus_easypost/pull/81) ([aldesantis](https://github.com/aldesantis))
29
+ - Extract EasyPost object builders into separate classes [\#80](https://github.com/solidusio-contrib/solidus_easypost/pull/80) ([aldesantis](https://github.com/aldesantis))
30
+ - Improve extension extendability [\#79](https://github.com/solidusio-contrib/solidus_easypost/pull/79) ([aldesantis](https://github.com/aldesantis))
31
+ - Update extension to latest defaults from solidus\_dev\_support [\#78](https://github.com/solidusio-contrib/solidus_easypost/pull/78) ([aldesantis](https://github.com/aldesantis))
32
+
33
+ ## [v2.0.0](https://github.com/solidusio-contrib/solidus_easypost/tree/v2.0.0) (2020-07-24)
34
+
35
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_easypost/compare/v1.0.4...v2.0.0)
36
+
37
+ **Breaking changes:**
38
+
39
+ - keep same namespace in all files [\#68](https://github.com/solidusio-contrib/solidus_easypost/pull/68) ([ccarruitero](https://github.com/ccarruitero))
40
+
41
+ **Closed issues:**
42
+
43
+ - Dependabot can't resolve your Ruby dependency files [\#59](https://github.com/solidusio-contrib/solidus_easypost/issues/59)
44
+ - Dependabot can't resolve your Ruby dependency files [\#57](https://github.com/solidusio-contrib/solidus_easypost/issues/57)
45
+ - Dependabot can't resolve your Ruby dependency files [\#56](https://github.com/solidusio-contrib/solidus_easypost/issues/56)
46
+ - Dependabot can't resolve your Ruby dependency files [\#54](https://github.com/solidusio-contrib/solidus_easypost/issues/54)
47
+ - Dependabot can't resolve your Ruby dependency files [\#53](https://github.com/solidusio-contrib/solidus_easypost/issues/53)
48
+ - Dependabot can't resolve your Ruby dependency files [\#52](https://github.com/solidusio-contrib/solidus_easypost/issues/52)
49
+ - Config is now frozen. [\#49](https://github.com/solidusio-contrib/solidus_easypost/issues/49)
50
+ - Easypost rate is bought twice [\#42](https://github.com/solidusio-contrib/solidus_easypost/issues/42)
51
+ - UPS carrier doesn't allow empty company name in `from_address` [\#41](https://github.com/solidusio-contrib/solidus_easypost/issues/41)
52
+ - Exception thrown by Estimator [\#35](https://github.com/solidusio-contrib/solidus_easypost/issues/35)
53
+ - rake railties:install:migrations [\#30](https://github.com/solidusio-contrib/solidus_easypost/issues/30)
54
+ - Easypost Migrations aren't working [\#22](https://github.com/solidusio-contrib/solidus_easypost/issues/22)
55
+ - Missing for 2.1 solidus? [\#18](https://github.com/solidusio-contrib/solidus_easypost/issues/18)
56
+ - Charge customer different amount? [\#17](https://github.com/solidusio-contrib/solidus_easypost/issues/17)
57
+ - 1.3.0 seems to be empty [\#15](https://github.com/solidusio-contrib/solidus_easypost/issues/15)
58
+ - Uninitialized constant EasyPost Error [\#14](https://github.com/solidusio-contrib/solidus_easypost/issues/14)
59
+
60
+ **Merged pull requests:**
61
+
62
+ - Extension cleanup [\#74](https://github.com/solidusio-contrib/solidus_easypost/pull/74) ([aldesantis](https://github.com/aldesantis))
63
+ - Standardize whitespace in README [\#72](https://github.com/solidusio-contrib/solidus_easypost/pull/72) ([brchristian](https://github.com/brchristian))
64
+ - Fix deprecation warning in engine.rb [\#71](https://github.com/solidusio-contrib/solidus_easypost/pull/71) ([brchristian](https://github.com/brchristian))
65
+ - Update README.md [\#70](https://github.com/solidusio-contrib/solidus_easypost/pull/70) ([brchristian](https://github.com/brchristian))
66
+ - Relax solidus\_support dependency [\#65](https://github.com/solidusio-contrib/solidus_easypost/pull/65) ([kennyadsl](https://github.com/kennyadsl))
67
+ - Upgrade to the latest solidus\_dev\_support [\#60](https://github.com/solidusio-contrib/solidus_easypost/pull/60) ([vassalloandrea](https://github.com/vassalloandrea))
68
+ - Fix CONFIGS constant not being modifiable [\#51](https://github.com/solidusio-contrib/solidus_easypost/pull/51) ([aldesantis](https://github.com/aldesantis))
69
+ - Reorganize and improve tests [\#50](https://github.com/solidusio-contrib/solidus_easypost/pull/50) ([aldesantis](https://github.com/aldesantis))
70
+ - Adopt solidus\_extension\_dev\_tools [\#48](https://github.com/solidusio-contrib/solidus_easypost/pull/48) ([aldesantis](https://github.com/aldesantis))
71
+ - Use different easypost\_address for the stock locations [\#43](https://github.com/solidusio-contrib/solidus_easypost/pull/43) ([vassalloandrea](https://github.com/vassalloandrea))
72
+ - Fix broken Rails 6 build [\#40](https://github.com/solidusio-contrib/solidus_easypost/pull/40) ([aldesantis](https://github.com/aldesantis))
73
+ - Adopt CircleCI instead of Travis [\#39](https://github.com/solidusio-contrib/solidus_easypost/pull/39) ([aldesantis](https://github.com/aldesantis))
74
+ - Fixing Travis [\#38](https://github.com/solidusio-contrib/solidus_easypost/pull/38) ([spaghetticode](https://github.com/spaghetticode))
75
+ - Add Rubocop for linting [\#37](https://github.com/solidusio-contrib/solidus_easypost/pull/37) ([aitbw](https://github.com/aitbw))
76
+ - Lock SQLite3 to version 1.3 [\#34](https://github.com/solidusio-contrib/solidus_easypost/pull/34) ([aitbw](https://github.com/aitbw))
77
+ - Use dynamic attributes on factories [\#33](https://github.com/solidusio-contrib/solidus_easypost/pull/33) ([aitbw](https://github.com/aitbw))
78
+ - add solidus\_easypost file [\#32](https://github.com/solidusio-contrib/solidus_easypost/pull/32) ([peterberkenbosch](https://github.com/peterberkenbosch))
79
+ - Add Solidus v2.8 to Travis config [\#31](https://github.com/solidusio-contrib/solidus_easypost/pull/31) ([aitbw](https://github.com/aitbw))
80
+ - Spec suite maintenance [\#29](https://github.com/solidusio-contrib/solidus_easypost/pull/29) ([aitbw](https://github.com/aitbw))
81
+ - Remove 2.2 from CI \(EOL\) [\#28](https://github.com/solidusio-contrib/solidus_easypost/pull/28) ([jacobherrington](https://github.com/jacobherrington))
82
+ - Remove versions past EOL from .travis.yml [\#26](https://github.com/solidusio-contrib/solidus_easypost/pull/26) ([jacobherrington](https://github.com/jacobherrington))
83
+ - Add Solidus 2.3-2.7 to .travis.yml [\#25](https://github.com/solidusio-contrib/solidus_easypost/pull/25) ([jacobherrington](https://github.com/jacobherrington))
84
+ - Support Solidus 1.3 and beyond [\#19](https://github.com/solidusio-contrib/solidus_easypost/pull/19) ([jhawthorn](https://github.com/jhawthorn))
85
+ - Add the require pry to spec helper [\#7](https://github.com/solidusio-contrib/solidus_easypost/pull/7) ([qr8r](https://github.com/qr8r))
86
+ - Fix multiple version testing [\#5](https://github.com/solidusio-contrib/solidus_easypost/pull/5) ([jhawthorn](https://github.com/jhawthorn))
87
+
88
+ ## [v1.0.4](https://github.com/solidusio-contrib/solidus_easypost/tree/v1.0.4) (2016-10-03)
89
+
90
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_easypost/compare/v1.0.3...v1.0.4)
91
+
92
+ ## [v1.0.3](https://github.com/solidusio-contrib/solidus_easypost/tree/v1.0.3) (2016-07-20)
93
+
94
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_easypost/compare/v1.0.2...v1.0.3)
95
+
96
+ ## [v1.0.2](https://github.com/solidusio-contrib/solidus_easypost/tree/v1.0.2) (2016-03-14)
97
+
98
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_easypost/compare/solidus-1.0.2...v1.0.2)
99
+
100
+ **Merged pull requests:**
101
+
102
+ - Update Gemspec [\#4](https://github.com/solidusio-contrib/solidus_easypost/pull/4) ([qr8r](https://github.com/qr8r))
103
+ - Version 1.0.0 [\#3](https://github.com/solidusio-contrib/solidus_easypost/pull/3) ([qr8r](https://github.com/qr8r))
104
+ - Add a travis config file [\#2](https://github.com/solidusio-contrib/solidus_easypost/pull/2) ([qr8r](https://github.com/qr8r))
105
+ - Fix address decorator spec [\#1](https://github.com/solidusio-contrib/solidus_easypost/pull/1) ([travisp](https://github.com/travisp))
106
+
107
+ ## [solidus-1.0.2](https://github.com/solidusio-contrib/solidus_easypost/tree/solidus-1.0.2) (2015-12-08)
108
+
109
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_easypost/compare/d963686e8d728ec5beec6c04fd4ae99e3cf7450e...solidus-1.0.2)
110
+
111
+
112
+
113
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Needed to help Bundler figure out how to resolve dependencies,
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
14
+ # Provides basic authentication functionality for testing parts of your engine
15
+ gem 'solidus_auth_devise'
16
+
17
+ case ENV['DB']
18
+ when 'mysql'
19
+ gem 'mysql2'
20
+ when 'postgresql'
21
+ gem 'pg'
22
+ else
23
+ gem 'sqlite3'
24
+ end
25
+
26
+ gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g. pry-byebug.
30
+ #
31
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2015 Brendan Deere
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # solidus_easypost
2
+
3
+
4
+
5
+ This is an extension to integrate EasyPost with Solidus.
6
+
7
+ Due to how it works, you will not be able to use any other extension for shipping methods. Your own
8
+ shipping methods will not work, either. But the good thing is that you won't have to worry about
9
+ that, because EasyPost handles it all for you.
10
+
11
+ You will need to [sign up for an account](https://www.easypost.com/) to use this extension.
12
+
13
+ ## Installation
14
+
15
+ Add solidus_easypost to your Gemfile:
16
+
17
+ ```ruby
18
+ gem 'solidus_easypost'
19
+ ```
20
+
21
+ Bundle your dependencies and run the installation generator:
22
+
23
+ ```shell
24
+ bin/rails generate solidus_easypost:install
25
+ ```
26
+
27
+ This will create an initializer at `config/initializers/solidus_easypost.rb`. Read through the
28
+ available configuration options and make sure to adjust the extension for your requirements.
29
+
30
+ Finally, you will need to configure Solidus to use the EasyPost stock estimator:
31
+
32
+ ```ruby
33
+ # config/initializers/spree.rb
34
+ Spree.config do |config|
35
+ config.stock.estimator_class = 'SolidusEasypost::Estimator'
36
+ end
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ Once you switch to the EasyPost rate calculator, the extension will start calculating shipping rates
42
+ for all shipments. The cheapest rate will be selected by default, but your users will be able to
43
+ change the selected rate in the `delivery` step of the checkout process, if they wish.
44
+
45
+ Admins will also be able to download the postage label associated to each EasyPost shipment after
46
+ a shipment has been bought.
47
+
48
+ ### Buying labels upon shipping
49
+
50
+ By default, the extension also adds a callback to the `ship` event on the `Spree::Shipment` model,
51
+ automatically buying the selected rate from EasyPost.
52
+
53
+ If you want to disable this logic, you can set `purchase_labels` to `false`.
54
+
55
+ ### Customizing shipping rate calculation
56
+
57
+ By default, the extension will pass the entire cost of shipping to the user (i.e., the shipping cost
58
+ presented to the user will be equal to the rate received from the EasyPost API).
59
+
60
+ If you want to override this logic (e.g., you want to offer your users free shipping, but still buy
61
+ the rates from EasyPost), you can provide your own `shipping_rate_calculator_class`.
62
+
63
+ ### Customizing shipping method selection
64
+
65
+ By default, the extension will create shipping methods for each type of carrier/service for which it
66
+ receives a rate from the EasyPost API. These are not available to users by default, and must be
67
+ enabled before they are visible and selectable in the storefront during the checkout process.
68
+
69
+ If you want to override this logic, you can provide your own `shipping_method_selector_class`.
70
+
71
+ ### Customizing parcel dimension calculator
72
+
73
+ By default, the extension will use the default weight dimension calculator to calculate the parcel dimension that is passed to EasyPost. The default calculator uses the variants weight to calculate the parcel weight without taking into consideration the other package properties like `width`, `height`, and `lenght`.
74
+
75
+ If you want to override this logic, you can provide your own `parcel_dimension_calculator_class`.
76
+
77
+ ### Tracking cartons via EasyPost
78
+
79
+ You can optionally track packages via EasyPost's [Trackers API](https://www.easypost.com/docs/api#trackers).
80
+ In order to do this, you can call the `#easypost_tracker` method on any carton:
81
+
82
+ ```ruby
83
+ carton = Spree::Carton.find(2)
84
+ carton.easypost_tracker # => #<Easypost::Tracker>
85
+ ```
86
+
87
+ This will also save the ID of the tracker on the `easy_post_tracker_id` column, to more easily
88
+ retrieve the tracker in the future.
89
+
90
+ > NOTE: In orders for carton tracking to work, you need to make sure that the `tracking` column
91
+ > in `spree_cartons` contains a valid tracking number, and that the `carrier` column in
92
+ > `spree_shipping_methods` contains a carrier name [that EasyPost will recognize](https://www.easypost.com/docs/api#carrier-tracking-strings).
93
+ > The extension already generates compliant shipping methods by default, but you may need to change
94
+ > the data on your custom shipping methods if you want to track them.
95
+
96
+ You can also enable automatic tracking for all created cartons:
97
+
98
+ ```ruby
99
+ SolidusEasypost.configure do |config|
100
+ config.track_all_cartons = true
101
+ end
102
+ ```
103
+
104
+ ### Getting tracking updates via webhooks
105
+
106
+ Once a tracker has been created for a given carton, you can either use it manually or you can use
107
+ EasyPost's [webhooks](https://www.easypost.com/docs/api#webhooks) to have any shipping updates
108
+ forwarded to your application.
109
+
110
+ In order for webhooks to work, you need to install the [solidus_webhooks](https://github.com/solidusio-contrib/solidus_webhooks)
111
+ extension. When the extension is available, a webhook will be automatically configured at
112
+ `/webhooks/easypost_trackers`. Simply add it to your EasyPost dashboard with the following
113
+ configuration:
114
+
115
+ - *Environment:* `Production` or `Test`
116
+ - *Webhook URL:* `https://your-store.com/webhooks/easypost_trackers?token=[YOUR_TOKEN]` (replace`[YOUR_TOKEN]` with the API key of an admin user or, better yet, a[webhook user](https://github.com/solidusio-contrib/solidus_webhooks#restricting-permissions)
117
+
118
+ Now, when Solidus gets a tracking update from EasyPost, a `solidus_easypost.tracker.updated` event
119
+ will be fired. The event's payload will contain the `:carton` and `:payload` keys, with the
120
+ `Spree::Carton` object associated to the tracker and the EasyPost payload respectively.
121
+
122
+ ### Customizing the tracking webhook handler
123
+
124
+ If you want to override default webhook handler, you can provide your own `webhook_handler_class` in your configuration.
125
+
126
+ Note that, if you override the webhook handler, no events will be fired out of the box.
127
+
128
+ ## Development
129
+
130
+ ### Testing the extension
131
+
132
+ First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
133
+ app if it does not exist, then it will run specs. The dummy app can be regenerated by using
134
+ `bin/rake extension:test_app`.
135
+
136
+ ```shell
137
+ bin/rake
138
+ ```
139
+
140
+ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
141
+
142
+ ```shell
143
+ bundle exec rubocop
144
+ ```
145
+
146
+ When testing your application's integration with this extension you may use its factories.
147
+ Simply add this require statement to your spec_helper:
148
+
149
+ ```ruby
150
+ require 'solidus_easypost/factories'
151
+ ```
152
+
153
+ ### Running the sandbox
154
+
155
+ To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
156
+ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
157
+ `sandbox/bin/rails`.
158
+
159
+ Here's an example:
160
+
161
+ ```
162
+ $ bin/rails server
163
+ => Booting Puma
164
+ => Rails 6.0.2.1 application starting in development
165
+ * Listening on tcp://127.0.0.1:3000
166
+ Use Ctrl-C to stop
167
+ ```
168
+
169
+ ### Updating the changelog
170
+
171
+ Before and after releases the changelog should be updated to reflect the up-to-date status of
172
+ the project:
173
+
174
+ ```shell
175
+ bin/rake changelog
176
+ git add CHANGELOG.md
177
+ git commit -m "Update the changelog"
178
+ ```
179
+
180
+ ### Releasing new versions
181
+
182
+ Your new extension version can be released using `gem-release` like this:
183
+
184
+ ```shell
185
+ bundle exec gem bump -v 1.6.0
186
+ bin/rake changelog
187
+ git commit -a --amend
188
+ git push
189
+ bundle exec gem release
190
+ ```
191
+
192
+ ## License
193
+
194
+ Copyright (c) 2015 Brendan Deere, released under the New BSD License.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
5
+
6
+ task default: 'extension:specs'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Admin
5
+ class PostageLabelsController < Spree::Admin::BaseController
6
+ def show
7
+ @shipment = Spree::Shipment.find_by(number: params[:shipment_id])
8
+ authorize! @shipment, :show
9
+
10
+ unless @shipment.easypost_postage_label_url
11
+ flash[:error] = t('.no_postage_label', shipment_number: @shipment.number)
12
+ redirect_back(fallback_location: edit_admin_order_path(@shipment.order))
13
+ return
14
+ end
15
+
16
+ redirect_to @shipment.easypost_postage_label_url
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusEasypost
4
+ module Spree
5
+ module CartonDecorator
6
+ def self.prepended(base)
7
+ base.after_create :track_via_easypost
8
+ end
9
+
10
+ def easypost_tracker
11
+ return @easypost_tracker if @easypost_tracker
12
+
13
+ if easy_post_tracker_id.present?
14
+ @easypost_tracker = EasyPost::Tracker.retrieve(easy_post_tracker_id)
15
+ else
16
+ @easypost_tracker = EasyPost::Tracker.create(
17
+ tracking_code: tracking,
18
+ carrier: shipping_method.carrier,
19
+ )
20
+
21
+ update!(easy_post_tracker_id: @easypost_tracker.id)
22
+ end
23
+
24
+ @easypost_tracker
25
+ end
26
+
27
+ private
28
+
29
+ def track_via_easypost
30
+ return unless SolidusEasypost.configuration.track_all_cartons
31
+
32
+ easypost_tracker
33
+ end
34
+
35
+ ::Spree::Carton.prepend self
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusEasypost
4
+ module Spree
5
+ module ShipmentDecorator
6
+ def self.prepended(base)
7
+ base.state_machine.before_transition(
8
+ to: :shipped,
9
+ do: :buy_easypost_rate,
10
+ if: -> { SolidusEasypost.configuration.purchase_labels }
11
+ )
12
+
13
+ base.delegate(
14
+ :easy_post_rate_id,
15
+ :easy_post_shipment_id,
16
+ to: :selected_shipping_rate,
17
+ prefix: :selected,
18
+ allow_nil: true,
19
+ )
20
+ end
21
+
22
+ def easypost_shipment
23
+ return unless selected_easy_post_shipment_id
24
+
25
+ @easypost_shipment ||= ::EasyPost::Shipment.retrieve(selected_easy_post_shipment_id)
26
+ end
27
+
28
+ def easypost_postage_label_url
29
+ easypost_shipment&.postage_label&.label_url
30
+ end
31
+
32
+ private
33
+
34
+ def buy_easypost_rate
35
+ rate = easypost_shipment.rates.find do |easypost_rate|
36
+ easypost_rate.id == selected_easy_post_rate_id
37
+ end
38
+
39
+ easypost_shipment.buy(rate)
40
+
41
+ self.tracking = easypost_shipment.tracking_code
42
+ end
43
+
44
+ ::Spree::Shipment.prepend self
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusEasypost
4
+ module Spree
5
+ module ShippingRateDecorator
6
+ def name
7
+ read_attribute(:name) || super
8
+ end
9
+
10
+ ::Spree::ShippingRate.prepend self
11
+ end
12
+ end
13
+ end