Divshot Api
Wrapper for the Divshot API.
Contents
Install
npm install divshot --save
Usage
Refer to the Narrator api for a more in depth understanding of all available methods.
CommonJS (Node/Browserify)
var Divshot = require('divshot');
Standalone
<script src="/path/to/divshot.standalone.min.js"></div>
###Instantiate
var api = Divshot.createClient({
email: 'someone@divshot.com',
password: 'somepassword123!',
token: 'your divshot access token'
});
###Angular Module
Located at /dist/divshot.angular.js
angular.module('myApp', ['divshot'])
.config(function (divshotProvider) {
divshotProvider.configure({
token: 'divshot_api_access_token'
});
}).
controller('SomeCtrl', function ($scope, divshot) {
$scope.apps = divshot.apps.list();
});
###User
By default, the authenticate
method will be called on each request as a pre hook. If a token is provided, this does not create another http request.
api.user.authenticate(function (err, token) {
});
api.user.setCredentials({
email: 'someone@divshot.com',
password: 'somepassword123!',
token: 'some_really_long_access_token_from_divshot'
});
api.user.self().then(function (user) {
});
api.user.id(userId).get().then(function (user) {
});
var user = api.user.id(userId);
user.update({
name: 'First Last'
}).then(function (user) {
});
User password
divshot.user.password.update({
password: 'Password123',
password_confirm: 'Password123'
}).then(function (res) {
});
User Emails
divshot.user.emails.add('something@aol.com').then(function (res) {
});
divshot.user.emails.primary('something@aol.com').then(function (res) {
});
divshot.user.emails.remove('something@aol.com').then(function (res) {
});
divshot.user.emails.resend('something@aol.com').then(function (res) {
});
Organizations
divshot.organizations.list().then(function (orgs) {
});
divshot.organizations.id(someOrgId).get().then(function (org) {
});
divshot.organizations.id(someOrgId).apps.list().then(function (apps) {
});
divshot.organizations.id(someOrgId).update({
name: 'name',
billing_email: 'someone@aol.com',
gravatar_email: 'someone@aol.com',
etc: 'other stuff'
}).then(function (res) {
});
Organization Members
divshot.organizations.id(someOrg).members.list().then(function (members) {
});
divshot.organizations.id(someOrg).members.create({
name: email,
email: email
}).then(function (res) {
});
divshot.organizations.id(someOrg).members.id(memberid).update({
admin: false
}).then(function (res) {
});
divshot.organizations.id(someOrg).members.id(memberId).remove().then(function () {
});
Apps
api.apps.list().then(function (apps) {
});
api.apps.create('app-name').then(function (app) {
});
var app = api.apps.id('app name');
app.get().then(function (app) {
});
Builds
app.builds.list(function (err, builds) {
});
app.builds.id('build id').get(function (err, build) {
});
app.builds.id('build id').finalize(function (err, response) {
});
app.builds.id('build id').release('production', function (err, response) {
});
###Releases
app.releases.list(function (err, releases) {
});
app.releases.env('production').get(function (err, release) {
});
app.releases.env('production').rollback(function (err, response) {
});
app.releases.env('production').promote('staging', function (err, callback) {
});
###Domains
app.domains.list().then(function(domains) {
});
app.domains.add('www.domain.com').then(function (response) {
});
app.domains.remove('www.domain.com').then(function (response) {
});
###App Environment Configuration
app.env('development').config({
auth: 'username:password'
}, function (err, response) {
});
Build
grunt build