Class: API::WhatCounts::Service

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/whatcounts/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_message_responseObject

Returns the value of attribute api_message_response.



11
12
13
# File 'lib/whatcounts/base.rb', line 11

def api_message_response
  @api_message_response
end

Instance Method Details

#send_one_off_message(message) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/whatcounts/base.rb', line 13

def send_one_off_message(message)
  message_request = API::WhatCounts::OneOffMessageRequest.new
  
  # assemble the data in a hash for the POST
  message_request.set_data(message)
  
  # make the call, parse the response
  response = API::WhatCounts::OneOffMessageResponse.new( ssl_post(message_request.url, message_request.data) )
  
  self.api_message_response = response
  
  return response
rescue Exception => err
  log_error(err, 'send_one_off_message()')
  
  # raise a generic error for the caller
  raise ServiceError
end