Class: AppleMusic::Client
- Inherits:
-
Object
- Object
- AppleMusic::Client
show all
- Defined in:
- lib/client.rb
Instance Method Summary
collapse
Constructor Details
#initialize(token) ⇒ Client
31
32
33
|
# File 'lib/client.rb', line 31
def initialize(token)
@token = token
end
|
Instance Method Details
#get(resource) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/client.rb', line 35
def get(resource)
response = HTTParty.get(
"https://api.music.apple.com#{resource}",
{headers: })
if response.code == 200
JSON.parse(response.body)
else
puts "NON 200 CODE for resource #{resource}"
puts response
end
end
|
55
56
57
58
59
|
# File 'lib/client.rb', line 55
def
{
'Authorization': "Bearer #{@token}"
}
end
|
#post(resource) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/client.rb', line 48
def post(resource)
HTTParty.post(
"https://api.music.apple.com#{resource}",
{headers: }
)
end
|