7digital 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -0
- data/lib/peachy_patchy.rb +14 -0
- data/lib/sevendigital.rb +53 -0
- data/lib/sevendigital/api_operator.rb +31 -0
- data/lib/sevendigital/api_operator_cached.rb +23 -0
- data/lib/sevendigital/api_request.rb +24 -0
- data/lib/sevendigital/client.rb +124 -0
- data/lib/sevendigital/default_configuration.yml +2 -0
- data/lib/sevendigital/digestion_tract/api_response_digestor.rb +52 -0
- data/lib/sevendigital/digestion_tract/artist_digestor.rb +31 -0
- data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +27 -0
- data/lib/sevendigital/digestion_tract/digestor.rb +66 -0
- data/lib/sevendigital/digestion_tract/format_digestor.rb +21 -0
- data/lib/sevendigital/digestion_tract/label_digestor.rb +20 -0
- data/lib/sevendigital/digestion_tract/pager_digestor.rb +23 -0
- data/lib/sevendigital/digestion_tract/price_digestor.rb +25 -0
- data/lib/sevendigital/digestion_tract/release_digestor.rb +52 -0
- data/lib/sevendigital/digestion_tract/track_digestor.rb +37 -0
- data/lib/sevendigital/management/artist_manager.rb +39 -0
- data/lib/sevendigital/management/manager.rb +11 -0
- data/lib/sevendigital/management/release_manager.rb +51 -0
- data/lib/sevendigital/management/track_manager.rb +18 -0
- data/lib/sevendigital/model/api_response.rb +13 -0
- data/lib/sevendigital/model/artist.rb +37 -0
- data/lib/sevendigital/model/chart_item.rb +9 -0
- data/lib/sevendigital/model/format.rb +9 -0
- data/lib/sevendigital/model/label.rb +9 -0
- data/lib/sevendigital/model/price.rb +11 -0
- data/lib/sevendigital/model/release.rb +34 -0
- data/lib/sevendigital/model/sevendigital_error.rb +3 -0
- data/lib/sevendigital/model/sevendigital_object.rb +51 -0
- data/lib/sevendigital/model/track.rb +8 -0
- data/lib/sevendigital/pager.rb +17 -0
- data/lib/sevendigital/proxy_police.rb +24 -0
- data/lib/sevendigital/version.rb +3 -0
- data/spec/api_operator_cached_spec.rb +47 -0
- data/spec/api_operator_spec.rb +108 -0
- data/spec/api_request_spec.rb +27 -0
- data/spec/client_spec.rb +46 -0
- data/spec/data/config/sevendigital.yml +5 -0
- data/spec/data/configuration_env_override.yml +5 -0
- data/spec/data/configuration_override.yml +1 -0
- data/spec/digestion_tract/api_response_digestor_spec.rb +74 -0
- data/spec/digestion_tract/artist_digestor_spec.rb +83 -0
- data/spec/digestion_tract/chart_digestor_spec.rb +54 -0
- data/spec/digestion_tract/format_digestor_spec.rb +40 -0
- data/spec/digestion_tract/label_digestor_spec.rb +35 -0
- data/spec/digestion_tract/pager_digestor_spec.rb +52 -0
- data/spec/digestion_tract/price_digestor_spec.rb +57 -0
- data/spec/digestion_tract/release_digestor_spec.rb +102 -0
- data/spec/digestion_tract/track_digestor_spec.rb +107 -0
- data/spec/management/artist_manager_spec.rb +108 -0
- data/spec/management/release_manager_spec.rb +178 -0
- data/spec/management/track_manager_spec.rb +52 -0
- data/spec/model/api_response_spec.rb +32 -0
- data/spec/model/artist_spec.rb +122 -0
- data/spec/model/release_spec.rb +111 -0
- data/spec/pager_spec.rb +8 -0
- data/spec/proxy_police_spec.rb +49 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/test-xml/methods/artist/byTag/top.xml +51 -0
- data/spec/test-xml/methods/artist/details.xml +10 -0
- data/spec/test-xml/methods/artist/releases.xml +545 -0
- data/spec/test-xml/methods/artist/similar.xml +40 -0
- data/spec/test-xml/methods/artist/toptracks.xml +280 -0
- data/spec/test-xml/methods/release/bydate.xml +174 -0
- data/spec/test-xml/methods/release/bytag/top.xml +151 -0
- data/spec/test-xml/methods/release/chart.xml +182 -0
- data/spec/test-xml/methods/release/details.xml +49 -0
- data/spec/test-xml/methods/release/recommend.xml +90 -0
- data/spec/test-xml/methods/release/tracks.xml +29 -0
- data/spec/test-xml/methods/track/chart.xml +150 -0
- data/spec/test-xml/methods/track/details.xml +31 -0
- data/spec/test-xml/objects/artist.xml +7 -0
- data/spec/test-xml/objects/artist_chart_item.xml +8 -0
- data/spec/test-xml/objects/artist_list.xml +23 -0
- data/spec/test-xml/objects/artist_list_empty.xml +5 -0
- data/spec/test-xml/objects/price.xml +8 -0
- data/spec/test-xml/objects/release.xml +40 -0
- data/spec/test-xml/objects/release_chart_item.xml +34 -0
- data/spec/test-xml/objects/release_list.xml +19 -0
- data/spec/test-xml/objects/release_list_empty.xml +5 -0
- data/spec/test-xml/objects/track.xml +34 -0
- data/spec/test-xml/objects/track_chart_item.xml +28 -0
- metadata +151 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
class FormatDigestor < Digestor
|
4
|
+
|
5
|
+
def default_element_name; :format end
|
6
|
+
def default_list_element_name; :formats end
|
7
|
+
|
8
|
+
def from_proxy(format_proxy)
|
9
|
+
make_sure_not_eating_nil (format_proxy)
|
10
|
+
format = Format.new()
|
11
|
+
format.id = format_proxy.id.to_i
|
12
|
+
format.file_format = format_proxy.file_format.value.to_sym
|
13
|
+
format.bit_rate = format_proxy.bit_rate.value.to_i
|
14
|
+
format.drm_free = format_proxy.drm_free.value.to_s.downcase == "true"
|
15
|
+
|
16
|
+
return format
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
class LabelDigestor < Digestor
|
4
|
+
|
5
|
+
def default_element_name; :label end
|
6
|
+
def default_list_element_name; :labels end
|
7
|
+
|
8
|
+
def from_proxy(label_proxy)
|
9
|
+
make_sure_not_eating_nil(label_proxy)
|
10
|
+
|
11
|
+
label = Label.new()
|
12
|
+
label.id = label_proxy.id.to_i
|
13
|
+
label.name = label_proxy.name.value.to_s
|
14
|
+
|
15
|
+
return label
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
class PagerDigestor < Digestor
|
4
|
+
|
5
|
+
def default_element_name; :results end
|
6
|
+
def default_list_element_name; nil end
|
7
|
+
|
8
|
+
def from_proxy(pager_proxy)
|
9
|
+
make_sure_not_eating_nil(pager_proxy)
|
10
|
+
return nil unless paging_info_available?(pager_proxy)
|
11
|
+
pager = Pager.new
|
12
|
+
pager.page = pager_proxy.page.value.to_i
|
13
|
+
pager.page_size = pager_proxy.page_size.value.to_i
|
14
|
+
pager.total_items = pager_proxy.total_items.value.to_i
|
15
|
+
return pager
|
16
|
+
end
|
17
|
+
|
18
|
+
def paging_info_available?(pager_proxy)
|
19
|
+
pager_proxy.page && pager_proxy.page_size && pager_proxy.total_items
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +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
|
+
|
25
|
+
end
|
@@ -0,0 +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
|
@@ -0,0 +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
|
@@ -0,0 +1,39 @@
|
|
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
|
@@ -0,0 +1,51 @@
|
|
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
|
+
|
51
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
class Artist < SevendigitalObject
|
4
|
+
|
5
|
+
attr_accessor :id, :name, :appears_as
|
6
|
+
|
7
|
+
sevendigital_basic_property :sort_name, :image, :url
|
8
|
+
|
9
|
+
def get_details(options={})
|
10
|
+
artist_with_details = @api_client.artist.get_details(@id, options)
|
11
|
+
copy_basic_properties_from(artist_with_details)
|
12
|
+
end
|
13
|
+
|
14
|
+
sevendigital_extended_property :releases
|
15
|
+
sevendigital_extended_property :top_tracks
|
16
|
+
sevendigital_extended_property :similar
|
17
|
+
|
18
|
+
def get_releases(options={})
|
19
|
+
@releases = @api_client.artist.get_releases(@id, options).collect do |release|
|
20
|
+
release.artist = self
|
21
|
+
release
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_top_tracks(options={})
|
26
|
+
@tracks = @api_client.artist.get_top_tracks(@id, options).collect do |track|
|
27
|
+
track.artist = self
|
28
|
+
track
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_similar(options={})
|
33
|
+
@similar = @api_client.artist.get_similar(@id, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "peachy"
|
2
|
+
require "will_paginate"
|
3
|
+
|
4
|
+
module Sevendigital
|
5
|
+
|
6
|
+
class Release < SevendigitalObject
|
7
|
+
|
8
|
+
attr_accessor :id, :title
|
9
|
+
|
10
|
+
sevendigital_basic_property :version, :type, :artist, :image, :url, :release_date,
|
11
|
+
:added_date, :barcode, :year, :explicit_content, :formats, :label, :price
|
12
|
+
|
13
|
+
sevendigital_extended_property :tracks
|
14
|
+
sevendigital_extended_property :recommendations
|
15
|
+
|
16
|
+
def get_details(options={})
|
17
|
+
release_with_details = @api_client.release.get_details(@id, options)
|
18
|
+
copy_basic_properties_from(release_with_details)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_tracks(options={})
|
22
|
+
@tracks = @api_client.release.get_tracks(@id, options).collect do |track|
|
23
|
+
track.release = self
|
24
|
+
track
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_recommendations(options={})
|
29
|
+
@recommendations = @api_client.release.get_recommendations(@id, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|