Module: Graham::API::Connection

Included in:
Graham::API
Defined in:
lib/graham/api/connection.rb

Instance Method Summary collapse

Instance Method Details

#delete(url, option = nil) {|res, body| ... } ⇒ Object

Yields:

  • (res, body)


22
23
24
25
26
27
28
# File 'lib/graham/api/connection.rb', line 22

def delete(url, option = nil)
  options                = prepareOption(option)
  res                    = config.conn.delete(url, options)
  body                   = JSON.parse res.body
  yield(res, body) if block_given?
  res
end

#get(url, option = nil) {|res, body| ... } ⇒ Object

Yields:

  • (res, body)


14
15
16
17
18
19
20
# File 'lib/graham/api/connection.rb', line 14

def get(url, option = nil)
  options                = prepareOption(option)
  res                    = config.conn.get(url, options)
  body                   = JSON.parse res.body
  yield(res, body) if block_given?
  res
end

#post(url, option = nil) {|res, body| ... } ⇒ Object

Yields:

  • (res, body)


6
7
8
9
10
11
12
# File 'lib/graham/api/connection.rb', line 6

def post(url, option = nil)
  options                = prepareOption(option)
  res                    = config.conn.post(url, options)
  body                   = JSON.parse res.body
  yield(res, body) if block_given?
  res
end