Sha256: f5ea56e93425fabf55d459f84c76da76f9235a63031099b2bc024b0a55a45f68

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 KB

Contents

module Paid
  class Invoice < APIResource
    attr_reader :id
    attr_reader :object
    attr_accessor :summary
    attr_accessor :chase_schedule
    attr_accessor :next_chase_on
    attr_accessor :customer
    attr_accessor :issued_at
    attr_accessor :terms
    attr_accessor :url

    def self.all(params={}, headers={})
      method = APIMethod.new(:get, "/invoices", params, headers, self)
      APIList.new(self, method.execute, method)
    end

    def self.retrieve(id, params={}, headers={})
      params = ParamsBuilder.merge(params, {
        :id => id
      })
      method = APIMethod.new(:get, "/invoices/:id", params, headers, self)
      self.new(method.execute, method)
    end

    def self.create(params={}, headers={})
      method = APIMethod.new(:post, "/invoices", params, headers, self)
      self.new(method.execute, method)
    end

    def refresh(params={}, headers={})
      method = APIMethod.new(:get, "/invoices/:id", params, headers, self)
      self.refresh_from(method.execute, method)
    end

    def issue(params={}, headers={})
      method = APIMethod.new(:post, "/invoices/:id/issue", params, headers, self)
      self.refresh_from(method.execute, method)
    end

    def mark_as_paid(params={}, headers={})
      method = APIMethod.new(:post, "/invoices/:id/mark_as_paid", params, headers, self)
      self.refresh_from(method.execute, method)
    end

    def void(params={}, headers={})
      method = APIMethod.new(:post, "/invoices/:id/void", params, headers, self)
      self.refresh_from(method.execute, method)
    end


    APIResource.register_api_subclass(self, "invoice")
    @api_attributes = {
      :id => { :readonly => true },
      :object => { :readonly => true },
      :summary => nil,
      :chase_schedule => nil,
      :next_chase_on => nil,
      :customer => nil,
      :issued_at => nil,
      :terms => nil,
      :url => nil
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paid-1.0.7 lib/paid/invoice.rb
paid-1.0.6 lib/paid/invoice.rb
paid-1.0.5 lib/paid/invoice.rb
paid-1.0.3 lib/paid/invoice.rb