Skip to content

Instantly share code, notes, and snippets.

@rinaldifonseca
Created February 19, 2015 17:08
Show Gist options
  • Save rinaldifonseca/438933aeeb1d0ee2ced1 to your computer and use it in GitHub Desktop.
Save rinaldifonseca/438933aeeb1d0ee2ced1 to your computer and use it in GitHub Desktop.
adyen
# 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