Class: Outreach::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Errors
Defined in:
lib/outreach/request.rb

Instance Method Summary collapse

Methods included from Errors

#check_for_error

Constructor Details

#initialize(access_token = nil) ⇒ Request

Returns a new instance of Request.



11
12
13
# File 'lib/outreach/request.rb', line 11

def initialize(access_token=nil)
  @access_token = access_token
end

Instance Method Details

#delete(url) ⇒ Object



26
27
28
29
# File 'lib/outreach/request.rb', line 26

def delete(url)
  response = HTTParty.delete(url, headers: auth_header)
  parse_response(response)
end

#get(url, query = {}) ⇒ Object



15
16
17
18
# File 'lib/outreach/request.rb', line 15

def get(url, query={})
  response = HTTParty.get(url, query: query, headers: auth_header)
  parse_response(response)
end

#post(url, params) ⇒ Object



20
21
22
23
24
# File 'lib/outreach/request.rb', line 20

def post(url, params)
  response_format = params.delete(:response_format) || :json
  response = HTTParty.post(url, body: params.to_json, headers: auth_header)
  parse_response(response, response_format)
end