7digital 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +143 -143
  3. data/lib/sevendigital.rb +55 -55
  4. data/lib/sevendigital/api_operator.rb +127 -127
  5. data/lib/sevendigital/api_operator_cached.rb +91 -62
  6. data/lib/sevendigital/api_request.rb +72 -62
  7. data/lib/sevendigital/client.rb +122 -122
  8. data/lib/sevendigital/client_configuration.rb +85 -83
  9. data/lib/sevendigital/client_digestors.rb +122 -122
  10. data/lib/sevendigital/client_managers.rb +57 -57
  11. data/lib/sevendigital/digestion_tract/api_response_digestor.rb +48 -48
  12. data/lib/sevendigital/digestion_tract/artist_digestor.rb +35 -35
  13. data/lib/sevendigital/digestion_tract/basket_digestor.rb +19 -19
  14. data/lib/sevendigital/digestion_tract/basket_item_digestor.rb +26 -26
  15. data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +34 -34
  16. data/lib/sevendigital/digestion_tract/country_digestor.rb +15 -15
  17. data/lib/sevendigital/digestion_tract/digestor.rb +122 -122
  18. data/lib/sevendigital/digestion_tract/download_url_digestor.rb +23 -23
  19. data/lib/sevendigital/digestion_tract/format_digestor.rb +24 -24
  20. data/lib/sevendigital/digestion_tract/label_digestor.rb +21 -21
  21. data/lib/sevendigital/digestion_tract/list_digestor.rb +24 -24
  22. data/lib/sevendigital/digestion_tract/list_item_digestor.rb +26 -26
  23. data/lib/sevendigital/digestion_tract/locker_digestor.rb +22 -22
  24. data/lib/sevendigital/digestion_tract/locker_release_digestor.rb +26 -26
  25. data/lib/sevendigital/digestion_tract/locker_track_digestor.rb +26 -26
  26. data/lib/sevendigital/digestion_tract/oauth_access_token_digestor.rb +18 -18
  27. data/lib/sevendigital/digestion_tract/oauth_request_token_digestor.rb +18 -18
  28. data/lib/sevendigital/digestion_tract/pager_digestor.rb +28 -28
  29. data/lib/sevendigital/digestion_tract/price_digestor.rb +28 -28
  30. data/lib/sevendigital/digestion_tract/release_digestor.rb +45 -45
  31. data/lib/sevendigital/digestion_tract/tag_digestor.rb +23 -23
  32. data/lib/sevendigital/digestion_tract/track_digestor.rb +38 -37
  33. data/lib/sevendigital/digestion_tract/user_card_digestor.rb +24 -24
  34. data/lib/sevendigital/digestion_tract/user_digestor.rb +21 -21
  35. data/lib/sevendigital/management/artist_manager.rb +97 -97
  36. data/lib/sevendigital/management/basket_manager.rb +29 -29
  37. data/lib/sevendigital/management/country_manager.rb +10 -10
  38. data/lib/sevendigital/management/list_manager.rb +18 -18
  39. data/lib/sevendigital/management/manager.rb +12 -12
  40. data/lib/sevendigital/management/oauth_manager.rb +23 -23
  41. data/lib/sevendigital/management/release_manager.rb +54 -54
  42. data/lib/sevendigital/management/tag_manager.rb +10 -10
  43. data/lib/sevendigital/management/track_manager.rb +29 -27
  44. data/lib/sevendigital/management/user_card_manager.rb +26 -26
  45. data/lib/sevendigital/management/user_manager.rb +76 -76
  46. data/lib/sevendigital/model/api_response.rb +32 -32
  47. data/lib/sevendigital/model/artist.rb +104 -104
  48. data/lib/sevendigital/model/basket.rb +15 -15
  49. data/lib/sevendigital/model/basket_item.rb +14 -14
  50. data/lib/sevendigital/model/card.rb +11 -11
  51. data/lib/sevendigital/model/chart_item.rb +9 -9
  52. data/lib/sevendigital/model/download_url.rb +7 -7
  53. data/lib/sevendigital/model/format.rb +7 -7
  54. data/lib/sevendigital/model/label.rb +7 -7
  55. data/lib/sevendigital/model/list.rb +4 -4
  56. data/lib/sevendigital/model/list_item.rb +8 -8
  57. data/lib/sevendigital/model/locker.rb +4 -4
  58. data/lib/sevendigital/model/locker_release.rb +9 -9
  59. data/lib/sevendigital/model/locker_track.rb +9 -9
  60. data/lib/sevendigital/model/price.rb +9 -9
  61. data/lib/sevendigital/model/release.rb +57 -57
  62. data/lib/sevendigital/model/sevendigital_error.rb +11 -11
  63. data/lib/sevendigital/model/sevendigital_object.rb +57 -57
  64. data/lib/sevendigital/model/tag.rb +7 -7
  65. data/lib/sevendigital/model/track.rb +87 -83
  66. data/lib/sevendigital/model/user.rb +74 -74
  67. data/lib/sevendigital/pager.rb +20 -20
  68. data/lib/sevendigital/version.rb +5 -5
  69. data/spec/api_operator_cached_spec.rb +233 -178
  70. data/spec/api_operator_spec.rb +320 -320
  71. data/spec/api_request_spec.rb +46 -31
  72. data/spec/client_configuration_spec.rb +78 -78
  73. data/spec/client_spec.rb +161 -161
  74. data/spec/data/config/sevendigital.yml +5 -5
  75. data/spec/data/configuration_env_override.yml +5 -5
  76. data/spec/data/configuration_override.yml +1 -1
  77. data/spec/digestion_tract/api_response_digestor_spec.rb +93 -93
  78. data/spec/digestion_tract/artist_digestor_spec.rb +81 -81
  79. data/spec/digestion_tract/basket_digestor_spec.rb +31 -31
  80. data/spec/digestion_tract/basket_item_digestor_spec.rb +58 -58
  81. data/spec/digestion_tract/chart_digestor_spec.rb +52 -52
  82. data/spec/digestion_tract/country_digestor_spec.rb +33 -33
  83. data/spec/digestion_tract/digestor_spec.rb +33 -33
  84. data/spec/digestion_tract/download_url_digestor_spec.rb +40 -40
  85. data/spec/digestion_tract/format_digestor_spec.rb +38 -38
  86. data/spec/digestion_tract/label_digestor_spec.rb +33 -33
  87. data/spec/digestion_tract/list_digestor_spec.rb +31 -31
  88. data/spec/digestion_tract/list_item_digestor_spec.rb +80 -80
  89. data/spec/digestion_tract/locker_digestor_spec.rb +30 -30
  90. data/spec/digestion_tract/locker_release_digestor_spec.rb +70 -70
  91. data/spec/digestion_tract/locker_track_digestor_spec.rb +56 -56
  92. data/spec/digestion_tract/oauth_access_token_digestor_spec.rb +34 -34
  93. data/spec/digestion_tract/oauth_request_token_digestor_spec.rb +34 -34
  94. data/spec/digestion_tract/pager_digestor_spec.rb +50 -50
  95. data/spec/digestion_tract/price_digestor_spec.rb +73 -73
  96. data/spec/digestion_tract/release_digestor_spec.rb +115 -115
  97. data/spec/digestion_tract/tag_digestor_spec.rb +46 -46
  98. data/spec/digestion_tract/track_digestor_spec.rb +105 -104
  99. data/spec/digestion_tract/user_card_digestor_spec.rb +58 -58
  100. data/spec/digestion_tract/user_digestor_spec.rb +42 -42
  101. data/spec/integration/artist_spec.rb +99 -86
  102. data/spec/integration/country_spec.rb +18 -18
  103. data/spec/integration/list_spec.rb +22 -22
  104. data/spec/integration/purchasing_spec.rb +24 -24
  105. data/spec/integration/release_spec.rb +34 -34
  106. data/spec/integration/sevendigital_spec.yml +4 -4
  107. data/spec/integration/track_spec.rb +38 -23
  108. data/spec/integration/user_spec.rb +22 -22
  109. data/spec/management/artist_manager_spec.rb +172 -172
  110. data/spec/management/basket_manager_spec.rb +77 -77
  111. data/spec/management/country_manager_spec.rb +34 -34
  112. data/spec/management/list_manager_spec.rb +26 -26
  113. data/spec/management/oauth_manager_spec.rb +72 -72
  114. data/spec/management/release_manager_spec.rb +200 -200
  115. data/spec/management/tag_manager_spec.rb +34 -34
  116. data/spec/management/track_manager_spec.rb +111 -107
  117. data/spec/management/user_card_manager_spec.rb +78 -78
  118. data/spec/management/user_manager_spec.rb +218 -218
  119. data/spec/model/api_response_spec.rb +48 -48
  120. data/spec/model/artist_spec.rb +162 -162
  121. data/spec/model/basket_spec.rb +62 -62
  122. data/spec/model/release_spec.rb +133 -133
  123. data/spec/model/sevendigital_object_spec.rb +73 -73
  124. data/spec/model/track_spec.rb +146 -144
  125. data/spec/model/user_spec.rb +181 -181
  126. data/spec/spec_helper.rb +86 -84
  127. data/spec/test-xml/methods/artist/browse.xml +21 -21
  128. data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
  129. data/spec/test-xml/methods/artist/chart.xml +30 -30
  130. data/spec/test-xml/methods/artist/details.xml +9 -9
  131. data/spec/test-xml/methods/artist/releases.xml +544 -544
  132. data/spec/test-xml/methods/artist/search.xml +18 -18
  133. data/spec/test-xml/methods/artist/similar.xml +39 -39
  134. data/spec/test-xml/methods/artist/tags.xml +11 -11
  135. data/spec/test-xml/methods/artist/toptracks.xml +279 -279
  136. data/spec/test-xml/methods/basket/additem.xml +23 -23
  137. data/spec/test-xml/methods/basket/create.xml +10 -10
  138. data/spec/test-xml/methods/basket/index.xml +23 -23
  139. data/spec/test-xml/methods/basket/removeitem.xml +10 -10
  140. data/spec/test-xml/methods/country/resolve.xml +6 -6
  141. data/spec/test-xml/methods/editorial/list.xml +170 -170
  142. data/spec/test-xml/methods/oauth/accesstoken.xml +5 -5
  143. data/spec/test-xml/methods/oauth/requesttoken.xml +5 -5
  144. data/spec/test-xml/methods/release/bydate.xml +173 -173
  145. data/spec/test-xml/methods/release/bytag/top.xml +150 -150
  146. data/spec/test-xml/methods/release/chart.xml +181 -181
  147. data/spec/test-xml/methods/release/details.xml +48 -48
  148. data/spec/test-xml/methods/release/recommend.xml +89 -89
  149. data/spec/test-xml/methods/release/search.xml +194 -194
  150. data/spec/test-xml/methods/release/tags.xml +27 -27
  151. data/spec/test-xml/methods/release/tracks.xml +28 -28
  152. data/spec/test-xml/methods/tag/index.xml +16 -16
  153. data/spec/test-xml/methods/track/chart.xml +149 -149
  154. data/spec/test-xml/methods/track/details.xml +30 -30
  155. data/spec/test-xml/methods/track/search.xml +159 -159
  156. data/spec/test-xml/methods/user/details.xml +4 -4
  157. data/spec/test-xml/methods/user/locker.xml +49 -49
  158. data/spec/test-xml/methods/user/payment/card/add.xml +7 -7
  159. data/spec/test-xml/methods/user/payment/card/index.xml +7 -7
  160. data/spec/test-xml/methods/user/purchase/basket.xml +48 -48
  161. data/spec/test-xml/methods/user/purchase/item.xml +48 -48
  162. data/spec/test-xml/methods/user/signUp.xml +5 -5
  163. data/spec/test-xml/objects/artist.xml +7 -7
  164. data/spec/test-xml/objects/artist_chart_item.xml +7 -7
  165. data/spec/test-xml/objects/artist_list.xml +22 -22
  166. data/spec/test-xml/objects/artist_list_empty.xml +4 -4
  167. data/spec/test-xml/objects/basket.xml +21 -21
  168. data/spec/test-xml/objects/basket_item.xml +11 -11
  169. data/spec/test-xml/objects/basket_item_list.xml +25 -25
  170. data/spec/test-xml/objects/basket_item_list_empty.xml +1 -1
  171. data/spec/test-xml/objects/download_url.xml +7 -7
  172. data/spec/test-xml/objects/list.xml +89 -89
  173. data/spec/test-xml/objects/list_item_list.xml +85 -85
  174. data/spec/test-xml/objects/list_item_release.xml +13 -13
  175. data/spec/test-xml/objects/locker.xml +47 -47
  176. data/spec/test-xml/objects/locker_release.xml +40 -40
  177. data/spec/test-xml/objects/locker_release_list.xml +87 -87
  178. data/spec/test-xml/objects/locker_release_list_empty.xml +4 -4
  179. data/spec/test-xml/objects/locker_release_one_item_list.xml +43 -43
  180. data/spec/test-xml/objects/locker_track.xml +25 -25
  181. data/spec/test-xml/objects/locker_track_list.xml +26 -26
  182. data/spec/test-xml/objects/locker_track_list_empty.xml +2 -2
  183. data/spec/test-xml/objects/nested_release_list.xml +22 -22
  184. data/spec/test-xml/objects/oauth_access_token.xml +3 -3
  185. data/spec/test-xml/objects/oauth_request_token.xml +3 -3
  186. data/spec/test-xml/objects/price.xml +7 -7
  187. data/spec/test-xml/objects/release.xml +40 -40
  188. data/spec/test-xml/objects/release_chart_item.xml +39 -39
  189. data/spec/test-xml/objects/release_list.xml +18 -18
  190. data/spec/test-xml/objects/release_list_empty.xml +4 -4
  191. data/spec/test-xml/objects/response.xml +38 -38
  192. data/spec/test-xml/objects/tag.xml +4 -4
  193. data/spec/test-xml/objects/track.xml +34 -33
  194. data/spec/test-xml/objects/track_chart_item.xml +27 -27
  195. data/spec/test-xml/objects/user.xml +4 -4
  196. data/spec/test-xml/objects/user_payment_card.xml +5 -5
  197. metadata +15 -25
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 36d94274cc1be10ed544d2aaf8d51be299ce6d44
4
+ data.tar.gz: adc1dd2580b618ddfe18490afc20cc3404531e43
5
+ SHA512:
6
+ metadata.gz: f3d446e04ead7ed31dc63c80fcccb488d4adf926aa4f5e890ac56ccd657bb30f2ee355f3a3f761fc62d527b4ea661462f335a61de7640983c391a3671fe6add9
7
+ data.tar.gz: 374a9079b342af262135dd269894b2bebd9f45b23ae09e7015bcf4e6cfdd9da797df424de2659f2e97912bd720e743f27419ac23ed31f0943e43bfc5abd7de38
@@ -1,143 +1,143 @@
1
- =Ruby wrapper for 7digital API
2
-
3
- This is a ruby wrapper for the 7digital API.
4
-
5
- ==About 7digital
6
-
7
- 7digital.com is an online music store operating in over 30 countries and offering more than 20 million high quality DRM free MP3s (320kbps) from all major labels and wide range of idependent labels and distributors. 7digital API will give you access to the full catalogue including high quality album art, 30s preview clips for all tracks, commissions on sales, integrated purchasing and full length streaming. More details at http://developer.7digital.net
8
-
9
- ==Installation
10
-
11
- gem install 7digital
12
-
13
-
14
- ==Quick start example
15
-
16
-
17
- require "sevendigital"
18
-
19
- api_client = Sevendigital::Client.new(:oauth_consumer_key => "YOUR_KEY_HERE", :country => "GB")
20
-
21
- an_artist = api_client.artist.search("radiohead").first
22
-
23
- a_release = an_artist.releases(:page_size=>100).sort_by{|release| release.year}.last
24
-
25
- puts "the latest #{an_artist.name} release is #{a_release.title} from #{a_release.year}"
26
-
27
- puts "go and buy it at #{a_release.url} !"
28
-
29
-
30
- ==Usage details
31
-
32
- ===Initializing & configuring an API Client
33
-
34
- To use the wrapper and access the 7digital API you need a configured instance of Sevendigital::Client. Create one using the standard new method:
35
-
36
- client = Sevendigital::Client.new
37
-
38
- This will get you an API client configured with default settings. At very least before making any API calls you will need to update the configuration with your own API key. You can adjust the client's configuration in several ways:
39
-
40
- 1. In Rails app you can put _sevendigital.yml_ inside your app's config dir and this will be automatically picked up (for a template please see the examples directory)
41
-
42
- 2. You can provide a custom location of configuration file when instantiating a client
43
-
44
- client = Sevendigital::Client.new("dir/subdir/my_7d_configuration.yml")
45
- 3. You can supply a hash of configuration settings when instantiating a client
46
-
47
- client = Sevendigital::Client.new(:oauth_consumer_key => "YOUR_KEY_HERE", :country => "GB")
48
- 4. You can update the configuration in block whilst instantiating a client
49
-
50
- client = Sevendigital::Client.new { |config|
51
- config.oauth_consumer_key => "YOUR_KEY_HERE"
52
- config.verbose => true
53
- }
54
-
55
- You can also combine all of the above (if the same setting is specified multiple times the last one will be applied)
56
- An extreme example:
57
-
58
- client = Sevendigital::Client.new("7digital_default_settings.yml", :oauth_consumer_key => "MY_OTHER_KEY") { |conf|
59
- conf.country = "SE"
60
- conf.oauth_consumer_key = "ACTUALLY_USE_THIS_KEY"
61
- }
62
-
63
- ===Using the client
64
-
65
- List of all available API methods and their return types
66
-
67
- ----
68
-
69
- Provided by Sevendigital::ArtistManager :
70
-
71
- client.artist.*get_details*(artist_id, options={}) => Sevendigital::Artist
72
-
73
- client.artist.*get_releases*(artist_id, options={}) => [ Sevendigital::Release ]
74
-
75
- client.artist.*get_similar*(artist_id, options={}) => [ Sevendigital::Artist ]
76
-
77
- client.artist.*get_top_by_tag*(tags, options={}) => [ Sevendigital::Artist ]
78
-
79
- client.artist.*get_top_tracks*(artist_id, options={}) => [ Sevendigital::Track ]
80
-
81
- client.artist.*search*(query, options={}) => [ Sevendigital::Artist ]
82
-
83
- ----
84
-
85
- Provided by Sevendigital::ReleaseManager :
86
-
87
- client.release.*get_details*(release_id, options = {}) => Sevendigital::Release
88
-
89
- client.release.*get_tracks*(release_id, options = {}) => [ Sevendigital::Track ]
90
-
91
- client.release.*get_chart*(options={}) => [ Sevendigital::ChartItem ]
92
-
93
- client.release.*get_by_date*(from_date = nil, to_date = nil, options = {}) => [ Sevendigital::Release ]
94
-
95
- client.release.*get_recommendations*(release_id, options = {}) => [ Sevendigital::Release ]
96
-
97
- client.release.*get_top_by_tag*(tags, options = {}) => [ Sevendigital::Release ]
98
-
99
- client.release.*search*(query, options={}) => [ Sevendigital::Release ]
100
-
101
- ----
102
-
103
- client.track.*get_details*(id, options={}) => Sevendigital::Track
104
-
105
- client.track.*get_details_from_release*(track_id, release_id, options={}) => Sevendigital::Track
106
-
107
- client.track.*get_chart*(options={}) => [ Sevendigital::ChartItem ]
108
-
109
- client.track.*build_preview_url*(id, options={}) => String
110
-
111
- client.track.*search*(query, options={}) => [ Sevendigital::Track ]
112
-
113
- ---
114
-
115
- client.basket.*get*(basket_id, options={}) => Sevendigital::Basket
116
-
117
- client.basket.*create*(options={}) => Sevendigital::Basket
118
-
119
- client.basket.*add_item*(basket_id, release_id, track_id=nil, options={}) => Sevendigital::Basket
120
-
121
- client.basket.*remove_item*(basket_id, item_id, options={}) => Sevendigital::Basket
122
-
123
- ---
124
-
125
- client.oauth.*get_request_token* => OAuth::RequestToken
126
-
127
- client.oauth.*get_access_token*(request_token) => OAuth::AccessToken
128
-
129
- ---
130
-
131
- client.user.*login*(access_token) => Sevendigital::User
132
-
133
- client.user.*authenticate*(email, password) => Sevendigital::User
134
-
135
- client.user.*get_locker*(token, options={}) => Sevendgital::Locker
136
-
137
- client.user.*purchase*(release_id, track_id, price, token, options={}) => Sevendgital::Locker
138
-
139
- client.user.*get_stream_track_url*(release_id, track_id, token, options={}) => String
140
-
141
- client.user.*get_add_card_url*(return_url, token, options={}) => String
142
-
143
-
1
+ =Ruby wrapper for 7digital API
2
+
3
+ This is a ruby wrapper for the 7digital API.
4
+
5
+ ==About 7digital
6
+
7
+ 7digital.com is an online music store operating in over 30 countries and offering more than 20 million high quality DRM free MP3s (320kbps) from all major labels and wide range of idependent labels and distributors. 7digital API will give you access to the full catalogue including high quality album art, 30s preview clips for all tracks, commissions on sales, integrated purchasing and full length streaming. More details at http://developer.7digital.net
8
+
9
+ ==Installation
10
+
11
+ gem install 7digital
12
+
13
+
14
+ ==Quick start example
15
+
16
+
17
+ require "sevendigital"
18
+
19
+ api_client = Sevendigital::Client.new(:oauth_consumer_key => "YOUR_KEY_HERE", :country => "GB")
20
+
21
+ an_artist = api_client.artist.search("radiohead").first
22
+
23
+ a_release = an_artist.releases(:page_size=>100).sort_by{|release| release.year}.last
24
+
25
+ puts "the latest #{an_artist.name} release is #{a_release.title} from #{a_release.year}"
26
+
27
+ puts "go and buy it at #{a_release.url} !"
28
+
29
+
30
+ ==Usage details
31
+
32
+ ===Initializing & configuring an API Client
33
+
34
+ To use the wrapper and access the 7digital API you need a configured instance of Sevendigital::Client. Create one using the standard new method:
35
+
36
+ client = Sevendigital::Client.new
37
+
38
+ This will get you an API client configured with default settings. At very least before making any API calls you will need to update the configuration with your own API key. You can adjust the client's configuration in several ways:
39
+
40
+ 1. In Rails app you can put _sevendigital.yml_ inside your app's config dir and this will be automatically picked up (for a template please see the examples directory)
41
+
42
+ 2. You can provide a custom location of configuration file when instantiating a client
43
+
44
+ client = Sevendigital::Client.new("dir/subdir/my_7d_configuration.yml")
45
+ 3. You can supply a hash of configuration settings when instantiating a client
46
+
47
+ client = Sevendigital::Client.new(:oauth_consumer_key => "YOUR_KEY_HERE", :country => "GB")
48
+ 4. You can update the configuration in block whilst instantiating a client
49
+
50
+ client = Sevendigital::Client.new { |config|
51
+ config.oauth_consumer_key => "YOUR_KEY_HERE"
52
+ config.verbose => true
53
+ }
54
+
55
+ You can also combine all of the above (if the same setting is specified multiple times the last one will be applied)
56
+ An extreme example:
57
+
58
+ client = Sevendigital::Client.new("7digital_default_settings.yml", :oauth_consumer_key => "MY_OTHER_KEY") { |conf|
59
+ conf.country = "SE"
60
+ conf.oauth_consumer_key = "ACTUALLY_USE_THIS_KEY"
61
+ }
62
+
63
+ ===Using the client
64
+
65
+ List of all available API methods and their return types
66
+
67
+ ----
68
+
69
+ Provided by Sevendigital::ArtistManager :
70
+
71
+ client.artist.*get_details*(artist_id, options={}) => Sevendigital::Artist
72
+
73
+ client.artist.*get_releases*(artist_id, options={}) => [ Sevendigital::Release ]
74
+
75
+ client.artist.*get_similar*(artist_id, options={}) => [ Sevendigital::Artist ]
76
+
77
+ client.artist.*get_top_by_tag*(tags, options={}) => [ Sevendigital::Artist ]
78
+
79
+ client.artist.*get_top_tracks*(artist_id, options={}) => [ Sevendigital::Track ]
80
+
81
+ client.artist.*search*(query, options={}) => [ Sevendigital::Artist ]
82
+
83
+ ----
84
+
85
+ Provided by Sevendigital::ReleaseManager :
86
+
87
+ client.release.*get_details*(release_id, options = {}) => Sevendigital::Release
88
+
89
+ client.release.*get_tracks*(release_id, options = {}) => [ Sevendigital::Track ]
90
+
91
+ client.release.*get_chart*(options={}) => [ Sevendigital::ChartItem ]
92
+
93
+ client.release.*get_by_date*(from_date = nil, to_date = nil, options = {}) => [ Sevendigital::Release ]
94
+
95
+ client.release.*get_recommendations*(release_id, options = {}) => [ Sevendigital::Release ]
96
+
97
+ client.release.*get_top_by_tag*(tags, options = {}) => [ Sevendigital::Release ]
98
+
99
+ client.release.*search*(query, options={}) => [ Sevendigital::Release ]
100
+
101
+ ----
102
+
103
+ client.track.*get_details*(id, options={}) => Sevendigital::Track
104
+
105
+ client.track.*get_details_from_release*(track_id, release_id, options={}) => Sevendigital::Track
106
+
107
+ client.track.*get_chart*(options={}) => [ Sevendigital::ChartItem ]
108
+
109
+ client.track.*build_preview_url*(id, options={}) => String
110
+
111
+ client.track.*search*(query, options={}) => [ Sevendigital::Track ]
112
+
113
+ ---
114
+
115
+ client.basket.*get*(basket_id, options={}) => Sevendigital::Basket
116
+
117
+ client.basket.*create*(options={}) => Sevendigital::Basket
118
+
119
+ client.basket.*add_item*(basket_id, release_id, track_id=nil, options={}) => Sevendigital::Basket
120
+
121
+ client.basket.*remove_item*(basket_id, item_id, options={}) => Sevendigital::Basket
122
+
123
+ ---
124
+
125
+ client.oauth.*get_request_token* => OAuth::RequestToken
126
+
127
+ client.oauth.*get_access_token*(request_token) => OAuth::AccessToken
128
+
129
+ ---
130
+
131
+ client.user.*login*(access_token) => Sevendigital::User
132
+
133
+ client.user.*authenticate*(email, password) => Sevendigital::User
134
+
135
+ client.user.*get_locker*(token, options={}) => Sevendgital::Locker
136
+
137
+ client.user.*purchase*(release_id, track_id, price, token, options={}) => Sevendgital::Locker
138
+
139
+ client.user.*get_stream_track_url*(release_id, track_id, token, options={}) => String
140
+
141
+ client.user.*get_add_card_url*(return_url, token, options={}) => String
142
+
143
+
@@ -1,55 +1,55 @@
1
-
2
- module Sevendigital
3
-
4
- # :stopdoc:
5
- LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
- PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
- # :startdoc:
8
-
9
- # Returns the version string for the library.
10
- #
11
- def self.version
12
- VERSION
13
- end
14
-
15
- # Returns the library path for the module. If any arguments are given,
16
- # they will be joined to the end of the libray path using
17
- # <tt>File.join</tt>.
18
- #
19
- def self.libpath( *args )
20
- args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
21
- end
22
-
23
- # Returns the lpath for the module. If any arguments are given,
24
- # they will be joined to the end of the path using
25
- # <tt>File.join</tt>.
26
- #
27
- def self.path( *args )
28
- args.empty? ? PATH : ::File.join(PATH, args.flatten)
29
- end
30
-
31
- # Utility method used to require all files ending in .rb that lie in the
32
- # directory below this file that has the same name as the filename passed
33
- # in. Optionally, a specific _directory_ name can be passed in such that
34
- # the _filename_ does not have to be equivalent to the directory.
35
- #
36
- def self.require_all_libs_relative_to( fname, dir = nil )
37
- dir ||= ::File.basename(fname, '.*')
38
- search_me = ::File.expand_path(
39
- ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
40
-
41
- Dir.glob(search_me).sort.each {|rb| require rb }
42
- end
43
-
44
- end # module 7digital
45
-
46
- require 'nokogiri'
47
- require 'bigdecimal'
48
- require 'bigdecimal/util'
49
- require 'logger'
50
- require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'client_configuration')
51
- require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'management', 'manager')
52
- require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'digestion_tract', 'digestor')
53
- require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'model', 'sevendigital_object')
54
- Sevendigital.require_all_libs_relative_to(__FILE__)
55
-
1
+
2
+ module Sevendigital
3
+
4
+ # :stopdoc:
5
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
+ # :startdoc:
8
+
9
+ # Returns the version string for the library.
10
+ #
11
+ def self.version
12
+ VERSION
13
+ end
14
+
15
+ # Returns the library path for the module. If any arguments are given,
16
+ # they will be joined to the end of the libray path using
17
+ # <tt>File.join</tt>.
18
+ #
19
+ def self.libpath( *args )
20
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
21
+ end
22
+
23
+ # Returns the lpath for the module. If any arguments are given,
24
+ # they will be joined to the end of the path using
25
+ # <tt>File.join</tt>.
26
+ #
27
+ def self.path( *args )
28
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
29
+ end
30
+
31
+ # Utility method used to require all files ending in .rb that lie in the
32
+ # directory below this file that has the same name as the filename passed
33
+ # in. Optionally, a specific _directory_ name can be passed in such that
34
+ # the _filename_ does not have to be equivalent to the directory.
35
+ #
36
+ def self.require_all_libs_relative_to( fname, dir = nil )
37
+ dir ||= ::File.basename(fname, '.*')
38
+ search_me = ::File.expand_path(
39
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
40
+
41
+ Dir.glob(search_me).sort.each {|rb| require rb }
42
+ end
43
+
44
+ end # module 7digital
45
+
46
+ require 'nokogiri'
47
+ require 'bigdecimal'
48
+ require 'bigdecimal/util'
49
+ require 'logger'
50
+ require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'client_configuration')
51
+ require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'management', 'manager')
52
+ require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'digestion_tract', 'digestor')
53
+ require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'model', 'sevendigital_object')
54
+ Sevendigital.require_all_libs_relative_to(__FILE__)
55
+
@@ -1,127 +1,127 @@
1
- module Sevendigital
2
-
3
- require 'net/http'
4
- require 'net/https'
5
- require 'oauth'
6
- require 'uri'
7
- require 'cgi'
8
-
9
- #@private
10
- #internal class used for translating ApiRequests into http calls
11
- #deals with OAuth signing requests that require signature, making sure parameters are in correct format etc
12
- class ApiOperator # :nodoc:
13
-
14
- RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
15
-
16
- def initialize(client)
17
- @client = client
18
- end
19
-
20
- def call_api(api_request)
21
- make_http_request_and_digest(api_request).tap do |api_response|
22
- @client.log(:very_verbose) { "ApiOperator: API Response: #{api_response}" }
23
- end
24
- end
25
-
26
- def get_request_uri(api_request)
27
- api_request.signature_scheme = :query_string if api_request.requires_signature?
28
- http_client, http_request = create_http_request(api_request)
29
- path = http_request.instance_variable_get("@path")
30
- host = http_client.instance_variable_get("@address")
31
- port = http_client.instance_variable_get("@port")
32
- scheme = port == 443 ? "https" : "http"
33
- "#{scheme}://#{host}#{path}"
34
- end
35
-
36
- def make_http_request_and_digest(api_request)
37
- digest_http_response(make_http_request(api_request))
38
- end
39
-
40
- def make_http_request(api_request)
41
- http_client, http_request = create_http_request(api_request)
42
- @client.log(:verbose) { "ApiOperator: Making HTTP Request..." }
43
- http_client.request(http_request).tap do |http_response|
44
- @client.log(:very_verbose) { "ApiOperator: Response Headers: #{http_response.header.to_yaml}" }
45
- end
46
- end
47
-
48
- def digest_http_response(http_response)
49
- @client.api_response_digestor.from_http_response(http_response).tap do |api_response|
50
- unless api_response.ok?
51
- raise Sevendigital::SevendigitalError.new(api_response.error_code, api_response.error_message), "#{api_response.error_code} - #{api_response.error_message}"
52
- end
53
- end
54
- end
55
-
56
- def create_http_request(api_request)
57
- http_client, http_request = create_standard_http_request(api_request)
58
- if (api_request.requires_signature?)
59
- oauth_sign_request(http_client, http_request, api_request)
60
- else
61
- end
62
- [http_client, http_request]
63
- end
64
-
65
- def oauth_sign_request(http_client, http_request, api_request)
66
- http_request.oauth!( \
67
- http_client, \
68
- @client.oauth_consumer, \
69
- api_request.token, \
70
- {:scheme => api_request.signature_scheme}
71
- )
72
- http_request
73
- end
74
-
75
- def create_standard_http_request(api_request)
76
- request_uri = create_request_uri(api_request)
77
- http_client = Net::HTTP.new(request_uri.host, request_uri.port)
78
-
79
- if !api_request.requires_signature?
80
- request_uri.query ||= ""
81
- request_uri.query += "&oauth_consumer_key=#{@client.configuration.oauth_consumer_key}"
82
- end
83
-
84
- http_request = new_http_request(request_uri.request_uri, api_request.http_method)
85
-
86
- ensure_secure_connection(http_client) if api_request.requires_secure_connection?
87
- add_form_parameters(http_request, api_request)
88
-
89
- @client.log(:verbose) { "ApiOperator: Creating HTTP Request: #{request_uri}" }
90
-
91
- [http_client, http_request]
92
- end
93
-
94
- def ensure_secure_connection(http_client)
95
- http_client.use_ssl = true
96
- http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
97
- end
98
-
99
- def create_request_uri(api_request)
100
- host, version = @client.api_host_and_version(api_request.api_service)
101
- path = "/#{version}/#{api_request.api_method}"
102
- query = api_request.parameters.map{ |k,v| "#{escape(k)}=#{escape(v)}" }.join("&")
103
- query = nil if query == ""
104
- if api_request.requires_secure_connection? then
105
- URI::HTTPS.build(:host => host, :path => path, :query =>query)
106
- else
107
- URI::HTTP.build(:host => host, :path => path, :query =>query)
108
- end
109
- end
110
-
111
- def new_http_request(request_uri, http_method)
112
- request_type = Kernel.const_get("Net").const_get("HTTP").const_get(http_method.to_s.capitalize)
113
- request_type.new(request_uri, {"user-agent" => @client.user_agent_info})
114
- end
115
-
116
- def add_form_parameters(http_request, api_request)
117
- http_request.body = api_request.form_parameters.map {|k, v| "#{escape(k)}=#{escape(v)}" }.flatten.join('&')
118
- http_request.content_type = 'application/x-www-form-urlencoded'
119
- end
120
-
121
- def escape(value)
122
- URI::escape(value.to_s, RESERVED_CHARACTERS)
123
- rescue ArgumentError
124
- URI::escape(value.to_s.force_encoding(Encoding::UTF_8), RESERVED_CHARACTERS)
125
- end
126
- end
127
- end
1
+ module Sevendigital
2
+
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'oauth'
6
+ require 'uri'
7
+ require 'cgi'
8
+
9
+ #@private
10
+ #internal class used for translating ApiRequests into http calls
11
+ #deals with OAuth signing requests that require signature, making sure parameters are in correct format etc
12
+ class ApiOperator # :nodoc:
13
+
14
+ RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
15
+
16
+ def initialize(client)
17
+ @client = client
18
+ end
19
+
20
+ def call_api(api_request)
21
+ make_http_request_and_digest(api_request).tap do |api_response|
22
+ @client.log(:very_verbose) { "ApiOperator: API Response: #{api_response}" }
23
+ end
24
+ end
25
+
26
+ def get_request_uri(api_request)
27
+ api_request.signature_scheme = :query_string if api_request.requires_signature?
28
+ http_client, http_request = create_http_request(api_request)
29
+ path = http_request.instance_variable_get("@path")
30
+ host = http_client.instance_variable_get("@address")
31
+ port = http_client.instance_variable_get("@port")
32
+ scheme = port == 443 ? "https" : "http"
33
+ "#{scheme}://#{host}#{path}"
34
+ end
35
+
36
+ def make_http_request_and_digest(api_request)
37
+ digest_http_response(make_http_request(api_request))
38
+ end
39
+
40
+ def make_http_request(api_request)
41
+ http_client, http_request = create_http_request(api_request)
42
+ @client.log(:verbose) { "ApiOperator: Making HTTP Request..." }
43
+ http_client.request(http_request).tap do |http_response|
44
+ @client.log(:very_verbose) { "ApiOperator: Response Headers: #{http_response.header.to_yaml}" }
45
+ end
46
+ end
47
+
48
+ def digest_http_response(http_response)
49
+ @client.api_response_digestor.from_http_response(http_response).tap do |api_response|
50
+ unless api_response.ok?
51
+ raise Sevendigital::SevendigitalError.new(api_response.error_code, api_response.error_message), "#{api_response.error_code} - #{api_response.error_message}"
52
+ end
53
+ end
54
+ end
55
+
56
+ def create_http_request(api_request)
57
+ http_client, http_request = create_standard_http_request(api_request)
58
+ if (api_request.requires_signature?)
59
+ oauth_sign_request(http_client, http_request, api_request)
60
+ else
61
+ end
62
+ [http_client, http_request]
63
+ end
64
+
65
+ def oauth_sign_request(http_client, http_request, api_request)
66
+ http_request.oauth!( \
67
+ http_client, \
68
+ @client.oauth_consumer, \
69
+ api_request.token, \
70
+ {:scheme => api_request.signature_scheme}
71
+ )
72
+ http_request
73
+ end
74
+
75
+ def create_standard_http_request(api_request)
76
+ request_uri = create_request_uri(api_request)
77
+ http_client = Net::HTTP.new(request_uri.host, request_uri.port)
78
+
79
+ if !api_request.requires_signature?
80
+ request_uri.query ||= ""
81
+ request_uri.query += "&oauth_consumer_key=#{@client.configuration.oauth_consumer_key}"
82
+ end
83
+
84
+ http_request = new_http_request(request_uri.request_uri, api_request.http_method)
85
+
86
+ ensure_secure_connection(http_client) if api_request.requires_secure_connection?
87
+ add_form_parameters(http_request, api_request)
88
+
89
+ @client.log(:verbose) { "ApiOperator: Creating HTTP Request: #{request_uri}" }
90
+
91
+ [http_client, http_request]
92
+ end
93
+
94
+ def ensure_secure_connection(http_client)
95
+ http_client.use_ssl = true
96
+ http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
97
+ end
98
+
99
+ def create_request_uri(api_request)
100
+ host, version = @client.api_host_and_version(api_request.api_service)
101
+ path = (version.to_s.strip.empty? ? "" : "/#{version}") + "/#{api_request.api_method}"
102
+ query = api_request.parameters.map{ |k,v| "#{escape(k)}=#{escape(v)}" }.join("&")
103
+ query = nil if query == ""
104
+ if api_request.requires_secure_connection? then
105
+ URI::HTTPS.build(:host => host, :path => path, :query =>query)
106
+ else
107
+ URI::HTTP.build(:host => host, :path => path, :query =>query)
108
+ end
109
+ end
110
+
111
+ def new_http_request(request_uri, http_method)
112
+ request_type = Kernel.const_get("Net").const_get("HTTP").const_get(http_method.to_s.capitalize)
113
+ request_type.new(request_uri, {"user-agent" => @client.user_agent_info})
114
+ end
115
+
116
+ def add_form_parameters(http_request, api_request)
117
+ http_request.body = api_request.form_parameters.map {|k, v| "#{escape(k)}=#{escape(v)}" }.flatten.join('&')
118
+ http_request.content_type = 'application/x-www-form-urlencoded'
119
+ end
120
+
121
+ def escape(value)
122
+ URI::escape(value.to_s, RESERVED_CHARACTERS)
123
+ rescue ArgumentError
124
+ URI::escape(value.to_s.force_encoding(Encoding::UTF_8), RESERVED_CHARACTERS)
125
+ end
126
+ end
127
+ end