wink-sdk-travel-agent 0.0.55__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. wink_sdk_travel_agent/__init__.py +229 -0
  2. wink_sdk_travel_agent/api/__init__.py +6 -0
  3. wink_sdk_travel_agent/api/analytics_api.py +671 -0
  4. wink_sdk_travel_agent/api/travel_agent_api.py +1668 -0
  5. wink_sdk_travel_agent/api_client.py +805 -0
  6. wink_sdk_travel_agent/api_response.py +21 -0
  7. wink_sdk_travel_agent/configuration.py +582 -0
  8. wink_sdk_travel_agent/exceptions.py +217 -0
  9. wink_sdk_travel_agent/models/__init__.py +106 -0
  10. wink_sdk_travel_agent/models/address_agent.py +111 -0
  11. wink_sdk_travel_agent/models/affiliate_account_agent.py +181 -0
  12. wink_sdk_travel_agent/models/affiliate_account_user_agent.py +115 -0
  13. wink_sdk_travel_agent/models/agent_booking_request_agent.py +130 -0
  14. wink_sdk_travel_agent/models/aggregate_descriptor_agent.py +100 -0
  15. wink_sdk_travel_agent/models/ancillary_request_agent.py +111 -0
  16. wink_sdk_travel_agent/models/authenticated_user_agent.py +100 -0
  17. wink_sdk_travel_agent/models/bed_agent.py +91 -0
  18. wink_sdk_travel_agent/models/bedroom_agent.py +106 -0
  19. wink_sdk_travel_agent/models/bedroom_configuration_agent.py +102 -0
  20. wink_sdk_travel_agent/models/beneficiary_agent.py +156 -0
  21. wink_sdk_travel_agent/models/beneficiary_charge_agent.py +97 -0
  22. wink_sdk_travel_agent/models/booking_agent.py +342 -0
  23. wink_sdk_travel_agent/models/booking_analytics_supplier.py +96 -0
  24. wink_sdk_travel_agent/models/booking_ancillary_agent.py +155 -0
  25. wink_sdk_travel_agent/models/booking_confirmations_agent.py +101 -0
  26. wink_sdk_travel_agent/models/booking_contract_agent.py +697 -0
  27. wink_sdk_travel_agent/models/booking_contract_item_agent.py +206 -0
  28. wink_sdk_travel_agent/models/booking_contract_payment_details_agent.py +124 -0
  29. wink_sdk_travel_agent/models/booking_itinerary_agent.py +113 -0
  30. wink_sdk_travel_agent/models/booking_itinerary_room_configuration_agent.py +98 -0
  31. wink_sdk_travel_agent/models/booking_itinerary_room_configuration_child_agent.py +90 -0
  32. wink_sdk_travel_agent/models/booking_overview_request_supplier.py +97 -0
  33. wink_sdk_travel_agent/models/booking_user_agent.py +102 -0
  34. wink_sdk_travel_agent/models/booking_user_request_agent.py +96 -0
  35. wink_sdk_travel_agent/models/booking_user_session_agent.py +112 -0
  36. wink_sdk_travel_agent/models/booking_view_agent.py +101 -0
  37. wink_sdk_travel_agent/models/boolean_response_agent.py +90 -0
  38. wink_sdk_travel_agent/models/cancellation_detail_agent.py +98 -0
  39. wink_sdk_travel_agent/models/cancellation_policy_agent.py +166 -0
  40. wink_sdk_travel_agent/models/cancellation_policy_exception_agent.py +100 -0
  41. wink_sdk_travel_agent/models/cancellation_policy_exceptions_agent.py +97 -0
  42. wink_sdk_travel_agent/models/cancellation_policy_lightweight_agent.py +167 -0
  43. wink_sdk_travel_agent/models/chart_category_axis_supplier.py +88 -0
  44. wink_sdk_travel_agent/models/chart_legend_supplier.py +88 -0
  45. wink_sdk_travel_agent/models/chart_series_supplier.py +90 -0
  46. wink_sdk_travel_agent/models/chart_title_supplier.py +88 -0
  47. wink_sdk_travel_agent/models/child_agent.py +91 -0
  48. wink_sdk_travel_agent/models/commissionable_entry_agent.py +102 -0
  49. wink_sdk_travel_agent/models/company_agent.py +176 -0
  50. wink_sdk_travel_agent/models/company_user_agent.py +114 -0
  51. wink_sdk_travel_agent/models/company_view_agent.py +101 -0
  52. wink_sdk_travel_agent/models/composite_filter_descriptor_agent.py +108 -0
  53. wink_sdk_travel_agent/models/contact_agent.py +104 -0
  54. wink_sdk_travel_agent/models/country_agent.py +100 -0
  55. wink_sdk_travel_agent/models/country_lightweight_agent.py +100 -0
  56. wink_sdk_travel_agent/models/create_agent_booking400_response.py +141 -0
  57. wink_sdk_travel_agent/models/create_agent_booking_request_agent.py +105 -0
  58. wink_sdk_travel_agent/models/custom_monetary_amount.py +91 -0
  59. wink_sdk_travel_agent/models/customization_lightweight_agent.py +232 -0
  60. wink_sdk_travel_agent/models/customization_theme_colors_agent.py +108 -0
  61. wink_sdk_travel_agent/models/daily_rate_agent.py +115 -0
  62. wink_sdk_travel_agent/models/dow_pattern_group_agent.py +102 -0
  63. wink_sdk_travel_agent/models/engine_configuration_booking_report_agent.py +230 -0
  64. wink_sdk_travel_agent/models/engine_configuration_theme_agent.py +108 -0
  65. wink_sdk_travel_agent/models/engine_configuration_theme_colors_agent.py +108 -0
  66. wink_sdk_travel_agent/models/extra_charge_agent.py +103 -0
  67. wink_sdk_travel_agent/models/extra_charges_agent.py +112 -0
  68. wink_sdk_travel_agent/models/fee_agent.py +105 -0
  69. wink_sdk_travel_agent/models/filter_descriptor_agent.py +107 -0
  70. wink_sdk_travel_agent/models/general_manager_agent.py +104 -0
  71. wink_sdk_travel_agent/models/generic_error_message.py +94 -0
  72. wink_sdk_travel_agent/models/geo_json_point_agent.py +94 -0
  73. wink_sdk_travel_agent/models/geo_name_agent.py +136 -0
  74. wink_sdk_travel_agent/models/geo_name_lightweight_agent.py +136 -0
  75. wink_sdk_travel_agent/models/group_descriptor_agent.py +110 -0
  76. wink_sdk_travel_agent/models/grouped_booking_sales_metrics_supplier_details.py +110 -0
  77. wink_sdk_travel_agent/models/guest_room_agent.py +258 -0
  78. wink_sdk_travel_agent/models/guest_room_lightweight_agent.py +259 -0
  79. wink_sdk_travel_agent/models/guest_user_agent.py +108 -0
  80. wink_sdk_travel_agent/models/hotel_on_map_agent.py +270 -0
  81. wink_sdk_travel_agent/models/image_attribution_agent.py +91 -0
  82. wink_sdk_travel_agent/models/line_chart_supplier.py +122 -0
  83. wink_sdk_travel_agent/models/localized_description_agent.py +109 -0
  84. wink_sdk_travel_agent/models/localized_price_agent.py +162 -0
  85. wink_sdk_travel_agent/models/managed_by_entity_agent.py +103 -0
  86. wink_sdk_travel_agent/models/managed_by_entity_rules_agent.py +95 -0
  87. wink_sdk_travel_agent/models/media_author_attribution_agent.py +91 -0
  88. wink_sdk_travel_agent/models/online_presence_agent.py +112 -0
  89. wink_sdk_travel_agent/models/page_booking_agent.py +124 -0
  90. wink_sdk_travel_agent/models/page_booking_view_agent.py +124 -0
  91. wink_sdk_travel_agent/models/pageable_object_agent.py +102 -0
  92. wink_sdk_travel_agent/models/payout_agent.py +158 -0
  93. wink_sdk_travel_agent/models/payout_fee_agent.py +116 -0
  94. wink_sdk_travel_agent/models/pending_refund_agent.py +99 -0
  95. wink_sdk_travel_agent/models/perk_lightweight_agent.py +105 -0
  96. wink_sdk_travel_agent/models/personal_agent.py +139 -0
  97. wink_sdk_travel_agent/models/pet_info_dto_agent.py +90 -0
  98. wink_sdk_travel_agent/models/preferences_agent.py +128 -0
  99. wink_sdk_travel_agent/models/profile_agent.py +110 -0
  100. wink_sdk_travel_agent/models/profile_lightweight_agent.py +111 -0
  101. wink_sdk_travel_agent/models/profile_user_agent.py +100 -0
  102. wink_sdk_travel_agent/models/property_aggregate_lightweight_agent.py +245 -0
  103. wink_sdk_travel_agent/models/property_policy_agent.py +150 -0
  104. wink_sdk_travel_agent/models/quote_agent.py +94 -0
  105. wink_sdk_travel_agent/models/quote_lightweight_agent.py +95 -0
  106. wink_sdk_travel_agent/models/rate_plan_agent.py +172 -0
  107. wink_sdk_travel_agent/models/rate_plan_level_fee_agent.py +112 -0
  108. wink_sdk_travel_agent/models/refund_agent.py +167 -0
  109. wink_sdk_travel_agent/models/reporting_ancillary_agent.py +108 -0
  110. wink_sdk_travel_agent/models/reporting_daily_rate_agent.py +99 -0
  111. wink_sdk_travel_agent/models/reporting_extra_charge_agent.py +98 -0
  112. wink_sdk_travel_agent/models/review_agent.py +133 -0
  113. wink_sdk_travel_agent/models/review_answer_agent.py +102 -0
  114. wink_sdk_travel_agent/models/review_lightweight_agent.py +134 -0
  115. wink_sdk_travel_agent/models/review_user_agent.py +99 -0
  116. wink_sdk_travel_agent/models/room_configuration_agent.py +99 -0
  117. wink_sdk_travel_agent/models/room_configuration_price_rate_plan_agent.py +130 -0
  118. wink_sdk_travel_agent/models/room_stay_agent.py +183 -0
  119. wink_sdk_travel_agent/models/simple_address_agent.py +109 -0
  120. wink_sdk_travel_agent/models/simple_date_time_itinerary_agent.py +108 -0
  121. wink_sdk_travel_agent/models/simple_description_agent.py +111 -0
  122. wink_sdk_travel_agent/models/simple_multimedia_agent.py +156 -0
  123. wink_sdk_travel_agent/models/social_agent.py +100 -0
  124. wink_sdk_travel_agent/models/sort_descriptor_agent.py +100 -0
  125. wink_sdk_travel_agent/models/sort_object.py +96 -0
  126. wink_sdk_travel_agent/models/sort_object_agent.py +92 -0
  127. wink_sdk_travel_agent/models/state_agent.py +117 -0
  128. wink_sdk_travel_agent/models/stay_rate_agent.py +209 -0
  129. wink_sdk_travel_agent/models/sub_country_agent.py +92 -0
  130. wink_sdk_travel_agent/models/sub_country_lightweight_agent.py +92 -0
  131. wink_sdk_travel_agent/models/sub_sub_country_agent.py +92 -0
  132. wink_sdk_travel_agent/models/sub_sub_country_lightweight_agent.py +92 -0
  133. wink_sdk_travel_agent/models/supplier_contract_item_policy_agent.py +170 -0
  134. wink_sdk_travel_agent/models/travel_agent_agent.py +90 -0
  135. wink_sdk_travel_agent/models/travel_inventory_recognition_agent.py +121 -0
  136. wink_sdk_travel_agent/models/upsert_travel_agent_request_agent.py +90 -0
  137. wink_sdk_travel_agent/models/wink_booking_contract_agent.py +697 -0
  138. wink_sdk_travel_agent/py.typed +0 -0
  139. wink_sdk_travel_agent/rest.py +259 -0
  140. wink_sdk_travel_agent-0.0.55.dist-info/METADATA +539 -0
  141. wink_sdk_travel_agent-0.0.55.dist-info/RECORD +144 -0
  142. wink_sdk_travel_agent-0.0.55.dist-info/WHEEL +5 -0
  143. wink_sdk_travel_agent-0.0.55.dist-info/licenses/LICENSE +201 -0
  144. wink_sdk_travel_agent-0.0.55.dist-info/top_level.txt +1 -0
@@ -0,0 +1,805 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Wink API
5
+
6
+ # Introduction Welcome to the Wink API - A programmer-friendly way to manage, sell and book travel inventory on the Wink platform. The API gives you all the tools you need to ready your properties and inventory for sale across 1000s of our native sales channels. Integrators, affiliates, travel agents and content creators have the ability search for your travel inventory and promote / sell it in a wide variety of ways. # Integrations We have already integrated with the most well-known channel managers so you don't have to. To see our current integrations, please go to https://extranet.wink.travel and scroll to Connectivity section. Once your properties are set up, you can finish the setup by mapping your property to Wink using your channel manager partner portal. If your properties don't have a channel manager, you can easily manage rates and availability with this API. # Intended Audience Programmers are [most likely] a requirement to start integrating with Wink. Companies and organizations that would most benefit from integrating with us are new and existing travel companies that have relationships with suppliers and that need an advanced system from which to manage their travel inventory and get that same inventory out to as many eyeballs as possible at the lowest price possible. - Hotel chains - Hotel brands - Travel tech companies - Destination sites - Integrators - Aggregators - Destination management companies - Travel agencies - OTAs ## APIs Not every integrator needs every API. For that reason, we have separated APIs into context. ### Test API - [Ping](/ping): The Ping API is a quick test endpoint to verify that your credentials work Wink. ### Common APIs - [Notifications](/notifications): The Notifications API is a way for us to stay in touch with your user, property or affiliate account. - [User Settings](/user-settings): The User Settings API exposes endpoints to allow 3rd party integrators to communicate with Wink. ### Consume APIs Consume endpoints are for developers who want to find existing travel inventory and either book it or use it to advertise through one of their Wink affiliate accounts. - [Configuration](/customization-client): A single endpoint to retrieve whitelabel + customization information for the booking customization. - [Lookup](/lookup): All APIs related to locating inventory by region, locale and property flags. - [Inventory](/inventory): All APIs related to retrieve known travel inventory as it was found using the Lookup API.. - [Booking](/booking): All APIs related to creating bookings on the platform. - [Travel Agent](/travel-agent): The Travel Agent API exposes endpoints to manage agent-facilitated bookings. ### Produce APIs Produce endpoints are for developers who want to create and manage travel inventory. #### Property - [Property registration](/extranet/property/register): As a producer, this is, oftentimes, where you start your journey. These endpoints let you create properties on Wink. - [Property](/extranet/property): This collection of property endpoints are mostly management endpoints that let you display, change status and similar for your existing properties. - [Facilities](/extranet/facilities): This collection of endpoints let you manage facilities; such as room types. - [Experiences](/extranet/experiences): This collection of endpoints let you manage experiences, such as activities. - [Monetize](/extranet/monetize): The Monetize API exposes endpoints for managing cancellation polies, rate plans, promotions and more on Wink. - [Distribution](/extranet/distribution): The Distribution API exposes endpoints for sales channels, connecting with affiliates, managing rates and inventory calendars and more on Wink. - [Property Booking](/extranet/booking): The Property Booking API exposes endpoints for managing bookings and reviews at the property-level. #### Affiliate - [Affiliate](/affiliate): This collection of affiliate endpoints are mostly management endpoints that let you display, change status and similar for your existing accounts. - [Browse](/affiliate/browse): The Browse API exposes endpoints for affiliates to find suppliers and inventory to sell. - [Inventory](/affiliate/inventory): The Inventory API exposes endpoints for affiliates to manage the inventory they want to sell and how they want to sell it. - [Sales Channel](/affiliate/sales-channel): The Sales Channel API exposes endpoints for affiliates to manage existing sales channels as well as find new ones. - [WinkLinks](/affiliate/winklinks): The WinkLinks API exposes endpoints for affiliates to manage their WinkLinks page. #### Rate provider - [Channel manager](/channel-manager): The Channel Manager API enables external channel manager partners to map, exchange rate / availability information with us as well as be informed of bookings that occur on the Wink platform for one of their properties. ### Taxonomy APIs Taxonomy endpoints are for developers who want to consume and produce travel inventory and need taxonomies of standard and non-standard codes for inventory types, classes, statuses etc. - [Reference](/reference): All APIs related to retrieving platform-supported taxonomies. ### Insight APIs Insight endpoints do exactly what the name implies - They offer platform-level insight into the activities of producers and consumers. - [Analytics](/analytics): All APIs related to tracking metrics across a wide variety of data source segments including, more entertaining, leaderboard metrics. ### Payment APIs Payment endpoints are for developers who want to purchase travel inventory. This can be done via the API as a registered Travel Agent or using our API in conjunction with our PCI compliant payment widget for all other entities. - [TripPay](/payment): All APIs related to TripPay account management, booking, mapping and integration features. ## SDKs We are actively working on supporting the most used languages out there. If you don't see your language here, reach out to us with a request to officially add your language. In the meantime, if you want to roll your own SDK, you can do so by downloading the OpenAPI spec and using one of the many available OpenAPI generators available: [https://openapi-generator.tech/docs/generators](https://openapi-generator.tech/docs/generators). - Java SDK [https://github.com/wink-travel/wink-sdk-java](https://github.com/wink-travel/wink-sdk-java) ## Usage These features are made available to you via a [REST API](https://en.wikipedia.org/wiki/Representational_state_transfer). This API is language agnostic. ## Versioning We chose to version our endpoints in a way that we hope affects your integration minimally. You request the version of our API you wish to work with via the `Wink-Version` header. When it's time for you to upgrade, you only have to change the version number to get access to our updated endpoints. ## Release history - Follow updates on Github: https://github.com/wink-travel/wink-sdk-java/blob/master/CHANGELOG.md # Travel Agent API The Travel Agent API exposes endpoints to manage agent-facilitated bookings. This API lets you: 1. Travel Agent: Manage agent entity. 2. Booking: Create / Manage bookings Browse the endpoints in the left navigation bar to get started.
7
+
8
+ The version of the OpenAPI document: 30.29.0
9
+ Contact: bjorn@wink.travel
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ import datetime
17
+ from dateutil.parser import parse
18
+ from enum import Enum
19
+ import decimal
20
+ import json
21
+ import mimetypes
22
+ import os
23
+ import re
24
+ import tempfile
25
+ import uuid
26
+
27
+ from urllib.parse import quote
28
+ from typing import Tuple, Optional, List, Dict, Union
29
+ from pydantic import SecretStr
30
+
31
+ from wink_sdk_travel_agent.configuration import Configuration
32
+ from wink_sdk_travel_agent.api_response import ApiResponse, T as ApiResponseT
33
+ import wink_sdk_travel_agent.models
34
+ from wink_sdk_travel_agent import rest
35
+ from wink_sdk_travel_agent.exceptions import (
36
+ ApiValueError,
37
+ ApiException,
38
+ BadRequestException,
39
+ UnauthorizedException,
40
+ ForbiddenException,
41
+ NotFoundException,
42
+ ServiceException
43
+ )
44
+
45
+ RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
46
+
47
+ class ApiClient:
48
+ """Generic API client for OpenAPI client library builds.
49
+
50
+ OpenAPI generic API client. This client handles the client-
51
+ server communication, and is invariant across implementations. Specifics of
52
+ the methods and models for each application are generated from the OpenAPI
53
+ templates.
54
+
55
+ :param configuration: .Configuration object for this client
56
+ :param header_name: a header to pass when making calls to the API.
57
+ :param header_value: a header value to pass when making calls to
58
+ the API.
59
+ :param cookie: a cookie to include in the header when making calls
60
+ to the API
61
+ """
62
+
63
+ PRIMITIVE_TYPES = (float, bool, bytes, str, int)
64
+ NATIVE_TYPES_MAPPING = {
65
+ 'int': int,
66
+ 'long': int, # TODO remove as only py3 is supported?
67
+ 'float': float,
68
+ 'str': str,
69
+ 'bool': bool,
70
+ 'date': datetime.date,
71
+ 'datetime': datetime.datetime,
72
+ 'decimal': decimal.Decimal,
73
+ 'object': object,
74
+ }
75
+ _pool = None
76
+
77
+ def __init__(
78
+ self,
79
+ configuration=None,
80
+ header_name=None,
81
+ header_value=None,
82
+ cookie=None
83
+ ) -> None:
84
+ # use default configuration if none is provided
85
+ if configuration is None:
86
+ configuration = Configuration.get_default()
87
+ self.configuration = configuration
88
+
89
+ self.rest_client = rest.RESTClientObject(configuration)
90
+ self.default_headers = {}
91
+ if header_name is not None:
92
+ self.default_headers[header_name] = header_value
93
+ self.cookie = cookie
94
+ # Set default User-Agent.
95
+ self.user_agent = 'wink-sdk-python'
96
+ self.client_side_validation = configuration.client_side_validation
97
+
98
+ def __enter__(self):
99
+ return self
100
+
101
+ def __exit__(self, exc_type, exc_value, traceback):
102
+ pass
103
+
104
+ @property
105
+ def user_agent(self):
106
+ """User agent for this API client"""
107
+ return self.default_headers['User-Agent']
108
+
109
+ @user_agent.setter
110
+ def user_agent(self, value):
111
+ self.default_headers['User-Agent'] = value
112
+
113
+ def set_default_header(self, header_name, header_value):
114
+ self.default_headers[header_name] = header_value
115
+
116
+
117
+ _default = None
118
+
119
+ @classmethod
120
+ def get_default(cls):
121
+ """Return new instance of ApiClient.
122
+
123
+ This method returns newly created, based on default constructor,
124
+ object of ApiClient class or returns a copy of default
125
+ ApiClient.
126
+
127
+ :return: The ApiClient object.
128
+ """
129
+ if cls._default is None:
130
+ cls._default = ApiClient()
131
+ return cls._default
132
+
133
+ @classmethod
134
+ def set_default(cls, default):
135
+ """Set default instance of ApiClient.
136
+
137
+ It stores default ApiClient.
138
+
139
+ :param default: object of ApiClient.
140
+ """
141
+ cls._default = default
142
+
143
+ def param_serialize(
144
+ self,
145
+ method,
146
+ resource_path,
147
+ path_params=None,
148
+ query_params=None,
149
+ header_params=None,
150
+ body=None,
151
+ post_params=None,
152
+ files=None, auth_settings=None,
153
+ collection_formats=None,
154
+ _host=None,
155
+ _request_auth=None
156
+ ) -> RequestSerialized:
157
+
158
+ """Builds the HTTP request params needed by the request.
159
+ :param method: Method to call.
160
+ :param resource_path: Path to method endpoint.
161
+ :param path_params: Path parameters in the url.
162
+ :param query_params: Query parameters in the url.
163
+ :param header_params: Header parameters to be
164
+ placed in the request header.
165
+ :param body: Request body.
166
+ :param post_params dict: Request post form parameters,
167
+ for `application/x-www-form-urlencoded`, `multipart/form-data`.
168
+ :param auth_settings list: Auth Settings names for the request.
169
+ :param files dict: key -> filename, value -> filepath,
170
+ for `multipart/form-data`.
171
+ :param collection_formats: dict of collection formats for path, query,
172
+ header, and post parameters.
173
+ :param _request_auth: set to override the auth_settings for an a single
174
+ request; this effectively ignores the authentication
175
+ in the spec for a single request.
176
+ :return: tuple of form (path, http_method, query_params, header_params,
177
+ body, post_params, files)
178
+ """
179
+
180
+ config = self.configuration
181
+
182
+ # header parameters
183
+ header_params = header_params or {}
184
+ header_params.update(self.default_headers)
185
+ if self.cookie:
186
+ header_params['Cookie'] = self.cookie
187
+ if header_params:
188
+ header_params = self.sanitize_for_serialization(header_params)
189
+ header_params = dict(
190
+ self.parameters_to_tuples(header_params,collection_formats)
191
+ )
192
+
193
+ # path parameters
194
+ if path_params:
195
+ path_params = self.sanitize_for_serialization(path_params)
196
+ path_params = self.parameters_to_tuples(
197
+ path_params,
198
+ collection_formats
199
+ )
200
+ for k, v in path_params:
201
+ # specified safe chars, encode everything
202
+ resource_path = resource_path.replace(
203
+ '{%s}' % k,
204
+ quote(str(v), safe=config.safe_chars_for_path_param)
205
+ )
206
+
207
+ # post parameters
208
+ if post_params or files:
209
+ post_params = post_params if post_params else []
210
+ post_params = self.sanitize_for_serialization(post_params)
211
+ post_params = self.parameters_to_tuples(
212
+ post_params,
213
+ collection_formats
214
+ )
215
+ if files:
216
+ post_params.extend(self.files_parameters(files))
217
+
218
+ # auth setting
219
+ self.update_params_for_auth(
220
+ header_params,
221
+ query_params,
222
+ auth_settings,
223
+ resource_path,
224
+ method,
225
+ body,
226
+ request_auth=_request_auth
227
+ )
228
+
229
+ # body
230
+ if body:
231
+ body = self.sanitize_for_serialization(body)
232
+
233
+ # request url
234
+ if _host is None or self.configuration.ignore_operation_servers:
235
+ url = self.configuration.host + resource_path
236
+ else:
237
+ # use server/host defined in path or operation instead
238
+ url = _host + resource_path
239
+
240
+ # query parameters
241
+ if query_params:
242
+ query_params = self.sanitize_for_serialization(query_params)
243
+ url_query = self.parameters_to_url_query(
244
+ query_params,
245
+ collection_formats
246
+ )
247
+ url += "?" + url_query
248
+
249
+ return method, url, header_params, body, post_params
250
+
251
+
252
+ def call_api(
253
+ self,
254
+ method,
255
+ url,
256
+ header_params=None,
257
+ body=None,
258
+ post_params=None,
259
+ _request_timeout=None
260
+ ) -> rest.RESTResponse:
261
+ """Makes the HTTP request (synchronous)
262
+ :param method: Method to call.
263
+ :param url: Path to method endpoint.
264
+ :param header_params: Header parameters to be
265
+ placed in the request header.
266
+ :param body: Request body.
267
+ :param post_params dict: Request post form parameters,
268
+ for `application/x-www-form-urlencoded`, `multipart/form-data`.
269
+ :param _request_timeout: timeout setting for this request.
270
+ :return: RESTResponse
271
+ """
272
+
273
+ try:
274
+ # perform request and return response
275
+ response_data = self.rest_client.request(
276
+ method, url,
277
+ headers=header_params,
278
+ body=body, post_params=post_params,
279
+ _request_timeout=_request_timeout
280
+ )
281
+
282
+ except ApiException as e:
283
+ raise e
284
+
285
+ return response_data
286
+
287
+ def response_deserialize(
288
+ self,
289
+ response_data: rest.RESTResponse,
290
+ response_types_map: Optional[Dict[str, ApiResponseT]]=None
291
+ ) -> ApiResponse[ApiResponseT]:
292
+ """Deserializes response into an object.
293
+ :param response_data: RESTResponse object to be deserialized.
294
+ :param response_types_map: dict of response types.
295
+ :return: ApiResponse
296
+ """
297
+
298
+ msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
299
+ assert response_data.data is not None, msg
300
+
301
+ response_type = response_types_map.get(str(response_data.status), None)
302
+ if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599:
303
+ # if not found, look for '1XX', '2XX', etc.
304
+ response_type = response_types_map.get(str(response_data.status)[0] + "XX", None)
305
+
306
+ # deserialize response data
307
+ response_text = None
308
+ return_data = None
309
+ try:
310
+ if response_type == "bytearray":
311
+ return_data = response_data.data
312
+ elif response_type == "file":
313
+ return_data = self.__deserialize_file(response_data)
314
+ elif response_type is not None:
315
+ match = None
316
+ content_type = response_data.getheader('content-type')
317
+ if content_type is not None:
318
+ match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
319
+ encoding = match.group(1) if match else "utf-8"
320
+ response_text = response_data.data.decode(encoding)
321
+ return_data = self.deserialize(response_text, response_type, content_type)
322
+ finally:
323
+ if not 200 <= response_data.status <= 299:
324
+ raise ApiException.from_response(
325
+ http_resp=response_data,
326
+ body=response_text,
327
+ data=return_data,
328
+ )
329
+
330
+ return ApiResponse(
331
+ status_code = response_data.status,
332
+ data = return_data,
333
+ headers = response_data.getheaders(),
334
+ raw_data = response_data.data
335
+ )
336
+
337
+ def sanitize_for_serialization(self, obj):
338
+ """Builds a JSON POST object.
339
+
340
+ If obj is None, return None.
341
+ If obj is SecretStr, return obj.get_secret_value()
342
+ If obj is str, int, long, float, bool, return directly.
343
+ If obj is datetime.datetime, datetime.date
344
+ convert to string in iso8601 format.
345
+ If obj is decimal.Decimal return string representation.
346
+ If obj is list, sanitize each element in the list.
347
+ If obj is dict, return the dict.
348
+ If obj is OpenAPI model, return the properties dict.
349
+
350
+ :param obj: The data to serialize.
351
+ :return: The serialized form of data.
352
+ """
353
+ if obj is None:
354
+ return None
355
+ elif isinstance(obj, Enum):
356
+ return obj.value
357
+ elif isinstance(obj, SecretStr):
358
+ return obj.get_secret_value()
359
+ elif isinstance(obj, self.PRIMITIVE_TYPES):
360
+ return obj
361
+ elif isinstance(obj, uuid.UUID):
362
+ return str(obj)
363
+ elif isinstance(obj, list):
364
+ return [
365
+ self.sanitize_for_serialization(sub_obj) for sub_obj in obj
366
+ ]
367
+ elif isinstance(obj, tuple):
368
+ return tuple(
369
+ self.sanitize_for_serialization(sub_obj) for sub_obj in obj
370
+ )
371
+ elif isinstance(obj, (datetime.datetime, datetime.date)):
372
+ return obj.isoformat()
373
+ elif isinstance(obj, decimal.Decimal):
374
+ return str(obj)
375
+
376
+ elif isinstance(obj, dict):
377
+ obj_dict = obj
378
+ else:
379
+ # Convert model obj to dict except
380
+ # attributes `openapi_types`, `attribute_map`
381
+ # and attributes which value is not None.
382
+ # Convert attribute name to json key in
383
+ # model definition for request.
384
+ if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
385
+ obj_dict = obj.to_dict()
386
+ else:
387
+ obj_dict = obj.__dict__
388
+
389
+ if isinstance(obj_dict, list):
390
+ # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
391
+ return self.sanitize_for_serialization(obj_dict)
392
+
393
+ return {
394
+ key: self.sanitize_for_serialization(val)
395
+ for key, val in obj_dict.items()
396
+ }
397
+
398
+ def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
399
+ """Deserializes response into an object.
400
+
401
+ :param response: RESTResponse object to be deserialized.
402
+ :param response_type: class literal for
403
+ deserialized object, or string of class name.
404
+ :param content_type: content type of response.
405
+
406
+ :return: deserialized object.
407
+ """
408
+
409
+ # fetch data from response object
410
+ if content_type is None:
411
+ try:
412
+ data = json.loads(response_text)
413
+ except ValueError:
414
+ data = response_text
415
+ elif re.match(r'^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
416
+ if response_text == "":
417
+ data = ""
418
+ else:
419
+ data = json.loads(response_text)
420
+ elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE):
421
+ data = response_text
422
+ else:
423
+ raise ApiException(
424
+ status=0,
425
+ reason="Unsupported content type: {0}".format(content_type)
426
+ )
427
+
428
+ return self.__deserialize(data, response_type)
429
+
430
+ def __deserialize(self, data, klass):
431
+ """Deserializes dict, list, str into an object.
432
+
433
+ :param data: dict, list or str.
434
+ :param klass: class literal, or string of class name.
435
+
436
+ :return: object.
437
+ """
438
+ if data is None:
439
+ return None
440
+
441
+ if isinstance(klass, str):
442
+ if klass.startswith('List['):
443
+ m = re.match(r'List\[(.*)]', klass)
444
+ assert m is not None, "Malformed List type definition"
445
+ sub_kls = m.group(1)
446
+ return [self.__deserialize(sub_data, sub_kls)
447
+ for sub_data in data]
448
+
449
+ if klass.startswith('Dict['):
450
+ m = re.match(r'Dict\[([^,]*), (.*)]', klass)
451
+ assert m is not None, "Malformed Dict type definition"
452
+ sub_kls = m.group(2)
453
+ return {k: self.__deserialize(v, sub_kls)
454
+ for k, v in data.items()}
455
+
456
+ # convert str to class
457
+ if klass in self.NATIVE_TYPES_MAPPING:
458
+ klass = self.NATIVE_TYPES_MAPPING[klass]
459
+ else:
460
+ klass = getattr(wink_sdk_travel_agent.models, klass)
461
+
462
+ if klass in self.PRIMITIVE_TYPES:
463
+ return self.__deserialize_primitive(data, klass)
464
+ elif klass is object:
465
+ return self.__deserialize_object(data)
466
+ elif klass is datetime.date:
467
+ return self.__deserialize_date(data)
468
+ elif klass is datetime.datetime:
469
+ return self.__deserialize_datetime(data)
470
+ elif klass is decimal.Decimal:
471
+ return decimal.Decimal(data)
472
+ elif issubclass(klass, Enum):
473
+ return self.__deserialize_enum(data, klass)
474
+ else:
475
+ return self.__deserialize_model(data, klass)
476
+
477
+ def parameters_to_tuples(self, params, collection_formats):
478
+ """Get parameters as list of tuples, formatting collections.
479
+
480
+ :param params: Parameters as dict or list of two-tuples
481
+ :param dict collection_formats: Parameter collection formats
482
+ :return: Parameters as list of tuples, collections formatted
483
+ """
484
+ new_params: List[Tuple[str, str]] = []
485
+ if collection_formats is None:
486
+ collection_formats = {}
487
+ for k, v in params.items() if isinstance(params, dict) else params:
488
+ if k in collection_formats:
489
+ collection_format = collection_formats[k]
490
+ if collection_format == 'multi':
491
+ new_params.extend((k, value) for value in v)
492
+ else:
493
+ if collection_format == 'ssv':
494
+ delimiter = ' '
495
+ elif collection_format == 'tsv':
496
+ delimiter = '\t'
497
+ elif collection_format == 'pipes':
498
+ delimiter = '|'
499
+ else: # csv is the default
500
+ delimiter = ','
501
+ new_params.append(
502
+ (k, delimiter.join(str(value) for value in v)))
503
+ else:
504
+ new_params.append((k, v))
505
+ return new_params
506
+
507
+ def parameters_to_url_query(self, params, collection_formats):
508
+ """Get parameters as list of tuples, formatting collections.
509
+
510
+ :param params: Parameters as dict or list of two-tuples
511
+ :param dict collection_formats: Parameter collection formats
512
+ :return: URL query string (e.g. a=Hello%20World&b=123)
513
+ """
514
+ new_params: List[Tuple[str, str]] = []
515
+ if collection_formats is None:
516
+ collection_formats = {}
517
+ for k, v in params.items() if isinstance(params, dict) else params:
518
+ if isinstance(v, bool):
519
+ v = str(v).lower()
520
+ if isinstance(v, (int, float)):
521
+ v = str(v)
522
+ if isinstance(v, dict):
523
+ v = json.dumps(v)
524
+
525
+ if k in collection_formats:
526
+ collection_format = collection_formats[k]
527
+ if collection_format == 'multi':
528
+ new_params.extend((k, quote(str(value))) for value in v)
529
+ else:
530
+ if collection_format == 'ssv':
531
+ delimiter = ' '
532
+ elif collection_format == 'tsv':
533
+ delimiter = '\t'
534
+ elif collection_format == 'pipes':
535
+ delimiter = '|'
536
+ else: # csv is the default
537
+ delimiter = ','
538
+ new_params.append(
539
+ (k, delimiter.join(quote(str(value)) for value in v))
540
+ )
541
+ else:
542
+ new_params.append((k, quote(str(v))))
543
+
544
+ return "&".join(["=".join(map(str, item)) for item in new_params])
545
+
546
+ def files_parameters(
547
+ self,
548
+ files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
549
+ ):
550
+ """Builds form parameters.
551
+
552
+ :param files: File parameters.
553
+ :return: Form parameters with files.
554
+ """
555
+ params = []
556
+ for k, v in files.items():
557
+ if isinstance(v, str):
558
+ with open(v, 'rb') as f:
559
+ filename = os.path.basename(f.name)
560
+ filedata = f.read()
561
+ elif isinstance(v, bytes):
562
+ filename = k
563
+ filedata = v
564
+ elif isinstance(v, tuple):
565
+ filename, filedata = v
566
+ elif isinstance(v, list):
567
+ for file_param in v:
568
+ params.extend(self.files_parameters({k: file_param}))
569
+ continue
570
+ else:
571
+ raise ValueError("Unsupported file value")
572
+ mimetype = (
573
+ mimetypes.guess_type(filename)[0]
574
+ or 'application/octet-stream'
575
+ )
576
+ params.append(
577
+ tuple([k, tuple([filename, filedata, mimetype])])
578
+ )
579
+ return params
580
+
581
+ def select_header_accept(self, accepts: List[str]) -> Optional[str]:
582
+ """Returns `Accept` based on an array of accepts provided.
583
+
584
+ :param accepts: List of headers.
585
+ :return: Accept (e.g. application/json).
586
+ """
587
+ if not accepts:
588
+ return None
589
+
590
+ for accept in accepts:
591
+ if re.search('json', accept, re.IGNORECASE):
592
+ return accept
593
+
594
+ return accepts[0]
595
+
596
+ def select_header_content_type(self, content_types):
597
+ """Returns `Content-Type` based on an array of content_types provided.
598
+
599
+ :param content_types: List of content-types.
600
+ :return: Content-Type (e.g. application/json).
601
+ """
602
+ if not content_types:
603
+ return None
604
+
605
+ for content_type in content_types:
606
+ if re.search('json', content_type, re.IGNORECASE):
607
+ return content_type
608
+
609
+ return content_types[0]
610
+
611
+ def update_params_for_auth(
612
+ self,
613
+ headers,
614
+ queries,
615
+ auth_settings,
616
+ resource_path,
617
+ method,
618
+ body,
619
+ request_auth=None
620
+ ) -> None:
621
+ """Updates header and query params based on authentication setting.
622
+
623
+ :param headers: Header parameters dict to be updated.
624
+ :param queries: Query parameters tuple list to be updated.
625
+ :param auth_settings: Authentication setting identifiers list.
626
+ :resource_path: A string representation of the HTTP request resource path.
627
+ :method: A string representation of the HTTP request method.
628
+ :body: A object representing the body of the HTTP request.
629
+ The object type is the return value of sanitize_for_serialization().
630
+ :param request_auth: if set, the provided settings will
631
+ override the token in the configuration.
632
+ """
633
+ if not auth_settings:
634
+ return
635
+
636
+ if request_auth:
637
+ self._apply_auth_params(
638
+ headers,
639
+ queries,
640
+ resource_path,
641
+ method,
642
+ body,
643
+ request_auth
644
+ )
645
+ else:
646
+ for auth in auth_settings:
647
+ auth_setting = self.configuration.auth_settings().get(auth)
648
+ if auth_setting:
649
+ self._apply_auth_params(
650
+ headers,
651
+ queries,
652
+ resource_path,
653
+ method,
654
+ body,
655
+ auth_setting
656
+ )
657
+
658
+ def _apply_auth_params(
659
+ self,
660
+ headers,
661
+ queries,
662
+ resource_path,
663
+ method,
664
+ body,
665
+ auth_setting
666
+ ) -> None:
667
+ """Updates the request parameters based on a single auth_setting
668
+
669
+ :param headers: Header parameters dict to be updated.
670
+ :param queries: Query parameters tuple list to be updated.
671
+ :resource_path: A string representation of the HTTP request resource path.
672
+ :method: A string representation of the HTTP request method.
673
+ :body: A object representing the body of the HTTP request.
674
+ The object type is the return value of sanitize_for_serialization().
675
+ :param auth_setting: auth settings for the endpoint
676
+ """
677
+ if auth_setting['in'] == 'cookie':
678
+ headers['Cookie'] = auth_setting['value']
679
+ elif auth_setting['in'] == 'header':
680
+ if auth_setting['type'] != 'http-signature':
681
+ headers[auth_setting['key']] = auth_setting['value']
682
+ elif auth_setting['in'] == 'query':
683
+ queries.append((auth_setting['key'], auth_setting['value']))
684
+ else:
685
+ raise ApiValueError(
686
+ 'Authentication token must be in `query` or `header`'
687
+ )
688
+
689
+ def __deserialize_file(self, response):
690
+ """Deserializes body to file
691
+
692
+ Saves response body into a file in a temporary folder,
693
+ using the filename from the `Content-Disposition` header if provided.
694
+
695
+ handle file downloading
696
+ save response body into a tmp file and return the instance
697
+
698
+ :param response: RESTResponse.
699
+ :return: file path.
700
+ """
701
+ fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
702
+ os.close(fd)
703
+ os.remove(path)
704
+
705
+ content_disposition = response.getheader("Content-Disposition")
706
+ if content_disposition:
707
+ m = re.search(
708
+ r'filename=[\'"]?([^\'"\s]+)[\'"]?',
709
+ content_disposition
710
+ )
711
+ assert m is not None, "Unexpected 'content-disposition' header value"
712
+ filename = m.group(1)
713
+ path = os.path.join(os.path.dirname(path), filename)
714
+
715
+ with open(path, "wb") as f:
716
+ f.write(response.data)
717
+
718
+ return path
719
+
720
+ def __deserialize_primitive(self, data, klass):
721
+ """Deserializes string to primitive type.
722
+
723
+ :param data: str.
724
+ :param klass: class literal.
725
+
726
+ :return: int, long, float, str, bool.
727
+ """
728
+ try:
729
+ return klass(data)
730
+ except UnicodeEncodeError:
731
+ return str(data)
732
+ except TypeError:
733
+ return data
734
+
735
+ def __deserialize_object(self, value):
736
+ """Return an original value.
737
+
738
+ :return: object.
739
+ """
740
+ return value
741
+
742
+ def __deserialize_date(self, string):
743
+ """Deserializes string to date.
744
+
745
+ :param string: str.
746
+ :return: date.
747
+ """
748
+ try:
749
+ return parse(string).date()
750
+ except ImportError:
751
+ return string
752
+ except ValueError:
753
+ raise rest.ApiException(
754
+ status=0,
755
+ reason="Failed to parse `{0}` as date object".format(string)
756
+ )
757
+
758
+ def __deserialize_datetime(self, string):
759
+ """Deserializes string to datetime.
760
+
761
+ The string should be in iso8601 datetime format.
762
+
763
+ :param string: str.
764
+ :return: datetime.
765
+ """
766
+ try:
767
+ return parse(string)
768
+ except ImportError:
769
+ return string
770
+ except ValueError:
771
+ raise rest.ApiException(
772
+ status=0,
773
+ reason=(
774
+ "Failed to parse `{0}` as datetime object"
775
+ .format(string)
776
+ )
777
+ )
778
+
779
+ def __deserialize_enum(self, data, klass):
780
+ """Deserializes primitive type to enum.
781
+
782
+ :param data: primitive type.
783
+ :param klass: class literal.
784
+ :return: enum value.
785
+ """
786
+ try:
787
+ return klass(data)
788
+ except ValueError:
789
+ raise rest.ApiException(
790
+ status=0,
791
+ reason=(
792
+ "Failed to parse `{0}` as `{1}`"
793
+ .format(data, klass)
794
+ )
795
+ )
796
+
797
+ def __deserialize_model(self, data, klass):
798
+ """Deserializes list or dict to model.
799
+
800
+ :param data: dict, list.
801
+ :param klass: class literal.
802
+ :return: model object.
803
+ """
804
+
805
+ return klass.from_dict(data)