7digital 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/README.rdoc +9 -7
  2. data/lib/sevendigital.rb +54 -53
  3. data/lib/sevendigital/api_operator.rb +33 -30
  4. data/lib/sevendigital/api_operator_cached.rb +23 -23
  5. data/lib/sevendigital/api_request.rb +23 -23
  6. data/lib/sevendigital/client.rb +136 -124
  7. data/lib/sevendigital/default_configuration.yml +2 -2
  8. data/lib/sevendigital/digestion_tract/api_response_digestor.rb +52 -52
  9. data/lib/sevendigital/digestion_tract/artist_digestor.rb +31 -31
  10. data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +27 -27
  11. data/lib/sevendigital/digestion_tract/digestor.rb +66 -66
  12. data/lib/sevendigital/digestion_tract/format_digestor.rb +21 -21
  13. data/lib/sevendigital/digestion_tract/label_digestor.rb +19 -19
  14. data/lib/sevendigital/digestion_tract/pager_digestor.rb +23 -23
  15. data/lib/sevendigital/digestion_tract/price_digestor.rb +24 -24
  16. data/lib/sevendigital/digestion_tract/release_digestor.rb +52 -52
  17. data/lib/sevendigital/digestion_tract/track_digestor.rb +37 -37
  18. data/lib/sevendigital/management/artist_manager.rb +45 -39
  19. data/lib/sevendigital/management/manager.rb +11 -11
  20. data/lib/sevendigital/management/release_manager.rb +57 -50
  21. data/lib/sevendigital/management/track_manager.rb +28 -17
  22. data/lib/sevendigital/model/api_response.rb +24 -12
  23. data/lib/sevendigital/model/artist.rb +46 -36
  24. data/lib/sevendigital/model/chart_item.rb +9 -9
  25. data/lib/sevendigital/model/format.rb +9 -9
  26. data/lib/sevendigital/model/label.rb +9 -9
  27. data/lib/sevendigital/model/price.rb +11 -11
  28. data/lib/sevendigital/model/release.rb +33 -33
  29. data/lib/sevendigital/model/sevendigital_error.rb +3 -3
  30. data/lib/sevendigital/model/sevendigital_object.rb +51 -51
  31. data/lib/sevendigital/model/track.rb +28 -7
  32. data/lib/sevendigital/pager.rb +16 -16
  33. data/lib/sevendigital/peachy_patch.rb +19 -0
  34. data/lib/sevendigital/proxy_police.rb +23 -23
  35. data/spec/api_operator_cached_spec.rb +47 -46
  36. data/spec/api_operator_spec.rb +114 -107
  37. data/spec/api_request_spec.rb +26 -27
  38. data/spec/client_spec.rb +75 -45
  39. data/spec/data/config/sevendigital.yml +5 -5
  40. data/spec/data/configuration_env_override.yml +5 -5
  41. data/spec/digestion_tract/api_response_digestor_spec.rb +78 -74
  42. data/spec/digestion_tract/artist_digestor_spec.rb +81 -82
  43. data/spec/digestion_tract/chart_digestor_spec.rb +52 -53
  44. data/spec/digestion_tract/format_digestor_spec.rb +38 -39
  45. data/spec/digestion_tract/label_digestor_spec.rb +33 -34
  46. data/spec/digestion_tract/pager_digestor_spec.rb +50 -51
  47. data/spec/digestion_tract/price_digestor_spec.rb +57 -57
  48. data/spec/digestion_tract/release_digestor_spec.rb +101 -102
  49. data/spec/digestion_tract/track_digestor_spec.rb +104 -106
  50. data/spec/management/artist_manager_spec.rb +128 -107
  51. data/spec/management/release_manager_spec.rb +222 -178
  52. data/spec/management/track_manager_spec.rb +88 -52
  53. data/spec/model/api_response_spec.rb +44 -31
  54. data/spec/model/artist_spec.rb +166 -121
  55. data/spec/model/release_spec.rb +109 -110
  56. data/spec/model/track_spec.rb +140 -0
  57. data/spec/pager_spec.rb +7 -8
  58. data/spec/peachy_spec_helper_patch.rb +7 -0
  59. data/spec/proxy_police_spec.rb +47 -48
  60. data/spec/spec_helper.rb +52 -48
  61. data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
  62. data/spec/test-xml/methods/artist/details.xml +9 -9
  63. data/spec/test-xml/methods/artist/releases.xml +544 -544
  64. data/spec/test-xml/methods/artist/search.xml +19 -0
  65. data/spec/test-xml/methods/artist/similar.xml +39 -39
  66. data/spec/test-xml/methods/artist/toptracks.xml +279 -279
  67. data/spec/test-xml/methods/release/bydate.xml +173 -173
  68. data/spec/test-xml/methods/release/bytag/top.xml +150 -150
  69. data/spec/test-xml/methods/release/chart.xml +181 -181
  70. data/spec/test-xml/methods/release/details.xml +48 -48
  71. data/spec/test-xml/methods/release/recommend.xml +89 -89
  72. data/spec/test-xml/methods/release/search.xml +195 -0
  73. data/spec/test-xml/methods/release/tracks.xml +28 -28
  74. data/spec/test-xml/methods/track/chart.xml +149 -149
  75. data/spec/test-xml/methods/track/details.xml +30 -30
  76. data/spec/test-xml/methods/track/search.xml +160 -0
  77. data/spec/test-xml/objects/artist.xml +6 -6
  78. data/spec/test-xml/objects/artist_chart_item.xml +7 -7
  79. data/spec/test-xml/objects/artist_list.xml +22 -22
  80. data/spec/test-xml/objects/artist_list_empty.xml +4 -4
  81. data/spec/test-xml/objects/price.xml +7 -7
  82. data/spec/test-xml/objects/release.xml +40 -40
  83. data/spec/test-xml/objects/release_chart_item.xml +39 -34
  84. data/spec/test-xml/objects/release_list.xml +18 -18
  85. data/spec/test-xml/objects/release_list_empty.xml +4 -4
  86. data/spec/test-xml/objects/response.xml +39 -0
  87. data/spec/test-xml/objects/track.xml +33 -33
  88. data/spec/test-xml/objects/track_chart_item.xml +27 -27
  89. metadata +10 -5
  90. data/lib/peachy_patchy.rb +0 -14
  91. data/lib/sevendigital/version.rb +0 -3
@@ -1,25 +1,25 @@
1
- require 'rational'
2
- module Sevendigital
3
-
4
- class PriceDigestor < Digestor
5
-
6
- def default_element_name; :price end
7
- def default_list_element_name; nil end
8
-
9
- def from_proxy(price_proxy)
10
- make_sure_not_eating_nil(price_proxy)
11
- price = Sevendigital::Price.new()
12
- price.currency_code = price_proxy.currency.code.to_s.upcase.to_sym
13
- price.currency_symbol= price_proxy.currency.value
14
- price.value= price_proxy.value.value.to_f
15
- price.formatted_price= price_proxy.formatted_price.value
16
- price.rrp= price_proxy.rrp.value.to_f if price_proxy.rrp
17
- price.formatted_rrp= price_proxy.formatted_rrp.value if price_proxy.formatted_rrp
18
- price.on_sale = price_proxy.on_sale.value.to_s.downcase == "true"
19
-
20
- return price
21
- end
22
-
23
- end
24
-
1
+ require 'rational'
2
+ module Sevendigital
3
+
4
+ class PriceDigestor < Digestor
5
+
6
+ def default_element_name; :price end
7
+ def default_list_element_name; nil end
8
+
9
+ def from_proxy(price_proxy)
10
+ make_sure_not_eating_nil(price_proxy)
11
+ price = Sevendigital::Price.new()
12
+ price.currency_code = price_proxy.currency.code.to_s.upcase.to_sym
13
+ price.currency_symbol= price_proxy.currency.value
14
+ price.value= price_proxy.value.value.to_f
15
+ price.formatted_price= price_proxy.formatted_price.value
16
+ price.rrp= price_proxy.rrp.value.to_f if price_proxy.rrp
17
+ price.formatted_rrp= price_proxy.formatted_rrp.value if price_proxy.formatted_rrp
18
+ price.on_sale = price_proxy.on_sale.value.to_s.downcase == "true"
19
+
20
+ return price
21
+ end
22
+
23
+ end
24
+
25
25
  end
@@ -1,52 +1,52 @@
1
- module Sevendigital
2
-
3
- require 'date'
4
-
5
- class ReleaseDigestor < Digestor
6
-
7
- def default_element_name; :release end
8
- def default_list_element_name; :releases end
9
-
10
- def from_proxy(release_proxy)
11
- make_sure_not_eating_nil(release_proxy)
12
- release = Release.new(@api_client)
13
-
14
- populate_required_properties(release, release_proxy)
15
- populate_optional_properties(release, release_proxy)
16
- populate_formats(release, release_proxy)
17
-
18
- return release
19
- end
20
-
21
- def populate_required_properties(release, release_proxy)
22
- release.id = release_proxy.id.to_i
23
- release.title = release_proxy.title.value.to_s
24
- release.artist = @api_client.artist_digestor.from_proxy(release_proxy.artist)
25
- end
26
-
27
- def populate_optional_properties(release, release_proxy)
28
- release.version = release_proxy.version.value.to_s if release_proxy.version
29
- release.type = release_proxy.type.value.downcase.to_sym if value_present?(release_proxy.type)
30
- release.barcode = release_proxy.barcode.value.to_s if value_present?(release_proxy.barcode)
31
- release.year = release_proxy.year.value.to_i if value_present?(release_proxy.year)
32
- release.explicit_content = release_proxy.explicit_content.value.to_s.downcase == "true" if value_present?(release_proxy.explicit_content)
33
- release.release_date = DateTime.parse(release_proxy.release_date.value.to_s) if value_present?(release_proxy.release_date)
34
- release.added_date = DateTime.parse(release_proxy.added_date.value.to_s) if value_present?(release_proxy.added_date)
35
- release.label = @api_client.label_digestor.from_proxy(release_proxy.label) if content_present?(release_proxy.label)
36
- release.image = release_proxy.image.value.to_s if value_present?(release_proxy.image)
37
- release.url = release_proxy.url.value.to_s if value_present?(release_proxy.url)
38
- release.price = @api_client.price_digestor.from_proxy(release_proxy.price) if content_present?(release_proxy.price)
39
- end
40
-
41
- def populate_formats(release, release_proxy)
42
- if release_proxy.formats && release_proxy.formats.format then
43
- release.formats = Array.new
44
- release_proxy.formats.format.each do |format|
45
- release.formats << @api_client.format_digestor.from_proxy(format)
46
- end
47
- end
48
- end
49
-
50
- end
51
-
52
- end
1
+ module Sevendigital
2
+
3
+ require 'date'
4
+
5
+ class ReleaseDigestor < Digestor
6
+
7
+ def default_element_name; :release end
8
+ def default_list_element_name; :releases end
9
+
10
+ def from_proxy(release_proxy)
11
+ make_sure_not_eating_nil(release_proxy)
12
+ release = Release.new(@api_client)
13
+
14
+ populate_required_properties(release, release_proxy)
15
+ populate_optional_properties(release, release_proxy)
16
+ populate_formats(release, release_proxy)
17
+
18
+ return release
19
+ end
20
+
21
+ def populate_required_properties(release, release_proxy)
22
+ release.id = release_proxy.id.to_i
23
+ release.title = release_proxy.title.value.to_s
24
+ release.artist = @api_client.artist_digestor.from_proxy(release_proxy.artist)
25
+ end
26
+
27
+ def populate_optional_properties(release, release_proxy)
28
+ release.version = release_proxy.version.value.to_s if release_proxy.version
29
+ release.type = release_proxy.type.value.downcase.to_sym if value_present?(release_proxy.type)
30
+ release.barcode = release_proxy.barcode.value.to_s if value_present?(release_proxy.barcode)
31
+ release.year = release_proxy.year.value.to_i if value_present?(release_proxy.year)
32
+ release.explicit_content = release_proxy.explicit_content.value.to_s.downcase == "true" if value_present?(release_proxy.explicit_content)
33
+ release.release_date = DateTime.parse(release_proxy.release_date.value.to_s) if value_present?(release_proxy.release_date)
34
+ release.added_date = DateTime.parse(release_proxy.added_date.value.to_s) if value_present?(release_proxy.added_date)
35
+ release.label = @api_client.label_digestor.from_proxy(release_proxy.label) if content_present?(release_proxy.label)
36
+ release.image = release_proxy.image.value.to_s if value_present?(release_proxy.image)
37
+ release.url = release_proxy.url.value.to_s if value_present?(release_proxy.url)
38
+ release.price = @api_client.price_digestor.from_proxy(release_proxy.price) if content_present?(release_proxy.price)
39
+ end
40
+
41
+ def populate_formats(release, release_proxy)
42
+ if release_proxy.formats && release_proxy.formats.format then
43
+ release.formats = Array.new
44
+ release_proxy.formats.format.each do |format|
45
+ release.formats << @api_client.format_digestor.from_proxy(format)
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -1,37 +1,37 @@
1
- module Sevendigital
2
-
3
- class TrackDigestor < Digestor
4
-
5
- def default_element_name; :track end
6
- def default_list_element_name; :tracks end
7
-
8
-
9
- def from_proxy(track_proxy)
10
- make_sure_not_eating_nil (track_proxy)
11
-
12
- track = Track.new(@api_client)
13
- populate_required_properties(track, track_proxy)
14
- populate_optional_properties(track, track_proxy)
15
-
16
- return track
17
- end
18
-
19
- def populate_required_properties(track, track_proxy)
20
- track.id = track_proxy.id.to_i
21
- track.title = track_proxy.title.value.to_s
22
- track.artist = @api_client.artist_digestor.from_proxy(track_proxy.artist)
23
- end
24
-
25
- def populate_optional_properties(track, track_proxy)
26
- track.version = track_proxy.version.value.to_s if track_proxy.version
27
- track.track_number = track_proxy.track_number.value.to_i if track_proxy.track_number
28
- track.duration = track_proxy.duration.value.to_i if track_proxy.duration
29
- track.release = @api_client.release_digestor.from_proxy(track_proxy.release) if track_proxy.release
30
- track.explicit_content = track_proxy.explicit_content.value.to_s.downcase == "true" if track_proxy.explicit_content
31
- track.isrc = track_proxy.isrc.value.to_s if track_proxy.isrc
32
- track.image = track_proxy.image.value.to_s if track_proxy.image
33
- track.url = track_proxy.url.value.to_s if track_proxy.url
34
- track.price = @api_client.price_digestor.from_proxy(track_proxy.price) if track_proxy.price
35
- end
36
- end
37
- end
1
+ module Sevendigital
2
+
3
+ class TrackDigestor < Digestor
4
+
5
+ def default_element_name; :track end
6
+ def default_list_element_name; :tracks end
7
+
8
+
9
+ def from_proxy(track_proxy)
10
+ make_sure_not_eating_nil (track_proxy)
11
+
12
+ track = Track.new(@api_client)
13
+ populate_required_properties(track, track_proxy)
14
+ populate_optional_properties(track, track_proxy)
15
+
16
+ return track
17
+ end
18
+
19
+ def populate_required_properties(track, track_proxy)
20
+ track.id = track_proxy.id.to_i
21
+ track.title = track_proxy.title.value.to_s
22
+ track.artist = @api_client.artist_digestor.from_proxy(track_proxy.artist)
23
+ end
24
+
25
+ def populate_optional_properties(track, track_proxy)
26
+ track.version = track_proxy.version.value.to_s if track_proxy.version
27
+ track.track_number = track_proxy.track_number.value.to_i if track_proxy.track_number
28
+ track.duration = track_proxy.duration.value.to_i if track_proxy.duration
29
+ track.release = @api_client.release_digestor.from_proxy(track_proxy.release) if track_proxy.release
30
+ track.explicit_content = track_proxy.explicit_content.value.to_s.downcase == "true" if track_proxy.explicit_content
31
+ track.isrc = track_proxy.isrc.value.to_s if track_proxy.isrc
32
+ track.image = track_proxy.image.value.to_s if track_proxy.image
33
+ track.url = track_proxy.url.value.to_s if track_proxy.url
34
+ track.price = @api_client.price_digestor.from_proxy(track_proxy.price) if track_proxy.price
35
+ end
36
+ end
37
+ end
@@ -1,39 +1,45 @@
1
- require "peachy"
2
-
3
- module Sevendigital
4
-
5
- class ArtistManager < Manager
6
-
7
- def get_details(id)
8
- api_request = Sevendigital::ApiRequest.new("artist/details", {:artistId => id})
9
- api_response = @api_client.operator.call_api(api_request)
10
- @api_client.artist_digestor.from_xml(api_response.content.artist)
11
- end
12
-
13
- def get_releases(id, options={})
14
- api_request = Sevendigital::ApiRequest.new("artist/releases", {:artistId => id}, options)
15
- api_response = @api_client.operator.call_api(api_request)
16
- @api_client.release_digestor.list_from_xml(api_response.content.releases)
17
- end
18
-
19
- def get_top_tracks(id, options={})
20
- api_request = Sevendigital::ApiRequest.new("artist/toptracks", {:artistId => id}, options)
21
- api_response = @api_client.operator.call_api(api_request)
22
- @api_client.track_digestor.list_from_xml(api_response.content.tracks)
23
- end
24
-
25
- def get_similar(id, options={})
26
- api_request = Sevendigital::ApiRequest.new("artist/similar", {:artistId => id}, options)
27
- api_response = @api_client.operator.call_api(api_request)
28
- @api_client.artist_digestor.list_from_xml(api_response.content.artists)
29
- end
30
-
31
- def get_top_by_tag(tags, options={})
32
- api_request = Sevendigital::ApiRequest.new("artist/byTag/top", {:tags => tags}, options)
33
- api_response = @api_client.operator.call_api(api_request)
34
- @api_client.artist_digestor.nested_list_from_xml(api_response.content.tagged_results, :tagged_item, :tagged_results)
35
- end
36
-
37
- end
38
-
39
- end
1
+ require "peachy"
2
+
3
+ module Sevendigital
4
+
5
+ class ArtistManager < Manager
6
+
7
+ def get_details(id, options={})
8
+ api_request = Sevendigital::ApiRequest.new("artist/details", {:artistId => id}, options)
9
+ api_response = @api_client.operator.call_api(api_request)
10
+ @api_client.artist_digestor.from_xml(api_response.content.artist)
11
+ end
12
+
13
+ def get_releases(id, options={})
14
+ api_request = Sevendigital::ApiRequest.new("artist/releases", {:artistId => id}, options)
15
+ api_response = @api_client.operator.call_api(api_request)
16
+ @api_client.release_digestor.list_from_xml(api_response.content.releases)
17
+ end
18
+
19
+ def get_top_tracks(id, options={})
20
+ api_request = Sevendigital::ApiRequest.new("artist/toptracks", {:artistId => id}, options)
21
+ api_response = @api_client.operator.call_api(api_request)
22
+ @api_client.track_digestor.list_from_xml(api_response.content.tracks)
23
+ end
24
+
25
+ def get_similar(id, options={})
26
+ api_request = Sevendigital::ApiRequest.new("artist/similar", {:artistId => id}, options)
27
+ api_response = @api_client.operator.call_api(api_request)
28
+ @api_client.artist_digestor.list_from_xml(api_response.content.artists)
29
+ end
30
+
31
+ def get_top_by_tag(tags, options={})
32
+ api_request = Sevendigital::ApiRequest.new("artist/byTag/top", {:tags => tags}, options)
33
+ api_response = @api_client.operator.call_api(api_request)
34
+ @api_client.artist_digestor.nested_list_from_xml(api_response.content.tagged_results, :tagged_item, :tagged_results)
35
+ end
36
+
37
+ def search(query, options={})
38
+ api_request = Sevendigital::ApiRequest.new("artist/search", {:q => query}, options)
39
+ api_response = @api_client.operator.call_api(api_request)
40
+ @api_client.artist_digestor.nested_list_from_xml(api_response.content.search_results, :search_result, :search_results)
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -1,11 +1,11 @@
1
- module Sevendigital
2
-
3
- class Manager
4
-
5
- def initialize(api_client)
6
- @api_client = api_client
7
- end
8
-
9
- end
10
-
11
- end
1
+ module Sevendigital
2
+
3
+ class Manager
4
+
5
+ def initialize(api_client)
6
+ @api_client = api_client
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -1,51 +1,58 @@
1
- require "peachy"
2
-
3
- module Sevendigital
4
-
5
- class ReleaseManager < Manager
6
-
7
- def get_details(release_id, options = {})
8
- api_request = Sevendigital::ApiRequest.new("release/details", {:releaseId => release_id}, options)
9
- api_response = @api_client.operator.call_api(api_request)
10
- @api_client.release_digestor.from_xml(api_response.content.release)
11
- end
12
-
13
- def get_tracks(release_id, options = {})
14
- api_request = Sevendigital::ApiRequest.new("release/tracks", {:releaseId => release_id}, options)
15
- api_response = @api_client.operator.call_api(api_request)
16
- @api_client.track_digestor.list_from_xml(api_response.content.tracks)
17
- end
18
-
19
- def get_chart(options={})
20
- api_request = Sevendigital::ApiRequest.new("release/chart", {}, options)
21
- api_response = @api_client.operator.call_api(api_request)
22
- @api_client.chart_item_digestor.list_from_xml(api_response.content.chart)
23
- end
24
-
25
- def get_by_date(from_date = nil, to_date = nil, options = {})
26
- parameters = Hash.new
27
- parameters[:fromDate] = from_date.strftime("%Y%m%d") if from_date
28
- parameters[:toDate] = to_date.strftime("%Y%m%d") if to_date
29
-
30
- api_request = Sevendigital::ApiRequest.new("release/byDate", parameters, options)
31
- api_response = @api_client.operator.call_api(api_request)
32
- @api_client.release_digestor.list_from_xml(api_response.content.releases)
33
- end
34
-
35
- def get_recommendations(release_id, options = {})
36
- api_request = Sevendigital::ApiRequest.new("release/recommend", {:releaseId => release_id}, options)
37
- api_response = @api_client.operator.call_api(api_request)
38
- @api_client.release_digestor.nested_list_from_xml(api_response.content.recommendations, :recommended_item, :recommendations)
39
- end
40
-
41
-
42
- def get_top_by_tag(tags, options = {})
43
- api_request = Sevendigital::ApiRequest.new("release/byTag/top", {:tags => tags}, options)
44
- api_response = @api_client.operator.call_api(api_request)
45
- @api_client.release_digestor.nested_list_from_xml( \
46
- api_response.content.tagged_results, :tagged_item, :tagged_results )
47
- end
48
-
49
- end
50
-
1
+ require "peachy"
2
+
3
+ module Sevendigital
4
+
5
+ class ReleaseManager < Manager
6
+
7
+ def get_details(release_id, options = {})
8
+ api_request = Sevendigital::ApiRequest.new("release/details", {:releaseId => release_id}, options)
9
+ api_response = @api_client.operator.call_api(api_request)
10
+ @api_client.release_digestor.from_xml(api_response.content.release)
11
+ end
12
+
13
+ def get_tracks(release_id, options = {})
14
+ options[:page_size] ||= 100
15
+ api_request = Sevendigital::ApiRequest.new("release/tracks", {:releaseId => release_id}, options)
16
+ api_response = @api_client.operator.call_api(api_request)
17
+ @api_client.track_digestor.list_from_xml(api_response.content.tracks)
18
+ end
19
+
20
+ def get_chart(options={})
21
+ api_request = Sevendigital::ApiRequest.new("release/chart", {}, options)
22
+ api_response = @api_client.operator.call_api(api_request)
23
+ @api_client.chart_item_digestor.list_from_xml(api_response.content.chart)
24
+ end
25
+
26
+ def get_by_date(from_date = nil, to_date = nil, options = {})
27
+ parameters = Hash.new
28
+ parameters[:fromDate] = from_date.strftime("%Y%m%d") if from_date
29
+ parameters[:toDate] = to_date.strftime("%Y%m%d") if to_date
30
+
31
+ api_request = Sevendigital::ApiRequest.new("release/byDate", parameters, options)
32
+ api_response = @api_client.operator.call_api(api_request)
33
+ @api_client.release_digestor.list_from_xml(api_response.content.releases)
34
+ end
35
+
36
+ def get_recommendations(release_id, options = {})
37
+ api_request = Sevendigital::ApiRequest.new("release/recommend", {:releaseId => release_id}, options)
38
+ api_response = @api_client.operator.call_api(api_request)
39
+ @api_client.release_digestor.nested_list_from_xml(api_response.content.recommendations, :recommended_item, :recommendations)
40
+ end
41
+
42
+
43
+ def get_top_by_tag(tags, options = {})
44
+ api_request = Sevendigital::ApiRequest.new("release/byTag/top", {:tags => tags}, options)
45
+ api_response = @api_client.operator.call_api(api_request)
46
+ @api_client.release_digestor.nested_list_from_xml( \
47
+ api_response.content.tagged_results, :tagged_item, :tagged_results )
48
+ end
49
+
50
+ def search(query, options={})
51
+ api_request = Sevendigital::ApiRequest.new("release/search", {:q => query}, options)
52
+ api_response = @api_client.operator.call_api(api_request)
53
+ @api_client.release_digestor.nested_list_from_xml(api_response.content.search_results, :search_result, :search_results)
54
+ end
55
+
56
+ end
57
+
51
58
  end
@@ -1,18 +1,29 @@
1
- module Sevendigital
2
-
3
- class TrackManager < Manager
4
-
5
- def get_details(id)
6
- api_request = Sevendigital::ApiRequest.new("track/details", {:trackId => id})
7
- api_response = @api_client.operator.call_api(api_request)
8
- @api_client.track_digestor.from_xml(api_response.content.track)
9
- end
10
-
11
- def get_chart(options={})
12
- api_request = Sevendigital::ApiRequest.new("track/chart", {}, options)
13
- api_response = @api_client.operator.call_api(api_request)
14
- @api_client.chart_item_digestor.list_from_xml(api_response.content.chart)
15
- end
16
-
17
- end
1
+ module Sevendigital
2
+
3
+ class TrackManager < Manager
4
+
5
+ def get_details(id)
6
+ api_request = Sevendigital::ApiRequest.new("track/details", {:trackId => id})
7
+ api_response = @api_client.operator.call_api(api_request)
8
+ @api_client.track_digestor.from_xml(api_response.content.track)
9
+ end
10
+
11
+ def get_chart(options={})
12
+ api_request = Sevendigital::ApiRequest.new("track/chart", {}, options)
13
+ api_response = @api_client.operator.call_api(api_request)
14
+ @api_client.chart_item_digestor.list_from_xml(api_response.content.chart)
15
+ end
16
+
17
+ def build_preview_url(id, options={})
18
+ api_request = Sevendigital::ApiRequest.new("track/preview", {:trackId => id}, options)
19
+ @api_client.operator.create_request_uri(api_request)
20
+ end
21
+
22
+ def search(query, options={})
23
+ api_request = Sevendigital::ApiRequest.new("track/search", {:q => query}, options)
24
+ api_response = @api_client.operator.call_api(api_request)
25
+ @api_client.track_digestor.nested_list_from_xml(api_response.content.search_results, :search_result, :search_results)
26
+ end
27
+
28
+ end
18
29
  end