siilar 2.0.0 → 2.0.1

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: 0b17083450469418ae3c14ddb410f8fb30a15241
4
- data.tar.gz: ef87152d3243cb1991e2ab91a418c9d695b0352c
3
+ metadata.gz: 13cc2720495e50f39c2d576217590c8ef9f4800e
4
+ data.tar.gz: 368212c6437680a9c47ce823b14b3fe1d2c4283b
5
5
  SHA512:
6
- metadata.gz: fb9aeba2546609d274c0a58d5b763a5eb44c28f9205956a78da75c2130af4b4c1db6d11e97f4c41ef9a37245b4dda3ebb39504c19cfac334194f5438cac71f90
7
- data.tar.gz: 3c6b546f65b3d7795ca7214ca8128d9b699df0d1cbd16143b4af21ed4fa92accf07aa9fc2259d5934f20dd4ad538b88004d85a94664cb294caa0fdc9da00c376
6
+ metadata.gz: dedde1f074ca0ae9d1f7dfae0f3d779c601db4792ea5a454c31980dbce75aa63467beea35a4d9f355a28527e8cd09200e6607c382ba9fd8fce1ab1673055b470
7
+ data.tar.gz: 3e895f6f223361b15eb0524137a05ad8d41f7390ce5de8a7447d4129acffa82d81250f6cdda6776d6d9cd7a4b7a23ea5379c4bcc053d602e1bdf1126f167d118
@@ -53,7 +53,7 @@ module Siilar
53
53
  #
54
54
  # @see http://api.niland.io/2.0/doc/radios#notify-a-skip
55
55
  def notify_skip(radio, attributes = {})
56
- Extra.validate_mandatory_attributes(attributes, [:track])
56
+ validate_arguments_has_track_or_reference(attributes)
57
57
  response = client.post("2.0/radios/#{radio}/skips", attributes)
58
58
  Struct::Radio.new(response)
59
59
  end
@@ -62,7 +62,7 @@ module Siilar
62
62
  #
63
63
  # @see http://api.niland.io/2.0/doc/radios#notify-a-like
64
64
  def notify_like(radio, attributes = {})
65
- Extra.validate_mandatory_attributes(attributes, [:track])
65
+ validate_arguments_has_track_or_reference(attributes)
66
66
  response = client.post("2.0/radios/#{radio}/likes", attributes)
67
67
  Struct::Radio.new(response)
68
68
  end
@@ -71,7 +71,7 @@ module Siilar
71
71
  #
72
72
  # @see http://api.niland.io/2.0/doc/radios#notify-a-dislike
73
73
  def notify_dislike(radio, attributes = {})
74
- Extra.validate_mandatory_attributes(attributes, [:track])
74
+ validate_arguments_has_track_or_reference(attributes)
75
75
  response = client.post("2.0/radios/#{radio}/dislikes", attributes)
76
76
  Struct::Radio.new(response)
77
77
  end
@@ -80,7 +80,7 @@ module Siilar
80
80
  #
81
81
  # @see http://api.niland.io/2.0/doc/radios#notify-a-ban
82
82
  def notify_ban(radio, attributes = {})
83
- Extra.validate_mandatory_attributes(attributes, [:track])
83
+ validate_arguments_has_track_or_reference(attributes)
84
84
  response = client.post("2.0/radios/#{radio}/bans", attributes)
85
85
  Struct::Radio.new(response)
86
86
  end
@@ -89,7 +89,7 @@ module Siilar
89
89
  #
90
90
  # @see http://api.niland.io/2.0/doc/radios#notify-a-favorite
91
91
  def notify_favorite(radio, attributes = {})
92
- Extra.validate_mandatory_attributes(attributes, [:track])
92
+ validate_arguments_has_track_or_reference(attributes)
93
93
  response = client.post("2.0/radios/#{radio}/favorites", attributes)
94
94
  Struct::Radio.new(response)
95
95
  end
@@ -98,10 +98,19 @@ module Siilar
98
98
  #
99
99
  # @see http://api.niland.io/2.0/doc/radios#notify-a-not-played-track
100
100
  def notify_not_played(radio, attributes = {})
101
- Extra.validate_mandatory_attributes(attributes, [:track])
101
+ validate_arguments_has_track_or_reference(attributes)
102
102
  response = client.post("2.0/radios/#{radio}/notplayed", attributes)
103
103
  Struct::Radio.new(response)
104
104
  end
105
+
106
+ private
107
+
108
+ def validate_arguments_has_track_or_reference(attributes)
109
+ if !(attributes.key?(:track) ^ attributes.key?(:reference))
110
+ raise(ArgumentError, ":track or :reference is required. They are mutually exclusive")
111
+ end
112
+ end
113
+
105
114
  end
106
115
  end
107
116
  end
@@ -64,6 +64,15 @@ module Siilar
64
64
  Struct::Track.new(response)
65
65
  end
66
66
 
67
+ # Updates a track from its reference.
68
+ #
69
+ # @see http://api.niland.io/2.0/doc/tracks#edit-a-track
70
+ def update_from_reference(reference, attributes = {})
71
+ response = client.patch("2.0/tracks/reference/#{reference}", attributes)
72
+
73
+ Struct::Track.new(response)
74
+ end
75
+
67
76
  # Updates a track audio file
68
77
  #
69
78
  # @see https://api.niland.io/2.0/doc/tracks#upload-a-temporary-track
@@ -94,6 +103,16 @@ module Siilar
94
103
 
95
104
  response.map { |tag| Struct::Tag.new(tag) }
96
105
  end
106
+
107
+
108
+ # Gets a track's tags from its internal reference.
109
+ #
110
+ # @see https://api.niland.io/2.0/doc/tracks#get-track-tags
111
+ def tags_from_reference(reference)
112
+ response = client.get("2.0/tracks/reference/#{reference}/tags")
113
+
114
+ response.map { |tag| Struct::Tag.new(tag) }
115
+ end
97
116
  end
98
117
  end
99
118
  end
@@ -1,6 +1,6 @@
1
1
  module Siilar
2
2
  module Default
3
- API_ENDPOINT = "https://api.niland.io/".freeze
3
+ API_ENDPOINT = "https://api.niland.io/2.0/".freeze
4
4
  USER_AGENT = "niland-siilar-ruby/#{VERSION}".freeze
5
5
 
6
6
  class << self
@@ -1,3 +1,3 @@
1
1
  module Siilar
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehdi Lahmam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-24 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty