channeladvisor 0.1.0

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 (205) hide show
  1. data/.gitignore +7 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +6 -0
  4. data/.yardopts +8 -0
  5. data/Gemfile +31 -0
  6. data/Guardfile +28 -0
  7. data/LICENSE +19 -0
  8. data/README.md +40 -0
  9. data/Rakefile +69 -0
  10. data/channeladvisor.gemspec +29 -0
  11. data/lib/channeladvisor.rb +27 -0
  12. data/lib/channeladvisor/account_authorization.rb +14 -0
  13. data/lib/channeladvisor/address.rb +39 -0
  14. data/lib/channeladvisor/admin.rb +75 -0
  15. data/lib/channeladvisor/base.rb +34 -0
  16. data/lib/channeladvisor/client.rb +3 -0
  17. data/lib/channeladvisor/configuration.rb +11 -0
  18. data/lib/channeladvisor/error.rb +30 -0
  19. data/lib/channeladvisor/line_item.rb +38 -0
  20. data/lib/channeladvisor/order.rb +179 -0
  21. data/lib/channeladvisor/order_status.rb +14 -0
  22. data/lib/channeladvisor/payment.rb +15 -0
  23. data/lib/channeladvisor/services.rb +11 -0
  24. data/lib/channeladvisor/services/admin_service.rb +47 -0
  25. data/lib/channeladvisor/services/base_service.rb +26 -0
  26. data/lib/channeladvisor/services/inventory_service.rb +90 -0
  27. data/lib/channeladvisor/services/order_service.rb +117 -0
  28. data/lib/channeladvisor/services/shipping_service.rb +164 -0
  29. data/lib/channeladvisor/shipment.rb +71 -0
  30. data/lib/channeladvisor/shopping_cart.rb +26 -0
  31. data/lib/channeladvisor/version.rb +3 -0
  32. data/spec/fixtures/requests/admin_service/get_authorization_list.xml +1 -0
  33. data/spec/fixtures/requests/admin_service/get_authorization_list_with_local_id.xml +1 -0
  34. data/spec/fixtures/requests/admin_service/ping.xml +1 -0
  35. data/spec/fixtures/requests/admin_service/request_access.xml +1 -0
  36. data/spec/fixtures/requests/inventory_service/ping.xml +1 -0
  37. data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/price_only.xml +1 -0
  38. data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_and_price.xml +1 -0
  39. data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_only.xml +1 -0
  40. data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/price_only.xml +1 -0
  41. data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_and_price.xml +1 -0
  42. data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_only.xml +1 -0
  43. data/spec/fixtures/requests/inventory_service/update_item_price.xml +1 -0
  44. data/spec/fixtures/requests/inventory_service/update_item_quantity.xml +1 -0
  45. data/spec/fixtures/requests/inventory_service/update_item_quantity_and_price.xml +1 -0
  46. data/spec/fixtures/requests/order_service/get_order_list/with_checkout_status_filter.xml +1 -0
  47. data/spec/fixtures/requests/order_service/get_order_list/with_created_from_date.xml +1 -0
  48. data/spec/fixtures/requests/order_service/get_order_list/with_created_to_date.xml +1 -0
  49. data/spec/fixtures/requests/order_service/get_order_list/with_detail_level.xml +1 -0
  50. data/spec/fixtures/requests/order_service/get_order_list/with_distribution_center_code.xml +1 -0
  51. data/spec/fixtures/requests/order_service/get_order_list/with_export_state.xml +1 -0
  52. data/spec/fixtures/requests/order_service/get_order_list/with_join_dates.xml +1 -0
  53. data/spec/fixtures/requests/order_service/get_order_list/with_one_client_order_id.xml +1 -0
  54. data/spec/fixtures/requests/order_service/get_order_list/with_one_order_id.xml +1 -0
  55. data/spec/fixtures/requests/order_service/get_order_list/with_order_state_filter.xml +1 -0
  56. data/spec/fixtures/requests/order_service/get_order_list/with_page_number_filter.xml +1 -0
  57. data/spec/fixtures/requests/order_service/get_order_list/with_page_size.xml +1 -0
  58. data/spec/fixtures/requests/order_service/get_order_list/with_payment_status_filter.xml +1 -0
  59. data/spec/fixtures/requests/order_service/get_order_list/with_refund_status_filter.xml +1 -0
  60. data/spec/fixtures/requests/order_service/get_order_list/with_shipping_status_filter.xml +1 -0
  61. data/spec/fixtures/requests/order_service/get_order_list/with_two_client_order_ids.xml +1 -0
  62. data/spec/fixtures/requests/order_service/get_order_list/with_two_order_ids.xml +1 -0
  63. data/spec/fixtures/requests/order_service/get_order_list/with_updated_from_date.xml +1 -0
  64. data/spec/fixtures/requests/order_service/get_order_list/with_updated_to_date.xml +1 -0
  65. data/spec/fixtures/requests/order_service/get_order_list/without_order_criteria.xml +1 -0
  66. data/spec/fixtures/requests/order_service/ping.xml +1 -0
  67. data/spec/fixtures/requests/order_service/set_orders_export_status/with_one_client_order_id.xml +1 -0
  68. data/spec/fixtures/requests/order_service/set_orders_export_status/with_two_client_order_ids.xml +1 -0
  69. data/spec/fixtures/requests/shipping_service/get_shipping_carrier_list.xml +1 -0
  70. data/spec/fixtures/requests/shipping_service/ping.xml +1 -0
  71. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/with_one_shipment.xml +1 -0
  72. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/with_two_shipments.xml +1 -0
  73. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_carrier_code.xml +1 -0
  74. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_class_code.xml +1 -0
  75. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_client_order_id.xml +1 -0
  76. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_seller_id.xml +1 -0
  77. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_tracking_number.xml +1 -0
  78. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/with_one_line_item.xml +1 -0
  79. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/with_two_line_items.xml +1 -0
  80. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/with_two_shipments.xml +1 -0
  81. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_carrier_code.xml +1 -0
  82. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_class_code.xml +1 -0
  83. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_seller_id.xml +1 -0
  84. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_tracking_number.xml +1 -0
  85. data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/with_partial_and_full_shipments.xml +1 -0
  86. data/spec/fixtures/responses/admin/get_authorization_list/failure.yml +50 -0
  87. data/spec/fixtures/responses/admin/get_authorization_list/no_authorizations.yml +49 -0
  88. data/spec/fixtures/responses/admin/get_authorization_list/one_authorization.yml +49 -0
  89. data/spec/fixtures/responses/admin/get_authorization_list/success.yml +49 -0
  90. data/spec/fixtures/responses/admin/get_authorization_list/two_authorizations.yml +49 -0
  91. data/spec/fixtures/responses/admin/ping/failure.yml +50 -0
  92. data/spec/fixtures/responses/admin/ping/success.yml +218 -0
  93. data/spec/fixtures/responses/admin/request_access/failure.yml +50 -0
  94. data/spec/fixtures/responses/admin/request_access/success.yml +49 -0
  95. data/spec/fixtures/responses/admin_service/get_authorization_list/with_invalid_local_id.yml +219 -0
  96. data/spec/fixtures/responses/admin_service/get_authorization_list/with_local_id/success.yml +218 -0
  97. data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/multiple_authorizations.yml +49 -0
  98. data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/no_authorizations.yml +49 -0
  99. data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/one_authorization.yml +49 -0
  100. data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/success.yml +218 -0
  101. data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/multiple_authorizations.yml +49 -0
  102. data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/no_authorizations.yml +49 -0
  103. data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/one_authorization.yml +49 -0
  104. data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/success.yml +218 -0
  105. data/spec/fixtures/responses/admin_service/ping/failure.yml +222 -0
  106. data/spec/fixtures/responses/admin_service/ping/success.yml +218 -0
  107. data/spec/fixtures/responses/admin_service/request_access/failure.yml +219 -0
  108. data/spec/fixtures/responses/admin_service/request_access/success.yml +218 -0
  109. data/spec/fixtures/responses/http_error.yml +48 -0
  110. data/spec/fixtures/responses/inventory_service/ping.yml +1356 -0
  111. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price.yml +1356 -0
  112. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price/price_only.yml +144 -0
  113. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price/quantity_and_price.yml +191 -0
  114. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price/quantity_only.yml +1403 -0
  115. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list.yml +243 -0
  116. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/price_only.yml +97 -0
  117. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_and_price.yml +144 -0
  118. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_only.yml +51 -0
  119. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/price_only.yml +238 -0
  120. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_and_price.yml +285 -0
  121. data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_only.yml +191 -0
  122. data/spec/fixtures/responses/order/instance_set_export_status.yml +51 -0
  123. data/spec/fixtures/responses/order/instance_set_export_status/failure.yml +51 -0
  124. data/spec/fixtures/responses/order/instance_set_export_status/success/result_false.yml +51 -0
  125. data/spec/fixtures/responses/order/instance_set_export_status/success/result_true.yml +51 -0
  126. data/spec/fixtures/responses/order/list.yml +58 -0
  127. data/spec/fixtures/responses/order/list/failure.yml +56 -0
  128. data/spec/fixtures/responses/order/list/no_matching_orders.yml +56 -0
  129. data/spec/fixtures/responses/order/list/one_matching_order.yml +57 -0
  130. data/spec/fixtures/responses/order/list/two_matching_orders.yml +59 -0
  131. data/spec/fixtures/responses/order/list/with_criteria.yml +52 -0
  132. data/spec/fixtures/responses/order/list/with_no_criteria.yml +58 -0
  133. data/spec/fixtures/responses/order/ping.yml +868 -0
  134. data/spec/fixtures/responses/order/ping/failure.yml +50 -0
  135. data/spec/fixtures/responses/order/ping/success.yml +867 -0
  136. data/spec/fixtures/responses/order/set_export_status/failure.yml +51 -0
  137. data/spec/fixtures/responses/order/set_export_status/success/with_one_client_order_id.yml +51 -0
  138. data/spec/fixtures/responses/order/set_export_status/success/with_two_client_order_ids.yml +51 -0
  139. data/spec/fixtures/responses/order_service/get_order_list/.gitkeep +0 -0
  140. data/spec/fixtures/responses/order_service/get_order_list/with_checkout_status_filter.yml +875 -0
  141. data/spec/fixtures/responses/order_service/get_order_list/with_created_from_date.yml +874 -0
  142. data/spec/fixtures/responses/order_service/get_order_list/with_created_to_date.yml +874 -0
  143. data/spec/fixtures/responses/order_service/get_order_list/with_detail_level.yml +875 -0
  144. data/spec/fixtures/responses/order_service/get_order_list/with_distribution_center_code.yml +872 -0
  145. data/spec/fixtures/responses/order_service/get_order_list/with_export_state.yml +875 -0
  146. data/spec/fixtures/responses/order_service/get_order_list/with_join_dates.yml +869 -0
  147. data/spec/fixtures/responses/order_service/get_order_list/with_one_client_order_id.yml +872 -0
  148. data/spec/fixtures/responses/order_service/get_order_list/with_one_order_id.yml +873 -0
  149. data/spec/fixtures/responses/order_service/get_order_list/with_order_state_filter.yml +875 -0
  150. data/spec/fixtures/responses/order_service/get_order_list/with_page_number_filter.yml +875 -0
  151. data/spec/fixtures/responses/order_service/get_order_list/with_page_size.yml +874 -0
  152. data/spec/fixtures/responses/order_service/get_order_list/with_payment_status_filter.yml +875 -0
  153. data/spec/fixtures/responses/order_service/get_order_list/with_refund_status_filter.yml +875 -0
  154. data/spec/fixtures/responses/order_service/get_order_list/with_shipping_status_filter.yml +875 -0
  155. data/spec/fixtures/responses/order_service/get_order_list/with_two_client_order_ids.yml +872 -0
  156. data/spec/fixtures/responses/order_service/get_order_list/with_two_order_ids.yml +875 -0
  157. data/spec/fixtures/responses/order_service/get_order_list/with_updated_from_date.yml +874 -0
  158. data/spec/fixtures/responses/order_service/get_order_list/with_updated_to_date.yml +874 -0
  159. data/spec/fixtures/responses/order_service/get_order_list/without_order_criteria.yml +871 -0
  160. data/spec/fixtures/responses/order_service/get_order_refund_history/.gitkeep +0 -0
  161. data/spec/fixtures/responses/order_service/order_merge/.gitkeep +0 -0
  162. data/spec/fixtures/responses/order_service/order_split/.gitkeep +0 -0
  163. data/spec/fixtures/responses/order_service/ping/.gitkeep +0 -0
  164. data/spec/fixtures/responses/order_service/ping/failure.yml +871 -0
  165. data/spec/fixtures/responses/order_service/ping/success.yml +868 -0
  166. data/spec/fixtures/responses/order_service/set_orders_export_status/with_one_client_order_id.yml +867 -0
  167. data/spec/fixtures/responses/order_service/set_orders_export_status/with_two_client_order_id.yml +867 -0
  168. data/spec/fixtures/responses/order_service/set_seller_order_id/.gitkeep +0 -0
  169. data/spec/fixtures/responses/order_service/set_seller_order_item_id_list/.gitkeep +0 -0
  170. data/spec/fixtures/responses/order_service/submit_order/.gitkeep +0 -0
  171. data/spec/fixtures/responses/order_service/submit_order_refund/.gitkeep +0 -0
  172. data/spec/fixtures/responses/order_service/update_order_list/.gitkeep +0 -0
  173. data/spec/fixtures/responses/shipment/get_carriers.yml +53 -0
  174. data/spec/fixtures/responses/shipment/get_carriers/failure.yml +52 -0
  175. data/spec/fixtures/responses/shipment/submit.yml +464 -0
  176. data/spec/fixtures/responses/shipment/submit/failure.yml +462 -0
  177. data/spec/fixtures/responses/shipment/submit/one_shipment.yml +464 -0
  178. data/spec/fixtures/responses/shipment/submit/two_shipments.yml +56 -0
  179. data/spec/fixtures/responses/shipping_service/get_shipping_carrier_list.yml +953 -0
  180. data/spec/fixtures/responses/shipping_service/ping/failure.yml +55 -0
  181. data/spec/fixtures/responses/shipping_service/ping/success.yml +460 -0
  182. data/spec/fixtures/responses/shipping_service/submit_order_shipment_list.yml +55 -0
  183. data/spec/fixtures/responses/soap_fault.yml +53 -0
  184. data/spec/lib/channeladvisor/address_spec.rb +107 -0
  185. data/spec/lib/channeladvisor/admin_spec.rb +216 -0
  186. data/spec/lib/channeladvisor/line_item_spec.rb +147 -0
  187. data/spec/lib/channeladvisor/order_spec.rb +623 -0
  188. data/spec/lib/channeladvisor/order_status_spec.rb +36 -0
  189. data/spec/lib/channeladvisor/payment_spec.rb +38 -0
  190. data/spec/lib/channeladvisor/services/admin_service_spec.rb +65 -0
  191. data/spec/lib/channeladvisor/services/base_service_spec.rb +11 -0
  192. data/spec/lib/channeladvisor/services/inventory_service_spec.rb +214 -0
  193. data/spec/lib/channeladvisor/services/order_service_spec.rb +267 -0
  194. data/spec/lib/channeladvisor/services/shipping_service_spec.rb +288 -0
  195. data/spec/lib/channeladvisor/shipment_spec.rb +257 -0
  196. data/spec/lib/channeladvisor/shopping_cart_spec.rb +173 -0
  197. data/spec/lib/channeladvisor_spec.rb +18 -0
  198. data/spec/spec_helper.rb +29 -0
  199. data/spec/support/credentials.rb +15 -0
  200. data/spec/support/matchers/boolean.rb +17 -0
  201. data/spec/support/matchers/markup.rb +50 -0
  202. data/spec/support/rr.rb +38 -0
  203. data/spec/support/shared_examples.rb +4 -0
  204. data/spec/support/vcr.rb +38 -0
  205. metadata +501 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .yardoc/*
6
+ doc/*
7
+ coverage/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
6
+ script: "bundle exec rake spec"
data/.yardopts ADDED
@@ -0,0 +1,8 @@
1
+ --no-private
2
+ --protected
3
+ --markup markdown
4
+ --markup-provider redcarpet
5
+ lib/**/*.rb
6
+ -
7
+ README.md
8
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,31 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in channeladvisor.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'guard-rspec'
8
+ gem 'guard-bundler'
9
+ gem 'guard-yard', "~> 2.0.0", :platforms => [:ruby] if RUBY_VERSION >= "1.9.2"
10
+ gem 'rb-inotify', :require => false if RUBY_PLATFORM =~ /linux/i
11
+ gem 'libnotify', :require => false if RUBY_PLATFORM =~ /linux/i
12
+ gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
13
+ gem 'growl', :require => false if RUBY_PLATFORM =~ /darwin/i
14
+ gem 'win32console', :require => false, :platforms => [:mswin, :mingw]
15
+ gem 'rb-fchange', :require => false, :platforms => [:mswin, :mingw]
16
+ gem 'rb-notifu', :require => false, :platforms => [:mswin, :mingw]
17
+
18
+ platform :ruby_19 do
19
+ gem 'simplecov'
20
+ end
21
+ end
22
+
23
+ group :development do
24
+ gem 'yard'
25
+ gem 'redcarpet'
26
+ end
27
+
28
+ # platform :ruby_19 do
29
+ # gem 'ruby-debug19'
30
+ # gem 'pry'
31
+ # end
data/Guardfile ADDED
@@ -0,0 +1,28 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'bundler' do
5
+ watch('Gemfile')
6
+ watch(%r{^.+\.gemspec$})
7
+ end
8
+
9
+ if RUBY_PLATFORM =~ /w32/i
10
+ guard 'rspec', :run_all => {:cli => '-f p'}, :all_after_pass => false do
11
+ watch(%r{^(spec/.+_spec\.rb)$}) { |m| "#{m[1]}" }
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+ end
15
+ else
16
+ guard 'yard', :stdout => '/dev/null', :stderr => '/dev/null' do
17
+ watch(%r{lib/.+\.rb})
18
+ watch('README.md')
19
+ watch('LICENSE')
20
+ watch('.yardopts')
21
+ end
22
+
23
+ guard 'rspec', :rvm => ['1.9.2@channeladvisor', '1.9.3@channeladvisor'], :run_all => {:cli => '-f p'}, :all_after_pass => false do
24
+ watch(%r{^(spec/.+_spec\.rb)$}) { |m| "#{m[1]}" }
25
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
26
+ watch('spec/spec_helper.rb') { "spec" }
27
+ end
28
+ end
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 David Nunez
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ ChannelAdvisor [![Build Status](https://secure.travis-ci.org/dnunez24/channeladvisor.png)](http://travis-ci.org/dnunez24/channeladvisor)
2
+ ==============
3
+
4
+ Ruby wrapper for the SOAP API provided by ChannelAdvisor.
5
+
6
+ Install
7
+ -------
8
+
9
+ Install the gem:
10
+
11
+ ```bash
12
+ $ gem install channeladvisor
13
+ ```
14
+
15
+ Usage
16
+ -----
17
+
18
+ Setup the ChannelAdvisor client:
19
+
20
+ ```ruby
21
+ require 'channeladvisor'
22
+
23
+ ChannelAdvisor.configure do |config|
24
+ config.developer_key = YOUR_DEVELOPER_KEY
25
+ config.password = YOUR_PASSWORD
26
+ config.account_id = YOUR_ACCOUNT_ID
27
+ end
28
+ ```
29
+
30
+ Make a request to the service:
31
+
32
+ ```ruby
33
+ date_range = DateTime.new(2012,05,01)..DateTime.new(2012,06,01)
34
+
35
+ orders = ChannelAdvisor::Order.list(:created_between => date_range)
36
+ # => [<ChannelAdvisor::Order>, <ChannelAdvisor::Order>, ...]
37
+
38
+ orders.first.id
39
+ # => 1234567
40
+ ```
data/Rakefile ADDED
@@ -0,0 +1,69 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ require "channeladvisor/version"
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.rspec_opts = ["--format progress"]
8
+ end
9
+
10
+ task :default => :spec
11
+
12
+ task :build do
13
+ system "gem build channeladvisor.gemspec"
14
+ end
15
+
16
+ task :release => :build do
17
+ system "gem push channeladvisor-#{ChannelAdvisor::VERSION}"
18
+ end
19
+
20
+ desc "Display current gem version"
21
+ task :version do
22
+ puts "Current version: #{ChannelAdvisor::VERSION}"
23
+ end
24
+
25
+ namespace :version do
26
+ desc "Bump version (defaults to patch)"
27
+ task :bump => "bump:patch"
28
+
29
+ namespace :bump do
30
+ desc "Bump major version"
31
+ task :major => :version do |t|
32
+ bump_version(t.name.split(":").last)
33
+ end
34
+
35
+ desc "Bump minor version"
36
+ task :minor => :version do |t|
37
+ bump_version(t.name.split(":").last)
38
+ end
39
+
40
+ desc "Bump patch version"
41
+ task :patch => :version do |t|
42
+ bump_version(t.name.split(":").last)
43
+ end
44
+ end
45
+ end
46
+
47
+ def bump_version(segment)
48
+ segments = ChannelAdvisor::VERSION.split(".").map(&:to_i)
49
+
50
+ case segment
51
+ when "major"
52
+ segments[0] = segments[0] + 1
53
+ segments[1] = 0
54
+ segments[2] = 0
55
+ when "minor"
56
+ segments[1] = segments[1] + 1
57
+ segments[2] = 0
58
+ when "patch"
59
+ segments[2] = segments[2] + 1
60
+ end
61
+
62
+ new_version = segments.join(".")
63
+
64
+ file_name = "lib/channeladvisor/version.rb"
65
+ new_text = File.read(file_name).gsub(ChannelAdvisor::VERSION, new_version)
66
+ File.open(file_name, "w") { |f| f.puts new_text }
67
+
68
+ puts "New version: #{new_version}"
69
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "channeladvisor/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "channeladvisor"
7
+ s.version = ChannelAdvisor::VERSION
8
+ s.authors = ["Dave Nunez"]
9
+ s.email = ["dnunez24@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Ruby wrapper for the ChannelAdvisor API}
12
+ s.description = %q{Provides an easy-to-use interface for making requests to the ChannelAdvisor API. Includes all methods for requesting and updating data via API version 6.}
13
+
14
+ s.rubyforge_project = "channeladvisor"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "rspec", "~> 2.0"
23
+ s.add_development_dependency "rr", "~> 1.0.0"
24
+ s.add_development_dependency "vcr", "~> 2.2.0"
25
+ s.add_development_dependency "fakeweb", "~> 1.3.0"
26
+ s.add_development_dependency "timecop"
27
+
28
+ s.add_runtime_dependency "savon", "~> 1.0.0"
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'savon'
2
+ require 'channeladvisor/version'
3
+ require 'channeladvisor/error'
4
+ require 'channeladvisor/configuration'
5
+ require 'channeladvisor/client'
6
+ require 'channeladvisor/services'
7
+ require 'channeladvisor/base'
8
+ require 'channeladvisor/admin'
9
+ require 'channeladvisor/order'
10
+ require 'channeladvisor/order_status'
11
+ require 'channeladvisor/payment'
12
+ require 'channeladvisor/shipment'
13
+ require 'channeladvisor/address'
14
+ require 'channeladvisor/shopping_cart'
15
+ require 'channeladvisor/line_item'
16
+ require 'channeladvisor/account_authorization'
17
+
18
+ module ChannelAdvisor
19
+ def self.configuration
20
+ @configuration ||= Configuration.new
21
+ end
22
+
23
+ def self.configure
24
+ yield configuration if block_given?
25
+ end
26
+ end
27
+
@@ -0,0 +1,14 @@
1
+ module ChannelAdvisor
2
+ class AccountAuthorization
3
+ attr_reader :account_id, :local_id, :account_name, :account_type, :resource_name, :status
4
+
5
+ def initialize(account_id, local_id, account_name, account_type, resource_name, status)
6
+ @account_id = account_id
7
+ @local_id = local_id
8
+ @account_name = account_name
9
+ @account_type = account_type
10
+ @resource_name = resource_name
11
+ @status = status
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ module ChannelAdvisor
2
+ class Address
3
+ attr_accessor :line1, :line2, :city, :region, :region_description, :postal_code, :country_code,
4
+ :company_name, :job_title , :title, :first_name, :last_name, :suffix, :daytime_phone, :evening_phone
5
+
6
+ def initialize(attrs={})
7
+ @line1 = attrs[:address_line1]
8
+ @line2 = attrs[:address_line2]
9
+ @city = attrs[:city]
10
+ @region = attrs[:region]
11
+ @region_description = attrs[:region_description]
12
+ @postal_code = attrs[:postal_code]
13
+ @country_code = attrs[:country_code]
14
+ @company_name = attrs[:company_name]
15
+ @job_title = attrs[:job_title]
16
+ @title = attrs[:title]
17
+ @first_name = attrs[:first_name]
18
+ @last_name = attrs[:last_name]
19
+ @suffix = attrs[:suffix]
20
+ @daytime_phone = attrs[:phone_number_day]
21
+ @evening_phone = attrs[:phone_number_evening]
22
+ end
23
+
24
+ def full_name
25
+ [@title, @first_name, @last_name].join(" ") + ", #{@suffix}"
26
+ end
27
+
28
+ def formatted
29
+ <<-EOF
30
+ #{full_name}
31
+ #{job_title}
32
+ #{@line1}
33
+ #{@line2}
34
+ #{@city}, #{@region} #{@postal_code}
35
+ #{@country_code}
36
+ EOF
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,75 @@
1
+ module ChannelAdvisor
2
+ class Admin < Base
3
+ class << self
4
+ attr_reader :last_response
5
+
6
+ # Check authorization for and availability of the admin service
7
+ #
8
+ # @raise [ServiceFailure] If the SOAP response status is `Failure`
9
+ # @raise [SOAPFault] If the service responds with a SOAP fault
10
+ # @raise [HTTPError] If the service responds with an HTTP error
11
+ #
12
+ # @return [Boolean] Returns `true` if the SOAP response status is `Success`
13
+ def ping
14
+ handle_errors do
15
+ @last_response = Services::AdminService.ping
16
+ result = @last_response[:ping_response][:ping_result]
17
+ check_status_of result
18
+ end
19
+ end
20
+
21
+ # Request access to a specific ChannelAdvisor account
22
+ #
23
+ # @param [Integer] local_id Local ID of the ChannelAdvisor account to which you are requesting access
24
+ #
25
+ # @raise [ServiceFailure] If the SOAP response status is `Failure`
26
+ # @raise [SOAPFault] If the service responds with a SOAP fault
27
+ # @raise [HTTPError] If the service responds with an HTTP error
28
+ #
29
+ # @return [Boolean] Returns `true` if the SOAP response status is `Success`
30
+ def request_access(local_id)
31
+ handle_errors do
32
+ @last_response = Services::AdminService.request_access(local_id)
33
+ result = @last_response[:request_access_response][:request_access_result]
34
+ check_status_of result
35
+ end
36
+ end
37
+
38
+ # Retrieve a list of account authorizations for the given developer key and optional local ID
39
+ #
40
+ # @param [Integer] local_id Local ID of the ChannelAdvisor account for which you are checking authorization status
41
+ #
42
+ # @raise [ServiceFailure] If the SOAP response status is `Failure`
43
+ # @raise [SOAPFault] If the service responds with a SOAP fault
44
+ # @raise [HTTPError] If the service responds with an HTTP error
45
+ #
46
+ # @return [Array<AccountAuthorization>] An array of account authorizations
47
+ def get_authorization_list(local_id=nil)
48
+ handle_errors do
49
+ @last_response = Services::AdminService.get_authorization_list(local_id)
50
+ result = @last_response[:get_authorization_list_response][:get_authorization_list_result]
51
+ check_status_of result
52
+
53
+ account_authorizations = []
54
+
55
+ if result_data = result[:result_data]
56
+ authorizations = arrayify result_data[:authorization_response]
57
+
58
+ authorizations.each do |authorization|
59
+ account_authorizations << AccountAuthorization.new(
60
+ authorization[:account_id],
61
+ authorization[:local_id],
62
+ authorization[:account_name],
63
+ authorization[:account_type],
64
+ authorization[:resource_name],
65
+ authorization[:status]
66
+ )
67
+ end
68
+ end
69
+
70
+ return account_authorizations
71
+ end
72
+ end
73
+ end # self
74
+ end # Admin
75
+ end # ChannelAdvisor
@@ -0,0 +1,34 @@
1
+ module ChannelAdvisor
2
+ class Base
3
+
4
+ private
5
+
6
+ def arrayify(data)
7
+ self.class.arrayify(data)
8
+ end
9
+
10
+ def check_status_of(result)
11
+ self.class.check_status_of result
12
+ end
13
+
14
+ def handle_errors
15
+ self.class.handle_errors { yield }
16
+ end
17
+
18
+ def self.arrayify(data)
19
+ data.is_a?(Array) ? data : [data]
20
+ end
21
+
22
+ def self.check_status_of(result)
23
+ result[:status] == "Success" || raise(ServiceFailure, result[:message])
24
+ end
25
+
26
+ def self.handle_errors
27
+ yield
28
+ rescue Savon::SOAP::Fault => fault
29
+ raise SOAPFault.new(fault)
30
+ rescue Savon::HTTP::Error => error
31
+ raise HTTPError.new(error)
32
+ end
33
+ end # Base
34
+ end # ChannelAdvisor