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
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.channeladvisor.com/ChannelAdvisorAPI/v6/ShippingService.asmx
6
+ body:
7
+ encoding: US-ASCII
8
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
9
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.channeladvisor.com/webservices/"
10
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://api.channeladvisor.com/webservices/"
11
+ xmlns:ins1="http://api.channeladvisor.com/datacontracts/ShippingService"><env:Header><ins0:APICredentials><ins0:DeveloperKey>$$DEVELOPER_KEY$$</ins0:DeveloperKey><ins0:Password>$$PASSWORD$$</ins0:Password></ins0:APICredentials></env:Header><env:Body><ins0:SubmitOrderShipmentList><ins0:accountID>$$ACCOUNT_ID$$</ins0:accountID><ins0:ShipmentList><ins0:ShipmentList><ins0:OrderShipment><ins0:OrderId>123456</ins0:OrderId><ins0:ClientOrderIdentifier>ABCD1234</ins0:ClientOrderIdentifier><ins0:ShipmentType>Full</ins0:ShipmentType><ins0:FullShipment><ins0:dateShippedGMT>2012-05-19T00:00:00+00:00</ins0:dateShippedGMT><ins0:carrierCode>UPS</ins0:carrierCode><ins0:classCode>GND</ins0:classCode><ins0:trackingNumber>1ZABCE09813473497</ins0:trackingNumber><ins0:sellerFulfillmentID>999999</ins0:sellerFulfillmentID><ins0:shipmentCost>5.99</ins0:shipmentCost><ins0:shipmentTaxCost>1.99</ins0:shipmentTaxCost><ins0:insuranceCost>2.99</ins0:insuranceCost></ins0:FullShipment></ins0:OrderShipment></ins0:ShipmentList></ins0:ShipmentList></ins0:SubmitOrderShipmentList></env:Body></env:Envelope>
12
+ headers:
13
+ soapaction:
14
+ - ! '"http://api.channeladvisor.com/webservices/SubmitOrderShipmentList"'
15
+ content-type:
16
+ - text/xml;charset=UTF-8
17
+ content-length:
18
+ - '1439'
19
+ accept:
20
+ - ! '*/*'
21
+ user-agent:
22
+ - Ruby
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ date:
29
+ - Tue, 12 Jun 2012 20:24:11 GMT
30
+ server:
31
+ - Microsoft-IIS/6.0
32
+ x-servername:
33
+ - RDU-IISWEB-04
34
+ x-powered-by:
35
+ - ASP.NET
36
+ x-aspnet-version:
37
+ - 4.0.30319
38
+ cache-control:
39
+ - private, max-age=0
40
+ content-type:
41
+ - text/xml; charset=utf-8
42
+ content-length:
43
+ - '888'
44
+ body:
45
+ encoding: US-ASCII
46
+ string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
47
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SubmitOrderShipmentListResponse
48
+ xmlns="http://api.channeladvisor.com/webservices/"><SubmitOrderShipmentListResult><Status>Success</Status><MessageCode>0</MessageCode><ResultData><ShipmentResponse><Success
49
+ xmlns="http://api.channeladvisor.com/datacontracts/ShippingService">false</Success><Message
50
+ xmlns="http://api.channeladvisor.com/datacontracts/ShippingService">An unexpected
51
+ error occurred involving Order 123456. Please make sure sufficient unshipped
52
+ quantity exists on the order and that the Carrier and Class Codes are valid.</Message></ShipmentResponse></ResultData></SubmitOrderShipmentListResult></SubmitOrderShipmentListResponse></soap:Body></soap:Envelope>
53
+ http_version: '1.1'
54
+ recorded_at: Tue, 12 Jun 2012 20:24:11 GMT
55
+ recorded_with: VCR 2.2.0
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx
6
+ body:
7
+ encoding: US-ASCII
8
+ string: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
9
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
10
+ xmlns:web="http://api.channeladvisor.com/webservices/" xmlns:ord="http://api.channeladvisor.com/datacontracts/orders"><soap:Header><web:APICredentials><web:DeveloperKey>WRONG</web:DeveloperKey><web:Password>$$PASSWORD$$</web:Password></web:APICredentials></soap:Header><soap:Body><web:Ping/></soap:Body></soap:Envelope>
11
+ headers:
12
+ soapaction:
13
+ - ! '"http://api.channeladvisor.com/webservices/Ping"'
14
+ content-type:
15
+ - text/xml;charset=UTF-8
16
+ content-length:
17
+ - '523'
18
+ accept:
19
+ - ! '*/*'
20
+ user-agent:
21
+ - Ruby
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Tue, 22 May 2012 06:07:16 GMT
29
+ server:
30
+ - Microsoft-IIS/6.0
31
+ x-servername:
32
+ - RDU-IISWEB-08
33
+ x-powered-by:
34
+ - ASP.NET
35
+ x-aspnet-version:
36
+ - 4.0.30319
37
+ cache-control:
38
+ - private
39
+ content-type:
40
+ - text/xml; charset=utf-8
41
+ content-length:
42
+ - '517'
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ! "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\r\n
46
+ \ <soap:Body>\r\n <soap:Fault>\r\n
47
+ \ <faultcode>soap:Server</faultcode>\r\n <faultstring>Server
48
+ was unable to process request. Authentication failed.</faultstring>\r\n <detail/>\r\n
49
+ \ </soap:Fault>\r\n </soap:Body>\r\n
50
+ \ </soap:Envelope>"
51
+ http_version: '1.1'
52
+ recorded_at: Tue, 22 May 2012 06:07:16 GMT
53
+ recorded_with: VCR 2.1.1
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ module ChannelAdvisor
4
+ describe Address do
5
+ before(:each) do
6
+ @attrs = {
7
+ :address_line1 => "12345 Some Pl.",
8
+ :address_line2 => "Ste. 1",
9
+ :city => "Somewhere",
10
+ :region => "NY",
11
+ :region_description => "New York",
12
+ :postal_code => "10003",
13
+ :country_code => "US",
14
+ :company_name => "Some Company",
15
+ :job_title => "President",
16
+ :title => "Mr.",
17
+ :first_name => "Some",
18
+ :last_name => "Body",
19
+ :suffix => "Sr.",
20
+ :phone_number_day => "999-999-9999",
21
+ :phone_number_evening => "555-555-5555"
22
+ }
23
+ @address = Address.new(@attrs)
24
+ end
25
+
26
+ describe ".new" do
27
+ it "sets @line1" do
28
+ @address.line1.should == @attrs[:address_line1]
29
+ end
30
+
31
+ it "sets @line2" do
32
+ @address.line2.should == @attrs[:address_line2]
33
+ end
34
+
35
+ it "sets @city" do
36
+ @address.city.should == @attrs[:city]
37
+ end
38
+
39
+ it "sets @region" do
40
+ @address.region.should == @attrs[:region]
41
+ end
42
+
43
+ it "sets @region_description" do
44
+ @address.region_description.should == @attrs[:region_description]
45
+ end
46
+
47
+ it "sets @postal_code" do
48
+ @address.postal_code.should == @attrs[:postal_code]
49
+ end
50
+
51
+ it "sets @country_code" do
52
+ @address.country_code.should == @attrs[:country_code]
53
+ end
54
+
55
+ it "sets @company_name" do
56
+ @address.company_name.should == @attrs[:company_name]
57
+ end
58
+
59
+ it "sets @job_title" do
60
+ @address.job_title.should == @attrs[:job_title]
61
+ end
62
+
63
+ it "sets @title" do
64
+ @address.title.should == @attrs[:title]
65
+ end
66
+
67
+ it "sets @first_name" do
68
+ @address.first_name.should == @attrs[:first_name]
69
+ end
70
+
71
+ it "sets @last_name" do
72
+ @address.last_name.should == @attrs[:last_name]
73
+ end
74
+
75
+ it "sets @suffix" do
76
+ @address.suffix.should == @attrs[:suffix]
77
+ end
78
+
79
+ it "sets @daytime_phone" do
80
+ @address.daytime_phone.should == @attrs[:phone_number_day]
81
+ end
82
+
83
+ it "sets @evening_phone" do
84
+ @address.evening_phone.should == @attrs[:phone_number_evening]
85
+ end
86
+ end
87
+
88
+ describe "#full_name" do
89
+ it "returns a full name string" do
90
+ @address.full_name.should == "Mr. Some Body, Sr."
91
+ end
92
+ end
93
+
94
+ describe "#formatted" do
95
+ it "returns a formatted address" do
96
+ @address.formatted.should == <<-EOF
97
+ Mr. Some Body, Sr.
98
+ President
99
+ 12345 Some Pl.
100
+ Ste. 1
101
+ Somewhere, NY 10003
102
+ US
103
+ EOF
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,216 @@
1
+ require 'spec_helper'
2
+
3
+ module ChannelAdvisor
4
+ describe Admin do
5
+ describe ".ping" do
6
+ context "with a success status" do
7
+ use_vcr_cassette "responses/admin/ping/success"
8
+
9
+ it "records the last response" do
10
+ Admin.ping
11
+ Admin.last_response[:ping_response].should_not be_nil
12
+ end
13
+
14
+ it "returns true" do
15
+ Admin.ping.should be_true
16
+ end
17
+ end
18
+
19
+ context "with a failure status" do
20
+ failure = {:message => "Service Unavailable"}
21
+ use_vcr_cassette "responses/admin/ping/failure", :erb => failure
22
+
23
+ it "raises a ServiceFailure error" do
24
+ expect { Admin.ping }.to raise_error ServiceFailure, failure[:message]
25
+ end
26
+ end
27
+
28
+ context "with a SOAP fault" do
29
+ use_vcr_cassette "responses/soap_fault", :match_requests_on => [:method]
30
+
31
+ it "raises a SOAP fault error" do
32
+ ChannelAdvisor.configure { |c| c.developer_key = "WRONG" }
33
+ expect { Admin.ping }.to raise_error SOAPFault, "Server was unable to process request. Authentication failed."
34
+ end
35
+
36
+ it "stores the SOAP fault code" do
37
+ begin
38
+ Admin.ping
39
+ rescue SOAPFault => fault
40
+ fault.code.should == "soap:Server"
41
+ end
42
+ end
43
+ end
44
+
45
+ context "with an HTTP error" do
46
+ http_status = {:code => 500, :message => "Internal Server Error"}
47
+ use_vcr_cassette "responses/http_error", :match_requests_on => [:method], :erb => http_status
48
+
49
+ it "raises an HTTP error" do
50
+ expect { Admin.ping }.to raise_error HTTPError, "Failed with HTTP error #{http_status[:code]}"
51
+ end
52
+
53
+ it "stores the HTTP status code" do
54
+ begin
55
+ Admin.ping
56
+ rescue HTTPError => error
57
+ error.code.should == http_status[:code]
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ describe ".request_access" do
64
+ let(:local_id) { sensitive_data["local_ids"].first }
65
+
66
+ context "with a success status" do
67
+ use_vcr_cassette "responses/admin/request_access/success"
68
+
69
+ it "records the last response" do
70
+ Admin.request_access(local_id)
71
+ Admin.last_response[:request_access_response].should_not be_nil
72
+ end
73
+
74
+ it "returns true" do
75
+ Admin.request_access(local_id).should be_true
76
+ end
77
+ end
78
+
79
+ context "with a failure status" do
80
+ use_vcr_cassette "responses/admin/request_access/failure"
81
+
82
+ it "raises a ServiceFailure error" do
83
+ expect { Admin.request_access(local_id) }.to raise_error ServiceFailure, "An Authorization for the specified ID [$$LOCAL_ID$$] already exists!"
84
+ end
85
+ end
86
+
87
+ context "with a SOAP fault" do
88
+ use_vcr_cassette "responses/soap_fault", :match_requests_on => [:method]
89
+
90
+ it "raises a SOAP fault error" do
91
+ ChannelAdvisor.configure { |c| c.developer_key = "WRONG" }
92
+ expect { Admin.request_access(local_id) }.to raise_error SOAPFault, "Server was unable to process request. Authentication failed."
93
+ end
94
+
95
+ it "stores the SOAP fault code" do
96
+ begin
97
+ Admin.request_access(local_id)
98
+ rescue SOAPFault => fault
99
+ fault.code.should == "soap:Server"
100
+ end
101
+ end
102
+ end
103
+
104
+ context "with an HTTP error" do
105
+ http_status = {:code => 500, :message => "Internal Server Error"}
106
+ use_vcr_cassette "responses/http_error", :match_requests_on => [:method], :erb => http_status
107
+
108
+ it "raises an HTTP error" do
109
+ expect { Admin.request_access(local_id) }.to raise_error HTTPError, "Failed with HTTP error #{http_status[:code]}"
110
+ end
111
+
112
+ it "stores the HTTP status code" do
113
+ begin
114
+ Admin.request_access(local_id)
115
+ rescue HTTPError => error
116
+ error.code.should == http_status[:code]
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ describe ".get_authorization_list" do
123
+ let(:local_id) { sensitive_data["local_ids"].first }
124
+
125
+ context "with a success status" do
126
+ use_vcr_cassette "responses/admin/get_authorization_list/success"
127
+
128
+ it "records the last response" do
129
+ Admin.get_authorization_list(local_id)
130
+ Admin.last_response[:get_authorization_list_response].should_not be_nil
131
+ end
132
+
133
+ context "with no authorizations" do
134
+ use_vcr_cassette "responses/admin/get_authorization_list/no_authorizations", :exclusive => true
135
+
136
+ it "should return an array" do
137
+ Admin.get_authorization_list(local_id).should be_an Array
138
+ end
139
+
140
+ it "returns an empty array" do
141
+ Admin.get_authorization_list(local_id).should have(0).items
142
+ end
143
+ end
144
+
145
+ context "with one authorization" do
146
+ use_vcr_cassette "responses/admin/get_authorization_list/one_authorization", :exclusive => true
147
+
148
+ it "should be an array with one element" do
149
+ Admin.get_authorization_list(local_id).should have(1).item
150
+ end
151
+
152
+ it "should have an array containing an AccountAuthorization object" do
153
+ Admin.get_authorization_list(local_id).first.should be_an AccountAuthorization
154
+ end
155
+ end
156
+
157
+ context "with two authorizations" do
158
+ use_vcr_cassette "responses/admin/get_authorization_list/two_authorizations", :exclusive => true
159
+
160
+ it "should be an array with two elements" do
161
+ Admin.get_authorization_list.should have(2).items
162
+ end
163
+
164
+ it "should have an array containing AccountAuthorization objects" do
165
+ account_authorizations = Admin.get_authorization_list(local_id)
166
+ account_authorizations.each do |account_authorization|
167
+ account_authorization.should be_an AccountAuthorization
168
+ end
169
+ end
170
+ end
171
+ end
172
+
173
+ context "with a failure status" do
174
+ use_vcr_cassette "responses/admin/get_authorization_list/failure"
175
+
176
+ it "raises a ServiceFailure error" do
177
+ expect { Admin.get_authorization_list("WRONG") }.to raise_error ServiceFailure, "Input string was not in a correct format."
178
+ end
179
+ end
180
+
181
+ context "with a SOAP fault" do
182
+ use_vcr_cassette "responses/soap_fault", :match_requests_on => [:method]
183
+
184
+ it "raises a SOAP fault error" do
185
+ ChannelAdvisor.configure { |c| c.developer_key = "WRONG" }
186
+ expect { Admin.get_authorization_list(local_id) }.to raise_error SOAPFault, "Server was unable to process request. Authentication failed."
187
+ end
188
+
189
+ it "stores the SOAP fault code" do
190
+ begin
191
+ Admin.get_authorization_list(local_id)
192
+ rescue SOAPFault => fault
193
+ fault.code.should == "soap:Server"
194
+ end
195
+ end
196
+ end
197
+
198
+ context "with an HTTP error" do
199
+ http_status = {:code => 500, :message => "Internal Server Error"}
200
+ use_vcr_cassette "responses/http_error", :match_requests_on => [:method], :erb => http_status, :erb => http_status
201
+
202
+ it "raises an HTTP error" do
203
+ expect { Admin.get_authorization_list(local_id) }.to raise_error HTTPError, "Failed with HTTP error #{http_status[:code]}"
204
+ end
205
+
206
+ it "stores the HTTP status code" do
207
+ begin
208
+ Admin.get_authorization_list(local_id)
209
+ rescue HTTPError => error
210
+ error.code.should == http_status[:code]
211
+ end
212
+ end
213
+ end
214
+ end # get_authorization_list
215
+ end # Admin
216
+ end # ChannelAdvisor
@@ -0,0 +1,147 @@
1
+ require 'spec_helper'
2
+
3
+ module ChannelAdvisor
4
+ describe LineItem do
5
+ let(:attrs) do
6
+ {
7
+ :line_item_type => "SKU",
8
+ :unit_price => "6.9900",
9
+ :line_item_id => "17293910",
10
+ :allow_negative_quantity => false,
11
+ :quantity => "5",
12
+ :item_sale_source => "DIRECT_SALE",
13
+ :sku => "FAKE001",
14
+ :title => "Fake Item No. 1",
15
+ :buyer_user_id => "test@example.com",
16
+ :buyer_feedback_rating => "0",
17
+ :sales_source_id => "37081357",
18
+ :vat_rate => "0",
19
+ :tax_cost => "0.0000",
20
+ :shipping_cost => "0.0000",
21
+ :shipping_tax_cost => "0.0000",
22
+ :gift_wrap_cost => "0.0000",
23
+ :gift_wrap_tax_cost => "0.0000",
24
+ :gift_message => "Example gift message",
25
+ :gift_wrap_level => "Some Level",
26
+ :recycling_fee => "0.0000",
27
+ :unit_weight => "1.2",
28
+ :warehouse_location => "A14",
29
+ :user_name => "somebody",
30
+ :distribution_center_code => "ABC",
31
+ :is_fba => false,
32
+ :promo_code => "ABC123",
33
+ :"@xsi:type" => "q1:OrderLineItemItemResponse"
34
+ }
35
+ end
36
+
37
+ before(:each) do
38
+ @line_item = LineItem.new(attrs)
39
+ end
40
+
41
+ describe ".new" do
42
+ it "sets @type" do
43
+ @line_item.type.should == attrs[:line_item_type]
44
+ end
45
+
46
+ it "sets @id" do
47
+ @line_item.id.should == attrs[:line_item_id]
48
+ end
49
+
50
+ it "sets @unit_price" do
51
+ @line_item.unit_price.should == attrs[:unit_price].to_f
52
+ end
53
+
54
+ it "sets @allow_negative_quantity" do
55
+ @line_item.allow_negative_quantity.should == attrs[:allow_negative_quantity]
56
+ end
57
+
58
+ it "sets @quantity" do
59
+ @line_item.quantity.should == attrs[:quantity].to_i
60
+ end
61
+
62
+ it "sets @sale_source" do
63
+ @line_item.sale_source.should == attrs[:item_sale_source]
64
+ end
65
+
66
+ it "sets @sku" do
67
+ @line_item.sku.should == attrs[:sku]
68
+ end
69
+
70
+ it "sets @title" do
71
+ @line_item.title.should == attrs[:title]
72
+ end
73
+
74
+ it "sets @buyer_user_id" do
75
+ @line_item.buyer_user_id.should == attrs[:buyer_user_id]
76
+ end
77
+
78
+ it "sets @buyer_feedback_rating" do
79
+ @line_item.buyer_feedback_rating.should == attrs[:buyer_feedback_rating]
80
+ end
81
+
82
+ it "sets @sales_source_id" do
83
+ @line_item.sales_source_id.should == attrs[:sales_source_id]
84
+ end
85
+
86
+ it "sets @vat_rate" do
87
+ @line_item.vat_rate.should == attrs[:vat_rate].to_f
88
+ end
89
+
90
+ it "sets @tax_cost" do
91
+ @line_item.tax_cost.should == attrs[:tax_cost].to_f
92
+ end
93
+
94
+ it "sets @shipping_cost" do
95
+ @line_item.shipping_cost.should == attrs[:shipping_cost].to_f
96
+ end
97
+
98
+ it "sets @shipping_tax_cost" do
99
+ @line_item.shipping_tax_cost.should == attrs[:shipping_tax_cost].to_f
100
+ end
101
+
102
+ it "sets @gift_wrap_cost" do
103
+ @line_item.gift_wrap_cost.should == attrs[:gift_wrap_cost].to_f
104
+ end
105
+
106
+ it "sets @gift_wrap_tax_cost" do
107
+ @line_item.gift_wrap_tax_cost.should == attrs[:gift_wrap_tax_cost].to_f
108
+ end
109
+
110
+ it "sets @gift_message" do
111
+ @line_item.gift_message.should == attrs[:gift_message]
112
+ end
113
+
114
+ it "sets @gift_wrap_level" do
115
+ @line_item.gift_wrap_level.should == attrs[:gift_wrap_level]
116
+ end
117
+
118
+ it "sets @recycling_fee" do
119
+ @line_item.recycling_fee.should == attrs[:recycling_fee].to_f
120
+ end
121
+
122
+ it "sets @unit_weight" do
123
+ @line_item.unit_weight.should == attrs[:unit_weight].to_f
124
+ end
125
+
126
+ it "sets @warehouse_location" do
127
+ @line_item.warehouse_location.should == attrs[:warehouse_location]
128
+ end
129
+
130
+ it "sets @user_name" do
131
+ @line_item.user_name.should == attrs[:user_name]
132
+ end
133
+
134
+ it "sets @distribution_center_code" do
135
+ @line_item.distribution_center.should == attrs[:distribution_center_code]
136
+ end
137
+
138
+ it "sets @is_fba" do
139
+ @line_item.is_fba.should == attrs[:is_fba]
140
+ end
141
+
142
+ it "sets @promo_code" do
143
+ @line_item.promo_code.should == attrs[:promo_code]
144
+ end
145
+ end
146
+ end # LineItem
147
+ end # ChannelAdvisor