Class: Outreach::Request
- Inherits:
-
Object
- Object
- Outreach::Request
- Includes:
- HTTParty, Errors
- Defined in:
- lib/outreach/request.rb
Instance Method Summary collapse
- #delete(url) ⇒ Object
- #get(url, query = {}) ⇒ Object
-
#initialize(access_token = nil) ⇒ Request
constructor
A new instance of Request.
- #patch(url, params) ⇒ Object
- #post(url, params) ⇒ Object
Methods included from Errors
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
44 45 46 47 48 49 50 51 |
# File 'lib/outreach/request.rb', line 44 def delete(url) attrs = { headers: auth_header } attrs[:debug_output] = $stdout if Outreach.debug response = HTTParty.delete(url, attrs) parse_response(response) end |
#get(url, query = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/outreach/request.rb', line 15 def get(url, query={}) attrs = { query: query, headers: auth_header } attrs[:debug_output] = $stdout if Outreach.debug response = HTTParty.get(url, attrs) parse_response(response) end |
#patch(url, params) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/outreach/request.rb', line 34 def patch(url, params) response_format = params.delete(:response_format) || :json attrs = { body: params.to_json, headers: auth_header } attrs[:debug_output] = $stdout if Outreach.debug response = HTTParty.patch(url, attrs) parse_response(response, response_format) end |
#post(url, params) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/outreach/request.rb', line 24 def post(url, params) response_format = params.delete(:response_format) || :json attrs = { body: params.to_json, headers: auth_header } attrs[:debug_output] = $stdout if Outreach.debug response = HTTParty.post(url, attrs) parse_response(response, response_format) end |