Class: Redex::Response::BaseResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/redex/response/base_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ BaseResponse

Returns a new instance of BaseResponse.



6
7
8
# File 'lib/redex/response/base_response.rb', line 6

def initialize(raw_response)
	@raw = clear(raw_response)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/redex/response/base_response.rb', line 4

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/redex/response/base_response.rb', line 4

def message
  @message
end

#rawObject (readonly)

Returns the value of attribute raw.



4
5
6
# File 'lib/redex/response/base_response.rb', line 4

def raw
  @raw
end

#sequential_idObject (readonly)

Returns the value of attribute sequential_id.



4
5
6
# File 'lib/redex/response/base_response.rb', line 4

def sequential_id
  @sequential_id
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



4
5
6
# File 'lib/redex/response/base_response.rb', line 4

def transaction_id
  @transaction_id
end

Instance Method Details

#clear(httpi_result) ⇒ Object



10
11
12
13
14
# File 'lib/redex/response/base_response.rb', line 10

def clear(httpi_result)
	httpi_result = Hash[httpi_result.map { |k, v| [k.to_sym, v] }]
	httpi_result.select! {|k,v| v != [{"i:nil"=>"true"}]}
	httpi_result.each { |k, v| httpi_result[k] = v.first }
end

#datetime_sanitize(raw_date, raw_time) ⇒ Object



32
33
34
35
36
# File 'lib/redex/response/base_response.rb', line 32

def datetime_sanitize(raw_date, raw_time)
	if raw_date && raw_time
		DateTime.strptime(raw_date + raw_time + '-03:00', '%Y%m%d%H:%M:%S%z')
	end
end