Class: Fortnox::Invoice

Inherits:
API
  • Object
show all
Defined in:
lib/fortnox/invoice.rb

Class Method Summary collapse

Methods inherited from API

connection, establish_connection, query_parameters, query_parameters=, run

Class Method Details

.create(attributes = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/fortnox/invoice.rb', line 4

def create(attributes={})
  attributes = attributes.reject { |k,v| k == :id } if attributes[:id]

  response = run :post, :set_invoice, with_root(attributes)
  if response['result']
    return response['result']['id'].to_i
  else
    raise Error, response.body
  end
end

.destroy(id) ⇒ Object



20
21
22
23
# File 'lib/fortnox/invoice.rb', line 20

def destroy(id)
  response = run :post, :set_invoice_cancel, { :query => { :id => id } }
  response['result'] ? response['result'].to_i : false
end

.payedObject



30
31
32
33
# File 'lib/fortnox/invoice.rb', line 30

def payed
  response = run :get, :get_invoices, { :query => { :filter => "finalpayed" } }
  response['invoices']['invoice']
end

.show(id) ⇒ Object



25
26
27
28
# File 'lib/fortnox/invoice.rb', line 25

def show(id)
  response = run :get, :get_invoice, { :query => { :id => id } }
  response['invoice'] ? response['invoice'] : false
end

.update(attributes = {}) ⇒ Object



15
16
17
18
# File 'lib/fortnox/invoice.rb', line 15

def update(attributes={})
  response = run :post, :set_invoice, with_root(attributes)
  response['result'] ? response['result']['id'].to_i : false
end