Module: Bitbuckit::Connection
Instance Method Summary
collapse
#application_authentication
Instance Method Details
#agent ⇒ Object
37
38
39
40
41
42
|
# File 'lib/bitbuckit/connection.rb', line 37
def agent
@agent ||= Sawyer::Agent.new(endpoint) do |http|
http.[:content_type] = "application/json"
http.params = http.params.merge application_authentication
end
end
|
#get(url, options = {}) ⇒ Object
8
9
10
|
# File 'lib/bitbuckit/connection.rb', line 8
def get(url, options = {})
request(:get, url, options)
end
|
#last_response ⇒ Object
48
49
50
|
# File 'lib/bitbuckit/connection.rb', line 48
def last_response
@last_response if defined? @last_response
end
|
#paginate(url, options = {}, &block) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/bitbuckit/connection.rb', line 20
def paginate(url, options = {}, &block)
data = request(:get, url, options.dup)
if options[:auto_paginate]
while @last_response.data.next
request(:get, @last_response.data.next, options.dup)
if block_given?
yield(data.values, @last_response.data.values)
else
data.values.concat(@last_response.data.values)
end
end
end
data.values
end
|
#post(url, options = {}) ⇒ Object
12
13
14
|
# File 'lib/bitbuckit/connection.rb', line 12
def post(url, options = {})
request :post, url, options
end
|
#put(url, options = {}) ⇒ Object
16
17
18
|
# File 'lib/bitbuckit/connection.rb', line 16
def put(url, options = {})
request :put, url, options
end
|
#root ⇒ Object
44
45
46
|
# File 'lib/bitbuckit/connection.rb', line 44
def root
get "/"
end
|