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.
- data/README.rdoc +136 -136
- data/lib/sevendigital.rb +53 -53
- data/lib/sevendigital/api_operator.rb +130 -130
- data/lib/sevendigital/api_operator_cached.rb +41 -41
- data/lib/sevendigital/api_request.rb +65 -65
- data/lib/sevendigital/client.rb +113 -113
- data/lib/sevendigital/client_configuration.rb +86 -86
- data/lib/sevendigital/client_digestors.rb +107 -107
- data/lib/sevendigital/client_managers.rb +47 -47
- data/lib/sevendigital/digestion_tract/api_response_digestor.rb +58 -58
- data/lib/sevendigital/digestion_tract/artist_digestor.rb +32 -32
- data/lib/sevendigital/digestion_tract/basket_digestor.rb +19 -19
- data/lib/sevendigital/digestion_tract/basket_item_digestor.rb +26 -26
- data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +28 -28
- data/lib/sevendigital/digestion_tract/digestor.rb +71 -71
- data/lib/sevendigital/digestion_tract/download_url_digestor.rb +20 -20
- data/lib/sevendigital/digestion_tract/format_digestor.rb +22 -22
- data/lib/sevendigital/digestion_tract/label_digestor.rb +20 -20
- data/lib/sevendigital/digestion_tract/locker_digestor.rb +18 -18
- data/lib/sevendigital/digestion_tract/locker_release_digestor.rb +20 -20
- data/lib/sevendigital/digestion_tract/locker_track_digestor.rb +22 -22
- data/lib/sevendigital/digestion_tract/oauth_access_token_digestor.rb +14 -14
- data/lib/sevendigital/digestion_tract/oauth_request_token_digestor.rb +14 -14
- data/lib/sevendigital/digestion_tract/pager_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/price_digestor.rb +25 -25
- data/lib/sevendigital/digestion_tract/release_digestor.rb +53 -53
- data/lib/sevendigital/digestion_tract/tag_digestor.rb +22 -22
- data/lib/sevendigital/digestion_tract/track_digestor.rb +38 -38
- data/lib/sevendigital/digestion_tract/user_card_digestor.rb +23 -23
- data/lib/sevendigital/digestion_tract/user_digestor.rb +20 -20
- data/lib/sevendigital/management/artist_manager.rb +99 -99
- data/lib/sevendigital/management/basket_manager.rb +29 -29
- data/lib/sevendigital/management/manager.rb +12 -12
- data/lib/sevendigital/management/oauth_manager.rb +23 -23
- data/lib/sevendigital/management/release_manager.rb +56 -56
- data/lib/sevendigital/management/tag_manager.rb +10 -10
- data/lib/sevendigital/management/track_manager.rb +28 -28
- data/lib/sevendigital/management/user_card_manager.rb +26 -26
- data/lib/sevendigital/management/user_manager.rb +71 -71
- data/lib/sevendigital/model/api_response.rb +25 -25
- data/lib/sevendigital/model/artist.rb +94 -94
- data/lib/sevendigital/model/basket.rb +15 -15
- data/lib/sevendigital/model/basket_item.rb +14 -14
- data/lib/sevendigital/model/card.rb +11 -11
- data/lib/sevendigital/model/chart_item.rb +9 -9
- data/lib/sevendigital/model/download_url.rb +7 -7
- data/lib/sevendigital/model/format.rb +7 -7
- data/lib/sevendigital/model/label.rb +7 -7
- data/lib/sevendigital/model/locker.rb +4 -4
- data/lib/sevendigital/model/locker_release.rb +9 -9
- data/lib/sevendigital/model/locker_track.rb +9 -9
- data/lib/sevendigital/model/price.rb +9 -9
- data/lib/sevendigital/model/release.rb +52 -52
- data/lib/sevendigital/model/sevendigital_error.rb +11 -11
- data/lib/sevendigital/model/sevendigital_object.rb +57 -57
- data/lib/sevendigital/model/tag.rb +7 -7
- data/lib/sevendigital/model/track.rb +83 -83
- data/lib/sevendigital/model/user.rb +63 -63
- data/lib/sevendigital/pager.rb +23 -23
- data/lib/sevendigital/peachy_patchy.rb +9 -9
- data/lib/sevendigital/proxy_police.rb +27 -27
- data/lib/sevendigital/version.rb +5 -5
- data/spec/api_operator_cached_spec.rb +178 -178
- data/spec/api_operator_spec.rb +336 -336
- data/spec/api_request_spec.rb +31 -31
- data/spec/client_configuration_spec.rb +79 -74
- data/spec/client_spec.rb +162 -162
- data/spec/coverage/assets/0.3.9/app.js +66 -0
- data/spec/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
- data/spec/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/spec/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/spec/coverage/assets/0.3.9/favicon.png +0 -0
- data/spec/coverage/assets/0.3.9/jquery-1.4.2.min.js +155 -0
- data/spec/coverage/assets/0.3.9/jquery.dataTables.min.js +152 -0
- data/spec/coverage/assets/0.3.9/jquery.timeago.js +141 -0
- data/spec/coverage/assets/0.3.9/jquery.url.js +174 -0
- data/spec/coverage/assets/0.3.9/loading.gif +0 -0
- data/spec/coverage/assets/0.3.9/magnify.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +295 -0
- data/spec/coverage/assets/0.3.9/stylesheet.css +341 -0
- data/spec/coverage/index.html +47481 -0
- data/spec/coverage/resultset.yml +3556 -0
- data/spec/data/config/sevendigital.yml +5 -5
- data/spec/data/configuration_env_override.yml +5 -5
- data/spec/data/configuration_override.yml +1 -1
- data/spec/digestion_tract/api_response_digestor_spec.rb +92 -92
- data/spec/digestion_tract/artist_digestor_spec.rb +81 -81
- data/spec/digestion_tract/basket_digestor_spec.rb +31 -31
- data/spec/digestion_tract/basket_item_digestor_spec.rb +58 -58
- data/spec/digestion_tract/chart_digestor_spec.rb +52 -52
- data/spec/digestion_tract/download_url_digestor_spec.rb +40 -40
- data/spec/digestion_tract/format_digestor_spec.rb +38 -38
- data/spec/digestion_tract/label_digestor_spec.rb +33 -33
- data/spec/digestion_tract/locker_digestor_spec.rb +30 -30
- data/spec/digestion_tract/locker_release_digestor_spec.rb +70 -70
- data/spec/digestion_tract/locker_track_digestor_spec.rb +56 -56
- data/spec/digestion_tract/oauth_access_token_digestor_spec.rb +34 -34
- data/spec/digestion_tract/oauth_request_token_digestor_spec.rb +34 -34
- data/spec/digestion_tract/pager_digestor_spec.rb +50 -50
- data/spec/digestion_tract/price_digestor_spec.rb +73 -73
- data/spec/digestion_tract/release_digestor_spec.rb +101 -101
- data/spec/digestion_tract/tag_digestor_spec.rb +46 -46
- data/spec/digestion_tract/track_digestor_spec.rb +104 -104
- data/spec/digestion_tract/user_card_digestor_spec.rb +58 -58
- data/spec/digestion_tract/user_digestor_spec.rb +44 -44
- data/spec/management/artist_manager_spec.rb +151 -151
- data/spec/management/basket_manager_spec.rb +77 -77
- data/spec/management/oauth_manager_spec.rb +72 -72
- data/spec/management/release_manager_spec.rb +200 -200
- data/spec/management/tag_manager_spec.rb +34 -34
- data/spec/management/track_manager_spec.rb +107 -107
- data/spec/management/user_card_manager_spec.rb +78 -78
- data/spec/management/user_manager_spec.rb +202 -202
- data/spec/model/api_response_spec.rb +48 -48
- data/spec/model/artist_spec.rb +154 -154
- data/spec/model/basket_spec.rb +62 -62
- data/spec/model/coverage/assets/0.3.9/app.js +66 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/spec/model/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/spec/model/coverage/assets/0.3.9/favicon.png +0 -0
- data/spec/model/coverage/assets/0.3.9/jquery-1.4.2.min.js +155 -0
- data/spec/model/coverage/assets/0.3.9/jquery.dataTables.min.js +152 -0
- data/spec/model/coverage/assets/0.3.9/jquery.timeago.js +141 -0
- data/spec/model/coverage/assets/0.3.9/jquery.url.js +174 -0
- data/spec/model/coverage/assets/0.3.9/loading.gif +0 -0
- data/spec/model/coverage/assets/0.3.9/magnify.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/model/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +295 -0
- data/spec/model/coverage/assets/0.3.9/stylesheet.css +341 -0
- data/spec/model/coverage/index.html +8637 -0
- data/spec/model/coverage/resultset.yml +642 -0
- data/spec/model/release_spec.rb +122 -122
- data/spec/model/sevendigital_object_spec.rb +73 -73
- data/spec/model/track_spec.rb +144 -144
- data/spec/model/user_spec.rb +160 -160
- data/spec/pager_spec.rb +7 -7
- data/spec/peachy_spec_helper_patch.rb +6 -6
- data/spec/proxy_police_spec.rb +69 -69
- data/spec/sevendigital_spec.rb +51 -70
- data/spec/sevendigital_spec.yml +4 -4
- data/spec/spec_helper.rb +64 -64
- data/spec/test-xml/methods/artist/browse.xml +21 -21
- data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
- data/spec/test-xml/methods/artist/chart.xml +30 -30
- data/spec/test-xml/methods/artist/details.xml +9 -9
- data/spec/test-xml/methods/artist/releases.xml +544 -544
- data/spec/test-xml/methods/artist/search.xml +18 -18
- data/spec/test-xml/methods/artist/similar.xml +39 -39
- data/spec/test-xml/methods/artist/tags.xml +11 -11
- data/spec/test-xml/methods/artist/toptracks.xml +279 -279
- data/spec/test-xml/methods/basket/additem.xml +23 -23
- data/spec/test-xml/methods/basket/create.xml +10 -10
- data/spec/test-xml/methods/basket/index.xml +23 -23
- data/spec/test-xml/methods/basket/removeitem.xml +10 -10
- data/spec/test-xml/methods/oauth/accesstoken.xml +5 -5
- data/spec/test-xml/methods/oauth/requesttoken.xml +5 -5
- data/spec/test-xml/methods/release/bydate.xml +173 -173
- data/spec/test-xml/methods/release/bytag/top.xml +150 -150
- data/spec/test-xml/methods/release/chart.xml +181 -181
- data/spec/test-xml/methods/release/details.xml +48 -48
- data/spec/test-xml/methods/release/recommend.xml +89 -89
- data/spec/test-xml/methods/release/search.xml +194 -194
- data/spec/test-xml/methods/release/tags.xml +27 -27
- data/spec/test-xml/methods/release/tracks.xml +28 -28
- data/spec/test-xml/methods/tag/index.xml +16 -16
- data/spec/test-xml/methods/track/chart.xml +149 -149
- data/spec/test-xml/methods/track/details.xml +30 -30
- data/spec/test-xml/methods/track/search.xml +159 -159
- data/spec/test-xml/methods/user/locker.xml +49 -49
- data/spec/test-xml/methods/user/payment/card/add.xml +7 -7
- data/spec/test-xml/methods/user/payment/card/index.xml +7 -7
- data/spec/test-xml/methods/user/purchase/basket.xml +49 -0
- data/spec/test-xml/methods/user/purchase/item.xml +48 -48
- data/spec/test-xml/methods/user/signUp.xml +5 -5
- data/spec/test-xml/objects/artist.xml +6 -6
- data/spec/test-xml/objects/artist_chart_item.xml +7 -7
- data/spec/test-xml/objects/artist_list.xml +22 -22
- data/spec/test-xml/objects/artist_list_empty.xml +4 -4
- data/spec/test-xml/objects/basket.xml +21 -21
- data/spec/test-xml/objects/basket_item.xml +11 -11
- data/spec/test-xml/objects/basket_item_list.xml +25 -25
- data/spec/test-xml/objects/basket_item_list_empty.xml +1 -1
- data/spec/test-xml/objects/download_url.xml +7 -7
- data/spec/test-xml/objects/locker.xml +47 -47
- data/spec/test-xml/objects/locker_release.xml +40 -40
- data/spec/test-xml/objects/locker_release_list.xml +87 -87
- data/spec/test-xml/objects/locker_release_list_empty.xml +4 -4
- data/spec/test-xml/objects/locker_release_one_item_list.xml +43 -43
- data/spec/test-xml/objects/locker_track.xml +25 -25
- data/spec/test-xml/objects/locker_track_list.xml +26 -26
- data/spec/test-xml/objects/locker_track_list_empty.xml +2 -2
- data/spec/test-xml/objects/oauth_access_token.xml +3 -3
- data/spec/test-xml/objects/oauth_request_token.xml +3 -3
- data/spec/test-xml/objects/price.xml +7 -7
- data/spec/test-xml/objects/release.xml +40 -40
- data/spec/test-xml/objects/release_chart_item.xml +39 -39
- data/spec/test-xml/objects/release_list.xml +18 -18
- data/spec/test-xml/objects/release_list_empty.xml +4 -4
- data/spec/test-xml/objects/response.xml +38 -38
- data/spec/test-xml/objects/tag.xml +4 -4
- data/spec/test-xml/objects/track.xml +33 -33
- data/spec/test-xml/objects/track_chart_item.xml +27 -27
- data/spec/test-xml/objects/user.xml +4 -4
- data/spec/test-xml/objects/user_payment_card.xml +5 -5
- metadata +193 -3
data/spec/api_request_spec.rb
CHANGED
@@ -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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
Object.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|