siilar 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/siilar/client/clients.rb +10 -0
- data/lib/siilar/client/tags.rb +59 -0
- data/lib/siilar/client.rb +5 -2
- data/lib/siilar/default.rb +5 -1
- data/lib/siilar/struct/tag.rb +8 -0
- data/lib/siilar/struct/tag_collection.rb +18 -0
- data/lib/siilar/struct.rb +2 -0
- data/lib/siilar/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785bac5294e7164f071c426e8c303c40f9ea5531
|
4
|
+
data.tar.gz: aedda8542cbd5b2a6fbc7836ad7aa6134216666c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c7002b4e922661fa6efd9fc7dcef47618ca2b7a3b9c203c2d2d2a3dd7f2429d28689e9748a802963bdf2759f5a975918279a313ea6827c7d6f245c795bef37d
|
7
|
+
data.tar.gz: a16752cce8dffd219d79b6112b080ffc9139a48b02e2e2c10bd4abee6e6c1fa46a880cc3137c621737f0e54ca24fec98d4cd044425f2adfd23e1c1066f82983f
|
@@ -9,6 +9,10 @@ module Siilar
|
|
9
9
|
@services[:search] ||= Client::SearchService.new(self)
|
10
10
|
end
|
11
11
|
|
12
|
+
def tags
|
13
|
+
@services[:tags] ||= Client::TagsService.new(self)
|
14
|
+
end
|
15
|
+
|
12
16
|
class ClientService < ::Struct.new(:client)
|
13
17
|
end
|
14
18
|
|
@@ -23,5 +27,11 @@ module Siilar
|
|
23
27
|
class SearchService < ClientService
|
24
28
|
include Client::Search
|
25
29
|
end
|
30
|
+
|
31
|
+
require 'siilar/client/tags'
|
32
|
+
|
33
|
+
class TagsService < ClientService
|
34
|
+
include Client::Tags
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Siilar
|
2
|
+
class Client
|
3
|
+
module Tags
|
4
|
+
|
5
|
+
# Get all the tag collections
|
6
|
+
#
|
7
|
+
# @see http://api.siilar.com/1.0/doc/tags#list-tag-collections
|
8
|
+
def tag_collections
|
9
|
+
response = client.get('1.0/tag-collections')
|
10
|
+
|
11
|
+
response.map { |r| Struct::TagCollection.new(r) }
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get one tag collection
|
15
|
+
#
|
16
|
+
# @see http://api.siilar.com/1.0/doc/tags#get-tag-collections
|
17
|
+
def tag_collection(collection)
|
18
|
+
response = client.get("1.0/tag-collections/#{collection}")
|
19
|
+
|
20
|
+
Struct::TagCollection.new(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Create a tag collection
|
24
|
+
#
|
25
|
+
# @see http://api.siilar.com/1.0/doc/tags#create-tag-collections
|
26
|
+
def create_tag_collection(attributes = {})
|
27
|
+
Extra.validate_mandatory_attributes(attributes, [:name])
|
28
|
+
response = client.post('1.0/tag-collections', attributes)
|
29
|
+
|
30
|
+
Struct::TagCollection.new(response)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Edit a tag collection
|
34
|
+
#
|
35
|
+
# @see http://api.siilar.com/1.0/doc/tags#edit-tag-collections
|
36
|
+
def edit_tag_collection(collection, attributes = {})
|
37
|
+
response = client.patch("1.0/tag-collections/#{collection}", attributes)
|
38
|
+
|
39
|
+
Struct::TagCollection.new(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Delete a tag collection
|
43
|
+
#
|
44
|
+
# @see http://api.siilar.com/1.0/doc/tags#delete-tag-collections
|
45
|
+
def delete_tag_collection(collection)
|
46
|
+
client.delete("1.0/tag-collections/#{collection}")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Find tags
|
50
|
+
#
|
51
|
+
# @see http://api.siilar.com/1.0/doc/tags#find-tags
|
52
|
+
def find_tags(attributes = {})
|
53
|
+
response = client.get('1.0/tags', attributes)
|
54
|
+
|
55
|
+
Struct::Tag.new(response)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/siilar/client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'siilar/client/clients'
|
|
4
4
|
|
5
5
|
module Siilar
|
6
6
|
class Client
|
7
|
-
attr_accessor :api_endpoint, :api_key, :user_agent
|
7
|
+
attr_accessor :api_endpoint, :api_key, :user_agent, :requests_timeout
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
defaults = Siilar::Default.options
|
@@ -55,7 +55,6 @@ module Siilar
|
|
55
55
|
if !data.empty?
|
56
56
|
options[:body] = data.to_json
|
57
57
|
end
|
58
|
-
|
59
58
|
HTTParty.send(method, api_endpoint + path, Extra.deep_merge!(base_options, options))
|
60
59
|
end
|
61
60
|
|
@@ -75,6 +74,10 @@ module Siilar
|
|
75
74
|
}
|
76
75
|
}
|
77
76
|
|
77
|
+
if requests_timeout
|
78
|
+
options.merge!(timeout: requests_timeout)
|
79
|
+
end
|
80
|
+
|
78
81
|
if api_key
|
79
82
|
options.merge!(query: { key: api_key })
|
80
83
|
else
|
data/lib/siilar/default.rb
CHANGED
@@ -5,7 +5,7 @@ module Siilar
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def keys
|
8
|
-
@keys ||= [:api_endpoint, :api_key, :user_agent]
|
8
|
+
@keys ||= [:api_endpoint, :api_key, :user_agent, :requests_timeout]
|
9
9
|
end
|
10
10
|
|
11
11
|
def options
|
@@ -20,6 +20,10 @@ module Siilar
|
|
20
20
|
ENV['SIILAR_API_KEY']
|
21
21
|
end
|
22
22
|
|
23
|
+
def requests_timeout
|
24
|
+
ENV['SIILAR_REQUESTS_TIMEOUT'] || 10
|
25
|
+
end
|
26
|
+
|
23
27
|
def user_agent
|
24
28
|
ENV['SIILAR_USER_AGENT'] || USER_AGENT
|
25
29
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Siilar
|
2
|
+
module Struct
|
3
|
+
|
4
|
+
class TagCollection < Base
|
5
|
+
attr_accessor :id, :name, :description
|
6
|
+
|
7
|
+
def tags
|
8
|
+
@tags ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def tags=(attrs)
|
12
|
+
if attrs
|
13
|
+
@tags = attrs.map { |tag| Struct::Tag.new(tag) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/siilar/struct.rb
CHANGED
data/lib/siilar/version.rb
CHANGED
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.
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/siilar/client.rb
|
87
87
|
- lib/siilar/client/clients.rb
|
88
88
|
- lib/siilar/client/search.rb
|
89
|
+
- lib/siilar/client/tags.rb
|
89
90
|
- lib/siilar/client/tracks.rb
|
90
91
|
- lib/siilar/default.rb
|
91
92
|
- lib/siilar/error.rb
|
@@ -93,6 +94,8 @@ files:
|
|
93
94
|
- lib/siilar/struct.rb
|
94
95
|
- lib/siilar/struct/album.rb
|
95
96
|
- lib/siilar/struct/artist.rb
|
97
|
+
- lib/siilar/struct/tag.rb
|
98
|
+
- lib/siilar/struct/tag_collection.rb
|
96
99
|
- lib/siilar/struct/track.rb
|
97
100
|
- lib/siilar/version.rb
|
98
101
|
- siilar.gemspec
|