Class: Spire

Inherits:
Object
  • Object
show all
Defined in:
lib/spire_io.rb,
lib/spire/api.rb,
lib/spire/api/event.rb,
lib/spire/api/member.rb,
lib/spire/api/account.rb,
lib/spire/api/channel.rb,
lib/spire/api/session.rb,
lib/spire/api/resource.rb,
lib/spire/commands/cli.rb,
lib/spire/api/application.rb,
lib/spire/api/requestable.rb,
lib/spire/api/notification.rb,
lib/spire/api/subscription.rb,
lib/spire/commands/console.rb,
lib/spire/commands/register.rb,
lib/spire/commands/mixins/help.rb,
lib/spire/commands/mixins/authenticate.rb

Defined Under Namespace

Modules: Commands Classes: API

Constant Summary collapse

RETRY_CREATION_LIMIT =

How many times we will try to fetch a channel or subscription after getting a 409 Conflict.

3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = "https://api.spire.io") ⇒ Spire

Returns a new instance of Spire.



17
18
19
20
21
# File 'lib/spire_io.rb', line 17

def initialize(url="https://api.spire.io")
  @api = Spire::API.new(url)
  @url = url
  @api.discover
end

Instance Attribute Details

#apiObject

Spire API object. Has low-level methods for accessing the spire.io API.



15
16
17
# File 'lib/spire_io.rb', line 15

def api
  @api
end

#resourcesObject

Returns the value of attribute resources.



15
16
17
# File 'lib/spire_io.rb', line 15

def resources
  @resources
end

#sessionObject

Spire session. Contains methods for creating channels, subscriptions, and applications.



15
# File 'lib/spire_io.rb', line 15

attr_accessor :api, :session, :resources

Instance Method Details

#login(login, password) ⇒ Object

Authenticates a session using a login and password



29
30
31
32
# File 'lib/spire_io.rb', line 29

def (, password)
  @session = @api.(, password)
  self
end

#password_reset_request(email) ⇒ Object



43
44
45
# File 'lib/spire_io.rb', line 43

def password_reset_request(email)
  @api.password_reset_request(email)
end

#register(info) ⇒ Object

Register for a new spire account, and authenticates as the newly created account

Parameters:

  • :email (String)

    Email address of new account

  • :password (String)

    Password of new account

  • :password_confirmation (String)

    Password confirmation (optional)



38
39
40
41
# File 'lib/spire_io.rb', line 38

def register(info)
  @session = @api.(info)
  self
end

#start(secret) ⇒ Object



23
24
25
26
# File 'lib/spire_io.rb', line 23

def start(secret)
  @session = @api.create_session(secret)
  self
end