Skip to content

Instantly share code, notes, and snippets.

@zaneclaes
Created February 20, 2014 01:41
Show Gist options
  • Save zaneclaes/9105447 to your computer and use it in GitHub Desktop.
Save zaneclaes/9105447 to your computer and use it in GitHub Desktop.
module Api
module V2
class TripInvoicesPresenter < BasePresenter
def initialize(trip_invoice, current_user)
@trip_invoice = trip_invoice
@current_user = current_user
end
def to_json_default
invoice_items = @trip_invoice.trip_invoice.trip_invoice_items.map do |item|
item.trip_product = TripProduct.find_by_id(item.trip_product_id)
item
end
binding_.pry
json = {
:id => @trip_invoice.trip_invoice.id,
:open => @trip_invoice.trip_invoice.open?,
:parent_type => @trip_invoice.trip_invoice.parent_type,
:parent_id => @trip_invoice.trip_invoice.parent_id,
:payment_instrument_id => @trip_invoice.trip_invoice.payment_instrument_id,
:created_at => @trip_invoice.trip_invoice.created_at,
:updated_at => @trip_invoice.trip_invoice.updated_at,
:consumer_currency => @trip_invoice.trip_invoice.consumer_currency,
:consumer_balance_native => @trip_invoice.trip_invoice.consumer_balance_native,
:consumer_balance_usd => @trip_invoice.trip_invoice.consumer_balance_usd,
:consumer_total_native => @trip_invoice.trip_invoice.consumer_total_native,
:consumer => @trip_invoice.trip_invoice.consumer,
:providers => @trip_invoice.trip_invoice.providers,
:trip_invoice_items => invoice_items,
}
json
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment