Class Index | File Index

Classes


Class API

Collection of API methods
Defined in: api.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
API(spire, opts)
Abstraction for the Spire API
Field Summary
Field Attributes Field Name and Description
 
Schema definition for spire API.
 
Reference to spire object.
 
url
URL or spire.io API.
 
Version of spire.io API to use.
Method Summary
Method Attributes Method Name and Description
 
Get Account from url and capabilities.
 
authorization(resource, method)
Returns the Authorization header for the resource and method.
 
billing(cb)
Get billing information for the account.
 
Get Channel from url and capabilities.
 
createAccount(user, cb)
Register for a new spire account, and authenticates as the newly created account
 
createSession(secret, cb)
Creates a spire session from an account secret.
 
Discovers urls from Spire API.
 
getApplication(key, cb)
Returns an application when passed an application key.
 
login(email, password, cb)
Logs in with the given email and password.
 
mediaType(name)
Returns the MIME type for resourceName.
 
Request a password reset for email.
 
Make requests to the api.
 
Get Session from url and capabilities.
 
Get Subscription from url and capabilities.
 
Update Account from url and capability.
Class Detail
API(spire, opts)
Abstraction for the Spire API
var api = new API(options);
Parameters:
{object} spire
Spire object
{object} opts Optional
Options
{string} opts.url Optional
Spire api url
{string} opts.version Optional
Version of the Spire api to use
Field Detail
schema
Schema definition for spire API.

spire
Reference to spire object.

url
URL or spire.io API. Defaults to 'https://api.spire.io'

version
Version of spire.io API to use. Defaults to '1.0'
Method Detail
accountFromUrlAndCapabilities(creds, cb)
Get Account from url and capabilities. Use this method to get the account without starting a spire session. If you have a spire session, you should use spire.session.account.
var spire = new Spire();
spire.api.accountFromUrlAndCapabilities({
  url: account_url,
  capabilities: account_capabilities
}, function (err, account) {
  if (!err) {
    // ...
  }
})
Parameters:
{object} creds
Url and Capabilities
{string} creds.url
Url
{string} creds.capabilities
Capabilities
{function (err|account)} cb
Callback

{string} authorization(resource, method)
Returns the Authorization header for the resource and method.
Parameters:
{Resource} resource
Resource
{string} method
Method
Returns:
{string} Authorization header for the resource

billing(cb)
Get billing information for the account.
Parameters:
{function (err|billingResource)} cb
Callback

channelFromUrlAndCapabilities(creds, cb)
Get Channel from url and capabilities. Use this method to get a channel without starting a spire session. If you have a spire session, you should use spire.channel.
var spire = new Spire();
spire.api.channelFromUrlAndCapabilities({
  url: channel_url,
  capabilities: channel_capabilities
}, function (err, channel) {
  if (!err) {
    // ...
  }
})
Parameters:
{object} creds
Url and Capabilities
{string} creds.url
Url
{string} creds.capabilities
Capabilities
{function (err|channel)} cb
Callback

createAccount(user, cb)
Register for a new spire account, and authenticates as the newly created account
Parameters:
{object} user
User info
{string} user.email
Email
{string} user.password
Password
{string} user.password_confirmation Optional
Optional password confirmation
{function (err)} cb
Callback

createSession(secret, cb)
Creates a spire session from an account secret.
Parameters:
{string} secret
The acccount secret
{function(err)} cb
Callback

discover(cb)
Discovers urls from Spire API. Since this description does not change often, we only make the request once and cache the result for subsequent calls.
api.discover(function (err, discovered) {
  if (!err) {
    // ...
  }
});
Parameters:
{function(err|discovered)} cb
Callback

getApplication(key, cb)
Returns an application when passed an application key.
Parameters:
{string} key
Application key
{function(err)} cb
Callback

login(email, password, cb)
Logs in with the given email and password.
Parameters:
{string} email
Email
{string} password
Password
{function(err)} cb
Callback

{string} mediaType(name)
Returns the MIME type for resourceName.
Parameters:
{string} name Optional
Name of the resource MIME type to return
Returns:
{string} MIME type of the resource

passwordResetRequest(email, cb)
Request a password reset for email.
Parameters:
{string} email
Email
{function (err)} cb
Callback

request()
Make requests to the api.
See:
Resourse.prototype.request

sessionFromUrlAndCapabilities(creds, cb)
Get Session from url and capabilities.
Parameters:
{object} creds
Url and Capabilities
{string} creds.url
Url
{string} creds.capabilities
Capabilities
{function (err|subscription)} cb
Callback

subscriptionFromUrlAndCapabilities(creds, cb)
Get Subscription from url and capabilities. Use this method to get a subscription without starting a spire session. If you have a spire session, you should use spire.subscription.
var spire = new Spire();
spire.api.subscriptionFromUrlAndCapabilities({
  url: subscription_url,
  capabilities: subscription_capabilities
}, function (err, subscription) {
  if (!err) {
    // ...
  }
})
Parameters:
{object} creds
Url and Capabilities
{string} creds.url
Url
{string} creds.capabilities
Capabilities
{function (err|subscription)} cb
Callback

updateAccountWithUrlAndCapability(account, cb)
Update Account from url and capability.
Parameters:
{object} account
Must contain at least Url and Capability
{string} creds.url
Url
{string} creds.capability
Capability
{function (err|account)} cb
Callback

Documentation generated by JsDoc Toolkit 2.4.0 on Wed May 30 2012 16:58:14 GMT-0700 (PDT)