Class: Octobat::Invoice

Inherits:
APIResource show all
Extended by:
APIOperations::List
Includes:
APIOperations::Create, APIOperations::Update
Defined in:
lib/octobat/invoice.rb

Instance Attribute Summary

Attributes inherited from OctobatObject

#api_key, #parent_obj

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::List

list, set_parent_resource

Methods included from APIOperations::Update

#save, #serialize_metadata, #serialize_params

Methods included from APIOperations::Create

included

Methods inherited from APIResource

class_name, #refresh, retrieve, url, #url

Methods inherited from OctobatObject

#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Octobat::OctobatObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Octobat::OctobatObject

Class Method Details

.csv_export(params = {}, opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/octobat/invoice.rb', line 19

def self.csv_export(params = {}, opts={})
  api_key, headers = Util.parse_opts(opts)
  api_key ||= @api_key
  opts[:api_key] = api_key

  instance = self.new(nil, opts)

  response, api_key = Octobat.request(:post, url + '/csv_export', api_key, params, opts)
  return true
end

.pdf_export(params = {}, opts = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/octobat/invoice.rb', line 8

def self.pdf_export(params = {}, opts={})
  api_key, headers = Util.parse_opts(opts)
  api_key ||= @api_key
  opts[:api_key] = api_key

  instance = self.new(nil, opts)

  response, api_key = Octobat.request(:post, url + '/pdf_export', api_key, params, opts)
  return true
end

Instance Method Details

#cancel(params = {}, opts = {}) ⇒ Object



52
53
54
55
# File 'lib/octobat/invoice.rb', line 52

def cancel(params = {}, opts = {})
  response, api_key = Octobat.request(:patch, cancel_url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#cancel_and_replace(params = {}, opts = {}) ⇒ Object



57
58
59
60
# File 'lib/octobat/invoice.rb', line 57

def cancel_and_replace(params = {}, opts = {})
  response, api_key = Octobat.request(:patch, cancel_and_replace_url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#confirm(params = {}, opts = {}) ⇒ Object



36
37
38
39
# File 'lib/octobat/invoice.rb', line 36

def confirm(params = {}, opts = {})
  response, api_key = Octobat.request(:patch, confirm_url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#delete(params = {}, opts = {}) ⇒ Object



62
63
64
65
# File 'lib/octobat/invoice.rb', line 62

def delete(params = {}, opts = {})
  response, api_key = Octobat.request(:delete, url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#items(params = {}, opts = {}) ⇒ Object



67
68
69
# File 'lib/octobat/invoice.rb', line 67

def items(params = {}, opts = {})
  Item.list(params.merge({ :invoice => id }), {api_key: @api_key}.merge(opts))
end

#mark_uncollectible(params = {}, opts = {}) ⇒ Object



46
47
48
49
# File 'lib/octobat/invoice.rb', line 46

def mark_uncollectible(params = {}, opts = {})
  response, api_key = Octobat.request(:patch, mark_uncollectible_url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#send_by_email(params = {}, opts = {}) ⇒ Object



31
32
33
34
# File 'lib/octobat/invoice.rb', line 31

def send_by_email(params = {}, opts = {})
  response, api_key = Octobat.request(:post, send_url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#set_payment_terms(params = {}, opts = {}) ⇒ Object



41
42
43
44
# File 'lib/octobat/invoice.rb', line 41

def set_payment_terms(params = {}, opts = {})
  response, api_key = Octobat.request(:patch, set_payment_terms_url, @api_key, params, opts)
  refresh_from(response, api_key)
end

#transactions(params = {}, opts = {}) ⇒ Object



71
72
73
# File 'lib/octobat/invoice.rb', line 71

def transactions(params = {}, opts = {})
  Transaction.list(params.merge(invoice: id), {api_key: @api_key}.merge(opts))
end