Class: Files::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/invoice.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ Invoice

Returns a new instance of Invoice.



7
8
9
10
# File 'lib/files.com/models/invoice.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/invoice.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/invoice.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



94
95
96
# File 'lib/files.com/models/invoice.rb', line 94

def self.all(params = {}, options = {})
  list(params, options)
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - Invoice ID.


100
101
102
103
104
105
106
107
108
# File 'lib/files.com/models/invoice.rb', line 100

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/invoices/#{params[:id]}", :get, params, options)
  AccountLineItem.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



110
111
112
# File 'lib/files.com/models/invoice.rb', line 110

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via the X-Files-Cursor-Next header.
per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).


85
86
87
88
89
90
91
92
# File 'lib/files.com/models/invoice.rb', line 85

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)

  List.new(AccountLineItem, params) do
    Api.send_request("/invoices", :get, params, options)
  end
end

Instance Method Details

#amountObject

double - Line item amount



18
19
20
# File 'lib/files.com/models/invoice.rb', line 18

def amount
  @attributes[:amount]
end

#balanceObject

double - Line item balance



23
24
25
# File 'lib/files.com/models/invoice.rb', line 23

def balance
  @attributes[:balance]
end

#created_atObject

date-time - Line item created at



28
29
30
# File 'lib/files.com/models/invoice.rb', line 28

def created_at
  @attributes[:created_at]
end

#currencyObject

string - Line item currency



33
34
35
# File 'lib/files.com/models/invoice.rb', line 33

def currency
  @attributes[:currency]
end

#download_uriObject

string - Line item download uri



38
39
40
# File 'lib/files.com/models/invoice.rb', line 38

def download_uri
  @attributes[:download_uri]
end

#idObject

int64 - Line item Id



13
14
15
# File 'lib/files.com/models/invoice.rb', line 13

def id
  @attributes[:id]
end

#invoice_line_itemsObject

array - Associated invoice line items



43
44
45
# File 'lib/files.com/models/invoice.rb', line 43

def invoice_line_items
  @attributes[:invoice_line_items]
end

#methodObject

string - Line item payment method



48
49
50
# File 'lib/files.com/models/invoice.rb', line 48

def method
  @attributes[:method]
end

#payment_line_itemsObject

array - Associated payment line items



53
54
55
# File 'lib/files.com/models/invoice.rb', line 53

def payment_line_items
  @attributes[:payment_line_items]
end

#payment_reversed_atObject

date-time - Date/time payment was reversed if applicable



58
59
60
# File 'lib/files.com/models/invoice.rb', line 58

def payment_reversed_at
  @attributes[:payment_reversed_at]
end

#payment_typeObject

string - Type of payment if applicable



63
64
65
# File 'lib/files.com/models/invoice.rb', line 63

def payment_type
  @attributes[:payment_type]
end

#site_nameObject

string - Site name this line item is for



68
69
70
# File 'lib/files.com/models/invoice.rb', line 68

def site_name
  @attributes[:site_name]
end

#typeObject

string - Type of line item, either payment or invoice



73
74
75
# File 'lib/files.com/models/invoice.rb', line 73

def type
  @attributes[:type]
end

#updated_atObject

date-time - Line item updated at



78
79
80
# File 'lib/files.com/models/invoice.rb', line 78

def updated_at
  @attributes[:updated_at]
end