Class: Promoter::Request

Inherits:
Object
  • Object
show all
Extended by:
Errors
Includes:
HTTParty
Defined in:
lib/promoter/request.rb

Class Method Summary collapse

Methods included from Errors

check_for_error

Class Method Details

.delete(url) ⇒ Object



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

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

.get(url) ⇒ Object



16
17
18
19
# File 'lib/promoter/request.rb', line 16

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

.post(url, params) ⇒ Object



27
28
29
30
31
# File 'lib/promoter/request.rb', line 27

def self.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

.put(url, params) ⇒ Object



21
22
23
24
25
# File 'lib/promoter/request.rb', line 21

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