bbAttendee Service
====

This service is an agnostic tool to get, add and remove attendees no matter what's the product you're working on.

Regardless of you are on a public, admin or member journey, you just need to inject the `bbAttendees` service in the
controller which handles your attendee functionality.

Let's assume you have

- a page component within its controller        (`PageComponent`)
- a component which renders the attendee list   (`AttendeeList`)
- a form to add a new attendee                  (`AttendeeForm`)

**IMPORTANT**:
*All the methods from the service will return the updated list of attendees*

In your `PageComponent` you will be doing

```javascript
function PageComponent([...otherInjections], bbAttendees) {
    // This needs to be a HAL Resource, containing the _links
    const booking = theVariableWhichContainsTheBooking;

    // This will tell to the service which is the source to fetch from
    bbAttendees.setSource(booking);
}
```

The `AttendeeList` will do
```javascript
function AttendeeList([...otherInjections], bbAttendees) {

    // You can of course use async/await here
    bbAttendees.getAttendees().then(attendees => {
        this.attendees = attendees;
    });
}
```

The `AttendeeForm` will do
```javascript
function AttendeeForm([...otherInjections], bbAttendees) {

    this.onSubmit = (attendee) => {

        // You can of course use async/await here
        bbAttendees.addAttendee(attendee).then(attendees => {
            this.attendees = attendees;
        });
    };
}
```

The same happens if you want to remove an attendee


Methods
--------
**NOTE** : All the methods' signatures are `async/await`.

| Name | Params | Returns | Description |
| ----- | ------ | ------ | ----------- |
| setSource | source: **Object** (hal) | AttendeeService instance | Call this method when you need to initialise the attendees operations |   
| getAttendees | link: **String** (optional) | *Promise<Array<Attendees>>* or *Promise<EmptyArray>* | get the attendees using the link from the source set previously | 
| addAttendee | attendee: **Object**, link: **String** (optional) | *Promise<Array<Attendees>>* | Add a single attendee using the link from the source |  
| removeAttendee | attendee: **Object**, link: **String* (optional) | *Promise<Array<Attendees>>* | Remove a single attendee |

Notes
--------
You can access to the list of attendees using `bbAttendees.attendees`, since the service
takes care of adding/removing the elements from the list, but re-assigning the list coming back from the methods is
recommended.











