Class: BrightpearlApi::Configuration
- Inherits:
-
Object
- Object
- BrightpearlApi::Configuration
- Includes:
- Singleton
- Defined in:
- lib/brightpearl_api/configuration.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#datacenter ⇒ Object
Returns the value of attribute datacenter.
-
#email ⇒ Object
Returns the value of attribute email.
-
#password ⇒ Object
Returns the value of attribute password.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
7 8 9 |
# File 'lib/brightpearl_api/configuration.rb', line 7 def account @account end |
#datacenter ⇒ Object
Returns the value of attribute datacenter.
7 8 9 |
# File 'lib/brightpearl_api/configuration.rb', line 7 def datacenter @datacenter end |
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/brightpearl_api/configuration.rb', line 7 def email @email end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/brightpearl_api/configuration.rb', line 7 def password @password end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/brightpearl_api/configuration.rb', line 7 def version @version end |
Class Method Details
.instance ⇒ Object
9 10 11 |
# File 'lib/brightpearl_api/configuration.rb', line 9 def self.instance @@instance ||= new end |
Instance Method Details
#auth_uri ⇒ Object
36 37 38 |
# File 'lib/brightpearl_api/configuration.rb', line 36 def auth_uri uri('/authorise').sub("/" + @version, "") end |
#init(args = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/brightpearl_api/configuration.rb', line 13 def init(args = {}) @email = default_email @password = default_password @version = default_version @datacenter = default_datacenter @account = default_account args.each_pair do |option, value| self.send("#{option}=", value) end end |
#uri(path) ⇒ Object
32 33 34 |
# File 'lib/brightpearl_api/configuration.rb', line 32 def uri(path) "https://" + @datacenter + ".brightpearl.com/" + @version + "/" + @account + path end |
#valid? ⇒ Boolean
24 25 26 27 28 29 30 |
# File 'lib/brightpearl_api/configuration.rb', line 24 def valid? result = true [:email, :password, :version, :datacenter, :account].each do |value| result = false if self.send(value).blank? end result end |