BufferClient
Static Method Summary
Static Public Methods | ||
public static |
getAuthorizationUrl(client_id: String, redirect_url: String): * Gets the authorization URL for the current app |
Constructor Summary
Public Constructor | ||
public |
constructor(params: String, callback: Function) Builds the BufferClient class |
Member Summary
Public Members | ||
public |
The OAuth2 client that will be used to automatically authenticate API URLs |
|
public |
The Buffer configuration retrieved from the /info/configuration.json endpoint |
|
public |
A promise that will return after the BufferClient instance has been built |
Method Summary
Public Methods | ||
public |
deauthorizeUser(callback: Function) Revokes access for the Buffer Client to access the API on behalf of the currently logged in user |
|
public |
Queries an API endpoint using the GET method |
|
public |
getAccessToken(access_token: String, callback: Function) Gets a permanent access token when authenticating the user. |
|
public |
getConfiguration(callback: Function) Retrieves the current Buffer configuration |
|
public |
getProfile(profile_id: String): Object Returns a profile object with a given ID. |
|
public |
getProfiles(callback: Function) Gets a list of profiles associated with the authenticated user |
|
public |
Queries an API endpoint using the POST method |
Static Public Methods
Public Constructors
public constructor(params: String, callback: Function) source
Builds the BufferClient class
Params:
Name | Type | Attribute | Description |
params | String | The access token associated with the registered app |
|
params.authenticated | Boolean |
|
Flag to determine whether the user has been authenticated or not. If false, a long-lived access token will be generated and assigned upon instantiation. |
params.client_id | String | The client ID of your Buffer application |
|
params.client_secret | String | The client secret of your Buffer application |
|
params.access_token | String | The access token for the user. If the |
|
params.redirect_url | String | The redirection URL for your Buffer application |
|
callback | Function |
|
The callback to run when the request has been fulfilled |
Example:
new BufferClient({
access_token: '<your_access_token>',
client_id: '<your_client_id>',
client_secret: '<your_client_secret>',
redirect_url: '<your_redirection_url>'
});
new BufferClient({
access_token: '<your_access_token>',
client_id: '<your_client_id>',
client_secret: '<your_client_secret>',
redirect_url: '<your_redirection_url>',
authenticated: false
}, function (err, res) {
// Do something here
});
Public Members
public client: Object source
The OAuth2 client that will be used to automatically authenticate API URLs
Public Methods
public deauthorizeUser(callback: Function) source
Revokes access for the Buffer Client to access the API on behalf of the currently logged in user
Params:
Name | Type | Attribute | Description |
callback | Function | The callback to run when the request has been fulfilled |
public get(endpoint: String, params: Object, callback: Function) source
Queries an API endpoint using the GET method
Params:
Name | Type | Attribute | Description |
endpoint | String | The API endpoint to query. This should not be the full API URL. Example: 'users.json' |
|
params | Object | A list of params to be appended to the URL. If omitted, the default Buffer API attributes will be used. |
|
callback | Function | The callback to run when the request has been fulfilled |
Example:
this.get('profiles/4eb854340acb04e870000010/updates/sent.json', {
page: 2,
count: 100
}, function (err, res) {
// Do something
});
this.get('profiles/4eb854340acb04e870000010/updates/sent.json', function (err, res) {
// Do something
});
public getAccessToken(access_token: String, callback: Function) source
Gets a permanent access token when authenticating the user.
public getConfiguration(callback: Function) source
Retrieves the current Buffer configuration
Params:
Name | Type | Attribute | Description |
callback | Function | The callback to run when the request has been fulfilled |
Example:
// ...
client.getConfiguration(function (err, res) {
// Do something
});
public getProfile(profile_id: String): Object source
Returns a profile object with a given ID. Note that this does not query the API, so a list of profiles must have been retrieved beforehand.
Params:
Name | Type | Attribute | Description |
profile_id | String | The ID of the profile to retrieve |
public getProfiles(callback: Function) source
Gets a list of profiles associated with the authenticated user
Params:
Name | Type | Attribute | Description |
callback | Function | The callback to run when the request has been fulfilled |
public post(endpoint: String, params: Object, callback: Function) source
Queries an API endpoint using the POST method
Params:
Name | Type | Attribute | Description |
endpoint | String | The API endpoint to query. This should not be the full API URL. Example: 'users.json' |
|
params | Object | A list of params to be appended to the URL. If omitted, the default Buffer API attributes will be used. |
|
callback | Function | The callback to run when the request has been fulfilled |
Example:
this.post('profiles/4eb854340acb04e870000010/schedules/update.json', { ... }, function (err, res) {
// Do something
});
this.post('user/deauthorize.json', function (err, res) {
// Do something
});