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
-
.account ⇒ Object
Returns the value of attribute account.
-
.api_path ⇒ Object
Returns the value of attribute api_path.
-
.domain_format ⇒ Object
Returns the value of attribute domain_format.
-
.email ⇒ Object
Returns the value of attribute email.
-
.host_format ⇒ Object
Returns the value of attribute host_format.
-
.key ⇒ Object
Returns the value of attribute key.
-
.password ⇒ Object
Returns the value of attribute password.
-
.port ⇒ Object
Returns the value of attribute port.
-
.protocol ⇒ Object
Returns the value of attribute protocol.
Class Method Summary collapse
-
.authenticate(email, password) ⇒ Object
Sets up basic authentication credentials for all resources.
- .resources ⇒ Object
-
.validate ⇒ Object
Validates connection returns true when valid false when not.
-
.validate! ⇒ Object
Same as validate but raises http-error when connection is invalid.
Class Attribute Details
.account ⇒ Object
Returns the value of attribute account.
12 13 14 |
# File 'lib/billomat-rb.rb', line 12 def account @account end |
.api_path ⇒ Object
Returns the value of attribute api_path.
11 12 13 |
# File 'lib/billomat-rb.rb', line 11 def api_path @api_path end |
.domain_format ⇒ Object
Returns the value of attribute domain_format.
11 12 13 |
# File 'lib/billomat-rb.rb', line 11 def domain_format @domain_format end |
.email ⇒ Object
Returns the value of attribute email.
11 12 13 |
# File 'lib/billomat-rb.rb', line 11 def email @email end |
.host_format ⇒ Object
Returns the value of attribute host_format.
11 12 13 |
# File 'lib/billomat-rb.rb', line 11 def host_format @host_format end |
.key ⇒ Object
Returns the value of attribute key.
12 13 14 |
# File 'lib/billomat-rb.rb', line 12 def key @key end |
.password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/billomat-rb.rb', line 11 def password @password end |
.port ⇒ Object
Returns the value of attribute port.
11 12 13 |
# File 'lib/billomat-rb.rb', line 11 def port @port end |
.protocol ⇒ Object
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 |
.resources ⇒ Object
66 67 68 |
# File 'lib/billomat-rb.rb', line 66 def resources @resources ||= [] end |
.validate ⇒ Object
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.account.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 |