# @yourpass/api-js-client

> Yourpass Javascript/Typescript client

Latest version **1.0.1** (published 2019-07-23) · Apache License 2.0 license · 0 weekly downloads

## Install

```sh
npm install @yourpass/api-js-client
pnpm add @yourpass/api-js-client
yarn add @yourpass/api-js-client
bun add @yourpass/api-js-client
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-07-23 |
| First published | 2018-11-22 |
| Weekly downloads | 0 |
| License | Apache License 2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 404.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michal Černy |
| Maintainers | mblecek, yourpassowner |

## Links

- npm: https://www.npmjs.com/package/@yourpass/api-js-client
- npm.io page: https://npm.io/package/@yourpass/api-js-client

## Dependencies (3)

- [buffer](https://npm.io/package/buffer.md) ^5.2.1
- [commander](https://npm.io/package/commander.md) ^2.19.0
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^2.2.2

## Recent versions

- 1.0.1 (latest) — 2019-07-23
- 1.0.0 — 2019-04-09
- 0.0.0-beta.12 — 2019-01-21
- 0.0.0-beta.10 — 2019-01-02
- 0.0.0-beta.9 — 2018-12-19
- 0.0.0-beta.8 — 2018-12-19
- 0.0.0-beta.7 — 2018-12-19
- 0.0.0-beta.6 — 2018-12-17
- 0.0.0-beta.5 — 2018-12-17
- 0.0.0-beta.4 — 2018-12-13
- 0.0.0-beta.3 — 2018-11-29
- 0.0.0-beta.2 — 2018-11-25
- 0.0.0-beta.1 — 2018-11-24
- 0.0.0-beta — 2018-11-22

## README

# Yourpass Javascript/Typescript client library

This JavaScript/Typescript Client Library helps to develop  client-application integration with Yourpass API. It offers simple, flexible and easy to use [Yourpass API](https://doc.yourpass.eu/).

### About Yourpass

[Yourpass](https://www.yourpass.eu/) is a platform and service for creating digital cards for mobile wallets in PKPASS and Google Pay formats.

![Yourpass Use cases](yourpass.png)

If You do not know what is Yourpass please visit [Yourpass web site](https://www.yourpass.eu) for more information.

### Before you start

Before start you need to have Yourpass account. If you do not have Yourpass account go to [Yourpass Registration](https://https://login.yourpass.eu/?signup).

## Installation

```shell
npm install @yourpass/api-js-client --save
```

## Usage

This chapter describes basic usage of the client library. You can find more examples [here](/examples).

### Create OAuth2 client

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](https://doc.yourpass.eu). If You want your own clientId and clientSecret, please [contact us](https://www.yourpass.eu).
* clientSecret: OAuth client secret. You can get it on [Yourpass API Documentation](https://doc.yourpass.eu).
* username: Your Yourpass account username
* password: Your Yourpass account password

```javascript
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 });
```

### Pass listing

Use the following code to get list of digital passes:

```javascript
client.passList({ limit: 3 }).then((response) => {
  console.log(response);
});
```

### Pass create

Use the following code to create a new pass:

```javascript
conts pass = {
  templateId: "someTemplateId",
  dynamicData: {
    name: "Jan Novak",
    customerNr: 123456,
    loyaltyPoints: 0
  }
}

client.passCreate(pass).then((response) => {
  console.log(response);
});
```

### Pass update

Use the following code to update a pass:

```javascript
conts pass = {
  sid: "passId",
  templateId: "someTemplateId",
  dynamicData: {
    name: "Jan Novak",
    customerNr: 123456,
    loyaltyPoints: 10
  }
}

client.passUpdate(pass).then((response) => {
  console.log(response);
});
```

### Pass patch

Use the following code to patch the pass, eg. change pass template and update loyalty points:

```javascript
conts patch = {
  templateId: "someTemplateId2",
  dynamicData: {
    loyaltyPoints: 20
  }
}

client.passPatch(passId, patch).then((response) => {
  console.log(response);
});
```

## Documentation

See Yourpass Client [generated TypeDoc documentation](docs/).

For more information about API please visit [Yourpass API](https://doc.yourpass.eu/).

## Development

### Commands

- `npm run build` - compile typescript in to dist/ folder
- `npm run lint` - runs tslint check
- `npm run test` - runs all test
- `npm run test:unit` - runs unit tests
- `npm run test:integration` - runs integration test (see: [Itentegration test configuration](#itentegration-test-configuration))
- `npm run typedoc` - runs generate typedoc documentation
- `npm run prettier` - runs prettier to format code
- `npm publish --access public` - publish in npm registry

### Comfigure Test

Create .env file with your test account:

```
TEST_USERNAME=...
TEST_PASSWORD=...
TEST_CLIENT_ID=...
TEST_CLIENT_SECRET=...
TEST_API_URL=...
```

## Licence

Apache License 2.0

---
_Source: https://npm.io/package/@yourpass/api-js-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
