7digital 0.0.6 → 0.0.7

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 (269) hide show
  1. data/README.rdoc +136 -136
  2. data/lib/sevendigital.rb +53 -53
  3. data/lib/sevendigital/api_operator.rb +130 -130
  4. data/lib/sevendigital/api_operator_cached.rb +41 -41
  5. data/lib/sevendigital/api_request.rb +65 -65
  6. data/lib/sevendigital/client.rb +113 -113
  7. data/lib/sevendigital/client_configuration.rb +86 -86
  8. data/lib/sevendigital/client_digestors.rb +107 -107
  9. data/lib/sevendigital/client_managers.rb +47 -47
  10. data/lib/sevendigital/digestion_tract/api_response_digestor.rb +58 -58
  11. data/lib/sevendigital/digestion_tract/artist_digestor.rb +32 -32
  12. data/lib/sevendigital/digestion_tract/basket_digestor.rb +19 -19
  13. data/lib/sevendigital/digestion_tract/basket_item_digestor.rb +26 -26
  14. data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +28 -28
  15. data/lib/sevendigital/digestion_tract/digestor.rb +71 -71
  16. data/lib/sevendigital/digestion_tract/download_url_digestor.rb +20 -20
  17. data/lib/sevendigital/digestion_tract/format_digestor.rb +22 -22
  18. data/lib/sevendigital/digestion_tract/label_digestor.rb +20 -20
  19. data/lib/sevendigital/digestion_tract/locker_digestor.rb +18 -18
  20. data/lib/sevendigital/digestion_tract/locker_release_digestor.rb +20 -20
  21. data/lib/sevendigital/digestion_tract/locker_track_digestor.rb +22 -22
  22. data/lib/sevendigital/digestion_tract/oauth_access_token_digestor.rb +14 -14
  23. data/lib/sevendigital/digestion_tract/oauth_request_token_digestor.rb +14 -14
  24. data/lib/sevendigital/digestion_tract/pager_digestor.rb +24 -24
  25. data/lib/sevendigital/digestion_tract/price_digestor.rb +25 -25
  26. data/lib/sevendigital/digestion_tract/release_digestor.rb +53 -53
  27. data/lib/sevendigital/digestion_tract/tag_digestor.rb +22 -22
  28. data/lib/sevendigital/digestion_tract/track_digestor.rb +38 -38
  29. data/lib/sevendigital/digestion_tract/user_card_digestor.rb +23 -23
  30. data/lib/sevendigital/digestion_tract/user_digestor.rb +20 -20
  31. data/lib/sevendigital/management/artist_manager.rb +99 -99
  32. data/lib/sevendigital/management/basket_manager.rb +29 -29
  33. data/lib/sevendigital/management/manager.rb +12 -12
  34. data/lib/sevendigital/management/oauth_manager.rb +23 -23
  35. data/lib/sevendigital/management/release_manager.rb +56 -56
  36. data/lib/sevendigital/management/tag_manager.rb +10 -10
  37. data/lib/sevendigital/management/track_manager.rb +28 -28
  38. data/lib/sevendigital/management/user_card_manager.rb +26 -26
  39. data/lib/sevendigital/management/user_manager.rb +71 -71
  40. data/lib/sevendigital/model/api_response.rb +25 -25
  41. data/lib/sevendigital/model/artist.rb +94 -94
  42. data/lib/sevendigital/model/basket.rb +15 -15
  43. data/lib/sevendigital/model/basket_item.rb +14 -14
  44. data/lib/sevendigital/model/card.rb +11 -11
  45. data/lib/sevendigital/model/chart_item.rb +9 -9
  46. data/lib/sevendigital/model/download_url.rb +7 -7
  47. data/lib/sevendigital/model/format.rb +7 -7
  48. data/lib/sevendigital/model/label.rb +7 -7
  49. data/lib/sevendigital/model/locker.rb +4 -4
  50. data/lib/sevendigital/model/locker_release.rb +9 -9
  51. data/lib/sevendigital/model/locker_track.rb +9 -9
  52. data/lib/sevendigital/model/price.rb +9 -9
  53. data/lib/sevendigital/model/release.rb +52 -52
  54. data/lib/sevendigital/model/sevendigital_error.rb +11 -11
  55. data/lib/sevendigital/model/sevendigital_object.rb +57 -57
  56. data/lib/sevendigital/model/tag.rb +7 -7
  57. data/lib/sevendigital/model/track.rb +83 -83
  58. data/lib/sevendigital/model/user.rb +63 -63
  59. data/lib/sevendigital/pager.rb +23 -23
  60. data/lib/sevendigital/peachy_patchy.rb +9 -9
  61. data/lib/sevendigital/proxy_police.rb +27 -27
  62. data/lib/sevendigital/version.rb +5 -5
  63. data/spec/api_operator_cached_spec.rb +178 -178
  64. data/spec/api_operator_spec.rb +336 -336
  65. data/spec/api_request_spec.rb +31 -31
  66. data/spec/client_configuration_spec.rb +79 -74
  67. data/spec/client_spec.rb +162 -162
  68. data/spec/coverage/assets/0.3.9/app.js +66 -0
  69. data/spec/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
  70. data/spec/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
  71. data/spec/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
  72. data/spec/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
  73. data/spec/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
  74. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
  75. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
  76. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
  77. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
  78. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
  79. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
  80. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
  81. data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
  82. data/spec/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
  83. data/spec/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
  84. data/spec/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
  85. data/spec/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
  86. data/spec/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
  87. data/spec/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
  88. data/spec/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
  89. data/spec/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +363 -0
  90. data/spec/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  91. data/spec/coverage/assets/0.3.9/favicon.png +0 -0
  92. data/spec/coverage/assets/0.3.9/jquery-1.4.2.min.js +155 -0
  93. data/spec/coverage/assets/0.3.9/jquery.dataTables.min.js +152 -0
  94. data/spec/coverage/assets/0.3.9/jquery.timeago.js +141 -0
  95. data/spec/coverage/assets/0.3.9/jquery.url.js +174 -0
  96. data/spec/coverage/assets/0.3.9/loading.gif +0 -0
  97. data/spec/coverage/assets/0.3.9/magnify.png +0 -0
  98. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  99. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  100. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  101. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  102. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  103. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  104. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  105. data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  106. data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
  107. data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  108. data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
  109. data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
  110. data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  111. data/spec/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  112. data/spec/coverage/assets/0.3.9/stylesheet.css +341 -0
  113. data/spec/coverage/index.html +47481 -0
  114. data/spec/coverage/resultset.yml +3556 -0
  115. data/spec/data/config/sevendigital.yml +5 -5
  116. data/spec/data/configuration_env_override.yml +5 -5
  117. data/spec/data/configuration_override.yml +1 -1
  118. data/spec/digestion_tract/api_response_digestor_spec.rb +92 -92
  119. data/spec/digestion_tract/artist_digestor_spec.rb +81 -81
  120. data/spec/digestion_tract/basket_digestor_spec.rb +31 -31
  121. data/spec/digestion_tract/basket_item_digestor_spec.rb +58 -58
  122. data/spec/digestion_tract/chart_digestor_spec.rb +52 -52
  123. data/spec/digestion_tract/download_url_digestor_spec.rb +40 -40
  124. data/spec/digestion_tract/format_digestor_spec.rb +38 -38
  125. data/spec/digestion_tract/label_digestor_spec.rb +33 -33
  126. data/spec/digestion_tract/locker_digestor_spec.rb +30 -30
  127. data/spec/digestion_tract/locker_release_digestor_spec.rb +70 -70
  128. data/spec/digestion_tract/locker_track_digestor_spec.rb +56 -56
  129. data/spec/digestion_tract/oauth_access_token_digestor_spec.rb +34 -34
  130. data/spec/digestion_tract/oauth_request_token_digestor_spec.rb +34 -34
  131. data/spec/digestion_tract/pager_digestor_spec.rb +50 -50
  132. data/spec/digestion_tract/price_digestor_spec.rb +73 -73
  133. data/spec/digestion_tract/release_digestor_spec.rb +101 -101
  134. data/spec/digestion_tract/tag_digestor_spec.rb +46 -46
  135. data/spec/digestion_tract/track_digestor_spec.rb +104 -104
  136. data/spec/digestion_tract/user_card_digestor_spec.rb +58 -58
  137. data/spec/digestion_tract/user_digestor_spec.rb +44 -44
  138. data/spec/management/artist_manager_spec.rb +151 -151
  139. data/spec/management/basket_manager_spec.rb +77 -77
  140. data/spec/management/oauth_manager_spec.rb +72 -72
  141. data/spec/management/release_manager_spec.rb +200 -200
  142. data/spec/management/tag_manager_spec.rb +34 -34
  143. data/spec/management/track_manager_spec.rb +107 -107
  144. data/spec/management/user_card_manager_spec.rb +78 -78
  145. data/spec/management/user_manager_spec.rb +202 -202
  146. data/spec/model/api_response_spec.rb +48 -48
  147. data/spec/model/artist_spec.rb +154 -154
  148. data/spec/model/basket_spec.rb +62 -62
  149. data/spec/model/coverage/assets/0.3.9/app.js +66 -0
  150. data/spec/model/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
  151. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
  152. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
  153. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
  154. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
  155. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
  156. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
  157. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
  158. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
  159. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
  160. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
  161. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
  162. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
  163. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
  164. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
  165. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
  166. data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
  167. data/spec/model/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
  168. data/spec/model/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
  169. data/spec/model/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
  170. data/spec/model/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +363 -0
  171. data/spec/model/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  172. data/spec/model/coverage/assets/0.3.9/favicon.png +0 -0
  173. data/spec/model/coverage/assets/0.3.9/jquery-1.4.2.min.js +155 -0
  174. data/spec/model/coverage/assets/0.3.9/jquery.dataTables.min.js +152 -0
  175. data/spec/model/coverage/assets/0.3.9/jquery.timeago.js +141 -0
  176. data/spec/model/coverage/assets/0.3.9/jquery.url.js +174 -0
  177. data/spec/model/coverage/assets/0.3.9/loading.gif +0 -0
  178. data/spec/model/coverage/assets/0.3.9/magnify.png +0 -0
  179. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  180. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  181. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  182. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  183. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  184. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  185. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  186. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  187. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
  188. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  189. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
  190. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
  191. data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  192. data/spec/model/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  193. data/spec/model/coverage/assets/0.3.9/stylesheet.css +341 -0
  194. data/spec/model/coverage/index.html +8637 -0
  195. data/spec/model/coverage/resultset.yml +642 -0
  196. data/spec/model/release_spec.rb +122 -122
  197. data/spec/model/sevendigital_object_spec.rb +73 -73
  198. data/spec/model/track_spec.rb +144 -144
  199. data/spec/model/user_spec.rb +160 -160
  200. data/spec/pager_spec.rb +7 -7
  201. data/spec/peachy_spec_helper_patch.rb +6 -6
  202. data/spec/proxy_police_spec.rb +69 -69
  203. data/spec/sevendigital_spec.rb +51 -70
  204. data/spec/sevendigital_spec.yml +4 -4
  205. data/spec/spec_helper.rb +64 -64
  206. data/spec/test-xml/methods/artist/browse.xml +21 -21
  207. data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
  208. data/spec/test-xml/methods/artist/chart.xml +30 -30
  209. data/spec/test-xml/methods/artist/details.xml +9 -9
  210. data/spec/test-xml/methods/artist/releases.xml +544 -544
  211. data/spec/test-xml/methods/artist/search.xml +18 -18
  212. data/spec/test-xml/methods/artist/similar.xml +39 -39
  213. data/spec/test-xml/methods/artist/tags.xml +11 -11
  214. data/spec/test-xml/methods/artist/toptracks.xml +279 -279
  215. data/spec/test-xml/methods/basket/additem.xml +23 -23
  216. data/spec/test-xml/methods/basket/create.xml +10 -10
  217. data/spec/test-xml/methods/basket/index.xml +23 -23
  218. data/spec/test-xml/methods/basket/removeitem.xml +10 -10
  219. data/spec/test-xml/methods/oauth/accesstoken.xml +5 -5
  220. data/spec/test-xml/methods/oauth/requesttoken.xml +5 -5
  221. data/spec/test-xml/methods/release/bydate.xml +173 -173
  222. data/spec/test-xml/methods/release/bytag/top.xml +150 -150
  223. data/spec/test-xml/methods/release/chart.xml +181 -181
  224. data/spec/test-xml/methods/release/details.xml +48 -48
  225. data/spec/test-xml/methods/release/recommend.xml +89 -89
  226. data/spec/test-xml/methods/release/search.xml +194 -194
  227. data/spec/test-xml/methods/release/tags.xml +27 -27
  228. data/spec/test-xml/methods/release/tracks.xml +28 -28
  229. data/spec/test-xml/methods/tag/index.xml +16 -16
  230. data/spec/test-xml/methods/track/chart.xml +149 -149
  231. data/spec/test-xml/methods/track/details.xml +30 -30
  232. data/spec/test-xml/methods/track/search.xml +159 -159
  233. data/spec/test-xml/methods/user/locker.xml +49 -49
  234. data/spec/test-xml/methods/user/payment/card/add.xml +7 -7
  235. data/spec/test-xml/methods/user/payment/card/index.xml +7 -7
  236. data/spec/test-xml/methods/user/purchase/basket.xml +49 -0
  237. data/spec/test-xml/methods/user/purchase/item.xml +48 -48
  238. data/spec/test-xml/methods/user/signUp.xml +5 -5
  239. data/spec/test-xml/objects/artist.xml +6 -6
  240. data/spec/test-xml/objects/artist_chart_item.xml +7 -7
  241. data/spec/test-xml/objects/artist_list.xml +22 -22
  242. data/spec/test-xml/objects/artist_list_empty.xml +4 -4
  243. data/spec/test-xml/objects/basket.xml +21 -21
  244. data/spec/test-xml/objects/basket_item.xml +11 -11
  245. data/spec/test-xml/objects/basket_item_list.xml +25 -25
  246. data/spec/test-xml/objects/basket_item_list_empty.xml +1 -1
  247. data/spec/test-xml/objects/download_url.xml +7 -7
  248. data/spec/test-xml/objects/locker.xml +47 -47
  249. data/spec/test-xml/objects/locker_release.xml +40 -40
  250. data/spec/test-xml/objects/locker_release_list.xml +87 -87
  251. data/spec/test-xml/objects/locker_release_list_empty.xml +4 -4
  252. data/spec/test-xml/objects/locker_release_one_item_list.xml +43 -43
  253. data/spec/test-xml/objects/locker_track.xml +25 -25
  254. data/spec/test-xml/objects/locker_track_list.xml +26 -26
  255. data/spec/test-xml/objects/locker_track_list_empty.xml +2 -2
  256. data/spec/test-xml/objects/oauth_access_token.xml +3 -3
  257. data/spec/test-xml/objects/oauth_request_token.xml +3 -3
  258. data/spec/test-xml/objects/price.xml +7 -7
  259. data/spec/test-xml/objects/release.xml +40 -40
  260. data/spec/test-xml/objects/release_chart_item.xml +39 -39
  261. data/spec/test-xml/objects/release_list.xml +18 -18
  262. data/spec/test-xml/objects/release_list_empty.xml +4 -4
  263. data/spec/test-xml/objects/response.xml +38 -38
  264. data/spec/test-xml/objects/tag.xml +4 -4
  265. data/spec/test-xml/objects/track.xml +33 -33
  266. data/spec/test-xml/objects/track_chart_item.xml +27 -27
  267. data/spec/test-xml/objects/user.xml +4 -4
  268. data/spec/test-xml/objects/user_payment_card.xml +5 -5
  269. metadata +193 -3
@@ -1,31 +1,31 @@
1
- require "spec_helper"
2
-
3
- describe "ApiRequest" do
4
-
5
- it "should always provide selected parameters in 7digital API format" do
6
-
7
- request = Sevendigital::ApiRequest.new(:METHOD, 'method', {
8
- :page => 5,
9
- :per_page => 3,
10
- :shop_id => 99,
11
- :image_size => 999
12
- })
13
- request.parameters[:page].should == 5
14
- request.parameters[:pageSize].should == 3
15
- request.parameters[:per_page].should == nil
16
- request.parameters[:shopId].should == 99
17
- request.parameters[:shop_id].should == nil
18
- request.parameters[:imageSize].should == 999
19
- request.parameters[:image_size].should == nil
20
-
21
- end
22
-
23
- it "should not contain nil parameters" do
24
-
25
- request = Sevendigital::ApiRequest.new(:METHOD, 'method', {:key1 => "value", :key2 => nil})
26
- request.parameters[:key1].should == "value"
27
- request.parameters.has_key?(:key2).should == false
28
-
29
- end
30
-
31
- end
1
+ require "spec_helper"
2
+
3
+ describe "ApiRequest" do
4
+
5
+ it "should always provide selected parameters in 7digital API format" do
6
+
7
+ request = Sevendigital::ApiRequest.new(:METHOD, 'method', {
8
+ :page => 5,
9
+ :per_page => 3,
10
+ :shop_id => 99,
11
+ :image_size => 999
12
+ })
13
+ request.parameters[:page].should == 5
14
+ request.parameters[:pageSize].should == 3
15
+ request.parameters[:per_page].should == nil
16
+ request.parameters[:shopId].should == 99
17
+ request.parameters[:shop_id].should == nil
18
+ request.parameters[:imageSize].should == 999
19
+ request.parameters[:image_size].should == nil
20
+
21
+ end
22
+
23
+ it "should not contain nil parameters" do
24
+
25
+ request = Sevendigital::ApiRequest.new(:METHOD, 'method', {:key1 => "value", :key2 => nil})
26
+ request.parameters[:key1].should == "value"
27
+ request.parameters.has_key?(:key2).should == false
28
+
29
+ end
30
+
31
+ end
@@ -1,75 +1,80 @@
1
- require "spec_helper"
2
-
3
- describe "ClientConfiguration" do
4
-
5
- it "should initialize with default configuration" do
6
- configuration = Sevendigital::ClientConfiguration.new
7
- configuration.api_url.should == 'api.7digital.com'
8
- configuration.api_version.should == '1.2'
9
- configuration.media_api_url.should == 'media-eu.7digital.com'
10
- configuration.media_api_version.should == 'media'
11
- configuration.account_api_url.should == 'account.7digital.com'
12
- configuration.account_api_version.should == 'web'
13
- end
14
-
15
- it "should initialize using hash" do
16
- configuration = Sevendigital::ClientConfiguration.new(:api_url => "test-hash.7digital.com")
17
- configuration.api_url.should == 'test-hash.7digital.com'
18
- end
19
-
20
- it "should initialize using OpenStruct object" do
21
- configuration = Sevendigital::ClientConfiguration.new(OpenStruct.new(:api_url => "test-openstruct.7digital.com"))
22
- configuration.api_url.should == 'test-openstruct.7digital.com'
23
- end
24
-
25
- it "should initialize using simple YAML file" do
26
- configuration = Sevendigital::ClientConfiguration.new(File.join(File.dirname(__FILE__),"data", "configuration_override.yml"))
27
- configuration.api_url.should == 'test-yml-simple.7digital.com'
28
- end
29
-
30
- it "should initialize mixing configuration file name and explicit hash override" do
31
- conf_file = File.join(File.dirname(__FILE__),"data", "configuration_override.yml")
32
- configuration = Sevendigital::ClientConfiguration.new(conf_file, :api_url => 'hash-override')
33
- configuration.api_url.should == 'hash-override'
34
- configuration.api_version.should == 'yml-simple'
35
- end
36
-
37
- it "should initialize mixing hash settings and configuration file override" do
38
- conf_file = File.join(File.dirname(__FILE__),"data", "configuration_override.yml")
39
- configuration = Sevendigital::ClientConfiguration.new({:api_url => 'hash-override', :xxx => 'yyy'}, conf_file)
40
- configuration.api_url.should == 'test-yml-simple.7digital.com'
41
- configuration.xxx.should == 'yyy'
42
- end
43
-
44
- it "should initialize mixing 2 explicit hash overrides" do
45
- configuration = Sevendigital::ClientConfiguration.new( {:api_url => 'v1', :a => 'x'}, {:api_url => 'v2', :b => 'y'})
46
- configuration.api_url.should == 'v2'
47
- configuration.a.should == 'x'
48
- configuration.b.should == 'y'
49
- end
50
-
51
- it "should use environment specific configuration file" do
52
- conf_file = File.join(File.dirname(__FILE__),"data", "configuration_env_override.yml")
53
- configuration = Sevendigital::ClientConfiguration.new(conf_file)
54
- configuration.api_url.should == 'test-yml-common.7digital.com'
55
- end
56
-
57
- it "should use environment specific configuration file with environment specific settings" do
58
- conf_file = File.join(File.dirname(__FILE__),"data", "configuration_env_override.yml")
59
- puts conf_file
60
- Object.const_set(:RAILS_ENV, "development")
61
- configuration = Sevendigital::ClientConfiguration.new(conf_file)
62
- configuration.api_url.should == 'test-yml-development.7digital.com'
63
- Object.instance_eval{ remove_const :RAILS_ENV }
64
- end
65
-
66
- it "should use rails/config/sevendigital configuration as default rails settings" do
67
- rails_root = File.join(File.dirname(__FILE__),"data")
68
- puts rails_root
69
- Object.const_set(:RAILS_ROOT, rails_root)
70
- configuration = Sevendigital::ClientConfiguration.new()
71
- configuration.api_url.should == 'test-yml-rails-common.7digital.com'
72
- Object.instance_eval{ remove_const :RAILS_ROOT }
73
- end
74
-
1
+ require "spec_helper"
2
+
3
+ describe "ClientConfiguration" do
4
+
5
+ it "should initialize with default configuration" do
6
+ configuration = Sevendigital::ClientConfiguration.new
7
+ configuration.api_url.should == 'api.7digital.com'
8
+ configuration.api_version.should == '1.2'
9
+ configuration.media_api_url.should == 'media-eu.7digital.com'
10
+ configuration.media_api_version.should == 'media'
11
+ configuration.account_api_url.should == 'account.7digital.com'
12
+ configuration.account_api_version.should == 'web'
13
+ end
14
+
15
+ it "should initialize using hash" do
16
+ configuration = Sevendigital::ClientConfiguration.new(:api_url => "test-hash.7digital.com")
17
+ configuration.api_url.should == 'test-hash.7digital.com'
18
+ end
19
+
20
+ it "should initialize using OpenStruct object" do
21
+ configuration = Sevendigital::ClientConfiguration.new(OpenStruct.new(:api_url => "test-openstruct.7digital.com"))
22
+ configuration.api_url.should == 'test-openstruct.7digital.com'
23
+ end
24
+
25
+ it "should initialize using simple YAML file" do
26
+ configuration = Sevendigital::ClientConfiguration.new(File.join(File.dirname(__FILE__),"data", "configuration_override.yml"))
27
+ configuration.api_url.should == 'test-yml-simple.7digital.com'
28
+ end
29
+
30
+ it "should initialize mixing configuration file name and explicit hash override" do
31
+ conf_file = File.join(File.dirname(__FILE__),"data", "configuration_override.yml")
32
+ configuration = Sevendigital::ClientConfiguration.new(conf_file, :api_url => 'hash-override')
33
+ configuration.api_url.should == 'hash-override'
34
+ configuration.api_version.should == 'yml-simple'
35
+ end
36
+
37
+ it "should initialize mixing hash settings and configuration file override" do
38
+ conf_file = File.join(File.dirname(__FILE__),"data", "configuration_override.yml")
39
+ configuration = Sevendigital::ClientConfiguration.new({:api_url => 'hash-override', :xxx => 'yyy'}, conf_file)
40
+ configuration.api_url.should == 'test-yml-simple.7digital.com'
41
+ configuration.xxx.should == 'yyy'
42
+ end
43
+
44
+ it "should initialize mixing 2 explicit hash overrides" do
45
+ configuration = Sevendigital::ClientConfiguration.new( {:api_url => 'v1', :a => 'x'}, {:api_url => 'v2', :b => 'y'})
46
+ configuration.api_url.should == 'v2'
47
+ configuration.a.should == 'x'
48
+ configuration.b.should == 'y'
49
+ end
50
+
51
+ it "should use environment specific configuration file" do
52
+ conf_file = File.join(File.dirname(__FILE__),"data", "configuration_env_override.yml")
53
+ configuration = Sevendigital::ClientConfiguration.new(conf_file)
54
+ configuration.api_url.should == 'test-yml-common.7digital.com'
55
+ end
56
+
57
+ it "should use environment specific configuration file with environment specific settings" do
58
+ conf_file = File.join(File.dirname(__FILE__),"data", "configuration_env_override.yml")
59
+ puts conf_file
60
+
61
+ rails = OpenStruct.new
62
+ rails.env = "development"
63
+ Object.const_set(:Rails, rails)
64
+
65
+ configuration = Sevendigital::ClientConfiguration.new(conf_file)
66
+ configuration.api_url.should == 'test-yml-development.7digital.com'
67
+ Object.instance_eval{ remove_const :Rails }
68
+ end
69
+
70
+ it "should use rails/config/sevendigital configuration as default rails settings" do
71
+ rails = OpenStruct.new
72
+ rails.root = Pathname(File.join(File.dirname(__FILE__),"data"))
73
+ Object.const_set(:Rails, rails)
74
+
75
+ configuration = Sevendigital::ClientConfiguration.new()
76
+ configuration.api_url.should == 'test-yml-rails-common.7digital.com'
77
+ Object.instance_eval{ remove_const :Rails }
78
+ end
79
+
75
80
  end
data/spec/client_spec.rb CHANGED
@@ -1,163 +1,163 @@
1
- require "spec_helper"
2
-
3
- describe "Client" do
4
-
5
- it "should not be verbose if not told anything" do
6
- client = Sevendigital::Client.new
7
- client.verbose?.should == false
8
- client.very_verbose?.should == false
9
- end
10
-
11
- it "should not be verbose if told to so" do
12
- client = Sevendigital::Client.new(:verbose => false)
13
- client.verbose?.should == false
14
- client.very_verbose?.should == false
15
- end
16
-
17
- it "should be verbose if told to be verbose in configuration" do
18
- client = Sevendigital::Client.new(:verbose => true)
19
- client.verbose?.should == true
20
- client.very_verbose?.should == false
21
- end
22
-
23
- it "should be very verbose if told to be very verbose in configruation" do
24
- client = Sevendigital::Client.new(:verbose => :very_verbose)
25
- client.verbose?.should == true
26
- client.very_verbose?.should == true
27
- end
28
-
29
- it "should be verbose if told so" do
30
- client = Sevendigital::Client.new(:verbose => false)
31
- client.configuration.verbose = true
32
- client.verbose?.should == true
33
- client.very_verbose?.should == false
34
- end
35
-
36
- it "should provide selected properties as default parameters for all api requests" do
37
- client = Sevendigital::Client.new(:page_size => 12345, :country => 'gb')
38
- client.configuration.country = 'sk'
39
- client.send(:default_parameters).should == {:page_size => 12345, :country => 'sk'}
40
- end
41
-
42
- it "create_api_request should merge method parameters and options with parameters taking preference" do
43
- client = Sevendigital::Client.new
44
- parameters = {:trackId => 1239, :releaseId => 456, :country => "CU"}
45
- options = {:page => 1, :country => "US", :trackId => "SS"}
46
- request = client.create_api_request(:GET, 'method', parameters, options)
47
- request.parameters[:trackId].should == 1239
48
- request.parameters[:releaseId].should == 456
49
- request.parameters[:country].should == "CU"
50
- request.parameters[:page].should == 1
51
- puts request.parameters.inspect
52
- request.parameters.keys.size.should == 4 # page_size == null
53
-
54
- end
55
-
56
- it "create_api_request should add default parameters to request" do
57
- client = Sevendigital::Client.new
58
- client.configuration.page_size = 100
59
- client.configuration.shop_id = 200
60
- request = client.create_api_request('method', {}, {})
61
-
62
- request.parameters[:pageSize].should == 100;
63
- request.parameters[:shopId].should == 200;
64
-
65
- end
66
-
67
- it "should make an API call using API request created by the client itself " do
68
- a_method_name = "method"
69
- a_method_params = { :param1 => 1 }
70
- an_http_method = :METHOD
71
-
72
- an_api_response = stub(Sevendigital::ApiResponse)
73
- an_api_request = stub(Sevendigital::ApiRequest)
74
-
75
- client = Sevendigital::Client.new
76
- mock_operator = mock(Sevendigital::ApiOperator)
77
- client.stub!(:operator).and_return(mock_operator)
78
-
79
- client.should_receive(:create_api_request).with(an_http_method, a_method_name, a_method_params, {}).and_return(an_api_request)
80
-
81
- mock_operator.should_receive(:call_api).with(an_api_request).and_return(an_api_response)
82
-
83
- response = client.make_api_request(an_http_method, a_method_name, a_method_params, {})
84
-
85
- response.should == an_api_response
86
-
87
- end
88
-
89
- it "should make a signed & secure API call" do
90
- a_method_name = "method"
91
- a_method_params = { :param1 => 1 }
92
- an_http_method = :METHOD
93
- a_token = "token"
94
-
95
- an_api_response = "response"
96
-
97
- client = Sevendigital::Client.new
98
- mock_operator = mock(Sevendigital::ApiOperator)
99
- client.stub!(:operator).and_return(mock_operator)
100
-
101
- mock_operator.should_receive(:call_api) { |api_request|
102
- api_request.api_method.should == a_method_name
103
- api_request.http_method.should == an_http_method
104
- api_request.requires_secure_connection?.should == true
105
- api_request.requires_signature?.should == true
106
- api_request.parameters.should == a_method_params
107
- api_request.token.should == a_token
108
- an_api_response
109
- }
110
-
111
- response = client.make_signed_api_request(an_http_method, a_method_name, a_method_params, {}, a_token)
112
-
113
- response.should == an_api_response
114
-
115
- end
116
-
117
- it "should get API host url for specific API service from configuration" do
118
-
119
- client = Sevendigital::Client.new { |configuration|
120
- configuration.media_api_url = "media-base.api.url"
121
- configuration.media_api_version = "media-version"
122
- }
123
-
124
- client.api_host_and_version(:media).should == ["media-base.api.url", "media-version"]
125
-
126
- end
127
-
128
- it "should get API host url for standard API service from configuration" do
129
-
130
- client = Sevendigital::Client.new { |configuration|
131
- configuration.api_url = "base.api.url"
132
- configuration.api_version = "version"
133
- }
134
-
135
- client.send(:api_host_and_version).should == ["base.api.url", "version"]
136
-
137
- end
138
-
139
- it "should provide initialized oauth consumer" do
140
-
141
- configuration = Sevendigital::ClientConfiguration.new
142
- configuration.oauth_consumer_key = "api_key"
143
- configuration.oauth_consumer_secret = "secret"
144
- configuration.account_api_url = "account.7d.com"
145
- configuration.account_api_version = "mobile"
146
- client = Sevendigital::Client.new(configuration)
147
-
148
- consumer = client.oauth_consumer
149
- consumer.authorize_path.should == "https://account.7d.com/mobile/oauth/authorise"
150
- consumer.key.should == "api_key"
151
- consumer.secret.should == "secret"
152
-
153
- end
154
-
155
- it "user_agent_info should contain app_name & version if specified" do
156
- client = Sevendigital::Client.new(:app_name => "RSpec", :app_version => "0.0.7")
157
-
158
- client.user_agent_info.should == "7digital Gem #{Sevendigital::VERSION}/RSpec 0.0.7"
159
-
160
- end
161
-
162
-
1
+ require "spec_helper"
2
+
3
+ describe "Client" do
4
+
5
+ it "should not be verbose if not told anything" do
6
+ client = Sevendigital::Client.new
7
+ client.verbose?.should == false
8
+ client.very_verbose?.should == false
9
+ end
10
+
11
+ it "should not be verbose if told to so" do
12
+ client = Sevendigital::Client.new(:verbose => false)
13
+ client.verbose?.should == false
14
+ client.very_verbose?.should == false
15
+ end
16
+
17
+ it "should be verbose if told to be verbose in configuration" do
18
+ client = Sevendigital::Client.new(:verbose => true)
19
+ client.verbose?.should == true
20
+ client.very_verbose?.should == false
21
+ end
22
+
23
+ it "should be very verbose if told to be very verbose in configruation" do
24
+ client = Sevendigital::Client.new(:verbose => :very_verbose)
25
+ client.verbose?.should == true
26
+ client.very_verbose?.should == true
27
+ end
28
+
29
+ it "should be verbose if told so" do
30
+ client = Sevendigital::Client.new(:verbose => false)
31
+ client.configuration.verbose = true
32
+ client.verbose?.should == true
33
+ client.very_verbose?.should == false
34
+ end
35
+
36
+ it "should provide selected properties as default parameters for all api requests" do
37
+ client = Sevendigital::Client.new(:page_size => 12345, :country => 'gb')
38
+ client.configuration.country = 'sk'
39
+ client.send(:default_parameters).should == {:page_size => 12345, :country => 'sk'}
40
+ end
41
+
42
+ it "create_api_request should merge method parameters and options with parameters taking preference" do
43
+ client = Sevendigital::Client.new
44
+ parameters = {:trackId => 1239, :releaseId => 456, :country => "CU"}
45
+ options = {:page => 1, :country => "US", :trackId => "SS"}
46
+ request = client.create_api_request(:GET, 'method', parameters, options)
47
+ request.parameters[:trackId].should == 1239
48
+ request.parameters[:releaseId].should == 456
49
+ request.parameters[:country].should == "CU"
50
+ request.parameters[:page].should == 1
51
+ puts request.parameters.inspect
52
+ request.parameters.keys.size.should == 4 # page_size == null
53
+
54
+ end
55
+
56
+ it "create_api_request should add default parameters to request" do
57
+ client = Sevendigital::Client.new
58
+ client.configuration.page_size = 100
59
+ client.configuration.shop_id = 200
60
+ request = client.create_api_request('method', {}, {})
61
+
62
+ request.parameters[:pageSize].should == 100;
63
+ request.parameters[:shopId].should == 200;
64
+
65
+ end
66
+
67
+ it "should make an API call using API request created by the client itself " do
68
+ a_method_name = "method"
69
+ a_method_params = { :param1 => 1 }
70
+ an_http_method = :METHOD
71
+
72
+ an_api_response = stub(Sevendigital::ApiResponse)
73
+ an_api_request = stub(Sevendigital::ApiRequest)
74
+
75
+ client = Sevendigital::Client.new
76
+ mock_operator = mock(Sevendigital::ApiOperator)
77
+ client.stub!(:operator).and_return(mock_operator)
78
+
79
+ client.should_receive(:create_api_request).with(an_http_method, a_method_name, a_method_params, {}).and_return(an_api_request)
80
+
81
+ mock_operator.should_receive(:call_api).with(an_api_request).and_return(an_api_response)
82
+
83
+ response = client.make_api_request(an_http_method, a_method_name, a_method_params, {})
84
+
85
+ response.should == an_api_response
86
+
87
+ end
88
+
89
+ it "should make a signed & secure API call" do
90
+ a_method_name = "method"
91
+ a_method_params = { :param1 => 1 }
92
+ an_http_method = :METHOD
93
+ a_token = "token"
94
+
95
+ an_api_response = "response"
96
+
97
+ client = Sevendigital::Client.new
98
+ mock_operator = mock(Sevendigital::ApiOperator)
99
+ client.stub!(:operator).and_return(mock_operator)
100
+
101
+ mock_operator.should_receive(:call_api) { |api_request|
102
+ api_request.api_method.should == a_method_name
103
+ api_request.http_method.should == an_http_method
104
+ api_request.requires_secure_connection?.should == true
105
+ api_request.requires_signature?.should == true
106
+ api_request.parameters.should == a_method_params
107
+ api_request.token.should == a_token
108
+ an_api_response
109
+ }
110
+
111
+ response = client.make_signed_api_request(an_http_method, a_method_name, a_method_params, {}, a_token)
112
+
113
+ response.should == an_api_response
114
+
115
+ end
116
+
117
+ it "should get API host url for specific API service from configuration" do
118
+
119
+ client = Sevendigital::Client.new { |configuration|
120
+ configuration.media_api_url = "media-base.api.url"
121
+ configuration.media_api_version = "media-version"
122
+ }
123
+
124
+ client.api_host_and_version(:media).should == ["media-base.api.url", "media-version"]
125
+
126
+ end
127
+
128
+ it "should get API host url for standard API service from configuration" do
129
+
130
+ client = Sevendigital::Client.new { |configuration|
131
+ configuration.api_url = "base.api.url"
132
+ configuration.api_version = "version"
133
+ }
134
+
135
+ client.send(:api_host_and_version).should == ["base.api.url", "version"]
136
+
137
+ end
138
+
139
+ it "should provide initialized oauth consumer" do
140
+
141
+ configuration = Sevendigital::ClientConfiguration.new
142
+ configuration.oauth_consumer_key = "api_key"
143
+ configuration.oauth_consumer_secret = "secret"
144
+ configuration.account_api_url = "account.7d.com"
145
+ configuration.account_api_version = "mobile"
146
+ client = Sevendigital::Client.new(configuration)
147
+
148
+ consumer = client.oauth_consumer
149
+ consumer.authorize_path.should == "https://account.7d.com/mobile/oauth/authorise"
150
+ consumer.key.should == "api_key"
151
+ consumer.secret.should == "secret"
152
+
153
+ end
154
+
155
+ it "user_agent_info should contain app_name & version if specified" do
156
+ client = Sevendigital::Client.new(:app_name => "RSpec", :app_version => "0.0.7")
157
+
158
+ client.user_agent_info.should == "7digital Gem #{Sevendigital::VERSION}/RSpec 0.0.7"
159
+
160
+ end
161
+
162
+
163
163
  end