    import BidService from 'pvbid-sdk/src/domain/services/BidService.js'

public class | source

# BidService

## Constructor Summary

Public Constructor
public | constructor(context: PVBidContext) Creates an instance of BidService. |

## Member Summary

Public Members
public | context: * |
public | repositories: * |

## Method Summary

Public Methods
public | async addAssemblies(bid: Bid, assemblyMapIds: number[]): Promise<Object[]> Adds assemblies to bid. |
public | async addField(bid: Bid, title: string, type: string): Promise<Field> Adds a new field to the bid. |
public | async addLineItem(bid: Bid, title: string): Promise<LineItem> Adds a new line item to the bid. |
public | async addMetric(bid: Bid, title: string): Promise<Metric> Adds a new metric to the bid. |
public | async clone(bid: Bid): Promise<Bid> Clones bid returning an initialized Bid |
public | async createSnapshot(bid: Bid, title: string, description: string): Promise<object> Creates a snapshot of the current bid. |
public | async deleteBid(bid: Bid): Promise<null> Deletes bid. |
public | async recoverBid(bid: Bid, snapshotId: number): Promise<null> Recovers a bid from a snapshot. |
public | async removeAssembly(bid: Bid, assemblyId: number): Promise<null> Removes assembly from a bid. |
public | validate(bid: Bid): object[] Validates bid structure and references. |

## Public Constructors

### public constructor(context: PVBidContext) source

Creates an instance of BidService.

#### Params:

Name | Type | Attribute | Description
context | PVBidContext |  |

## Public Members

### public context: * source

### public repositories: * source

## Public Methods

### public async addAssemblies(bid: Bid, assemblyMapIds: number[]): Promise<Object[]> source

Adds assemblies to bid.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |
assemblyMapIds | number[] |  | An array of assembly mapping ids to add.

#### Return:

Promise<Object[]> | Array of created bid entities

### public async addField(bid: Bid, title: string, type: string): Promise<Field> source

Adds a new field to the bid.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

title

string

- optional
- default: New Field

type

string

- optional
- default: number

#### Return:

Promise<Field>

### public async addLineItem(bid: Bid, title: string): Promise<LineItem> source

Adds a new line item to the bid. The added line item is uncategorized in all component groups.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

title

string

- optional
- default: New Line Item

#### Return:

Promise<LineItem>

### public async addMetric(bid: Bid, title: string): Promise<Metric> source

Adds a new metric to the bid.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

title

string

- optional
- default: New Metric

#### Return:

Promise<Metric>

### public async clone(bid: Bid): Promise<Bid> source

Clones bid returning an initialized Bid

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

#### Return:

Promise<Bid>

### public async createSnapshot(bid: Bid, title: string, description: string): Promise<object> source

Creates a snapshot of the current bid.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

title

string

- nullable: true

Title of the snapshot

description

string

- nullable: true

Description of the snapshot.

#### Return:

Promise<object>

#### Return Properties:

Name | Type | Attribute | Description
id | number |  | The snapshot id.
title | string |  |
bid_id | number |  |
description | string |  |
is_auto | boolean |  | A flag to indicate the snapshot was generated automatically by the PVBid system.
created_at | string |  | Example format: 2016-04-10T21:08:05+00:00

### public async deleteBid(bid: Bid): Promise<null> source

Deletes bid.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

#### Return:

Promise<null>

### public async recoverBid(bid: Bid, snapshotId: number): Promise<null> source

Recovers a bid from a snapshot. An auto snapshot of the current state will be created.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |
snapshotId | number |  |

#### Return:

Promise<null>

### public async removeAssembly(bid: Bid, assemblyId: number): Promise<null> source

Removes assembly from a bid.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |
assemblyId | number |  |

#### Return:

Promise<null>

### public validate(bid: Bid): object[] source

Validates bid structure and references.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

#### Return:

object[] | Returns an array of validation errors.