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.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/.yardopts +8 -0
- data/Gemfile +31 -0
- data/Guardfile +28 -0
- data/LICENSE +19 -0
- data/README.md +40 -0
- data/Rakefile +69 -0
- data/channeladvisor.gemspec +29 -0
- data/lib/channeladvisor.rb +27 -0
- data/lib/channeladvisor/account_authorization.rb +14 -0
- data/lib/channeladvisor/address.rb +39 -0
- data/lib/channeladvisor/admin.rb +75 -0
- data/lib/channeladvisor/base.rb +34 -0
- data/lib/channeladvisor/client.rb +3 -0
- data/lib/channeladvisor/configuration.rb +11 -0
- data/lib/channeladvisor/error.rb +30 -0
- data/lib/channeladvisor/line_item.rb +38 -0
- data/lib/channeladvisor/order.rb +179 -0
- data/lib/channeladvisor/order_status.rb +14 -0
- data/lib/channeladvisor/payment.rb +15 -0
- data/lib/channeladvisor/services.rb +11 -0
- data/lib/channeladvisor/services/admin_service.rb +47 -0
- data/lib/channeladvisor/services/base_service.rb +26 -0
- data/lib/channeladvisor/services/inventory_service.rb +90 -0
- data/lib/channeladvisor/services/order_service.rb +117 -0
- data/lib/channeladvisor/services/shipping_service.rb +164 -0
- data/lib/channeladvisor/shipment.rb +71 -0
- data/lib/channeladvisor/shopping_cart.rb +26 -0
- data/lib/channeladvisor/version.rb +3 -0
- data/spec/fixtures/requests/admin_service/get_authorization_list.xml +1 -0
- data/spec/fixtures/requests/admin_service/get_authorization_list_with_local_id.xml +1 -0
- data/spec/fixtures/requests/admin_service/ping.xml +1 -0
- data/spec/fixtures/requests/admin_service/request_access.xml +1 -0
- data/spec/fixtures/requests/inventory_service/ping.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/price_only.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_and_price.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_only.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/price_only.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_and_price.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_only.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_item_price.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_item_quantity.xml +1 -0
- data/spec/fixtures/requests/inventory_service/update_item_quantity_and_price.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_checkout_status_filter.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_created_from_date.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_created_to_date.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_detail_level.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_distribution_center_code.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_export_state.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_join_dates.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_one_client_order_id.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_one_order_id.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_order_state_filter.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_page_number_filter.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_page_size.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_payment_status_filter.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_refund_status_filter.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_shipping_status_filter.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_two_client_order_ids.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_two_order_ids.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_updated_from_date.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/with_updated_to_date.xml +1 -0
- data/spec/fixtures/requests/order_service/get_order_list/without_order_criteria.xml +1 -0
- data/spec/fixtures/requests/order_service/ping.xml +1 -0
- data/spec/fixtures/requests/order_service/set_orders_export_status/with_one_client_order_id.xml +1 -0
- data/spec/fixtures/requests/order_service/set_orders_export_status/with_two_client_order_ids.xml +1 -0
- data/spec/fixtures/requests/shipping_service/get_shipping_carrier_list.xml +1 -0
- data/spec/fixtures/requests/shipping_service/ping.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/with_one_shipment.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/with_two_shipments.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_carrier_code.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_class_code.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_client_order_id.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_seller_id.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/full_shipment/without_tracking_number.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/with_one_line_item.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/with_two_line_items.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/with_two_shipments.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_carrier_code.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_class_code.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_seller_id.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/partial_shipment/without_tracking_number.xml +1 -0
- data/spec/fixtures/requests/shipping_service/submit_order_shipment_list/with_partial_and_full_shipments.xml +1 -0
- data/spec/fixtures/responses/admin/get_authorization_list/failure.yml +50 -0
- data/spec/fixtures/responses/admin/get_authorization_list/no_authorizations.yml +49 -0
- data/spec/fixtures/responses/admin/get_authorization_list/one_authorization.yml +49 -0
- data/spec/fixtures/responses/admin/get_authorization_list/success.yml +49 -0
- data/spec/fixtures/responses/admin/get_authorization_list/two_authorizations.yml +49 -0
- data/spec/fixtures/responses/admin/ping/failure.yml +50 -0
- data/spec/fixtures/responses/admin/ping/success.yml +218 -0
- data/spec/fixtures/responses/admin/request_access/failure.yml +50 -0
- data/spec/fixtures/responses/admin/request_access/success.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/with_invalid_local_id.yml +219 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/with_local_id/success.yml +218 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/multiple_authorizations.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/no_authorizations.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/one_authorization.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/with_valid_local_id/success.yml +218 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/multiple_authorizations.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/no_authorizations.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/one_authorization.yml +49 -0
- data/spec/fixtures/responses/admin_service/get_authorization_list/without_local_id/success.yml +218 -0
- data/spec/fixtures/responses/admin_service/ping/failure.yml +222 -0
- data/spec/fixtures/responses/admin_service/ping/success.yml +218 -0
- data/spec/fixtures/responses/admin_service/request_access/failure.yml +219 -0
- data/spec/fixtures/responses/admin_service/request_access/success.yml +218 -0
- data/spec/fixtures/responses/http_error.yml +48 -0
- data/spec/fixtures/responses/inventory_service/ping.yml +1356 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price.yml +1356 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price/price_only.yml +144 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price/quantity_and_price.yml +191 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price/quantity_only.yml +1403 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list.yml +243 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/price_only.yml +97 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_and_price.yml +144 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_one_item/quantity_only.yml +51 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/price_only.yml +238 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_and_price.yml +285 -0
- data/spec/fixtures/responses/inventory_service/update_inventory_item_quantity_and_price_list/with_two_items/quantity_only.yml +191 -0
- data/spec/fixtures/responses/order/instance_set_export_status.yml +51 -0
- data/spec/fixtures/responses/order/instance_set_export_status/failure.yml +51 -0
- data/spec/fixtures/responses/order/instance_set_export_status/success/result_false.yml +51 -0
- data/spec/fixtures/responses/order/instance_set_export_status/success/result_true.yml +51 -0
- data/spec/fixtures/responses/order/list.yml +58 -0
- data/spec/fixtures/responses/order/list/failure.yml +56 -0
- data/spec/fixtures/responses/order/list/no_matching_orders.yml +56 -0
- data/spec/fixtures/responses/order/list/one_matching_order.yml +57 -0
- data/spec/fixtures/responses/order/list/two_matching_orders.yml +59 -0
- data/spec/fixtures/responses/order/list/with_criteria.yml +52 -0
- data/spec/fixtures/responses/order/list/with_no_criteria.yml +58 -0
- data/spec/fixtures/responses/order/ping.yml +868 -0
- data/spec/fixtures/responses/order/ping/failure.yml +50 -0
- data/spec/fixtures/responses/order/ping/success.yml +867 -0
- data/spec/fixtures/responses/order/set_export_status/failure.yml +51 -0
- data/spec/fixtures/responses/order/set_export_status/success/with_one_client_order_id.yml +51 -0
- data/spec/fixtures/responses/order/set_export_status/success/with_two_client_order_ids.yml +51 -0
- data/spec/fixtures/responses/order_service/get_order_list/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_checkout_status_filter.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_created_from_date.yml +874 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_created_to_date.yml +874 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_detail_level.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_distribution_center_code.yml +872 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_export_state.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_join_dates.yml +869 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_one_client_order_id.yml +872 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_one_order_id.yml +873 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_order_state_filter.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_page_number_filter.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_page_size.yml +874 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_payment_status_filter.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_refund_status_filter.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_shipping_status_filter.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_two_client_order_ids.yml +872 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_two_order_ids.yml +875 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_updated_from_date.yml +874 -0
- data/spec/fixtures/responses/order_service/get_order_list/with_updated_to_date.yml +874 -0
- data/spec/fixtures/responses/order_service/get_order_list/without_order_criteria.yml +871 -0
- data/spec/fixtures/responses/order_service/get_order_refund_history/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/order_merge/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/order_split/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/ping/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/ping/failure.yml +871 -0
- data/spec/fixtures/responses/order_service/ping/success.yml +868 -0
- data/spec/fixtures/responses/order_service/set_orders_export_status/with_one_client_order_id.yml +867 -0
- data/spec/fixtures/responses/order_service/set_orders_export_status/with_two_client_order_id.yml +867 -0
- data/spec/fixtures/responses/order_service/set_seller_order_id/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/set_seller_order_item_id_list/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/submit_order/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/submit_order_refund/.gitkeep +0 -0
- data/spec/fixtures/responses/order_service/update_order_list/.gitkeep +0 -0
- data/spec/fixtures/responses/shipment/get_carriers.yml +53 -0
- data/spec/fixtures/responses/shipment/get_carriers/failure.yml +52 -0
- data/spec/fixtures/responses/shipment/submit.yml +464 -0
- data/spec/fixtures/responses/shipment/submit/failure.yml +462 -0
- data/spec/fixtures/responses/shipment/submit/one_shipment.yml +464 -0
- data/spec/fixtures/responses/shipment/submit/two_shipments.yml +56 -0
- data/spec/fixtures/responses/shipping_service/get_shipping_carrier_list.yml +953 -0
- data/spec/fixtures/responses/shipping_service/ping/failure.yml +55 -0
- data/spec/fixtures/responses/shipping_service/ping/success.yml +460 -0
- data/spec/fixtures/responses/shipping_service/submit_order_shipment_list.yml +55 -0
- data/spec/fixtures/responses/soap_fault.yml +53 -0
- data/spec/lib/channeladvisor/address_spec.rb +107 -0
- data/spec/lib/channeladvisor/admin_spec.rb +216 -0
- data/spec/lib/channeladvisor/line_item_spec.rb +147 -0
- data/spec/lib/channeladvisor/order_spec.rb +623 -0
- data/spec/lib/channeladvisor/order_status_spec.rb +36 -0
- data/spec/lib/channeladvisor/payment_spec.rb +38 -0
- data/spec/lib/channeladvisor/services/admin_service_spec.rb +65 -0
- data/spec/lib/channeladvisor/services/base_service_spec.rb +11 -0
- data/spec/lib/channeladvisor/services/inventory_service_spec.rb +214 -0
- data/spec/lib/channeladvisor/services/order_service_spec.rb +267 -0
- data/spec/lib/channeladvisor/services/shipping_service_spec.rb +288 -0
- data/spec/lib/channeladvisor/shipment_spec.rb +257 -0
- data/spec/lib/channeladvisor/shopping_cart_spec.rb +173 -0
- data/spec/lib/channeladvisor_spec.rb +18 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/credentials.rb +15 -0
- data/spec/support/matchers/boolean.rb +17 -0
- data/spec/support/matchers/markup.rb +50 -0
- data/spec/support/rr.rb +38 -0
- data/spec/support/shared_examples.rb +4 -0
- data/spec/support/vcr.rb +38 -0
- metadata +501 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
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 [](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
|