Class: BrightpearlApi::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/brightpearl_api/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject

Returns the value of attribute account.



7
8
9
# File 'lib/brightpearl_api/configuration.rb', line 7

def 
  @account
end

#datacenterObject

Returns the value of attribute datacenter.



7
8
9
# File 'lib/brightpearl_api/configuration.rb', line 7

def datacenter
  @datacenter
end

#emailObject

Returns the value of attribute email.



7
8
9
# File 'lib/brightpearl_api/configuration.rb', line 7

def email
  @email
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/brightpearl_api/configuration.rb', line 7

def password
  @password
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/brightpearl_api/configuration.rb', line 7

def version
  @version
end

Class Method Details

.instanceObject



9
10
11
# File 'lib/brightpearl_api/configuration.rb', line 9

def self.instance
  @@instance ||= new
end

Instance Method Details

#auth_uriObject



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 = 
  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

Returns:

  • (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