Module: Billomat

Defined in:
lib/billomat-rb.rb

Overview

A neat ruby library for interacting with the RESTfull API of billomat

Defined Under Namespace

Modules: ResourceWithoutId, ResourceWithoutWriteAccess Classes: Article, Base, Client, Confirmation, Invoice, MethodNotAvailable, Myself, Offer, ReadOnlySingletonBase, Reminder, Role, Settings, SingletonBase, Template, Unit, Users

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.accountObject

Returns the value of attribute account.



12
13
14
# File 'lib/billomat-rb.rb', line 12

def 
  @account
end

.api_pathObject

Returns the value of attribute api_path.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def api_path
  @api_path
end

.domain_formatObject

Returns the value of attribute domain_format.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def domain_format
  @domain_format
end

.emailObject

Returns the value of attribute email.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def email
  @email
end

.host_formatObject

Returns the value of attribute host_format.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def host_format
  @host_format
end

.keyObject

Returns the value of attribute key.



12
13
14
# File 'lib/billomat-rb.rb', line 12

def key
  @key
end

.passwordObject

Returns the value of attribute password.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def password
  @password
end

.portObject

Returns the value of attribute port.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def port
  @port
end

.protocolObject

Returns the value of attribute protocol.



11
12
13
# File 'lib/billomat-rb.rb', line 11

def protocol
  @protocol
end

Class Method Details

.authenticate(email, password) ⇒ Object

Sets up basic authentication credentials for all resources. Removes all earlier authentication info



24
25
26
27
28
29
30
31
32
33
# File 'lib/billomat-rb.rb', line 24

def authenticate (email,password)
  resources.each do |klass|
    klass.email = email
    klass.password = password
    klass.headers.delete 'X-BillomatApiKey'
  end
  @email = email
  @password = password
  @key = nil
end

.resourcesObject



66
67
68
# File 'lib/billomat-rb.rb', line 66

def resources
  @resources ||= []
end

.validateObject

Validates connection returns true when valid false when not



49
50
51
# File 'lib/billomat-rb.rb', line 49

def validate
  validate! rescue false
end

.validate!Object

Same as validate but raises http-error when connection is invalid



55
56
57
58
59
60
61
62
63
64
# File 'lib/billomat-rb.rb', line 55

def validate!
  if Billomat..nil?
    raise 'No Account set, use Billomat.account='
  end
  if !Billomat.key.nil? || ( !Billomat.email.nil? && !Billomat.password.nil? )
    !!Billomat::Myself.find
  else
    raise 'No authentication info set, set either Billomat.key XOR use Billomat.authenticate(email, password)'
  end
end