# Pomada

A shared FE business logic repository.

## Quick start

Install the library:

```
npm i @holaluz/pomada
```

Import and execute the use case you need. For example, getting prices of the products of a supply point:

```js
import { getProductPrices, getSupplyPoint } from '@holaluz/pomada'

getSupplyPoint(
  {
    cups: 'example cups',
  },
  {
    onSuccess(supplyPoint) {
      getProductPrices(
        {
          products: supplyPoint.contractableProducts,
          consumption: supplyPoint.consumption,
          currentPower: supplyPoint.currentPower,
          desiredPower: supplyPoint.optimizedPower,
          optimizedPower: supplyPoint.optimizedPower,
        },
        {
          onSuccess(prices) {
            console.log(prices)
          },
          onError(error) {
            console.log(error)
          },
        }
      )
    },
    onCupsAlreadyClient(supplyPoint) {
      console.log(supplyPoint)
    },
    onCupsInvalid(cupsError) {
      console.log(cupsError)
    },
  }
)
```
For a more in-depth documentation, check the [docs](https://holaluz.github.io/pomada/).

## Usage for staging or production

This library reads a `process.env.ENV` variable, and access staging APIs if `ENV = staging` or production APIs if `ENV = production`.

## Development

Use [Visual Studio Code](https://code.visualstudio.com/). Execute and debug code with its included Typescript debugger (pressing F5).

Documentation is generated automatically for every use case and models inside `src`. Check out [Typedoc](https://typedoc.org/guides/doccomments/) for the available options.


## Links

[Documentation](https://holaluz.github.io/pomada/).

[Npm Package](https://www.npmjs.com/package/@holaluz/pomada).

[Repository](https://github.com/holaluz/pomada).
