Class: HarvestToInfakt::Infakt::Invoice

Inherits:
Resource
  • Object
show all
Defined in:
lib/harvest_to_infakt/infakt/invoice.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#id, #initialize, #method_missing

Constructor Details

This class inherits a constructor from HarvestToInfakt::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HarvestToInfakt::Resource

Class Method Details

.basic_auth_optionsObject



7
8
9
# File 'lib/harvest_to_infakt/infakt/invoice.rb', line 7

def basic_auth_options
  { :username => HarvestToInfakt.configuration.infakt[:username], :password => HarvestToInfakt.configuration.infakt[:password] + HarvestToInfakt.configuration.infakt[:api_key]}
end

Instance Method Details

#saveObject



12
13
14
15
16
17
18
19
# File 'lib/harvest_to_infakt/infakt/invoice.rb', line 12

def save
  response = self.class.post('/api/invoices.xml', :basic_auth => self.class.basic_auth_options, :body => { :invoice => @data })
  if response.code == 200
    @data = response.parsed_response['zal_invoice']
  else
    raise HarvestToInfakt::Error.new('Save failed.')
  end
end