项目作者: engagepeople

项目描述 :
Podium Client JavaScript SDK
高级语言: TypeScript
项目地址: git://github.com/engagepeople/podium-js-sdk.git
创建时间: 2017-12-04T19:23:41Z
项目社区:https://github.com/engagepeople/podium-js-sdk

开源协议:Apache License 2.0

下载


Podium Client JavaScript SDK

This library allows you to access the Podium Client REST API for building client applications.

Installation

  1. npm install podium-sdk

Usage

  1. import { Podium, PodiumPaginator, PodiumFilter, PodiumSettings } from 'podium-sdk'
  2. let podiumSettings = new PodiumSettings().setEndpoint('https://api.podiumrewards.com/')
  3. let podium = new Podium(podiumSettings)
  4. podium.Auth.login(email, password, slug).then(rsp => {
  5. console.log(rsp.message)
  6. }).catch(error => {
  7. console.log(error.message)
  8. })
  9. let filter = new PodiumFilter()
  10. filter.setValues({ customer_id: 1, search: 'Dan' })
  11. let paginator = new PodiumPaginator()
  12. paginator.setPerPage(5)
  13. paginator.setSortField('last_name')
  14. paginator.setSortDirection('asc')
  15. podium.Users.List(filter, paginator).then((rsp) => {
  16. console.log(rsp)
  17. })

Settings

Settings can be passed into the Podium constructor as a PodiumSettings class.

Name Type Default Description
setEndpoint url https://api.podiumrewards.com/ The Podium endpoint URL.
setLocale API_LOCALE en-US The Podium endpoint URL.
setOnRequestError function(IPodiumErrorResponse) Callback when an API error is encountered.
setVersion number 1 Version of Podium API to use.

API methods

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.

  1. Podium.Auth.Login(email, password, slug)
  2. Podium.Auth.LoginAs(userAccount, token, slug)
  3. Podium.Auth.SSO(token)
  4. Podium.Auth.GetToken()
  5. Podium.Auth.SetToken(string)
  6. Podium.Auth.HasToken()
  7. Podium.Auth.logout()

Podium Resource

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.

Get
Name Type Required? Description
id number/string yes ID of Resource.
List
Name Type Required? Description
arg1 Filter/Paginator no Filter or Paginator Object.
paginator Paginator no Paginator if first parameter is filter.
Create
Name Type Required? Description
object object no Object to be created.
Update
Name Type Required? Description
id number/string yes ID of Resource.
object object no Object to be deleted.
Delete
Name Type Required? Description
id number/string yes ID of object to be delete.

Methods that extend Resource

  1. Podium.Discretionary.DirectReports
  2. Podium.Discretionary.Discretionary
  3. Podium.Discretionary.Ledger
  4. Podium.Discretionary.Transactions
  5. Podium.Ecards.Categories
  6. Podium.Ecards.Templates
  7. Podium.Permissions
  8. Podium.Shop.Cart
  9. Podium.Shop.Orders
  10. Podium.Shop.Products
  11. Podium.Shop.Wishlist
  12. Podium.User.Address
  13. Podium.User.Profile
  14. Podium.Users

Methods with additional functions

  1. Podium.Accounts.GetTravelUrl(AccountID)
  2. Podium.Accounts.GetTransactions(AccountID, Filter, Paginator)
  3. Podium.Accounts.Transfer(AccountID, ReceiverAccountID, Amount, SenderTransactionDescription, ReceiverTransactionDescription)
  4. Podium.Ecards.Ecards.GetReceived(Paginator)
  5. Podium.Ecards.Ecards.GetSent(Paginator)
  6. Podium.Ecards.Ecards.GetPending(Paginator)
  7. Podium.Ledgers.GetTransactions(LedgerID, Filter, Paginator)
  8. Podium.LRG.GetUrl(redirectUrl)
  9. Podium.LRG.Redirect(redirectUrl)
  10. Podium.Orders.Cancel(orderId: number | string)
  11. Podium.Shop.Cart.Confirm(cartId, addressId, ledgerId)
  12. Podium.Shop.Cart.Checkout(cartId, addressId, ledgerId)
  13. Podium.Terms.Accept(termsId)
  14. Podium.Utils.isRequesting - Property of boolean if SDK is currently making a request
  15. Podium.Utils.RequestsInProgress - array of request URL's SDK is currently making

Paginator properties

The following set properties are chainable:

  1. PodiumPaginator.setPage(number)
  2. PodiumPaginator.setPerPage(number)
  3. PodiumPaginator.setSortField(field)
  4. PodiumPaginator.setSortDirection([asc|desc])
  5. PodiumPaginator.setSortDesc(boolean)
  6. PodiumPaginator.toParams()

Filter properties

The following set properties are chainable:

  1. PodiumFilter.getFacets()
  2. PodiumFilter.setFacets(object)
  3. PodiumFilter.setValues(object)
  4. PodiumFilter.getValues(number)
  5. PodiumFilter.toParams()