class EzpayInvoice::Response
Attributes
body[R]
message[R]
result[R]
status[R]
Public Class Methods
new(rest_response)
click to toggle source
# File lib/ezpay-invoice/response.rb, line 9 def initialize(rest_response) response_hash = JSON.parse(rest_response.body) raise EzpayResponseError.new( response_hash['Message'], response_hash['Status'] ) if response_hash['Status'] != 'SUCCESS' @body = response_hash @status = response_hash['Status'] @message = response_hash['Message'] @result = transform_keys(JSON.parse(response_hash['Result'])) parse_item_detail end
Private Instance Methods
parse_item_detail()
click to toggle source
# File lib/ezpay-invoice/response.rb, line 24 def parse_item_detail if @result.has_key?('item_detail') item_detail = JSON.parse(@result['item_detail']).map { |item| transform_keys(item) } @result['item_detail'] = item_detail end end
transform_keys(hash)
click to toggle source
# File lib/ezpay-invoice/response.rb, line 31 def transform_keys(hash) hash.deep_transform_keys do |k| k.to_s.underscore end end