Class: GetResponseApi::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/get_response_api/connection.rb

Constant Summary collapse

API_ENDPOINT =
'https://api.getresponse.com/v3'
TIMEOUT =
7

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Connection

Returns a new instance of Connection.



8
9
10
# File 'lib/get_response_api/connection.rb', line 8

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#get(path, body: {}, headers: {}) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/get_response_api/connection.rb', line 22

def get(path, body: {}, headers: {})
  headers.merge!(auth)
  HTTParty.get(
    "#{API_ENDPOINT}#{path}",
    body: body.to_json,
    headers: headers,
    timeout: TIMEOUT
  )
end

#post(path, body: {}, headers: {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/get_response_api/connection.rb', line 12

def post(path, body: {}, headers: {})
  headers.merge!(auth)
  HTTParty.post(
    "#{API_ENDPOINT}#{path}",
    body: body.to_json,
    headers: headers,
    timeout: TIMEOUT
  )
end