#  Shipment

## Usage

```JavaScript
import { mockServer, ShipmentApi } from 'geta-checkout';

const shipmentApi = new ShipmentApi(mockServer.shipmentServices);

shipmentApi.get()
    .then(shipment => console.log('There are', shipment.methods.length, 'methods available.'))
```

## Properties

| Name                    | Type                    | Description                                   |
|-------------------------|-------------------------|-----------------------------------------------|
| methods                 | Array                   | Available shipment methods                    |
| selectedMethodId        | String                  | Example `home` or `null`.                     |

## Methods

### `get()`

→ `shipment` or `Error`

```javascript
shipmentApi.get()
    .then(console.log)
    .catch(console.error);
```
### `set(shipmentId, data)`

→ `shipment` or `Error`

## Shipment methods

### PostOffice

| Name                    | Type                        | Description                                   |
|-------------------------|-----------------------------|-----------------------------------------------|
| id                      | String                      | `postOffice`                                  |
| name                    | String                      |                                               |
| description             | String                      |                                               |
| image                   | [Image](../image/readme.md) |                                           |
| price                   | [Price](../price/readme.md) |                                               |
| postOffices             | Array                       | Example: `[{id: '1', name: 'City Post Office'}]`|
| selectedPostOfficeId    | String                      |                                               |
| selectValue             | String                      | Example: `0`                                  |

```javascript
shipmentApi
    .set('postOffice', { selectedPostOfficeId: '1' })
    .then(console.log)
    .catch(console.error);
```

### Home

| Name                    | Type                        | Description                                   |
|-------------------------|-----------------------------|-----------------------------------------------|
| id                      | String                      | `home`                                        |
| name                    | String                      |                                               |
| description             | String                      |                                               |
| image                   | [Image](../image/readme.md) |                                               |
| price                   | [Price](../price/readme.md) |                                               |
| selectValue             | String                      | Example: `1`                                  |

```javascript
shipmentApi
    .set('home')
    .then(console.log)
    .catch(console.error);
```

### Store

| Name                    | Type                         | Description                                   |
|-------------------------|------------------------------|-----------------------------------------------|
| id                      | String                       | `store`                                       |
| name                    | String                       |                                               |
| description             | String                       |                                               |
| image                   | [Image](../image/readme.md)  |                                               |
| price                   | [Price](../price/readme.md)  | Example: `Free`                               |
| stores                  | Array                        | Example: `[{id: '1', name: 'City Store'}]`    |
| selectedStoreId         | [Price](../price/readme.md)           |                                               |
| selectValue             | String                       | Example: `2`                                  |

```javascript
shipmentApi
    .set('store', { selectedStoreId: '1' })
    .then(console.log)
    .catch(console.error);
```