Skip to content

Commit aef90f9

Browse files
authored
TPD-5755: Add support for retrieving tickets (#127)
* Add support for retrieving tickets * Refactor get_ticket_by_id
1 parent 845317b commit aef90f9

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [4.25.0] - 2022-08-01
7+
8+
## Changed
9+
10+
- Added `get_tickets` and `get_ticket_by_id` to support `/v1/tickets` functionality.
11+
612
## [4.24.0] - 2022-07-07
713

814
## Changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='VacasaConnect',
5-
version='4.24.0',
5+
version='4.25.0',
66
description='A Python 3.6+ SDK for the connect.vacasa.com API.',
77
packages=['vacasa.connect'],
88
url='https://github.com/Vacasa/python-vacasa-connect-sdk',

vacasa/connect/connect.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,24 @@ def get_unit_bulk(self, ids: str):
20822082
return self._post(url, json={'data': {'attributes': payload}}, headers=headers).json()
20832083

20842084

2085+
def get_tickets(self, params: dict = None):
2086+
"""Retrieve a list of tickets
2087+
Yields:
2088+
An iterator of tickets. Each ticket is a dict.
2089+
"""
2090+
url = f"{self.endpoint}/v1/tickets"
2091+
headers = self._headers()
2092+
2093+
return self._iterate_pages(url, headers, params)
2094+
2095+
def get_ticket_by_id(self, ticket_id: int, params: dict = None):
2096+
""" Get a single ticket by ID """
2097+
url = f"{self.endpoint}/v1/tickets/{ticket_id}"
2098+
r = self._get(url, headers=self._headers(), params=params)
2099+
2100+
return r.json()['data']
2101+
2102+
20852103
def _trip_protection_to_integer(trip_protection: bool) -> int:
20862104
"""Convert from True/False/None to 1/0/-1"""
20872105
if trip_protection is None:

0 commit comments

Comments
 (0)