ship_compliant 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +47 -0
- data/cucumber.yml +9 -0
- data/features/add_update_brand.feature +20 -0
- data/features/add_update_product.feature +24 -0
- data/features/check_compliance_of_sales_order_with_address_validations.feature +18 -0
- data/features/commit_sales_order.feature +6 -0
- data/features/get_inventory_details.feature +7 -0
- data/features/get_sales_order_extended.feature +15 -0
- data/features/search_sales_orders.feature +13 -0
- data/features/step_definitions/brand_steps.rb +73 -0
- data/features/step_definitions/commit_sales_order/all_shipments.rb +15 -0
- data/features/step_definitions/compliance_check/available_product_steps.rb +175 -0
- data/features/step_definitions/compliance_check/missing_product_steps.rb +102 -0
- data/features/step_definitions/compliance_check/noncompliant_product.rb +102 -0
- data/features/step_definitions/credential_steps.rb +8 -0
- data/features/step_definitions/inventory_steps.rb +36 -0
- data/features/step_definitions/product_steps.rb +140 -0
- data/features/step_definitions/sales_order_extended_steps.rb +79 -0
- data/features/step_definitions/search_order_steps.rb +87 -0
- data/features/step_definitions/void_order_steps.rb +27 -0
- data/features/support/env.rb +14 -0
- data/features/void_sales_order.feature +11 -0
- data/fixtures/vcr_cassettes/brand_already_exists.yml +1038 -0
- data/fixtures/vcr_cassettes/brand_ignore_existing.yml +1037 -0
- data/fixtures/vcr_cassettes/brand_update_existing.yml +1037 -0
- data/fixtures/vcr_cassettes/brand_valid.yml +1037 -0
- data/fixtures/vcr_cassettes/commit_salesorder_all_shipments.yml +1034 -0
- data/fixtures/vcr_cassettes/compliance_available_product.yml +1075 -0
- data/fixtures/vcr_cassettes/compliance_missing_product.yml +1046 -0
- data/fixtures/vcr_cassettes/compliance_noncompliant_product.yml +1082 -0
- data/fixtures/vcr_cassettes/ignore_existing_product.yml +1035 -0
- data/fixtures/vcr_cassettes/invalid_search_sales_orders.yml +1038 -0
- data/fixtures/vcr_cassettes/inventory_details_for_everything.yml +1037 -0
- data/fixtures/vcr_cassettes/product_already_exists.yml +1036 -0
- data/fixtures/vcr_cassettes/product_invalid_brand.yml +1036 -0
- data/fixtures/vcr_cassettes/product_valid_brand.yml +1035 -0
- data/fixtures/vcr_cassettes/sales_order_extended.yml +1042 -0
- data/fixtures/vcr_cassettes/sales_order_missing.yml +1034 -0
- data/fixtures/vcr_cassettes/search_sales_orders.yml +1039 -0
- data/fixtures/vcr_cassettes/update_product.yml +1035 -0
- data/fixtures/vcr_cassettes/void_order.yml +1033 -0
- data/fixtures/vcr_cassettes/void_voided_order.yml +1034 -0
- data/lib/ship_compliant.rb +62 -0
- data/lib/ship_compliant/add_update_brand.rb +50 -0
- data/lib/ship_compliant/add_update_brand_result.rb +6 -0
- data/lib/ship_compliant/add_update_product.rb +66 -0
- data/lib/ship_compliant/add_update_product_result.rb +6 -0
- data/lib/ship_compliant/address.rb +87 -0
- data/lib/ship_compliant/address/suggested_address.rb +37 -0
- data/lib/ship_compliant/base_result.rb +43 -0
- data/lib/ship_compliant/channel_details.rb +31 -0
- data/lib/ship_compliant/check_compliance.rb +41 -0
- data/lib/ship_compliant/check_compliance_result.rb +95 -0
- data/lib/ship_compliant/client.rb +54 -0
- data/lib/ship_compliant/commit_sales_order.rb +48 -0
- data/lib/ship_compliant/commit_sales_order_result.rb +30 -0
- data/lib/ship_compliant/compliance_rule.rb +30 -0
- data/lib/ship_compliant/configuration.rb +46 -0
- data/lib/ship_compliant/error_result.rb +41 -0
- data/lib/ship_compliant/freight_sales_tax_rate.rb +8 -0
- data/lib/ship_compliant/get_inventory_details.rb +31 -0
- data/lib/ship_compliant/get_inventory_details_result.rb +41 -0
- data/lib/ship_compliant/get_sales_order_extended.rb +23 -0
- data/lib/ship_compliant/get_sales_order_extended_result.rb +65 -0
- data/lib/ship_compliant/inventory_product.rb +95 -0
- data/lib/ship_compliant/order_search.rb +92 -0
- data/lib/ship_compliant/package.rb +13 -0
- data/lib/ship_compliant/product_attributes.rb +98 -0
- data/lib/ship_compliant/product_sales_tax_rate.rb +23 -0
- data/lib/ship_compliant/sales_tax_rate.rb +22 -0
- data/lib/ship_compliant/search_sales_order_summary.rb +30 -0
- data/lib/ship_compliant/search_sales_orders.rb +53 -0
- data/lib/ship_compliant/search_sales_orders_result.rb +106 -0
- data/lib/ship_compliant/shipment.rb +59 -0
- data/lib/ship_compliant/shipment_compliance.rb +28 -0
- data/lib/ship_compliant/shipment_sales_tax_rate.rb +15 -0
- data/lib/ship_compliant/version.rb +3 -0
- data/lib/ship_compliant/void_sales_order.rb +42 -0
- data/lib/ship_compliant/void_sales_order_result.rb +20 -0
- data/ship_compliant.gemspec +33 -0
- data/spec/fixtures/add_update_product.xml +22 -0
- data/spec/fixtures/check_compliance.xml +125 -0
- data/spec/fixtures/coreservice.wsdl +1341 -0
- data/spec/fixtures/search_sales_orders.xml +52 -0
- data/spec/fixtures/void_order_failure.xml +31 -0
- data/spec/fixtures/void_order_success.xml +22 -0
- data/spec/lib/ship_compliant/add_update_brand_result_spec.rb +7 -0
- data/spec/lib/ship_compliant/add_update_brand_spec.rb +58 -0
- data/spec/lib/ship_compliant/add_update_product_result_spec.rb +7 -0
- data/spec/lib/ship_compliant/add_update_product_spec.rb +52 -0
- data/spec/lib/ship_compliant/address/suggested_address_spec.rb +28 -0
- data/spec/lib/ship_compliant/address_spec.rb +123 -0
- data/spec/lib/ship_compliant/base_result_spec.rb +127 -0
- data/spec/lib/ship_compliant/channel_details_spec.rb +40 -0
- data/spec/lib/ship_compliant/check_compliance_result_spec.rb +135 -0
- data/spec/lib/ship_compliant/check_compliance_spec.rb +43 -0
- data/spec/lib/ship_compliant/client_spec.rb +73 -0
- data/spec/lib/ship_compliant/commit_sales_order_result_spec.rb +32 -0
- data/spec/lib/ship_compliant/commit_sales_order_spec.rb +38 -0
- data/spec/lib/ship_compliant/compliance_rule_spec.rb +47 -0
- data/spec/lib/ship_compliant/configuration_spec.rb +47 -0
- data/spec/lib/ship_compliant/error_result_spec.rb +47 -0
- data/spec/lib/ship_compliant/freight_sales_tax_rate_spec.rb +7 -0
- data/spec/lib/ship_compliant/get_inventory_details_result_spec.rb +87 -0
- data/spec/lib/ship_compliant/get_inventory_details_spec.rb +35 -0
- data/spec/lib/ship_compliant/get_sales_order_extended_result_spec.rb +84 -0
- data/spec/lib/ship_compliant/get_sales_order_extended_spec.rb +39 -0
- data/spec/lib/ship_compliant/inventory_product_spec.rb +116 -0
- data/spec/lib/ship_compliant/order_search_spec.rb +21 -0
- data/spec/lib/ship_compliant/package_spec.rb +26 -0
- data/spec/lib/ship_compliant/product_attributes_spec.rb +36 -0
- data/spec/lib/ship_compliant/product_sales_tax_rate_spec.rb +22 -0
- data/spec/lib/ship_compliant/sales_tax_rate_spec.rb +21 -0
- data/spec/lib/ship_compliant/search_sales_order_summary_spec.rb +56 -0
- data/spec/lib/ship_compliant/search_sales_orders_result_spec.rb +121 -0
- data/spec/lib/ship_compliant/search_sales_orders_spec.rb +42 -0
- data/spec/lib/ship_compliant/shipment_compliance_spec.rb +46 -0
- data/spec/lib/ship_compliant/shipment_sales_tax_rate_spec.rb +20 -0
- data/spec/lib/ship_compliant/shipment_spec.rb +106 -0
- data/spec/lib/ship_compliant/void_sales_order_result_spec.rb +7 -0
- data/spec/lib/ship_compliant/void_sales_order_spec.rb +41 -0
- data/spec/spec_helper.rb +50 -0
- metadata +366 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
When(/^I check compliance with a missing product$/) do
|
2
|
+
VCR.use_cassette('compliance_missing_product') do
|
3
|
+
@compliance_status = ShipCompliant::CheckCompliance.of_sales_order({
|
4
|
+
'AddressOption' => {
|
5
|
+
'IgnoreStreetLevelErrors' => true,
|
6
|
+
'RejectIfAddressSuggested' => 'false'
|
7
|
+
},
|
8
|
+
'IncludeSalesTaxRates' => true,
|
9
|
+
'PersistOption' => 'Null',
|
10
|
+
'SalesOrder' => {
|
11
|
+
'BillTo' => {
|
12
|
+
'City' => 'Boulder',
|
13
|
+
'Company' => 'ShipCompliant',
|
14
|
+
'Country' => 'US',
|
15
|
+
'DateOfBirth' => DateTime.new(1987, 8, 6),
|
16
|
+
'Email' => 'emily@six88.com',
|
17
|
+
'FirstName' => 'Emily',
|
18
|
+
'LastName' => 'Sheehan',
|
19
|
+
'Phone' => '303-996-1626',
|
20
|
+
'State' => 'CO',
|
21
|
+
'Street1' => '1877 Broadway St',
|
22
|
+
'Street2' => 'SUITE 703',
|
23
|
+
'Zip1' => 80304
|
24
|
+
},
|
25
|
+
'CustomerKey' => 'd23c963b',
|
26
|
+
'Discounts' => nil,
|
27
|
+
'FulfillmentType' => 'Daily',
|
28
|
+
'OrderType' => 'Internet',
|
29
|
+
'Payments' => nil,
|
30
|
+
'PurchaseDate' => DateTime.new(2014, 3, 12),
|
31
|
+
'RegisterId' => 'cf3ee9',
|
32
|
+
'SalesOrderKey' => '1006891',
|
33
|
+
'SalesTaxCollected' => 0,
|
34
|
+
'Shipments' => {
|
35
|
+
'Shipment' => {
|
36
|
+
'Discounts' => nil,
|
37
|
+
'FulfillmentHouse' => 'InHouse',
|
38
|
+
'Handling' => 0,
|
39
|
+
'InsuredAmount' => 0,
|
40
|
+
'LicenseRelationship' => 'Default',
|
41
|
+
'Packages' => nil,
|
42
|
+
'ShipDate' => DateTime.new(2014, 3, 15),
|
43
|
+
'ShippingService' => 'UPS',
|
44
|
+
'ShipmentItems' => [
|
45
|
+
{
|
46
|
+
'ShipmentItem' => {
|
47
|
+
'BrandKey' => 'DEN',
|
48
|
+
'Discounts' => nil,
|
49
|
+
'ProductKey' => '04CHRCAB75',
|
50
|
+
'ProductQuantity' => 6,
|
51
|
+
'ProductUnitPrice' => 76
|
52
|
+
}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
'ShipmentItem' => {
|
56
|
+
'BrandKey' => 'DEN',
|
57
|
+
'Discounts' => nil,
|
58
|
+
'ProductKey' => 'Shoe',
|
59
|
+
'ProductQuantity' => 1,
|
60
|
+
'ProductUnitPrice' => 84.99
|
61
|
+
}
|
62
|
+
}
|
63
|
+
],
|
64
|
+
'ShipmentKey' => 1,
|
65
|
+
'ShipmentStatus' => 'SentToFulfillment',
|
66
|
+
'Shipping' => 15,
|
67
|
+
'ShipTo' => {
|
68
|
+
'City' => 'New York',
|
69
|
+
'Company' => nil,
|
70
|
+
'Country' => 'US',
|
71
|
+
'County' => nil,
|
72
|
+
'DateOfBirth' => DateTime.new(1987, 8, 6),
|
73
|
+
'Email' => 'emily@six88.com',
|
74
|
+
'Fax' => nil,
|
75
|
+
'FirstName' => 'Emily',
|
76
|
+
'LastName' => '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 a product key error$/) do
|
93
|
+
@compliance_status.failure?.should be_true
|
94
|
+
@compliance_status.error_count.should == 1
|
95
|
+
error = @compliance_status.errors.first
|
96
|
+
|
97
|
+
error.code.should == 201
|
98
|
+
error.key.should == '1'
|
99
|
+
error.message.should == 'Product matching given BrandKey/ProductKey does not exist [DEN,Shoe].'
|
100
|
+
error.target.should == 'Shipment'
|
101
|
+
error.type.should == 'Validation'
|
102
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
When(/^I check compliance with a non\-compliant product$/) do
|
2
|
+
VCR.use_cassette('compliance_noncompliant_product') do
|
3
|
+
@compliance_status = ShipCompliant::CheckCompliance.of_sales_order({
|
4
|
+
'AddressOption' => {
|
5
|
+
'IgnoreStreetLevelErrors' => true,
|
6
|
+
'RejectIfAddressSuggested' => 'false'
|
7
|
+
},
|
8
|
+
'IncludeSalesTaxRates' => true,
|
9
|
+
'PersistOption' => 'Null',
|
10
|
+
'SalesOrder' => {
|
11
|
+
'BillTo' => {
|
12
|
+
'City' => 'Boulder',
|
13
|
+
'Company' => 'ShipCompliant',
|
14
|
+
'Country' => 'US',
|
15
|
+
'DateOfBirth' => DateTime.new(1987, 8, 6),
|
16
|
+
'Email' => 'emily@six88.com',
|
17
|
+
'FirstName' => 'Emily',
|
18
|
+
'LastName' => 'Sheehan',
|
19
|
+
'Phone' => '303-996-1626',
|
20
|
+
'State' => 'CO',
|
21
|
+
'Street1' => '1877 Broadway St',
|
22
|
+
'Street2' => 'SUITE 703',
|
23
|
+
'Zip1' => 80304
|
24
|
+
},
|
25
|
+
'CustomerKey' => 'd23c963b',
|
26
|
+
'Discounts' => nil,
|
27
|
+
'FulfillmentType' => 'Daily',
|
28
|
+
'OrderType' => 'Internet',
|
29
|
+
'Payments' => nil,
|
30
|
+
'PurchaseDate' => DateTime.new(2014, 3, 12),
|
31
|
+
'RegisterId' => 'cf3ee9',
|
32
|
+
'SalesOrderKey' => '1006898',
|
33
|
+
'SalesTaxCollected' => 0,
|
34
|
+
'Shipments' => {
|
35
|
+
'Shipment' => {
|
36
|
+
'Discounts' => nil,
|
37
|
+
'FulfillmentHouse' => 'WineShipping',
|
38
|
+
'Handling' => 0,
|
39
|
+
'InsuredAmount' => 0,
|
40
|
+
'LicenseRelationship' => 'Default',
|
41
|
+
'Packages' => nil,
|
42
|
+
'ShipDate' => DateTime.new(2014, 3, 15),
|
43
|
+
'ShippingService' => 'UPS',
|
44
|
+
'ShipmentItems' => [
|
45
|
+
{
|
46
|
+
'ShipmentItem' => {
|
47
|
+
'BrandKey' => 'DEN',
|
48
|
+
'Discounts' => nil,
|
49
|
+
'ProductKey' => '09OTBC75',
|
50
|
+
'ProductQuantity' => 2,
|
51
|
+
'ProductUnitPrice' => 15.99
|
52
|
+
}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
'ShipmentItem' => {
|
56
|
+
'BrandKey' => 'DEN',
|
57
|
+
'Discounts' => nil,
|
58
|
+
'ProductKey' => 'SNFL13',
|
59
|
+
'ProductQuantity' => 2,
|
60
|
+
'ProductUnitPrice' => 22.99
|
61
|
+
}
|
62
|
+
}
|
63
|
+
],
|
64
|
+
'ShipmentKey' => 1,
|
65
|
+
'ShipmentStatus' => 'SentToFulfillment',
|
66
|
+
'Shipping' => 15,
|
67
|
+
'ShipTo' => {
|
68
|
+
'City' => 'Meridian',
|
69
|
+
'Company' => 'SMITH HOUSING',
|
70
|
+
'Country' => 'US',
|
71
|
+
'DateOfBirth' => DateTime.new(1987, 1, 1),
|
72
|
+
'Email' => 'bob.smith@smith.com',
|
73
|
+
'FirstName' => 'J Robert',
|
74
|
+
'LastName' => 'Love',
|
75
|
+
'Phone' => '770-551-0007',
|
76
|
+
'State' => 'ID',
|
77
|
+
'Street1' => '405 E Fairview Ave',
|
78
|
+
'Zip1' => 83642,
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
'Tags' => nil
|
83
|
+
}
|
84
|
+
})
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
Then(/^I should receive error messages$/) do
|
89
|
+
@compliance_status.compliant?.should be_false
|
90
|
+
shipment = @compliance_status.compliance_rules_for_shipment('1')
|
91
|
+
errors = shipment.rules.select { |r| !r.compliant? }
|
92
|
+
|
93
|
+
errors.map(&:rule_description).should == [
|
94
|
+
'Shipments to this region require an excise tax of $.45 per 1 gallon on offsite sales of wine due within 20 days after every month. For a summary of the taxes in the state, click here.',
|
95
|
+
'Shipments to this region for offsite sales require the following shipping label: Alcoholic Beverages - Cannot deliver to intoxicated persons.',
|
96
|
+
'Shipments to this region require sales tax for offsite sales shipments. For a summary of the taxes in the state, click here.',
|
97
|
+
'Shipments to this region have a per customer volume limit of 24 cases per individual per calendar year. The volume will be calculated from combined onsite and offsite sales.',
|
98
|
+
'A license is required for shipping offsite sales and must be renewed every 1 year. The cost of this license is $50.00. Note: Renewal fee is $25..',
|
99
|
+
'Suppliers shipping to this region must submit reporting data for offsite sales due within 1 month after every year. This region requires a periodic report even if no shipments have been made. The following information should be included within the report: ShipTo Name, ShipTo Address, BillTo Name, Type of Product (Eg: Wine, Sparkling Wine..), Volume of Product, Unit Price, Date of Purchase, Date of Shipment, Invoice Number. .',
|
100
|
+
'Only wines of your own production or bottling are allowed to be shipped to this region. Note: Authorized direct shipping includes "sales by a winery of wine produced or bottled by the winery."..'
|
101
|
+
]
|
102
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
When(/^I get inventory details with everthing$/) do
|
2
|
+
VCR.use_cassette('inventory_details_for_everything') do
|
3
|
+
@inventory_results = ShipCompliant::GetInventoryDetails.call({
|
4
|
+
brand_key: 'DEN',
|
5
|
+
fulfillment_location: 'WineShipping',
|
6
|
+
inventory_type: 'All',
|
7
|
+
product_key: '04CHRCAB75'
|
8
|
+
})
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Then(/^I should be able to get the product information$/) do
|
13
|
+
@inventory_results.products_for_location('WineShipping').should be_kind_of(Array)
|
14
|
+
@inventory_results.products_for_location('WineShipping').length.should == 1
|
15
|
+
product = @inventory_results.products_for_location('WineShipping').first
|
16
|
+
|
17
|
+
product.default_case.should == '12x750 mL'
|
18
|
+
product.description.should == 'Capital Hill Reserve Cabernet'
|
19
|
+
product.fulfillment_sku.should == '04CHRCAB75'
|
20
|
+
product.percent_alcohol.should == 13
|
21
|
+
product.product_key.should == '04CHRCAB75'
|
22
|
+
product.product_type.should == 'Wine'
|
23
|
+
product.unit_price.should == 0
|
24
|
+
product.vintage.should == 2011
|
25
|
+
product.volume_amount.should == 750
|
26
|
+
product.volume_ml.should == 750
|
27
|
+
product.volume_unit.should == 'Milliliter'
|
28
|
+
end
|
29
|
+
|
30
|
+
Then(/^I should inventory levels for a product$/) do
|
31
|
+
product = @inventory_results.products_for_location('WineShipping').first
|
32
|
+
product.inventory_levels.should == {
|
33
|
+
available: 25,
|
34
|
+
reserved: 25
|
35
|
+
}
|
36
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
When(/^I add a new product with invalid brand$/) do
|
2
|
+
VCR.use_cassette('product_invalid_brand') do
|
3
|
+
@product_response = ShipCompliant::AddUpdateProduct.product({
|
4
|
+
bottle_size_ms: 750,
|
5
|
+
brand_key: 'DENSNW',
|
6
|
+
default_case: 12,
|
7
|
+
default_wholesale_case_price: 270,
|
8
|
+
description: 'Denver Snow Flake Cab 2013',
|
9
|
+
percent_alcohol: 14.1,
|
10
|
+
product_distribution: 'Both',
|
11
|
+
product_key: 'SNFL13',
|
12
|
+
product_type: 'Wine',
|
13
|
+
unit_price: 49.99,
|
14
|
+
varietal: 'Cabernet Sauvignon',
|
15
|
+
vintage: 2013,
|
16
|
+
volume_amount: 750,
|
17
|
+
volume_unit: 'milliliter'
|
18
|
+
}, update_mode: 'ErrorOnExisting')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
When(/^I add a new product$/) do
|
23
|
+
VCR.use_cassette('product_valid_brand') do
|
24
|
+
@product_response = ShipCompliant::AddUpdateProduct.product({
|
25
|
+
bottle_size_ms: 750,
|
26
|
+
brand_key: 'DEN',
|
27
|
+
default_case: 12,
|
28
|
+
default_wholesale_case_price: 270,
|
29
|
+
description: 'Denver Snow Flake Cab 2013',
|
30
|
+
percent_alcohol: 14.1,
|
31
|
+
product_distribution: 'Both',
|
32
|
+
product_key: 'SNFL13',
|
33
|
+
product_type: 'Wine',
|
34
|
+
unit_price: 49.99,
|
35
|
+
varietal: 'Cabernet Sauvignon',
|
36
|
+
vintage: 2013,
|
37
|
+
volume_amount: 750,
|
38
|
+
volume_unit: 'milliliter'
|
39
|
+
}, update_mode: 'ErrorOnExisting')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
When(/^I add a product that already exists$/) do
|
44
|
+
VCR.use_cassette('product_already_exists') do
|
45
|
+
@product_response = ShipCompliant::AddUpdateProduct.product({
|
46
|
+
bottle_size_ms: 750,
|
47
|
+
brand_key: 'DEN',
|
48
|
+
default_case: 12,
|
49
|
+
default_wholesale_case_price: 270,
|
50
|
+
description: 'Denver Snow Flake Cab 2013',
|
51
|
+
percent_alcohol: 14.1,
|
52
|
+
product_distribution: 'Both',
|
53
|
+
product_key: 'SNFL13',
|
54
|
+
product_type: 'Wine',
|
55
|
+
unit_price: 49.99,
|
56
|
+
varietal: 'Cabernet Sauvignon',
|
57
|
+
vintage: 2013,
|
58
|
+
volume_amount: 750,
|
59
|
+
volume_unit: 'milliliter'
|
60
|
+
}, update_mode: 'ErrorOnExisting')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
When(/^I update a product$/) do
|
65
|
+
VCR.use_cassette('update_product') do
|
66
|
+
@product_response = ShipCompliant::AddUpdateProduct.product({
|
67
|
+
bottle_size_ms: 750,
|
68
|
+
brand_key: 'DEN',
|
69
|
+
default_case: 12,
|
70
|
+
default_wholesale_case_price: 270,
|
71
|
+
description: 'Denver Snow Flake Cab 2013',
|
72
|
+
percent_alcohol: 14.1,
|
73
|
+
product_distribution: 'Both',
|
74
|
+
product_key: 'SNFL13',
|
75
|
+
product_type: 'Wine',
|
76
|
+
unit_price: 49.99,
|
77
|
+
varietal: 'Cabernet Sauvignon',
|
78
|
+
vintage: 2013,
|
79
|
+
volume_amount: 750,
|
80
|
+
volume_unit: 'milliliter'
|
81
|
+
}, update_mode: 'UpdateExisting')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
When(/^I ignore existing product on update$/) do
|
86
|
+
VCR.use_cassette('ignore_existing_product') do
|
87
|
+
@product_response = ShipCompliant::AddUpdateProduct.product({
|
88
|
+
bottle_size_ms: 750,
|
89
|
+
brand_key: 'DEN',
|
90
|
+
default_case: 12,
|
91
|
+
default_wholesale_case_price: 270,
|
92
|
+
description: 'Denver Snow Flake Cab 2013',
|
93
|
+
percent_alcohol: 14.1,
|
94
|
+
product_distribution: 'Both',
|
95
|
+
product_key: 'SNFL13',
|
96
|
+
product_type: 'Wine',
|
97
|
+
unit_price: 49.99,
|
98
|
+
varietal: 'Cabernet Sauvignon',
|
99
|
+
vintage: 2013,
|
100
|
+
volume_amount: 750,
|
101
|
+
volume_unit: 'milliliter'
|
102
|
+
}, update_mode: 'IgnoreExisting')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
Then(/^the product should have been created$/) do
|
107
|
+
@product_response.success?.should be_true
|
108
|
+
end
|
109
|
+
|
110
|
+
Then(/^I should get a message that the product was updated$/) do
|
111
|
+
@product_response.success?.should be_true
|
112
|
+
end
|
113
|
+
|
114
|
+
Then(/^I should get an error message for the missing brand$/) do
|
115
|
+
product_response.failure?.should be_true
|
116
|
+
product_response.errors_count.should == 1
|
117
|
+
|
118
|
+
error = product_response.errors[0]
|
119
|
+
error.code.should == 100
|
120
|
+
error.key.should == 'SNFL13'
|
121
|
+
error.message.should == 'Brand does not exist [DENSNW].'
|
122
|
+
error.target.should == 'Product'
|
123
|
+
error.type.should == 'Validation'
|
124
|
+
end
|
125
|
+
|
126
|
+
Then(/^I should get an error for already defined product$/) do
|
127
|
+
product_response.failure?.should be_true
|
128
|
+
product_response.errors_count.should == 1
|
129
|
+
|
130
|
+
error = product_response.errors[0]
|
131
|
+
error.code.should == 2707
|
132
|
+
error.key.should == 'SNFL13'
|
133
|
+
error.message.should == 'Product already exists.'
|
134
|
+
error.target.should == 'Product'
|
135
|
+
error.type.should == 'Validation'
|
136
|
+
end
|
137
|
+
|
138
|
+
def product_response
|
139
|
+
@product_response #.to_hash[:add_update_product_response][:add_update_product_result]
|
140
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
When(/^I search for order information$/) do
|
2
|
+
VCR.use_cassette('sales_order_extended') do
|
3
|
+
@order_result = ShipCompliant::GetSalesOrderExtended.by_order_key('1006890')
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
When(/^I search for an invalid order$/) do
|
8
|
+
VCR.use_cassette('sales_order_missing') do
|
9
|
+
@order_result = ShipCompliant::GetSalesOrderExtended.by_order_key('order-404')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Then(/^I should receive shipment compliance statuses$/) do
|
14
|
+
shipment_compliance = @order_result.compliance_rules_for_shipment('1')
|
15
|
+
shipment_compliance.compliant?.should be_true
|
16
|
+
shipment_compliance.rules.should == []
|
17
|
+
end
|
18
|
+
|
19
|
+
Then(/^I should receive billing information$/) do
|
20
|
+
billing = @order_result.bill_to
|
21
|
+
billing.should be_kind_of(ShipCompliant::Address)
|
22
|
+
|
23
|
+
billing.city.should == 'St. Paul'
|
24
|
+
billing.company.should == 'SMITH HOUSING'
|
25
|
+
billing.country.should == 'US'
|
26
|
+
billing.county.should be_nil
|
27
|
+
billing.date_of_birth.should == DateTime.new(1987, 1, 1)
|
28
|
+
billing.email.should == 'bob.smith@smith.com'
|
29
|
+
billing.fax.should be_nil
|
30
|
+
billing.first_name.should == 'J Robert'
|
31
|
+
billing.last_name.should == 'Love'
|
32
|
+
billing.phone.should == '(770) 551-0007'
|
33
|
+
billing.state.should == 'MN'
|
34
|
+
billing.street1.should == '444 Cedar Street'
|
35
|
+
billing.street2.should be_nil
|
36
|
+
billing.zip1.should == 55101
|
37
|
+
billing.zip2.should be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
Then(/^I should receive shipment information$/) do
|
41
|
+
shipment = @order_result.find_shipment('1')
|
42
|
+
|
43
|
+
shipment.fulfillment_house.should == 'WineShipping'
|
44
|
+
shipment.fulfillment_exception_reason.should be_nil
|
45
|
+
shipment.fulfillment_exception_type.should == 'None'
|
46
|
+
shipment.fulfillment_status.should == 'Accepted'
|
47
|
+
|
48
|
+
shipment.handling.should == 0
|
49
|
+
shipment.insured_amount.should == 0
|
50
|
+
shipment.shipping.should == 30
|
51
|
+
|
52
|
+
shipment.ship_date.should == DateTime.new(2014, 2, 20, 20, 6)
|
53
|
+
shipment.shipment_status.should == 'Delivered'
|
54
|
+
shipment.shipping_service.should == 'UP2'
|
55
|
+
shipment.special_instructions.should be_nil
|
56
|
+
|
57
|
+
# Shipment Packages
|
58
|
+
package = shipment.packages.first
|
59
|
+
package.tracking_number.should == '1Z875F62A890362872'
|
60
|
+
package.tracking_status.should == 'Delivered'
|
61
|
+
|
62
|
+
# Ship To Address
|
63
|
+
shipment.ship_to.should be_kind_of(ShipCompliant::Address)
|
64
|
+
end
|
65
|
+
|
66
|
+
Then(/^I should receive order channel details$/) do
|
67
|
+
details = @order_result.channel_details
|
68
|
+
details.order_channel.should == 'MyOrders'
|
69
|
+
end
|
70
|
+
|
71
|
+
Then(/^I should receive an error that the order doesn't exist$/) do
|
72
|
+
@order_result.failure?.should be_true
|
73
|
+
error = @order_result.errors.first
|
74
|
+
|
75
|
+
error.code.should == 200
|
76
|
+
error.message.should == 'SalesOrder does not exist [order-404].'
|
77
|
+
error.target.should == 'Null'
|
78
|
+
error.type.should == 'Validation'
|
79
|
+
end
|