Package Exports
- podium-sdk
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (podium-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Podium Client JavaScript SDK
This library allows you to access the Podium REST API for building client applications.
Installation
npm install podium-sdkUsage
import Podium from 'podium-sdk';
let settings = {}
let podium = new Podium(settings);
podium.auth.login(email, password, progamId).then(rsp => {
console.log(rsp.message);
}).catch(error => {
console.log(error.message);
})Settings
Settings can be passed into the Podium constructor as a JSON object.
| Name | Type | Default | Description |
|---|---|---|---|
| endpoint | url | https://api.podiumrewards.com/v1/ | The Podium endpoint URL. |
| perPage | number | 50 | Default number of rows to return on paginator |
| catchError | function | - | The callback when any request has been unsuccessful. Takes one argument of the error. |
API methods
User authentication
Log in with a username and password and receive an API token to interact with other resources available via the API. The logout endpoint deletes the authentication token.
These methods map to the authentication endpoints in the API.
Podium.auth.login(email, password, programSlug)
Podium.auth.getToken()
Podium.auth.logout()Podium.auth.login parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| string | yes | The user's email address, which is the username required for login. | |
| password | string | yes | The password required for login. |
| programSlug | string | yes | The slug of the program to which you are authenticating the user. |
Member information
Get a member's profile information (e.g., name, email address), incentive balance, and list of incentive transactions.
These methods map to the profile and incentive endpoints in the API.
Podium.profile.get()
Podium.incentive.getLedger()
Podium.incentive.getLedgers(paginator)
Podium.incentive.getTransactions(ledgerId, paginator)Podium.incentive.getTransactions parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| paginator | PodiumPaginator | no | The paginator object will return paginated results. |
Terms and conditions
Get the latest terms and conditions for the user's program, and also save the version of the terms and conditions that the user has accepted.
These methods map to the terms endpoints in the API.
Podium.terms.get()
Podium.terms.accept(termsId)Podium.terms.accept parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| termsId | integer | yes | The ID of the terms and conditions that the user is accepting. |
LRG authentication
Authenticate a Podium user into LRG and redirect the user to the LRG site to shop and redeem. Alternatively, get the data needed to allow the user to shop on the LRG site (e.g., LRG redirect URL, authentication token).
These methods map to the LRG authentication endpoints in the API.
Podium.lrg.redirect(websiteBack)
Podium.lrg.get(websiteBack)Parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| websiteBack | string | yes | The URL used to route the user back to Podium when the user is finished shopping on LRG. |
Paginator
import Podium from 'podium-sdk';
let paginator = Podium.Paginator(); // Create an instance of PodiumPaginator
paginator.setPage(2).setPerPage(10)
Podium.incentive.getTransactions(paginator).then(rsp => {
console.log(rsp.data);
}).catch(error => {
console.log(error.message);
})Paginator properties
The following set properties are chainable:
PodiumPaginator.setPage(number)
The page number to be returned.
PodiumPaginator.setPerPage(number)
The number of rows of data returned per page.
PodiumPaginator.setSortField(field)
The field by which the rows of data are sorted.
PodiumPaginator.setSortDirection([asc|desc])
The sort direction, either ascending or descending.
PodiumPaginator.setSortDesc(boolean)
The descending sort direction set as either true or false.
PodiumPaginator.setContext(object)
Object must have the properties of currentPage, perPage, sortBy, and sortDesc.