# build-actions

> Calculate the differences between two customer objects and build the update actions

Latest version **1.0.2** (published 2015-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install build-actions
pnpm add build-actions
yarn add build-actions
bun add build-actions
```

## 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.0.2 |
| Published | 2015-11-08 |
| First published | 2015-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luigi Pinca |
| Maintainers | lpinca |

## Links

- npm: https://www.npmjs.com/package/build-actions
- Repository: https://github.com/lpinca/build-actions
- Issues: https://github.com/lpinca/build-actions/issues
- npm.io page: https://npm.io/package/build-actions

## Dependencies (2)

- [babel](https://npm.io/package/babel.md) ^5.8.23
- [jsondiffpatch](https://npm.io/package/jsondiffpatch.md) ^0.1.37

## Recent versions

- 1.0.2 (latest) — 2015-11-08
- 1.0.1 — 2015-10-26
- 1.0.0 — 2015-10-26

## README

# build-actions

Calculate the differences between two customer objects and build the update
actions as defined in [http://dev.sphere.io/http-api-projects-customers.html][customer].

[![Version npm][npm-build-actions-badge]][npm-build-actions]
[![Build Status][travis-build-actions-badge]][travis-build-actions]
[![Coverage Status][coverage-build-actions-badge]][coverage-build-actions]

## Install

```bash
npm install --save build-actions
```

## API

This module exports a single function that takes two arguments:

1. An object representing a customer.
2. An object representing the updated version of the same customer.

The function returns an array of [update actions][update-actions].

```js
var buildActions = require('build-actions');

var before = {
  email: 'foo.bar@domain.com',
  firstName: 'foo',
  lastName: 'bar',
  addresses: []
};

var after = {
  customerNumber: '123456',
  email: 'foobar@domain.com',
  firstName: 'foo',
  lastName: 'bar',
  middleName: 'baz',
  addresses: [{
    id: 'FjAJrc2C',
    country: 'NL'
  }],
  defaultShippingAddressId: 'FjAJrc2C'
};

var actions = buildActions(before, after);

console.log(actions);

/*
[{
  action: 'changeEmail',
  email: 'foobar@domain.com'
}, {
  action: 'addAddress',
  address: {
    id: 'FjAJrc2C',
    country: 'NL'
  }
}, {
  action: 'setCustomerNumber',
  customerNumber: '123456'
}, {
  action: 'changeName',
  firstName: 'foo',
  lastName: 'bar',
  middleName: 'baz'
}, {
  action: 'setDefaultShippingAddress',
  addressId: 'FjAJrc2C'
}]
*/
```

## License

[MIT](LICENSE)

[npm-build-actions-badge]: https://img.shields.io/npm/v/build-actions.svg
[npm-build-actions]: https://www.npmjs.com/package/build-actions
[travis-build-actions-badge]: https://img.shields.io/travis/lpinca/build-actions/master.svg
[travis-build-actions]: https://travis-ci.org/lpinca/build-actions
[coverage-build-actions-badge]: https://img.shields.io/coveralls/lpinca/build-actions/master.svg
[coverage-build-actions]: https://coveralls.io/r/lpinca/build-actions?branch=master
[customer]: http://dev.sphere.io/http-api-projects-customers.html
[update-actions]: http://dev.sphere.io/http-api-projects-customers.html#update-actions

---
_Source: https://npm.io/package/build-actions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
