secondrotation-channel_advisor 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/README +3 -0
  2. data/lib/channel_advisor.rb +8 -0
  3. data/lib/channel_advisor/auth_handler.rb +21 -0
  4. data/lib/channel_advisor/cart_service.rb +4 -0
  5. data/lib/channel_advisor/cart_service/client.rb +79 -0
  6. data/lib/channel_advisor/cart_service/mapping_registry.rb +344 -0
  7. data/lib/channel_advisor/cart_service/types.rb +385 -0
  8. data/lib/channel_advisor/errors.rb +10 -0
  9. data/lib/channel_advisor/inventory_service.rb +42 -0
  10. data/lib/channel_advisor/inventory_service/client.rb +199 -0
  11. data/lib/channel_advisor/inventory_service/mapping_registry.rb +1651 -0
  12. data/lib/channel_advisor/inventory_service/types.rb +1544 -0
  13. data/lib/channel_advisor/marketplace_ad_service.rb +4 -0
  14. data/lib/channel_advisor/marketplace_ad_service/client.rb +71 -0
  15. data/lib/channel_advisor/marketplace_ad_service/mapping_registry.rb +334 -0
  16. data/lib/channel_advisor/marketplace_ad_service/types.rb +317 -0
  17. data/lib/channel_advisor/message_code.rb +30 -0
  18. data/lib/channel_advisor/order_service.rb +4 -0
  19. data/lib/channel_advisor/order_service/client.rb +87 -0
  20. data/lib/channel_advisor/order_service/mapping_registry.rb +1356 -0
  21. data/lib/channel_advisor/order_service/types.rb +1422 -0
  22. data/lib/channel_advisor/shared_requires.rb +10 -0
  23. data/lib/channel_advisor/shipping_service.rb +4 -0
  24. data/lib/channel_advisor/shipping_service/client.rb +71 -0
  25. data/lib/channel_advisor/shipping_service/mapping_registry.rb +309 -0
  26. data/lib/channel_advisor/shipping_service/types.rb +280 -0
  27. data/lib/channel_advisor/store_service.rb +4 -0
  28. data/lib/channel_advisor/store_service/client.rb +55 -0
  29. data/lib/channel_advisor/store_service/mapping_registry.rb +250 -0
  30. data/lib/channel_advisor/store_service/types.rb +180 -0
  31. data/lib/channel_advisor/tax_service.rb +4 -0
  32. data/lib/channel_advisor/tax_service/client.rb +55 -0
  33. data/lib/channel_advisor/tax_service/mapping_registry.rb +233 -0
  34. data/lib/channel_advisor/tax_service/types.rb +221 -0
  35. data/test/lib/channel_advisor/auth_handler_spec.rb +46 -0
  36. data/test/lib/channel_advisor/inventory_service_spec.rb +62 -0
  37. data/test/lib/channel_advisor/message_code_spec.rb +40 -0
  38. data/test/spec.opts +2 -0
  39. data/test/spec_helper.rb +4 -0
  40. metadata +117 -0
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe ChannelAdvisor::AuthHandler do
4
+ before(:each) do
5
+ configatron.channel_advisor.developer_key = 'test_developer_key'
6
+ configatron.channel_advisor.password = 'test_password'
7
+ end
8
+
9
+ it "uses configatron for the authentication keys" do
10
+ auth = ChannelAdvisor::AuthHandler.new
11
+
12
+ auth.developer_key.should == 'test_developer_key'
13
+ auth.password.should == 'test_password'
14
+ end
15
+
16
+ it "uses values in the constructor if supplied" do
17
+ auth = ChannelAdvisor::AuthHandler.new('blurb', 'drab')
18
+
19
+ auth.developer_key.should == 'blurb'
20
+ auth.password.should == 'drab'
21
+ end
22
+
23
+ it "sets up the key and password for outbound requests" do
24
+ auth = ChannelAdvisor::AuthHandler.new('blurb', 'drab')
25
+
26
+ credentials = auth.on_simple_outbound
27
+ credentials[ChannelAdvisor::AuthHandler::DEVELOPER_KEY].should == 'blurb'
28
+ credentials[ChannelAdvisor::AuthHandler::PASSWORD].should == 'drab'
29
+ end
30
+
31
+ it "sets up the qname for the auth header element" do
32
+ auth = ChannelAdvisor::AuthHandler.new('blurb', 'drab')
33
+ auth.elename.should == ChannelAdvisor::AuthHandler::API_CREDENTIALS
34
+ end
35
+
36
+ it "sets up qnames for api credentials" do
37
+ ChannelAdvisor::AuthHandler::API_CREDENTIALS.namespace.should == 'http://api.channeladvisor.com/webservices/'
38
+ ChannelAdvisor::AuthHandler::API_CREDENTIALS.name.should == 'APICredentials'
39
+
40
+ ChannelAdvisor::AuthHandler::DEVELOPER_KEY.namespace.should == 'http://api.channeladvisor.com/webservices/'
41
+ ChannelAdvisor::AuthHandler::DEVELOPER_KEY.name.should == 'DeveloperKey'
42
+
43
+ ChannelAdvisor::AuthHandler::PASSWORD.namespace.should == 'http://api.channeladvisor.com/webservices/'
44
+ ChannelAdvisor::AuthHandler::PASSWORD.name.should == 'Password'
45
+ end
46
+ end
@@ -0,0 +1,62 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe ChannelAdvisor::InventoryService do
4
+ before(:each) do
5
+ configatron.channel_advisor.account_id = 'test_account_id'
6
+ @client = mock(ChannelAdvisor::InventoryServiceSOAP::InventoryServiceSoap)
7
+ @client.should_receive(:headerhandler).and_return([])
8
+ ChannelAdvisor::InventoryServiceSOAP::InventoryServiceSoap.should_receive(:new).and_return(@client)
9
+ end
10
+
11
+ describe "generated methods" do
12
+ it "handles getFilteredSkuList request" do
13
+ criteria = ChannelAdvisor::InventoryServiceSOAP::InventoryItemCriteria.new
14
+ criteria.skuStartsWith = 'SR123'
15
+ criteria.pageNumber = 1
16
+ criteria.pageSize = 10
17
+
18
+ request = mock(ChannelAdvisor::InventoryServiceSOAP::GetFilteredSkuList)
19
+ ChannelAdvisor::InventoryServiceSOAP::GetFilteredSkuList.should_receive(:new).with(
20
+ configatron.channel_advisor.account_id, criteria
21
+ ).and_return(request)
22
+
23
+ expected_result = ['SR123', 'SR321']
24
+
25
+ mock_result = mock(Object)
26
+ mock_result.should_receive(:status).and_return('Success')
27
+ mock_result.should_receive(:resultData).and_return(expected_result)
28
+
29
+ response = mock(ChannelAdvisor::InventoryServiceSOAP::GetFilteredSkuListResponse)
30
+ response.should_receive(:getFilteredSkuListResult).and_return(mock_result)
31
+
32
+ @client.should_receive(:getFilteredSkuList).with(request).and_return(response)
33
+
34
+ inventory = ChannelAdvisor::InventoryService.new
35
+ result = inventory.getFilteredSkuList(criteria)
36
+ result.should == expected_result
37
+ end
38
+
39
+ it "raises an error the result is not Success" do
40
+ request = mock(ChannelAdvisor::InventoryServiceSOAP::GetFilteredSkuList)
41
+ ChannelAdvisor::InventoryServiceSOAP::GetFilteredSkuList.stub!(:new).and_return(request)
42
+
43
+ mock_result = mock(Object)
44
+ mock_result.should_receive(:status).and_return('Failure')
45
+ mock_result.should_receive(:messageCode).and_return(ChannelAdvisor::MessageCode::Unexpected.code)
46
+
47
+ response = mock(ChannelAdvisor::InventoryServiceSOAP::GetFilteredSkuListResponse)
48
+ response.should_receive(:getFilteredSkuListResult).and_return(mock_result)
49
+
50
+ @client.should_receive(:getFilteredSkuList).with(request).and_return(response)
51
+
52
+ begin
53
+ inventory = ChannelAdvisor::InventoryService.new
54
+ inventory.getFilteredSkuList
55
+ fail('Expected an exception')
56
+ rescue ChannelAdvisor::Error => e
57
+ e.message_code.should == ChannelAdvisor::MessageCode::Unexpected
58
+ end
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe ChannelAdvisor::MessageCode do
4
+ it "defines known message codes" do
5
+ message_code = ChannelAdvisor::MessageCode.get(0)
6
+ message_code.code.should == 0
7
+ message_code.message.should == 'Success'
8
+
9
+ message_code = ChannelAdvisor::MessageCode.get(1)
10
+ message_code.code.should == 1
11
+ message_code.message.should == 'Unexpected'
12
+
13
+ message_code = ChannelAdvisor::MessageCode.get(3)
14
+ message_code.code.should == 3
15
+ message_code.message.should == 'No Account ID value was specified'
16
+
17
+ message_code = ChannelAdvisor::MessageCode.get(5)
18
+ message_code.code.should == 5
19
+ message_code.message.should == 'No Sku value was specified'
20
+
21
+ message_code = ChannelAdvisor::MessageCode.get(8)
22
+ message_code.code.should == 8
23
+ message_code.message.should == 'The number of Sku values specified was greater than the maximum amount allowed by the method definition'
24
+ end
25
+
26
+ it "accepts codes as strings" do
27
+ message_code = ChannelAdvisor::MessageCode.get('0')
28
+ message_code.code.should == 0
29
+ end
30
+
31
+ it "raises an error if the code is unknown" do
32
+ lambda {
33
+ ChannelAdvisor::MessageCode.get('49')
34
+ }.should raise_error(ArgumentError, 'Unknown code: 49')
35
+ end
36
+
37
+ it "uses the class values for get" do
38
+ ChannelAdvisor::MessageCode.get(0).should == ChannelAdvisor::MessageCode::Success
39
+ end
40
+ end
data/test/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --format specdoc
2
+ --colour
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'channel_advisor')
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: secondrotation-channel_advisor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Second Rotation, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-26 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: soap4r
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.8
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: configatron
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 2.0.0
32
+ version:
33
+ description: "channel_advisor was developed by: Second Rotation, Inc."
34
+ email: jason@secondrotation.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README
41
+ files:
42
+ - lib/channel_advisor/auth_handler.rb
43
+ - lib/channel_advisor/cart_service/client.rb
44
+ - lib/channel_advisor/cart_service/mapping_registry.rb
45
+ - lib/channel_advisor/cart_service/types.rb
46
+ - lib/channel_advisor/cart_service.rb
47
+ - lib/channel_advisor/errors.rb
48
+ - lib/channel_advisor/inventory_service/client.rb
49
+ - lib/channel_advisor/inventory_service/mapping_registry.rb
50
+ - lib/channel_advisor/inventory_service/types.rb
51
+ - lib/channel_advisor/inventory_service.rb
52
+ - lib/channel_advisor/marketplace_ad_service/client.rb
53
+ - lib/channel_advisor/marketplace_ad_service/mapping_registry.rb
54
+ - lib/channel_advisor/marketplace_ad_service/types.rb
55
+ - lib/channel_advisor/marketplace_ad_service.rb
56
+ - lib/channel_advisor/message_code.rb
57
+ - lib/channel_advisor/order_service/client.rb
58
+ - lib/channel_advisor/order_service/mapping_registry.rb
59
+ - lib/channel_advisor/order_service/types.rb
60
+ - lib/channel_advisor/order_service.rb
61
+ - lib/channel_advisor/shared_requires.rb
62
+ - lib/channel_advisor/shipping_service/client.rb
63
+ - lib/channel_advisor/shipping_service/mapping_registry.rb
64
+ - lib/channel_advisor/shipping_service/types.rb
65
+ - lib/channel_advisor/shipping_service.rb
66
+ - lib/channel_advisor/store_service/client.rb
67
+ - lib/channel_advisor/store_service/mapping_registry.rb
68
+ - lib/channel_advisor/store_service/types.rb
69
+ - lib/channel_advisor/store_service.rb
70
+ - lib/channel_advisor/tax_service/client.rb
71
+ - lib/channel_advisor/tax_service/mapping_registry.rb
72
+ - lib/channel_advisor/tax_service/types.rb
73
+ - lib/channel_advisor/tax_service.rb
74
+ - lib/channel_advisor.rb
75
+ - README
76
+ - test/lib
77
+ - test/lib/channel_advisor
78
+ - test/lib/channel_advisor/auth_handler_spec.rb
79
+ - test/lib/channel_advisor/inventory_service_spec.rb
80
+ - test/lib/channel_advisor/message_code_spec.rb
81
+ - test/spec.opts
82
+ - test/spec_helper.rb
83
+ has_rdoc: true
84
+ homepage: http://github.com/secondrotation/channel_advisor/
85
+ post_install_message:
86
+ rdoc_options: []
87
+
88
+ require_paths:
89
+ - lib
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ version:
103
+ requirements: []
104
+
105
+ rubyforge_project: channel_advisor
106
+ rubygems_version: 1.2.0
107
+ signing_key:
108
+ specification_version: 2
109
+ summary: channel_advisor
110
+ test_files:
111
+ - test/lib
112
+ - test/lib/channel_advisor
113
+ - test/lib/channel_advisor/auth_handler_spec.rb
114
+ - test/lib/channel_advisor/inventory_service_spec.rb
115
+ - test/lib/channel_advisor/message_code_spec.rb
116
+ - test/spec.opts
117
+ - test/spec_helper.rb