Sha256: 49618dfd0332ef96536b9234d10d14edd6643d73886561a9707dded76fd1eb22
Contents?: true
Size: 976 Bytes
Versions: 1
Compression:
Stored size: 976 Bytes
Contents
module Mousetrap class Invoice < Resource attr_accessor \ :id, :number, :billing_date, :created_at, :amount def initialize(hash = {}) super(self.class.attributes_from_api(hash)) end protected def self.plural_resource_name 'invoices' end def self.singular_resource_name 'invoice' end def attributes { :id => id, :number => number, :billing_date => billing_date, :created_at => created_at, :amount => amount } end def self.attributes_from_api(attributes) { :id => attributes['id'], :number => attributes['number'], :billing_date => attributes['billingDatetime'], :created_at => attributes['createdDatetime'], :amount => attributes['charges']['charge'].inject(0.0) {|sum, c| sum.to_f + c['eachAmount'].to_f} } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
madebyrocket-mousetrap-0.5.3.7 | lib/mousetrap/invoice.rb |