Class: Trello::Client
Constant Summary
Authorization::AuthPolicy
Class Method Summary
collapse
Class Method Details
.delete(path) ⇒ Object
24
25
26
27
|
# File 'lib/trello/client.rb', line 24
def delete(path)
uri = Addressable::URI.parse("https://api.trello.com/#{API_VERSION}#{path}")
invoke_verb(:delete, uri)
end
|
.get(path, params = {}) ⇒ Object
8
9
10
11
12
|
# File 'lib/trello/client.rb', line 8
def get(path, params = {})
uri = Addressable::URI.parse("https://api.trello.com/#{API_VERSION}#{path}")
uri.query_values = params unless params.empty?
invoke_verb(:get, uri)
end
|
.invoke_verb(name, uri, body = nil) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/trello/client.rb', line 29
def invoke_verb(name, uri, body = nil)
request = Request.new name, uri, {}, body
response = TInternet.execute AuthPolicy.authorize(request)
return '' unless response
if response.code.to_i == 401 && response.body =~ /expired token/
Trello.logger.error("[401 #{name.to_s.upcase} #{uri}]: Your access token has expired.")
raise InvalidAccessToken, response.body
end
unless [200, 201].include? response.code
Trello.logger.error("[#{response.code} #{name.to_s.upcase} #{uri}]: #{response.body}")
raise Error, response.body
end
response.body
end
|
.post(path, body = {}) ⇒ Object
14
15
16
17
|
# File 'lib/trello/client.rb', line 14
def post(path, body = {})
uri = Addressable::URI.parse("https://api.trello.com/#{API_VERSION}#{path}")
invoke_verb(:post, uri, body)
end
|
.put(path, body = {}) ⇒ Object
19
20
21
22
|
# File 'lib/trello/client.rb', line 19
def put(path, body = {})
uri = Addressable::URI.parse("https://api.trello.com/#{API_VERSION}#{path}")
invoke_verb(:put, uri, body)
end
|