Class: UniqueResponse::Client
- Inherits:
-
Object
- Object
- UniqueResponse::Client
- Defined in:
- lib/unique_response_ruby/client.rb
Constant Summary collapse
- HTTP_HEADERS =
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'Accept-Charset' => 'utf-8', 'User-Agent' => 'unique_response_ruby' }
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#successful ⇒ Object
readonly
Returns the value of attribute successful.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #save_response(response) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 |
# File 'lib/unique_response_ruby/client.rb', line 16 def initialize @account_id = ENV['UNIQUE_RESPONSE_ACCOUNT_ID'] @auth_token = ENV['UNIQUE_RESPONSE_AUTH_TOKEN'] if @account_id.nil? || @auth_token.nil? raise ArgumentError, 'Account SID and auth token are required' end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/unique_response_ruby/client.rb', line 7 def data @data end |
#successful ⇒ Object (readonly)
Returns the value of attribute successful.
7 8 9 |
# File 'lib/unique_response_ruby/client.rb', line 7 def successful @successful end |
Instance Method Details
#save_response(response) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/unique_response_ruby/client.rb', line 24 def save_response(response) @uri = URI(ENV['UNIQUE_RESPONSE_ENDPOINT']) @http_request = Net::HTTP::Post.new @uri.path, HTTP_HEADERS @http_request.body = response.to_h.to_json perform_request end |