Class: Harvest::API::Invoices

Inherits:
Base
  • Object
show all
Includes:
Behavior::Crud
Defined in:
lib/harvest/api/invoices.rb

Instance Attribute Summary

Attributes inherited from Base

#credentials

Instance Method Summary (collapse)

Methods included from Behavior::Crud

#create, #delete, #find, #update

Methods inherited from Base

api_model, #initialize

Constructor Details

This class inherits a constructor from Harvest::API::Base

Instance Method Details

- (Array<Harvest::Invoice>) all - (Array<Harvest::Invoice>) all(options)

Retrieves invoices

Available options

  • :status - invoices by status

  • :page

  • :updated_since

  • :timeframe (must be a nested hash with :to and :from)

Overloads:

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/harvest/api/invoices.rb', line 20

def all(options = {})
  query = {}
  query[:status]        = options[:status]        if options[:status]
  query[:page]          = options[:page]          if options[:page]
  query[:updated_since] = options[:updated_since] if options[:updated_since]
  if options[:timeframe]
    query[:from] = options[:timeframe][:from]
    query[:to]   = options[:timeframe][:to]
  end

  response = request(:get, credentials, "/invoices", :query => query)
  api_model.parse(response.parsed_response)
end