class MyERP::Credentials
Attributes
api_email[RW]
api_key[RW]
options[RW]
Public Class Methods
new(api_email, api_key, options)
click to toggle source
# File lib/myerp/credentials.rb, line 5 def initialize(api_email, api_key, options) @api_email, @api_key, @options = api_email, api_key, options end
Public Instance Methods
basic_auth()
click to toggle source
# File lib/myerp/credentials.rb, line 13 def basic_auth Base64.encode64("#{api_email}:#{api_key}").delete("\r\n") end
host()
click to toggle source
# 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?()
click to toggle source
# File lib/myerp/credentials.rb, line 9 def valid? !api_email.nil? && !api_key.nil? && !options.nil? end