This JavaScript/Typescript Client Library helps to develop client-application integration with Yourpass API. It offers simple, flexible and easy to use Yourpass API.
Yourpass is a platform and service for creating digital cards for mobile wallets in PKPASS and Google Pay formats.
If You do not know what is Yourpass please visit Yourpass web site for more information.
Before start you need to have Yourpass account. If you do not have Yourpass account go to Yourpass Registration.
npm install @yourpass/api-js-client --save
This chapter describes basic usage of the client library. You can find more examples here.
First, you have to create client and authenticate using OAuth2.
For authentication You need:
- clientId: OAuth client id. You can find the clientId on Yourpass API Documentation. If You want your own clientId and clientSecret, please contact us.
- clientSecret: OAuth client secret. You can get it on Yourpass API Documentation.
- username: Your Yourpass account username
- password: Your Yourpass account password
import { Client, createOAuthFetch } from "@yourpass/api-js-client";
const productionUrlBase = "https://api.yourpass.eu";
const fetch = createOAuthFetch({
clientId: "Your client ID",
clientSecret: "Your client secret",
username: "Your username",
password: "Your password",
url: productionUrlBase,
});
const client = new CoreClient({ fetch, urlBase: productionUrlBase });
Use the following code to get list of digital passes:
client.passList({ limit: 3 }).then((response) => {
console.log(response);
});
Use the following code to create a new pass:
conts pass = {
templateId: "someTemplateId",
dynamicData: {
name: "Jan Novak",
customerNr: 123456,
loyaltyPoints: 0
}
}
client.passCreate(pass).then((response) => {
console.log(response);
});
Use the following code to update a pass:
conts pass = {
sid: "passId",
templateId: "someTemplateId",
dynamicData: {
name: "Jan Novak",
customerNr: 123456,
loyaltyPoints: 10
}
}
client.passUpdate(pass).then((response) => {
console.log(response);
});
Use the following code to patch the pass, eg. change pass template and update loyalty points:
conts patch = {
templateId: "someTemplateId2",
dynamicData: {
loyaltyPoints: 20
}
}
client.passPatch(passId, patch).then((response) => {
console.log(response);
});
See Yourpass Client generated TypeDoc documentation.
For more information about API please visit Yourpass API.
npm run build
- compile typescript in to dist/ foldernpm run lint
- runs tslint checknpm run test
- runs all testnpm run test:unit
- runs unit testsnpm run test:integration
- runs integration test (see: Itentegration test configuration)npm run typedoc
- runs generate typedoc documentationnpm run prettier
- runs prettier to format codenpm publish --access public
- publish in npm registry
Create .env file with your test account:
TEST_USERNAME=...
TEST_PASSWORD=...
TEST_CLIENT_ID=...
TEST_CLIENT_SECRET=...
TEST_API_URL=...
Apache License 2.0