Class Spire
Spire API Client
Defined in: spire.io.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Spire(opts, secret)
Spire API Client
|
| Field Attributes | Field Name and Description |
|---|---|
|
Spire API resource.
|
|
|
Number of times to retry creating a channel or subscription before giving up.
|
|
|
Spire session.
|
|
|
Shred.
|
| Method Attributes | Method Name and Description |
|---|---|
|
getApplication(application_key, cb)
Retrieve an application with a given application key.
|
|
|
login(email, password, cb)
Start the Spire session with the given username and password.
|
|
|
passwordResetRequest(email, cb)
Requests a password reset for email.
|
|
|
register(user, cb)
Registers for a new spire account, and authenticates as the newly created account
|
|
|
start(secret, cb)
Start the Spire session with the given account secret.
|
Class Detail
Spire(opts, secret)
Spire API Client
var spire = new Spire();
var spire = new Spire({
secret: my_account_secret
});
- Parameters:
- {object} opts Optional
- Options for Spire
- {string} secret Optional
- The account API secret. If you do you not set this, you must call one of: * `spire.start(secret, callback)` * `spire.login(email, password, callback)` or * `spire.register(user, callback) before you can start creating channels.
- {string} opts.url Optional
- Spire url do use (defaults to 'https://api.spire.io')
- {string} opts.version
- Version of Spire api to use (defaults to '1.0')
- {boolean} opts.logCurl
- Log all requests as curl commands (defaults to false)
Field Detail
api
Spire API resource.
Contains low-level methods for interfacing with the Spire.io API.
CREATION_RETRY_LIMIT
Number of times to retry creating a channel or subscription before giving up.
session
Spire session.
Contains methods for creating channels, subscriptions, and applications.
shred
Shred.
The HTTP client used by the spire.io.js library.
Method Detail
getApplication(application_key, cb)
Retrieve an application with a given application key.
var spire = new Spire();
spire.getApplication('key-for-your-app', function (err, application) {
if (!err) {
// 'application' will now hold your application object.
}
});
- Parameters:
- {string} application_key
- Application key
- {function(err|application)} cb
- Callback
login(email, password, cb)
Start the Spire session with the given username and password.
var spire = new Spire();
spire.login(your_email, your_password, function (err, session) {
if (!err) {
// `session` is a spire session.
// Start creating channels and subscripions.
}
});
- Parameters:
- {string} email
- {string} password
- Password
- {function(err|session)} cb
- Callback
passwordResetRequest(email, cb)
Requests a password reset for email.
var spire = new Spire();
spire.passwordResetRequest(your_email, function (err) {
if (!err) {
// A password reset email has been sent.
}
});
- Parameters:
- {string} email
- {function (err)} cb
- Callback
register(user, cb)
Registers for a new spire account, and authenticates as the newly created account
var spire = new Spire();
spire.register({
email: your_email,
password: your_password,
password_confirmation: your_password_confirmation
}, function (err) {
if (!err) {
// Your account has been registered.
// `session` is a spire session.
// Start creating channels and subscripions.
}
});
- Parameters:
- {object} user
- User info
- {string} user.email
- {string} user.password
- Password
- {string} user.password_confirmation Optional
- Optional password confirmation
- {function (err|session)} cb
- Callback
start(secret, cb)
Start the Spire session with the given account secret.
var spire = new Spire();
spire.start(your_api_secret, function (err, session) {
if (!err) {
// `session` is a spire session.
// Start creating channels and subscripions.
}
});
- Parameters:
- {string} secret
- The acccount secret
- {function(err|session)} cb
- Callback