Created
February 19, 2015 17:08
-
-
Save rinaldifonseca/438933aeeb1d0ee2ced1 to your computer and use it in GitHub Desktop.
adyen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ListRecurringDetailsResponse#details | |
def details | |
mapped_attributes = { | |
:recurring_detail_reference => "recurringDetailReference", | |
:creation_date => "creationDate", | |
:variant => "variant", | |
:card_holder_name => "card.holderName", | |
:card_expiry_month => "card.expiryMonth", | |
:card_expiry_year => "card.expiryYear", | |
:card_number => "card.number" | |
} | |
map_response_list("recurringDetailsResult.details", mapped_attributes) | |
end | |
# Adyen::REST::Response#map_response_list | |
protected | |
def map_response_list(response_prefix, mapped_attributes) | |
list = [] | |
index = 0 | |
loop do | |
response = {} | |
mapped_attributes.each do |key, value| | |
new_value = attributes["#{response_prefix}.#{index.to_s}.#{value}"] | |
response[key] = new_value unless new_value.empty? | |
end | |
index += 1 | |
break unless response.any? | |
list << response | |
end | |
list | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment