Module: Contactology::API

Included in:
Campaign, Contact, List, TransactionalMessage
Defined in:
lib/contactology/api.rb

Instance Method Summary collapse

Instance Method Details

#query(method, attributes = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/contactology/api.rb', line 7

def query(method, attributes = {})
  configuration = extract_configuration!(attributes)
  handlers = extract_handlers!(attributes)
  remove_empty_values!(attributes)

  response = HTTParty.get(configuration.endpoint, {
    :query => {:key => configuration.key, :method => method}.merge(attributes),
    :headers => request_headers,
    :parser => request_parser
  })

  handle_query_response(response, handlers)
rescue Timeout::Error
  call_response_handler(handlers[:on_timeout], nil)
end

#request_headersObject



23
24
25
# File 'lib/contactology/api.rb', line 23

def request_headers
    { 'Accept' => 'application/json', 'User-Agent' => user_agent_string }
end