Sha256: 35442492f4f91d7b904ffbd93d8a2547bd9e8b067849fecd9aa387c0fcfc911d

Contents?: true

Size: 815 Bytes

Versions: 5

Compression:

Stored size: 815 Bytes

Contents

module Mousetrap
  class Invoice < Resource
    attr_accessor \
      :id,
      :number,
      :billing_date,
      :created_at

    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
      }
    end

    def self.attributes_from_api(attributes)
      {
        :id           => attributes['id'],
        :number       => attributes['number'],
        :billing_date => attributes['billingDatetime'],
        :created_at   => attributes['createdDatetime']
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
sproutbox-mousetrap-0.6.4 lib/mousetrap/invoice.rb
cameroncox-mousetrap-0.6.2 lib/mousetrap/invoice.rb
cameroncox-mousetrap-0.6.1 lib/mousetrap/invoice.rb
ryanwood-mousetrap-0.5.7 lib/mousetrap/invoice.rb
ryanwood-mousetrap-0.5.6 lib/mousetrap/invoice.rb