siilar 1.3.0 → 1.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d972ebb4830794176e2472aa14225629ae5b2c28
4
- data.tar.gz: 677fd50447cf59e058e9f1e6abd5c62319febce2
3
+ metadata.gz: 5ca39c15768d357e7f84fcb1bcccf2e3c4ca806c
4
+ data.tar.gz: 6ace98f69649c6f64582204454f26b6b055646f1
5
5
  SHA512:
6
- metadata.gz: 13f6fdf7903adecb9fabdd779e577ffe1189a96985a2ae6735e8e17c30c12d0c0a3b2192986303abfb72c3f5b78d109da3bcf768db65394a4647f9851a2308e3
7
- data.tar.gz: f197eded5bf3bb66174ea1053b496e469e0888fd4e9d6ce4f20ad70e4ab19a0a87b866d97359a06e4ff1b74592efbac5497accc40e3a5b956be035d04feea647
6
+ metadata.gz: 5fd797ad4a8ff0626f7ad4a37fefb71aff08dbd9bab941c41b4f64a473407a21070e9fe0182dcce0d1e0958128d798ba94d025d83af4e370741a4eea7b58ad8a
7
+ data.tar.gz: f98c8b75e8850c8f6005a8d1c9d5efecc05c7e83d55d4897658caf6459fa44c51133e64d19bbe1e97f68b8d3ec550fa5b161c7df28ae2f98ad40e4a4758301fc
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Siilar Ruby Client [![Build Status](https://travis-ci.org/craftsmen/niland-siilar-ruby.svg?branch=better-methods-names)](https://travis-ci.org/craftsmen/niland-siilar-ruby)
2
2
 
3
- A Ruby client for the [Siilar API](http://api.siilar.com/1.0/doc/).
3
+ A Ruby client for the [Siilar API](http://api.niland.io/1.0/doc/).
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- This library is a Ruby client you can use to interact with the [Siilar API](http://api.siilar.com/1.0/doc/).
21
+ This library is a Ruby client you can use to interact with the [Siilar API](http://api.niland.io/1.0/doc/).
22
22
 
23
23
  Here's a short example.
24
24
 
@@ -1,8 +1,8 @@
1
1
  module Siilar
2
2
  class Client
3
3
 
4
- def tracks
5
- @services[:tracks] ||= Client::TracksService.new(self)
4
+ def radios
5
+ @services[:radios] ||= Client::RadiosService.new(self)
6
6
  end
7
7
 
8
8
  def search
@@ -13,6 +13,14 @@ module Siilar
13
13
  @services[:tags] ||= Client::TagsService.new(self)
14
14
  end
15
15
 
16
+ def tracks
17
+ @services[:tracks] ||= Client::TracksService.new(self)
18
+ end
19
+
20
+ def users
21
+ @services[:users] ||= Client::UsersService.new(self)
22
+ end
23
+
16
24
  class ClientService < ::Struct.new(:client)
17
25
  end
18
26
 
@@ -33,5 +41,17 @@ module Siilar
33
41
  class TagsService < ClientService
34
42
  include Client::Tags
35
43
  end
44
+
45
+ require 'siilar/client/users'
46
+
47
+ class UsersService < ClientService
48
+ include Client::Users
49
+ end
50
+
51
+ require 'siilar/client/radios'
52
+
53
+ class RadiosService < ClientService
54
+ include Client::Radios
55
+ end
36
56
  end
37
57
  end
@@ -0,0 +1,82 @@
1
+ module Siilar
2
+ class Client
3
+ module Radios
4
+
5
+ # Get a list of your radios.
6
+ #
7
+ # @see http://api.niland.io/1.0/doc/radios#list-radios
8
+ def list
9
+ response = client.get('1.0/radios')
10
+ response.map { |radio| Struct::Radio.new(radio) }
11
+ end
12
+
13
+ # Get a radio.
14
+ #
15
+ # @see http://api.niland.io/1.0/doc/radios#get-a-radio
16
+ def get(radio)
17
+ response = client.get("1.0/radios/#{radio}")
18
+ Struct::Radio.new(response)
19
+ end
20
+
21
+ # Create a radio.
22
+ #
23
+ # @see http://api.niland.io/1.0/doc/radios#create-a-radio
24
+ def create(attributes = {})
25
+ response = client.post('1.0/radios', attributes)
26
+ Struct::Radio.new(response)
27
+ end
28
+
29
+ # Edit a radio.
30
+ #
31
+ # @see http://api.niland.io/1.0/doc/radios#edit-a-radio
32
+ def edit(radio, attributes = {})
33
+ response = client.patch("1.0/radios/#{radio}", attributes)
34
+ Struct::Radio.new(response)
35
+ end
36
+
37
+ # Get next radio tracks
38
+ #
39
+ # @see http://api.niland.io/1.0/doc/radios#get-next-radio-tracks
40
+ def get_next(radio)
41
+ response = client.get("1.0/radios/#{radio}/next")
42
+ response.map { |track| Struct::Track.new(track) }
43
+ end
44
+
45
+ # Notify a skip.
46
+ #
47
+ # @see http://api.niland.io/1.0/doc/radios#notify-a-skip
48
+ def notify_skip(radio, attributes = {})
49
+ Extra.validate_mandatory_attributes(attributes, [:track])
50
+ response = client.post("1.0/radios/#{radio}/skips", attributes)
51
+ Struct::Radio.new(response)
52
+ end
53
+
54
+ # Notify a like.
55
+ #
56
+ # @see http://api.niland.io/1.0/doc/radios#notify-a-like
57
+ def notify_like(radio, attributes = {})
58
+ Extra.validate_mandatory_attributes(attributes, [:track])
59
+ response = client.post("1.0/radios/#{radio}/likes", attributes)
60
+ Struct::Radio.new(response)
61
+ end
62
+
63
+ # Notify a dislike.
64
+ #
65
+ # @see http://api.niland.io/1.0/doc/radios#notify-a-dislike
66
+ def notify_dislike(radio, attributes = {})
67
+ Extra.validate_mandatory_attributes(attributes, [:track])
68
+ response = client.post("1.0/radios/#{radio}/dislikes", attributes)
69
+ Struct::Radio.new(response)
70
+ end
71
+
72
+ # Notify a favorite.
73
+ #
74
+ # @see http://api.niland.io/1.0/doc/radios#notify-a-favorite
75
+ def notify_favorite(radio, attributes = {})
76
+ Extra.validate_mandatory_attributes(attributes, [:track])
77
+ response = client.post("1.0/radios/#{radio}/favorites", attributes)
78
+ Struct::Radio.new(response)
79
+ end
80
+ end
81
+ end
82
+ end
@@ -4,7 +4,7 @@ module Siilar
4
4
 
5
5
  # Search for a track
6
6
  #
7
- # @see http://api.siilar.com/1.0/doc/search-and-analyze#search
7
+ # @see http://api.niland.io/1.0/doc/search-and-analyze#search
8
8
  def similar(query = {})
9
9
  options = { query: query }
10
10
  response = client.get('1.0/search', options)
@@ -14,7 +14,7 @@ module Siilar
14
14
 
15
15
  # Search for a track from external ids
16
16
  #
17
- # @see http://api.siilar.com/1.0/doc/search-and-analyze#search-from-external
17
+ # @see http://api.niland.io/1.0/doc/search-and-analyze#search-from-external
18
18
  def similar_from_external(query = {})
19
19
  options = { query: query }
20
20
  response = client.get('1.0/search-from-external', options)
@@ -4,7 +4,7 @@ module Siilar
4
4
 
5
5
  # Get all the tag collections
6
6
  #
7
- # @see http://api.siilar.com/1.0/doc/tags#list-tag-collections
7
+ # @see http://api.niland.io/1.0/doc/tags#list-tag-collections
8
8
  def tag_collections
9
9
  response = client.get('1.0/tag-collections')
10
10
 
@@ -13,7 +13,7 @@ module Siilar
13
13
 
14
14
  # Get one tag collection
15
15
  #
16
- # @see http://api.siilar.com/1.0/doc/tags#get-tag-collections
16
+ # @see http://api.niland.io/1.0/doc/tags#get-tag-collections
17
17
  def tag_collection(collection)
18
18
  response = client.get("1.0/tag-collections/#{collection}")
19
19
 
@@ -22,7 +22,7 @@ module Siilar
22
22
 
23
23
  # Create a tag collection
24
24
  #
25
- # @see http://api.siilar.com/1.0/doc/tags#create-tag-collections
25
+ # @see http://api.niland.io/1.0/doc/tags#create-tag-collections
26
26
  def create_tag_collection(attributes = {})
27
27
  Extra.validate_mandatory_attributes(attributes, [:name])
28
28
  response = client.post('1.0/tag-collections', attributes)
@@ -32,7 +32,7 @@ module Siilar
32
32
 
33
33
  # Edit a tag collection
34
34
  #
35
- # @see http://api.siilar.com/1.0/doc/tags#edit-tag-collections
35
+ # @see http://api.niland.io/1.0/doc/tags#edit-tag-collections
36
36
  def edit_tag_collection(collection, attributes = {})
37
37
  response = client.patch("1.0/tag-collections/#{collection}", attributes)
38
38
 
@@ -41,14 +41,14 @@ module Siilar
41
41
 
42
42
  # Delete a tag collection
43
43
  #
44
- # @see http://api.siilar.com/1.0/doc/tags#delete-tag-collections
44
+ # @see http://api.niland.io/1.0/doc/tags#delete-tag-collections
45
45
  def delete_tag_collection(collection)
46
46
  client.delete("1.0/tag-collections/#{collection}")
47
47
  end
48
48
 
49
49
  # Find tags
50
50
  #
51
- # @see http://api.siilar.com/1.0/doc/tags#find-tags
51
+ # @see http://api.niland.io/1.0/doc/tags#find-tags
52
52
  def find_tags(attributes = {})
53
53
  response = client.get('1.0/tags', attributes)
54
54
 
@@ -4,7 +4,7 @@ module Siilar
4
4
 
5
5
  # Gets a track.
6
6
  #
7
- # @see http://api.siilar.com/1.0/doc/tracks#get-a-track
7
+ # @see http://api.niland.io/1.0/doc/tracks#get-a-track
8
8
  def track(track)
9
9
  response = client.get("1.0/tracks/#{track}")
10
10
 
@@ -26,12 +26,12 @@ module Siilar
26
26
  def from_external(track)
27
27
  response = client.get("1.0/from-external/#{track}")
28
28
 
29
- Struct::Track.new(response)
29
+ response.map { |r| Struct::Track.new(r) }
30
30
  end
31
31
 
32
32
  # Creates a track.
33
33
  #
34
- # @see http://api.siilar.com/1.0/doc/tracks#create-a-track
34
+ # @see http://api.niland.io/1.0/doc/tracks#create-a-track
35
35
  def create(attributes = {})
36
36
  Extra.validate_mandatory_attributes(attributes, [:title, :external_id])
37
37
  response = client.post('1.0/tracks', attributes)
@@ -41,7 +41,7 @@ module Siilar
41
41
 
42
42
  # Updates a track.
43
43
  #
44
- # @see http://api.siilar.com/1.0/doc/tracks#edit-a-track
44
+ # @see http://api.niland.io/1.0/doc/tracks#edit-a-track
45
45
  def update(track, attributes = {})
46
46
  response = client.patch("1.0/tracks/#{track}", attributes)
47
47
 
@@ -50,7 +50,7 @@ module Siilar
50
50
 
51
51
  # Deletes a track.
52
52
  #
53
- # @see http://api.siilar.com/1.0/doc/tracks#delete-a-track
53
+ # @see http://api.niland.io/1.0/doc/tracks#delete-a-track
54
54
  def delete(track)
55
55
  client.delete("1.0/tracks/#{track}")
56
56
  end
@@ -0,0 +1,88 @@
1
+ module Siilar
2
+ class Client
3
+ module Users
4
+
5
+ # Get a list of your users.
6
+ #
7
+ # @see http://api.niland.io/1.0/doc/users#list-users
8
+ def list(query = {})
9
+ response = client.get('1.0/users')
10
+ response.map { |user| Struct::User.new(user) }
11
+ end
12
+
13
+ # Get a user.
14
+ #
15
+ # @see http://api.niland.io/1.0/doc/users#get-a-user
16
+ def get(user)
17
+ response = client.get("1.0/users/#{user}")
18
+ Struct::User.new(response)
19
+ end
20
+
21
+ # Create a user.
22
+ #
23
+ # @see http://api.niland.io/1.0/doc/users#create-a-user
24
+ def create(attributes = {})
25
+ Extra.validate_mandatory_attributes(attributes, [:external_id])
26
+ response = client.post('1.0/users', attributes)
27
+ Struct::User.new(response)
28
+ end
29
+
30
+ # Update a user.
31
+ #
32
+ # @see http://api.niland.io/1.0/doc/users#update-a-user
33
+ def update(user, attributes = {})
34
+ response = client.patch("1.0/users/#{user}", attributes)
35
+ Struct::User.new(response)
36
+ end
37
+
38
+ # Delete a user.
39
+ #
40
+ # @see http://api.niland.io/1.0/doc/users#delete-a-user
41
+ def delete(user)
42
+ client.delete("1.0/users/#{user}")
43
+ end
44
+
45
+ # Get next user tracks
46
+ #
47
+ # @see http://api.niland.io/1.0/doc/users#get-next-user-tracks
48
+ def get_next(user)
49
+ response = client.get("1.0/users/#{user}/next")
50
+ response.map { |user| Struct::User.new(response) }
51
+ end
52
+
53
+ # Get liked tracks.
54
+ #
55
+ # @see https://api.niland.io/doc/users#get-liked-tracks
56
+ def get_liked_tracks(user)
57
+ response = client.get("1.0/users/#{user}/likes")
58
+ response.map { |track| Struct::Track.new(track) }
59
+ end
60
+
61
+ # Add liked tracks.
62
+ #
63
+ # @see https://api.niland.io/doc/users#add-liked-track
64
+ def add_liked_track(user, attributes = {})
65
+ Extra.validate_mandatory_attributes(attributes, [:track])
66
+ response = client.post("1.0/users/#{user}/likes", attributes)
67
+ Struct::Track.new(response)
68
+ end
69
+
70
+ # Get disliked tracks.
71
+ #
72
+ # @see https://api.niland.io/doc/users#get-disliked-tracks
73
+ def get_disliked_tracks(user)
74
+ response = client.get("1.0/users/#{user}/dislikes")
75
+ response.map { |track| Struct::Track.new(track) }
76
+ end
77
+
78
+ # Add disliked tracks.
79
+ #
80
+ # @see https://api.niland.io/doc/users#add-disliked-track
81
+ def add_disliked_track(user, attributes = {})
82
+ Extra.validate_mandatory_attributes(attributes, [:track])
83
+ response = client.post("1.0/users/#{user}/dislikes", attributes)
84
+ Struct::Track.new(response)
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,6 +1,6 @@
1
1
  module Siilar
2
2
  module Default
3
- API_ENDPOINT = "http://api.siilar.com/".freeze
3
+ API_ENDPOINT = "https://api.niland.io/".freeze
4
4
  USER_AGENT = "niland-siilar-ruby/#{VERSION}".freeze
5
5
 
6
6
  class << self
@@ -0,0 +1,47 @@
1
+ module Siilar
2
+ module Struct
3
+
4
+ class Radio < Base
5
+ attr_accessor :id
6
+ def current_tracks
7
+ @current_tracks ||= []
8
+ end
9
+
10
+ def current_tracks=(attrs)
11
+ if attrs
12
+ @current_tracks = attrs.map { |track| Struct::Track.new(track) }
13
+ end
14
+ end
15
+
16
+ def seeds
17
+ @seeds ||= []
18
+ end
19
+
20
+ def seeds=(attrs)
21
+ if attrs
22
+ @seeds = attrs.map { |seed| Struct::Track.new(seed) }
23
+ end
24
+ end
25
+
26
+ def tags
27
+ @tags ||= []
28
+ end
29
+
30
+ def tags=(attrs)
31
+ if attrs
32
+ @tags = attrs.map { |tag| Struct::Tag.new(tag) }
33
+ end
34
+ end
35
+
36
+ def user
37
+ @tags ||= {}
38
+ end
39
+
40
+ def user=(attrs)
41
+ if attrs
42
+ @user = Struct::User.new(attrs)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -2,7 +2,7 @@ module Siilar
2
2
  module Struct
3
3
 
4
4
  class Track < Base
5
- attr_accessor :id, :hash, :title, :popularity, :duration, :external_id, :isrc, :waveform_url
5
+ attr_accessor :id, :hash, :title, :popularity, :duration, :external_id, :isrc, :year
6
6
 
7
7
  def album
8
8
  @album ||= {}
@@ -0,0 +1,8 @@
1
+ module Siilar
2
+ module Struct
3
+
4
+ class User < Base
5
+ attr_accessor :external_id, :birthdate, :gender, :country, :city
6
+ end
7
+ end
8
+ end
data/lib/siilar/struct.rb CHANGED
@@ -12,9 +12,11 @@ module Siilar
12
12
  end
13
13
  end
14
14
 
15
- require 'siilar/struct/track'
16
- require 'siilar/struct/external_track'
17
15
  require 'siilar/struct/album'
18
16
  require 'siilar/struct/artist'
17
+ require 'siilar/struct/external_track'
18
+ require 'siilar/struct/radio'
19
19
  require 'siilar/struct/tag'
20
20
  require 'siilar/struct/tag_collection'
21
+ require 'siilar/struct/track'
22
+ require 'siilar/struct/user'
@@ -1,3 +1,3 @@
1
1
  module Siilar
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siilar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehdi Lahmam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -85,9 +85,11 @@ files:
85
85
  - lib/siilar.rb
86
86
  - lib/siilar/client.rb
87
87
  - lib/siilar/client/clients.rb
88
+ - lib/siilar/client/radios.rb
88
89
  - lib/siilar/client/search.rb
89
90
  - lib/siilar/client/tags.rb
90
91
  - lib/siilar/client/tracks.rb
92
+ - lib/siilar/client/users.rb
91
93
  - lib/siilar/default.rb
92
94
  - lib/siilar/error.rb
93
95
  - lib/siilar/extra.rb
@@ -95,9 +97,11 @@ files:
95
97
  - lib/siilar/struct/album.rb
96
98
  - lib/siilar/struct/artist.rb
97
99
  - lib/siilar/struct/external_track.rb
100
+ - lib/siilar/struct/radio.rb
98
101
  - lib/siilar/struct/tag.rb
99
102
  - lib/siilar/struct/tag_collection.rb
100
103
  - lib/siilar/struct/track.rb
104
+ - lib/siilar/struct/user.rb
101
105
  - lib/siilar/version.rb
102
106
  - siilar.gemspec
103
107
  homepage: https://github.com/craftsmen/niland-siilar-ruby