Class: TdTip::Models::Response

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, HTTParty
Defined in:
lib/td_tip/models/response.rb

Overview

Response - performs request and handle response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ Response

Returns a new instance of Response.



20
21
22
# File 'lib/td_tip/models/response.rb', line 20

def initialize(parameters)
  @parameters = parameters
end

Instance Attribute Details

#amount_with_tipObject (readonly)

Returns the value of attribute amount_with_tip.



13
14
15
# File 'lib/td_tip/models/response.rb', line 13

def amount_with_tip
  @amount_with_tip
end

#currencyObject (readonly)

Returns the value of attribute currency.



13
14
15
# File 'lib/td_tip/models/response.rb', line 13

def currency
  @currency
end

#errorObject (readonly)

Returns the value of attribute error.



13
14
15
# File 'lib/td_tip/models/response.rb', line 13

def error
  @error
end

#parametersObject

Returns the value of attribute parameters.



12
13
14
# File 'lib/td_tip/models/response.rb', line 12

def parameters
  @parameters
end

#tipObject (readonly)

Returns the value of attribute tip.



13
14
15
# File 'lib/td_tip/models/response.rb', line 13

def tip
  @tip
end

Instance Method Details

#getObject

Performs request and handle response



25
26
27
28
29
30
31
32
# File 'lib/td_tip/models/response.rb', line 25

def get
  result = parse_and_symbolize_json
  @amount_with_tip = result[:amount_with_tip]
  @tip = result[:tip]
  @error = result[:error]
  @currency = parameters.currency
  self
end