I want to be able to parse through the API response in a loop.
I have this in a controller method:
@payout_batch= PayPal::SDK::REST::Payout.get('xxxxxxx')
logger.info "Got Payout Batch Status[#{@payout_batch.batch_header.payout_batch_id}]"
rescue ResourceNotFound => err
logger.error "Payout Batch not Found"
end
I can show results like this:
<%= @payout_batch.batch_header.amount.value %>
But I want to be able to loop through everything in an .each loop, if posible.. I have tried a few ways but nothing seems to be working:
<% @payout_batch.batch_header.each do |x| %>
<%= (x["amount"]) %>
<% end %>
And many more ways similar to this. Tried defining the response with:
json = JSON.parse(@payout_batch)
and looping with json but that wouldn't seem to work either eithe.
Question: How can I result the response in the views with a loop?