# @toxus/adrez-api-mock

> Mock version of the AdreZ api

Latest version **1.2.2** (published 2019-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @toxus/adrez-api-mock
pnpm add @toxus/adrez-api-mock
yarn add @toxus/adrez-api-mock
bun add @toxus/adrez-api-mock
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2019-08-19 |
| First published | 2019-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 925.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Jaap van der Kreeft |
| Maintainers | toxus |

## Links

- npm: https://www.npmjs.com/package/@toxus/adrez-api-mock
- Repository: https://github.com/toxus/adrez-api-mock
- Homepage: https://github.com/toxus/adrez-api-mock#readme
- Issues: https://github.com/toxus/adrez-api-mock/issues
- npm.io page: https://npm.io/package/@toxus/adrez-api-mock

## Dependencies (6)

- [jexl](https://npm.io/package/jexl.md) ^2.1.1
- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [faker](https://npm.io/package/faker.md) ^4.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [jsonfile](https://npm.io/package/jsonfile.md) ^5.0.0
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^15.1.0

## Recent versions

- 1.2.2 (latest) — 2019-08-19
- 1.2.1 — 2019-08-19
- 1.2.0 — 2019-08-16
- 1.1.6 — 2019-08-16
- 1.1.5 — 2019-08-15
- 1.1.4 — 2019-08-15
- 1.1.3 — 2019-08-15
- 1.1.2 — 2019-08-15
- 1.0.7 — 2019-08-12
- 1.0.6 — 2019-08-11
- 1.0.5 — 2019-08-11
- 1.0.4 — 2019-08-10
- 1.0.3 — 2019-08-10
- 1.0.2 — 2019-08-10
- 1.0.1 — 2019-08-10
- … 1 more at https://npm.io/package/@toxus/adrez-api-mock/versions

## README

# adrez-api-mock

Mock for the API of AdreZ

## Install

```
$ npm install @toxus/adrez-api-mock --save
```

## Usage

```js
const Adrez = require('@toxus/adrez-api-mock');

async function changeAdrez() {
  try {
      let connection  = await Adrez.Api.connection({
        customer: 'test',
        password: 'someVerySecretWord'
      })
      let addr = await connection.add({name: 'Test User', email: 'john@adrez.nl'});
      let id = addr.id;
      
      addr.name = 'Other name';
      await connection.update(addr.id, addr); // will update only the name field
      
      let usr = connection.get(id);
      
      await connection.remove(addr.id);
      
      await connection.close();
  } catch (err) {
     console.error(err)
  }
}

````

options:
* mockDef: standard, add, update, remove the delay for the api


## Address format

To update the AdreZ an object is used. There are a number of fields that can be added. 
A limited amount of fields are defined as repeating fields.

The basic, none repeating fields are:
- id
- addressId
- name
- fullName
- firstName
- insertion
- title
- gender

The repeating fields are:
- email
- telephone
- code
- description
- contact
- location (special)

Repeating fields are objects. The object has the fields 
- type
- value 
- _index (a special fields that indentifies this unique array element for updating)

The location field is different:
- street
- number
- zipcode
- city
- country
- countryCode

## example
```js
let addr = {
  name: 'Toxus',
  firstName: 'Jaap',
  email: [
    { value: 'info@example.com', type: 'work', _index: '0'},
    { value: 'news@example.con', type: 'newsletter', _index: '1'}
  ],
  telephone: '06 01020304',
  location: {
    _index: '0',
    street: 'mainstreet',
    number: '1234',
    city: 'Amsterdam',
    countryCode: 'nl'
  }  
}
```

 
## Maintainers

- [Jaap van der Kreeft](https://github.com/toxus)


## License

MIT

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