playlyfe 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/playlyfe.rb +32 -43
- metadata +2 -2
data/lib/playlyfe.rb
CHANGED
@@ -63,26 +63,32 @@ class Playlyfe
|
|
63
63
|
def get_access_token
|
64
64
|
begin
|
65
65
|
if @type == 'client'
|
66
|
-
access_token = RestClient.post
|
67
|
-
{
|
66
|
+
access_token = RestClient::Request.execute(:method => :post, :url => 'https://playlyfe.com/auth/token',
|
67
|
+
:payload => {
|
68
68
|
:client_id => @id,
|
69
69
|
:client_secret => @secret,
|
70
70
|
:grant_type => 'client_credentials'
|
71
71
|
}.to_json,
|
72
|
-
:
|
73
|
-
|
72
|
+
:headers => {
|
73
|
+
:content_type => :json,
|
74
|
+
:accepts => :json
|
75
|
+
},
|
76
|
+
:ssl_version => 'SSLv23'
|
74
77
|
)
|
75
78
|
else
|
76
|
-
access_token = RestClient.post
|
77
|
-
{
|
79
|
+
access_token = RestClient::Request.execute(:method => :post, :url => "https://playlyfe.com/auth/token",
|
80
|
+
:payload => {
|
78
81
|
:client_id => @id,
|
79
82
|
:client_secret => @secret,
|
80
83
|
:grant_type => 'authorization_code',
|
81
84
|
:code => @code,
|
82
85
|
:redirect_uri => @redirect_uri
|
83
86
|
}.to_json,
|
84
|
-
:
|
85
|
-
|
87
|
+
:headers => {
|
88
|
+
:content_type => :json,
|
89
|
+
:accepts => :json
|
90
|
+
},
|
91
|
+
:ssl_version => 'SSLv23'
|
86
92
|
)
|
87
93
|
end
|
88
94
|
access_token = JSON.parse(access_token)
|
@@ -111,39 +117,22 @@ class Playlyfe
|
|
111
117
|
access_token = @load.call
|
112
118
|
end
|
113
119
|
query[:access_token] = access_token['access_token']
|
120
|
+
query = hash_to_query(query)
|
114
121
|
end
|
115
122
|
|
116
123
|
def api(method, route, query = {}, body = {}, raw = false)
|
117
|
-
check_token(query)
|
124
|
+
query = check_token(query)
|
118
125
|
begin
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
)
|
130
|
-
when 'PUT'
|
131
|
-
res = RestClient.put("https://api.playlyfe.com/#{@version}#{route}?#{hash_to_query(query)}",
|
132
|
-
body.to_json,
|
133
|
-
:content_type => :json,
|
134
|
-
:accept => :json
|
135
|
-
)
|
136
|
-
when 'PATCH'
|
137
|
-
res = RestClient.patch("https://api.playlyfe.com/#{@version}#{route}?#{hash_to_query(query)}",
|
138
|
-
body.to_json,
|
139
|
-
:content_type => :json,
|
140
|
-
:accept => :json
|
141
|
-
)
|
142
|
-
when 'DELETE'
|
143
|
-
res = RestClient.delete("https://api.playlyfe.com/#{@version}#{route}",
|
144
|
-
{:params => query }
|
145
|
-
)
|
146
|
-
end
|
126
|
+
res = RestClient::Request.execute(
|
127
|
+
:method => method,
|
128
|
+
:url => "https://api.playlyfe.com/#{@version}#{route}?#{query}",
|
129
|
+
:headers => {
|
130
|
+
:content_type => :json,
|
131
|
+
:accepts => :json
|
132
|
+
},
|
133
|
+
:payload => body.to_json,
|
134
|
+
:ssl_version => 'SSLv23'
|
135
|
+
)
|
147
136
|
if raw == true
|
148
137
|
return res.body
|
149
138
|
else
|
@@ -159,27 +148,27 @@ class Playlyfe
|
|
159
148
|
end
|
160
149
|
|
161
150
|
def get(route, query = {})
|
162
|
-
api(
|
151
|
+
api(:get, route, query, {}, false)
|
163
152
|
end
|
164
153
|
|
165
154
|
def get_raw(route, query = {})
|
166
|
-
api(
|
155
|
+
api(:get, route, query, {}, true)
|
167
156
|
end
|
168
157
|
|
169
158
|
def post(route, query = {}, body = {})
|
170
|
-
api(
|
159
|
+
api(:post, route, query, body, false)
|
171
160
|
end
|
172
161
|
|
173
162
|
def put(route, query = {}, body = {})
|
174
|
-
api(
|
163
|
+
api(:put, route, query, body, false)
|
175
164
|
end
|
176
165
|
|
177
166
|
def patch(route, query = {}, body = {})
|
178
|
-
api(
|
167
|
+
api(:patch, route, query, body, false)
|
179
168
|
end
|
180
169
|
|
181
170
|
def delete(route, query = {})
|
182
|
-
api(
|
171
|
+
api(:delete, route, query, {}, false)
|
183
172
|
end
|
184
173
|
|
185
174
|
def hash_to_query(hash)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playlyfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest_client
|