ship_compliant 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +7 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +50 -0
  7. data/Rakefile +47 -0
  8. data/cucumber.yml +9 -0
  9. data/features/add_update_brand.feature +20 -0
  10. data/features/add_update_product.feature +24 -0
  11. data/features/check_compliance_of_sales_order_with_address_validations.feature +18 -0
  12. data/features/commit_sales_order.feature +6 -0
  13. data/features/get_inventory_details.feature +7 -0
  14. data/features/get_sales_order_extended.feature +15 -0
  15. data/features/search_sales_orders.feature +13 -0
  16. data/features/step_definitions/brand_steps.rb +73 -0
  17. data/features/step_definitions/commit_sales_order/all_shipments.rb +15 -0
  18. data/features/step_definitions/compliance_check/available_product_steps.rb +175 -0
  19. data/features/step_definitions/compliance_check/missing_product_steps.rb +102 -0
  20. data/features/step_definitions/compliance_check/noncompliant_product.rb +102 -0
  21. data/features/step_definitions/credential_steps.rb +8 -0
  22. data/features/step_definitions/inventory_steps.rb +36 -0
  23. data/features/step_definitions/product_steps.rb +140 -0
  24. data/features/step_definitions/sales_order_extended_steps.rb +79 -0
  25. data/features/step_definitions/search_order_steps.rb +87 -0
  26. data/features/step_definitions/void_order_steps.rb +27 -0
  27. data/features/support/env.rb +14 -0
  28. data/features/void_sales_order.feature +11 -0
  29. data/fixtures/vcr_cassettes/brand_already_exists.yml +1038 -0
  30. data/fixtures/vcr_cassettes/brand_ignore_existing.yml +1037 -0
  31. data/fixtures/vcr_cassettes/brand_update_existing.yml +1037 -0
  32. data/fixtures/vcr_cassettes/brand_valid.yml +1037 -0
  33. data/fixtures/vcr_cassettes/commit_salesorder_all_shipments.yml +1034 -0
  34. data/fixtures/vcr_cassettes/compliance_available_product.yml +1075 -0
  35. data/fixtures/vcr_cassettes/compliance_missing_product.yml +1046 -0
  36. data/fixtures/vcr_cassettes/compliance_noncompliant_product.yml +1082 -0
  37. data/fixtures/vcr_cassettes/ignore_existing_product.yml +1035 -0
  38. data/fixtures/vcr_cassettes/invalid_search_sales_orders.yml +1038 -0
  39. data/fixtures/vcr_cassettes/inventory_details_for_everything.yml +1037 -0
  40. data/fixtures/vcr_cassettes/product_already_exists.yml +1036 -0
  41. data/fixtures/vcr_cassettes/product_invalid_brand.yml +1036 -0
  42. data/fixtures/vcr_cassettes/product_valid_brand.yml +1035 -0
  43. data/fixtures/vcr_cassettes/sales_order_extended.yml +1042 -0
  44. data/fixtures/vcr_cassettes/sales_order_missing.yml +1034 -0
  45. data/fixtures/vcr_cassettes/search_sales_orders.yml +1039 -0
  46. data/fixtures/vcr_cassettes/update_product.yml +1035 -0
  47. data/fixtures/vcr_cassettes/void_order.yml +1033 -0
  48. data/fixtures/vcr_cassettes/void_voided_order.yml +1034 -0
  49. data/lib/ship_compliant.rb +62 -0
  50. data/lib/ship_compliant/add_update_brand.rb +50 -0
  51. data/lib/ship_compliant/add_update_brand_result.rb +6 -0
  52. data/lib/ship_compliant/add_update_product.rb +66 -0
  53. data/lib/ship_compliant/add_update_product_result.rb +6 -0
  54. data/lib/ship_compliant/address.rb +87 -0
  55. data/lib/ship_compliant/address/suggested_address.rb +37 -0
  56. data/lib/ship_compliant/base_result.rb +43 -0
  57. data/lib/ship_compliant/channel_details.rb +31 -0
  58. data/lib/ship_compliant/check_compliance.rb +41 -0
  59. data/lib/ship_compliant/check_compliance_result.rb +95 -0
  60. data/lib/ship_compliant/client.rb +54 -0
  61. data/lib/ship_compliant/commit_sales_order.rb +48 -0
  62. data/lib/ship_compliant/commit_sales_order_result.rb +30 -0
  63. data/lib/ship_compliant/compliance_rule.rb +30 -0
  64. data/lib/ship_compliant/configuration.rb +46 -0
  65. data/lib/ship_compliant/error_result.rb +41 -0
  66. data/lib/ship_compliant/freight_sales_tax_rate.rb +8 -0
  67. data/lib/ship_compliant/get_inventory_details.rb +31 -0
  68. data/lib/ship_compliant/get_inventory_details_result.rb +41 -0
  69. data/lib/ship_compliant/get_sales_order_extended.rb +23 -0
  70. data/lib/ship_compliant/get_sales_order_extended_result.rb +65 -0
  71. data/lib/ship_compliant/inventory_product.rb +95 -0
  72. data/lib/ship_compliant/order_search.rb +92 -0
  73. data/lib/ship_compliant/package.rb +13 -0
  74. data/lib/ship_compliant/product_attributes.rb +98 -0
  75. data/lib/ship_compliant/product_sales_tax_rate.rb +23 -0
  76. data/lib/ship_compliant/sales_tax_rate.rb +22 -0
  77. data/lib/ship_compliant/search_sales_order_summary.rb +30 -0
  78. data/lib/ship_compliant/search_sales_orders.rb +53 -0
  79. data/lib/ship_compliant/search_sales_orders_result.rb +106 -0
  80. data/lib/ship_compliant/shipment.rb +59 -0
  81. data/lib/ship_compliant/shipment_compliance.rb +28 -0
  82. data/lib/ship_compliant/shipment_sales_tax_rate.rb +15 -0
  83. data/lib/ship_compliant/version.rb +3 -0
  84. data/lib/ship_compliant/void_sales_order.rb +42 -0
  85. data/lib/ship_compliant/void_sales_order_result.rb +20 -0
  86. data/ship_compliant.gemspec +33 -0
  87. data/spec/fixtures/add_update_product.xml +22 -0
  88. data/spec/fixtures/check_compliance.xml +125 -0
  89. data/spec/fixtures/coreservice.wsdl +1341 -0
  90. data/spec/fixtures/search_sales_orders.xml +52 -0
  91. data/spec/fixtures/void_order_failure.xml +31 -0
  92. data/spec/fixtures/void_order_success.xml +22 -0
  93. data/spec/lib/ship_compliant/add_update_brand_result_spec.rb +7 -0
  94. data/spec/lib/ship_compliant/add_update_brand_spec.rb +58 -0
  95. data/spec/lib/ship_compliant/add_update_product_result_spec.rb +7 -0
  96. data/spec/lib/ship_compliant/add_update_product_spec.rb +52 -0
  97. data/spec/lib/ship_compliant/address/suggested_address_spec.rb +28 -0
  98. data/spec/lib/ship_compliant/address_spec.rb +123 -0
  99. data/spec/lib/ship_compliant/base_result_spec.rb +127 -0
  100. data/spec/lib/ship_compliant/channel_details_spec.rb +40 -0
  101. data/spec/lib/ship_compliant/check_compliance_result_spec.rb +135 -0
  102. data/spec/lib/ship_compliant/check_compliance_spec.rb +43 -0
  103. data/spec/lib/ship_compliant/client_spec.rb +73 -0
  104. data/spec/lib/ship_compliant/commit_sales_order_result_spec.rb +32 -0
  105. data/spec/lib/ship_compliant/commit_sales_order_spec.rb +38 -0
  106. data/spec/lib/ship_compliant/compliance_rule_spec.rb +47 -0
  107. data/spec/lib/ship_compliant/configuration_spec.rb +47 -0
  108. data/spec/lib/ship_compliant/error_result_spec.rb +47 -0
  109. data/spec/lib/ship_compliant/freight_sales_tax_rate_spec.rb +7 -0
  110. data/spec/lib/ship_compliant/get_inventory_details_result_spec.rb +87 -0
  111. data/spec/lib/ship_compliant/get_inventory_details_spec.rb +35 -0
  112. data/spec/lib/ship_compliant/get_sales_order_extended_result_spec.rb +84 -0
  113. data/spec/lib/ship_compliant/get_sales_order_extended_spec.rb +39 -0
  114. data/spec/lib/ship_compliant/inventory_product_spec.rb +116 -0
  115. data/spec/lib/ship_compliant/order_search_spec.rb +21 -0
  116. data/spec/lib/ship_compliant/package_spec.rb +26 -0
  117. data/spec/lib/ship_compliant/product_attributes_spec.rb +36 -0
  118. data/spec/lib/ship_compliant/product_sales_tax_rate_spec.rb +22 -0
  119. data/spec/lib/ship_compliant/sales_tax_rate_spec.rb +21 -0
  120. data/spec/lib/ship_compliant/search_sales_order_summary_spec.rb +56 -0
  121. data/spec/lib/ship_compliant/search_sales_orders_result_spec.rb +121 -0
  122. data/spec/lib/ship_compliant/search_sales_orders_spec.rb +42 -0
  123. data/spec/lib/ship_compliant/shipment_compliance_spec.rb +46 -0
  124. data/spec/lib/ship_compliant/shipment_sales_tax_rate_spec.rb +20 -0
  125. data/spec/lib/ship_compliant/shipment_spec.rb +106 -0
  126. data/spec/lib/ship_compliant/void_sales_order_result_spec.rb +7 -0
  127. data/spec/lib/ship_compliant/void_sales_order_spec.rb +41 -0
  128. data/spec/spec_helper.rb +50 -0
  129. metadata +366 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f65d2633670d76884e42d644855007e2da8ee22
4
+ data.tar.gz: 783a260776706a1f4a3aeb1ca9e6584285c4818f
5
+ SHA512:
6
+ metadata.gz: 0bfe10c93c02e0b4974fe9d6d3048c08169070789449c03dea8ab2b9cb8a94891e18aa77bd8e5ec7b898032c4f89db7602273050fa267a677080c80183e2e243
7
+ data.tar.gz: 9c94b6613394e17e863323a0bc9455aeacab931556cd5bd9bf4ade86bd5a5c1713175747b1106911372209e9fdf0c9d37f2789373b8fbbdf7470e120e9d15570
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ #- 1.9.2
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.0
8
+ env: CUCUMBER_FORMAT=progress SHIP_COMPLIANT_KEY=foo SHIP_COMPLIANT_USER=bar SHIP_COMPLIANT_PASS=baz
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ship_compliant.gemspec
4
+ gemspec
5
+
6
+ gem "savon_spec", group: :test
7
+ gem 'coveralls', require: false
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Baylor Rae'
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # ShipCompliant - Ruby API Client
2
+
3
+ The ShipCompliant gem is an API Client for the [SOAP][soap_wiki] API provided by
4
+ ShipCompliant. This gem has been created for fast implementation and supports
5
+ the 9 main API calls.
6
+
7
+ [Documentation][documentation_path] | [RDoc][rdoc_path] | [CoreService V1.2][core_service_path]
8
+
9
+ [![Build Status](https://travis-ci.org/BaylorRae/ship_compliant-ruby.png?branch=master)](https://travis-ci.org/BaylorRae/ship\_compliant-ruby) [![Code Climate](https://codeclimate.com/github/BaylorRae/ship_compliant-ruby.png)](https://codeclimate.com/github/BaylorRae/ship_compliant-ruby)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'ship_compliant'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```bash
22
+ $ bundle install
23
+ ```
24
+
25
+ Add this to `config/initializers/ship_compliant.rb`
26
+
27
+ ```ruby
28
+ ShipCompliant.configure do |c|
29
+ c.partner_key = ENV.fetch('SHIP_COMPLIANT_KEY')
30
+ c.username = ENV.fetch('SHIP_COMPLIANT_USER')
31
+ c.password = ENV.fetch('SHIP_COMPLIANT_PASS')
32
+ end
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ TODO: Coming soon...
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( http://github.com/BaylorRae/ship_compliant-ruby/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ [soap_wiki]: http://en.wikipedia.org/wiki/SOAP
48
+ [documentation_path]: http://baylorrae.github.io/ship_compliant-ruby/documentation/
49
+ [rdoc_path]: http://baylorrae.github.io/ship_compliant-ruby/rdoc/
50
+ [core_service_path]: https://shipcompliant.desk.com/customer/portal/articles/1451976-api-coreservice-v1-2?b_id=2759
@@ -0,0 +1,47 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.verbose = false
7
+ t.ruby_opts = "-I./spec -rspec_helper"
8
+ t.rspec_opts = %w[--format progress]
9
+ end
10
+
11
+ require 'cucumber/rake/task'
12
+ Cucumber::Rake::Task.new
13
+
14
+ task default: [:spec, :cucumber]
15
+
16
+ # SDoc command
17
+ # sdoc --main README.md lib README.md -o pages/rdoc --template=ship_complaint
18
+ require 'sdoc'
19
+
20
+ class RDoc::Generator::SDoc
21
+ protected
22
+ ### Create class tree structure and write it as json
23
+ def generate_class_tree
24
+ my_topclasses = %W(SearchSalesOrders VoidSalesOrder AddUpdateProduct CheckCompliance CommitSalesOrder GetInventoryDetails GetSalesOrderExtended AddUpdateBrand)
25
+
26
+ debug_msg "Generating class tree"
27
+ topclasses = @classes.select do |klass|
28
+ !(!my_topclasses.include?(klass.name) && RDoc::ClassModule === klass.parent)
29
+ end
30
+ tree = generate_file_tree + generate_class_tree_level(topclasses)
31
+ debug_msg " writing class tree to %s" % TREE_FILE
32
+ File.open(TREE_FILE, "w", 0644) do |f|
33
+ f.write('var tree = '); f.write(tree.to_json(:max_nesting => 0))
34
+ end unless @options.dry_run
35
+ end
36
+ end
37
+
38
+ RDoc::Task.new('docs') do |rdoc|
39
+ rdoc.title = 'ShipCompliant API'
40
+ rdoc.template = 'ship_complaint'
41
+ rdoc.options << '--format' << 'sdoc'
42
+ rdoc.options << '--github'
43
+
44
+ rdoc.rdoc_dir = 'pages/rdoc'
45
+ rdoc.rdoc_files.include('lib/**/*.rb', 'README.md')
46
+ rdoc.main = 'README.md'
47
+ end
@@ -0,0 +1,9 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
9
+
@@ -0,0 +1,20 @@
1
+ Feature: Add Update Brand
2
+
3
+ Background:
4
+ Given I've added my credentials
5
+
6
+ Scenario: I add a new brand
7
+ When I add a new brand
8
+ Then the brand should have been created
9
+
10
+ Scenario: I add a brand that already exists
11
+ When I add a brand that already exists
12
+ Then I should get an error for already defined brand
13
+
14
+ Scenario: I update a brand that already exists
15
+ When I update an existing brand
16
+ Then the brand should have been updated
17
+
18
+ Scenario: I ignore an existing brand
19
+ When I ignore existing brand on update
20
+ Then the brand should have been updated
@@ -0,0 +1,24 @@
1
+ Feature: Add Update Product
2
+
3
+ Background:
4
+ Given I've added my credentials
5
+
6
+ Scenario: Add new product with missing Brand
7
+ When I add a new product with invalid brand
8
+ Then I should get an error message for the missing brand
9
+
10
+ Scenario: Add new product
11
+ When I add a new product
12
+ Then the product should have been created
13
+
14
+ Scenario: Add product that already exists
15
+ When I add a product that already exists
16
+ Then I should get an error for already defined product
17
+
18
+ Scenario: Update product that already exists
19
+ When I update a product
20
+ Then I should get a message that the product was updated
21
+
22
+ Scenario: Ignore existing product
23
+ When I ignore existing product on update
24
+ Then I should get a message that the product was updated
@@ -0,0 +1,18 @@
1
+ Feature: Check Compliance Of SalesOrder With Address Validation
2
+
3
+ Background:
4
+ Given I've added my credentials
5
+
6
+ Scenario: Check compliance with missing product
7
+ When I check compliance with a missing product
8
+ Then I should receive a product key error
9
+
10
+ Scenario: Check compliance with available product
11
+ When I check compliance with an available product
12
+ Then I should receive the sales tax rates
13
+ And I should receive the shipment compliance results
14
+ And I should receive the suggested address
15
+
16
+ Scenario: Check compliance with non-compliant product
17
+ When I check compliance with a non-compliant product
18
+ Then I should receive error messages
@@ -0,0 +1,6 @@
1
+ Feature: Commit Sales Order
2
+
3
+ Scenario: I commit a sale with all shipments
4
+ Given I've added my credentials
5
+ When I commit a sale with all shipments
6
+ Then I get a successful commit message
@@ -0,0 +1,7 @@
1
+ Feature: Get Inventory Details
2
+
3
+ Scenario: Ask for everything on it
4
+ Given I've added my credentials
5
+ When I get inventory details with everthing
6
+ Then I should be able to get the product information
7
+ And I should inventory levels for a product
@@ -0,0 +1,15 @@
1
+ Feature: Get Sales Order Extended
2
+
3
+ Background:
4
+ Given I've added my credentials
5
+
6
+ Scenario: I search for order information
7
+ When I search for order information
8
+ Then I should receive shipment compliance statuses
9
+ And I should receive billing information
10
+ And I should receive shipment information
11
+ And I should receive order channel details
12
+
13
+ Scenario: I search for an order that doesn't exist
14
+ When I search for an invalid order
15
+ Then I should receive an error that the order doesn't exist
@@ -0,0 +1,13 @@
1
+ Feature: Search Sales Orders
2
+
3
+ Scenario: I search for orders by purchase date
4
+ Given I've added my credentials
5
+ When I search for orders by purchase date
6
+ Then I should find two orders
7
+ And I should receive a success status for search
8
+ And I should have paging cookie information
9
+
10
+ Scenario: I have an invalid search
11
+ Given I've added my credentials
12
+ When I search with invalid criteria
13
+ Then I should get an error status for search
@@ -0,0 +1,73 @@
1
+ When(/^I (create|update|ignore) a (?:new\s)?brand$/) do |action|
2
+ key = 'HCAS'
3
+ update_mode = 'ErrorOnExisting'
4
+
5
+ case action
6
+ when 'update'
7
+ key = 'HCAN'
8
+ update_mode = 'UpdateExisting'
9
+ when 'ignore'
10
+ update_mode = 'IgnoreExisting'
11
+ end
12
+
13
+ @brand_result = ShipCompliant::AddUpdateBrand.brand({
14
+ key: key,
15
+ name: 'Hiccups Anonymous',
16
+ owner: {
17
+ city: 'Ye Old Brew Port',
18
+ country: 'US',
19
+ name: 'John Doe',
20
+ state: 'LA',
21
+ street1: '1337 Drunken Ave.',
22
+ zip: 84742
23
+ },
24
+
25
+ this_brand_is_bottled_by_a_third_party: false,
26
+ this_brand_is_produced_by_a_third_party: false,
27
+ this_brand_operates_under_a_trade_name: true,
28
+ this_brand_was_acquired_from_a_third_party: false
29
+ }, update_mode: update_mode)
30
+ end
31
+
32
+ When(/^I add a new brand$/) do
33
+ VCR.use_cassette('brand_valid') do
34
+ step "I create a brand"
35
+ end
36
+ end
37
+
38
+ When(/^I add a brand that already exists$/) do
39
+ VCR.use_cassette('brand_already_exists') do
40
+ step "I create a new brand"
41
+ end
42
+ end
43
+
44
+ When(/^I update an existing brand$/) do
45
+ VCR.use_cassette('brand_update_existing') do
46
+ step "I update a brand"
47
+ end
48
+ end
49
+
50
+ When(/^I ignore existing brand on update$/) do
51
+ VCR.use_cassette('brand_ignore_existing') do
52
+ step "I ignore a new brand"
53
+ end
54
+ end
55
+
56
+ Then(/^I should get an error for already defined brand$/) do
57
+ @brand_result.failure?.should be_true
58
+ @brand_result.errors.length.should == 1
59
+ error = @brand_result.errors.first
60
+
61
+ error.code.should == 705
62
+ error.key.should == 'HCAS'
63
+ error.message.should == 'BrandKey exists.'
64
+ error.type.should == 'Validation'
65
+ end
66
+
67
+ Then(/^the brand should have been updated$/) do
68
+ @brand_result.success?.should be_true
69
+ end
70
+
71
+ Then(/^the brand should have been created$/) do
72
+ @brand_result.success?.should be_true
73
+ end
@@ -0,0 +1,15 @@
1
+ When(/^I commit a sale with all shipments$/) do
2
+ VCR.use_cassette('commit_salesorder_all_shipments') do
3
+ @order_commit_result = ShipCompliant::CommitSalesOrder.call({
4
+ commit_options: 'AllShipments',
5
+ payments: nil,
6
+ sales_tax_collected: 0,
7
+ sales_order_key: '1006932'
8
+ })
9
+ end
10
+ end
11
+
12
+ Then(/^I get a successful commit message$/) do
13
+ @order_commit_result.success?.should be_true
14
+ @order_commit_result.committed_shipments.should == ['1']
15
+ end
@@ -0,0 +1,175 @@
1
+ When(/^I check compliance with an available product$/) do
2
+ VCR.use_cassette('compliance_available_product') do
3
+ @compliance_status = ShipCompliant::CheckCompliance.of_sales_order({
4
+ address_option: {
5
+ ignore_street_level_errors: true,
6
+ reject_if_address_suggested: 'false'
7
+ },
8
+ include_sales_tax_rates: true,
9
+ persist_option: 'Null',
10
+ sales_order: {
11
+ bill_to: {
12
+ city: 'Boulder',
13
+ company: 'ShipCompliant',
14
+ country: 'US',
15
+ date_of_birth: DateTime.new(1987, 8, 6),
16
+ email: 'emiliy@six88.com',
17
+ first_name: 'Emily',
18
+ last_name: 'Sheehan',
19
+ phone: '303-996-1626',
20
+ state: 'CO',
21
+ street1: '1877 Broadway St',
22
+ street2: 'SUITE 703',
23
+ zip1: 80304
24
+ },
25
+ customer_key: 'd23c963b',
26
+ discounts: nil,
27
+ fulfillment_type: 'Daily',
28
+ order_type: 'Internet',
29
+ payments: nil,
30
+ purchase_date: DateTime.new(2014, 3, 12),
31
+ register_id: 'cf3ee9',
32
+ sales_order_key: '1006891',
33
+ sales_tax_collected: 0,
34
+ shipments: {
35
+ shipment: {
36
+ discounts: nil,
37
+ fulfillment_house: 'InHouse',
38
+ handling: 0,
39
+ insured_amount: 0,
40
+ license_relationship: 'Default',
41
+ packages: nil,
42
+ ship_date: DateTime.new(2014, 3, 15),
43
+ shipping_service: 'UPS',
44
+ shipment_items: [
45
+ {
46
+ shipment_item: {
47
+ brand_key: 'DEN',
48
+ discounts: nil,
49
+ product_key: '04CHRCAB75',
50
+ product_quantity: 6,
51
+ product_unit_price: 76
52
+ }
53
+ },
54
+ {
55
+ shipment_item: {
56
+ brand_key: 'DEN',
57
+ discounts: nil,
58
+ product_key: 'TShirt',
59
+ product_quantity: 1,
60
+ product_unit_price: 25.99
61
+ }
62
+ }
63
+ ],
64
+ shipment_key: 1,
65
+ shipment_status: 'SentToFulfillment',
66
+ shipping: 15,
67
+ ship_to: {
68
+ city: 'New York',
69
+ company: nil,
70
+ country: 'US',
71
+ county: nil,
72
+ date_of_birth: DateTime.new(1987, 8, 6),
73
+ email: 'emily@six88.com',
74
+ fax: nil,
75
+ first_name: 'Emily',
76
+ last_name: 'Sheehan',
77
+ phone: '7209375005',
78
+ state: 'NY',
79
+ street1: '253 Broadway Ave',
80
+ street2: 'Floor 9',
81
+ zip1: 10007,
82
+ zip2: nil
83
+ }
84
+ }
85
+ },
86
+ tags: nil
87
+ }
88
+ })
89
+ end
90
+ end
91
+
92
+ Then(/^I should receive the sales tax rates$/) do
93
+ @compliance_status.success?.should be_true
94
+ @compliance_status.compliant?.should be_true
95
+
96
+ # Tax Rates
97
+ @compliance_status.recommended_tax_due.should == 44.1
98
+ @compliance_status.shipment_sales_tax_rates.should be_kind_of(Array)
99
+ shipment_taxes = @compliance_status.taxes_for_shipment('1')
100
+
101
+ # Freight Taxes
102
+ shipment_taxes.freight.sales_tax_due.should == 1.33125
103
+ shipment_taxes.freight.sales_tax_rate.should == 8.875
104
+
105
+ # Product Taxes
106
+ shipment_taxes.taxes_for_product('04CHRCAB75').sales_tax_due.should == 40.47
107
+ shipment_taxes.taxes_for_product('04CHRCAB75').sales_tax_rate.should == 8.875
108
+
109
+ shipment_taxes.taxes_for_product('TShirt').sales_tax_due.should == 2.30661
110
+ shipment_taxes.taxes_for_product('TShirt').sales_tax_rate.should == 8.875
111
+ end
112
+
113
+ Then(/^I should receive the shipment compliance results$/) do
114
+ shipment_compliance = @compliance_status.compliance_rules_for_shipment('1')
115
+ shipment_compliance.compliant?.should be_true
116
+ shipment_compliance.shipment_key.should == '1'
117
+
118
+ shipment_compliance.rules.length.should == 6
119
+
120
+ # Compliance Descriptions
121
+ compliance_descriptions = shipment_compliance.rules.map { |c| c.compliance_description }
122
+ compliance_descriptions.should == [
123
+ 'No prohibited products in shipment.',
124
+ 'You have 1 current license in this region for the time of this shipment.',
125
+ 'Rule has been acknowledged.',
126
+ 'Rule has been acknowledged.',
127
+ 'All products within this shipment belong to self-produced brands.',
128
+ 'You have shipped 1.00 cases to this individual between 1/1/2014 and 12/31/2014 and thus are under the customer aggregate volume limit of 36 cases per calendar year.'
129
+ ]
130
+
131
+ # Rule Descriptions
132
+ rule_descriptions = shipment_compliance.rules.map { |c| c.rule_description }
133
+ rule_descriptions.should == [
134
+ 'Some Products are always non-compliant.',
135
+ 'A license is required for shipping offsite sales and must be renewed every 1 year. The cost of this license is $125.00.',
136
+ 'Shipments to this region require an excise tax of $.30 per 1 gallon on offsite sales of wine less than or equal to 24% alcohol due within 20 days after every month. For a summary of the taxes in the state, click here.',
137
+ 'Shipments to this region require sales tax for offsite sales shipments. For a summary of the taxes in the state, click here.',
138
+ 'Only wines of your own production are allowed to be shipped to this region. Note: The license holder must produce the wine being shipped..',
139
+ 'Shipments to this region have a per customer volume limit of 36 cases per individual per calendar year. The volume will be calculated from combined onsite and offsite sales.'
140
+ ]
141
+ end
142
+
143
+ Then(/^I should receive the suggested address$/) do
144
+ @compliance_status.address_validation_result.should == 'ValidatedWithStreetLevelNormalization'
145
+ address = @compliance_status.suggested_address
146
+
147
+ address.city.should == 'New York'
148
+ address.county.should == 'New York'
149
+ address.state.should == 'NY'
150
+ address.street1.should == '253 Broadway'
151
+ address.street2.should == 'Fl 9'
152
+ address.zip1.should == 10007
153
+ address.zip2.should == 2326
154
+
155
+ address.details.should == {
156
+ city_abbreviation: 'New York',
157
+ congressional_district: '10',
158
+ county_fips: '36061',
159
+ time_zone: 'Eastern Time',
160
+ time_zone_code: '05'
161
+ }
162
+
163
+ address.parts.should == {
164
+ company: nil,
165
+ mail_box_name: nil,
166
+ mail_box_number: nil,
167
+ post_direction: nil,
168
+ pre_direction: nil,
169
+ street_name: 'Broadway',
170
+ street_number: '253',
171
+ street_suffix: nil,
172
+ suite_name: 'Fl',
173
+ suite_number: '9'
174
+ }
175
+ end