## Ticket Objects

### class Ticket()

#### dumps

```python
 def dumps() -> Text:
    """Return json dump of `Ticket` as dictionary."""
```

#### from_dict

```python
 @classmethod
 def from_dict(cls, data: Dict[Text, Union[int, float]]) -> "Ticket":
    """Creates `Ticket` from dictionary."""
```

## TicketLock Objects

### class TicketLock()

Locking mechanism that issues tickets managing access to conversation IDs.

Tickets are issued in the order in which they are requested. A detailed
explanation of the ticket lock algorithm can be found at [this link](http://pages.cs.wisc.edu/~remzi/OSTEP/threads-locks.pdf#page=13).

#### from_dict

```python
 @classmethod
 def from_dict(cls, data: Dict[Text, Any]) -> "TicketLock":
    """Create `TicketLock` from dictionary."""
```

#### dumps

```python
 def dumps() -> Text:
    """Return json dump of `TicketLock`."""
```

#### is_locked

```python
 def is_locked(ticket_number: int) -> bool:
    """Return whether `ticket_number` is locked."
```  
**Returns**:

True if `now_serving` is not equal to `ticket`.

#### issue_ticket

```python
 def issue_ticket(lifetime: float) -> int:
    """Issue a new ticket and return its number."""
```

#### remove_expired_tickets

```python
 def remove_expired_tickets() -> None:
    """Remove expired tickets."""
```

#### last_issued

```python
 @property
 def last_issued() -> int:
    """Return number of the ticket that was last added."""
```
**Returns**:

Number of `Ticket` that was last added. `NO_TICKET_ISSUED` if no tickets exist.

#### now_serving

```python
 @property
 def now_serving() -> Optional[int]:
    """Get number of the ticket to be served next."""
```  
**Returns**:

Number of `Ticket` that is served next. 0 if no `Ticket` exists.

#### is_someone_waiting

```python
 def is_someone_waiting() -> bool:
    """Return whether someone is waiting for the lock to become available."""
```  
**Returns**:

True if the `self.tickets` queue has length greater than 0.

#### remove_ticket_for

```python
 def remove_ticket_for(ticket_number: int) -> None:
    """Remove `Ticket` for `ticket_number`."""
```
