Class: MyERP::Credentials
- Inherits:
-
Object
- Object
- MyERP::Credentials
- Defined in:
- lib/myerp/credentials.rb
Instance Attribute Summary collapse
-
#api_email ⇒ Object
Returns the value of attribute api_email.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #basic_auth ⇒ Object
- #host ⇒ Object
-
#initialize(api_email, api_key, options) ⇒ Credentials
constructor
A new instance of Credentials.
- #valid? ⇒ Boolean
Constructor Details
#initialize(api_email, api_key, options) ⇒ Credentials
Returns a new instance of Credentials.
5 6 7 |
# File 'lib/myerp/credentials.rb', line 5 def initialize(api_email, api_key, ) @api_email, @api_key, @options = api_email, api_key, end |
Instance Attribute Details
#api_email ⇒ Object
Returns the value of attribute api_email.
3 4 5 |
# File 'lib/myerp/credentials.rb', line 3 def api_email @api_email end |
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/myerp/credentials.rb', line 3 def api_key @api_key end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/myerp/credentials.rb', line 3 def @options end |
Instance Method Details
#basic_auth ⇒ Object
13 14 15 |
# File 'lib/myerp/credentials.rb', line 13 def basic_auth Base64.encode64("#{api_email}:#{api_key}").delete("\r\n") end |
#host ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/myerp/credentials.rb', line 17 def host site = "#{@options[:protocol]}://" if (@options[:protocol] == 'http' && @options[:port] == 80) || (@options[:protocol] == 'https' && @options[:port] == 443) site += @options[:host] else site += "#{@options[:host]}:#{@options[:port]}" end site += @options[:prefix].to_s end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/myerp/credentials.rb', line 9 def valid? !api_email.nil? && !api_key.nil? && !.nil? end |