Class: Alegra::Setup
- Inherits:
-
Object
- Object
- Alegra::Setup
- Defined in:
- lib/alegra/setup.rb
Instance Attribute Summary collapse
-
#apikey ⇒ Object
Returns the value of attribute apikey.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#host ⇒ Object
Returns the value of attribute host.
-
#path ⇒ Object
Returns the value of attribute path.
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #create_token! ⇒ Object
-
#initialize(username = nil, apikey = nil, debug = false) ⇒ Setup
constructor
A new instance of Setup.
Constructor Details
#initialize(username = nil, apikey = nil, debug = false) ⇒ Setup
Returns a new instance of Setup.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/alegra/setup.rb', line 9 def initialize(username=nil, apikey=nil, debug=false) @host = 'https://app.alegra.com/' @path = 'api/v1/' @debug = debug if not apikey if ENV['ALEGRA_APIKEY'] @apikey = ENV['ALEGRA_APIKEY'] else raise 'set up the ALEGRA_APIKEY environment variable' # apikey = read_configs end end if not username if ENV['ALEGRA_USERNAME'] @username = ENV['ALEGRA_USERNAME'] else raise 'set up the ALEGRA_USERNAME environment variable' # apikey = read_configs end end raise Error, 'You must provide a ALEGRA API key' if not apikey raise Error, 'You must provide a ALEGRA USERNAME' if not username @apikey = apikey @username = username create_token! end |
Instance Attribute Details
#apikey ⇒ Object
Returns the value of attribute apikey.
7 8 9 |
# File 'lib/alegra/setup.rb', line 7 def apikey @apikey end |
#debug ⇒ Object
Returns the value of attribute debug.
7 8 9 |
# File 'lib/alegra/setup.rb', line 7 def debug @debug end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/alegra/setup.rb', line 7 def host @host end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/alegra/setup.rb', line 7 def path @path end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/alegra/setup.rb', line 7 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/alegra/setup.rb', line 7 def username @username end |
Instance Method Details
#create_token! ⇒ Object
40 41 42 |
# File 'lib/alegra/setup.rb', line 40 def create_token! @token = ::Base64.strict_encode64("#{@username}:#{@apikey}") end |