muzooka 1.0.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 +7 -0
- data/lib/muzooka.rb +50 -0
- metadata +43 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ec60ffaa645ebbe61ece7a4465dfdcbd02743281e4bd8ca0ffbbaed13fa321bb
|
|
4
|
+
data.tar.gz: aa03136f161289cd25b84d20b7c084d5b290130d7df423ae5359fd42bc192c38
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5d8ac7a75652b62279e24cb5a90c2a3de2cf8966b28b8e0f0d2f141cc7973da487c1023792fd527e836879ba4b8372ca8949f526f15f4a6589eefc836a681c38
|
|
7
|
+
data.tar.gz: df95fd8e24e149b7365f16ff7f39962691aad3824c2491b8bb742f9adb0b810b24bf85a99215a615a7a6f7c4b288000a3da2609cc05b0438153a85bf0eab7661
|
data/lib/muzooka.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'active_support'
|
|
4
|
+
|
|
5
|
+
class Muzooka
|
|
6
|
+
URL = 'https://devapi.muzooka.com/v2/artists'.freeze
|
|
7
|
+
BIO = 'bio'.freeze
|
|
8
|
+
IMAGE = 'image'.freeze
|
|
9
|
+
SOCIAL_LINKS = 'socialLinks'.freeze
|
|
10
|
+
DATA = 'data'.freeze
|
|
11
|
+
|
|
12
|
+
def initialize(muzooka_api_key:, artist_name:)
|
|
13
|
+
@artist_name = artist_name.strip
|
|
14
|
+
@muzooka_api_key = muzooka_api_key
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def bio
|
|
18
|
+
response_body&.fetch(BIO, nil)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def images
|
|
22
|
+
response_body&.fetch(IMAGE, nil)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def social_links
|
|
26
|
+
response_body&.fetch(SOCIAL_LINKS, nil)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
attr_reader :artist_name, :muzooka_api_key
|
|
32
|
+
|
|
33
|
+
def response
|
|
34
|
+
url = URI.parse(URL)
|
|
35
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
36
|
+
http.use_ssl = true
|
|
37
|
+
req = Net::HTTP::Get.new(url.request_uri + url_query)
|
|
38
|
+
req['X-api-key'] = muzooka_api_key
|
|
39
|
+
@response ||= http.request(req)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def url_query
|
|
43
|
+
@url_query ||= "?name=#{artist_name.gsub(/\s/,'+')}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def response_body
|
|
47
|
+
raise("Invalid response: #{response.to_s}") unless response.is_a?(Net::HTTPSuccess)
|
|
48
|
+
@response_body ||= ActiveSupport::JSON.decode(response.body).fetch(DATA, nil)&.first
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: muzooka
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ivan Blazevic
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A ruby interface for Muzooka web services version 1.0
|
|
14
|
+
email: blaz1988@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/muzooka.rb
|
|
20
|
+
homepage: https://rubygems.org/gems/ruby-muzooka
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubygems_version: 3.0.3
|
|
40
|
+
signing_key:
|
|
41
|
+
specification_version: 4
|
|
42
|
+
summary: Muzooka API
|
|
43
|
+
test_files: []
|