1.2.2 • Published 5 years ago

@toxus/adrez-api-mock v1.2.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

adrez-api-mock

Mock for the API of AdreZ

Install

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

Usage

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

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

License

MIT

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago