wink-sdk-travel-agent 0.0.3__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.

Potentially problematic release.


This version of wink-sdk-travel-agent might be problematic. Click here for more details.

Files changed (110) hide show
  1. wink_sdk_travel_agent/__init__.py +129 -0
  2. wink_sdk_travel_agent/api/__init__.py +5 -0
  3. wink_sdk_travel_agent/api/travel_agent_api.py +1985 -0
  4. wink_sdk_travel_agent/api_client.py +798 -0
  5. wink_sdk_travel_agent/api_response.py +21 -0
  6. wink_sdk_travel_agent/configuration.py +459 -0
  7. wink_sdk_travel_agent/exceptions.py +200 -0
  8. wink_sdk_travel_agent/models/__init__.py +112 -0
  9. wink_sdk_travel_agent/models/address_agent.py +110 -0
  10. wink_sdk_travel_agent/models/agent_booking_request_agent.py +145 -0
  11. wink_sdk_travel_agent/models/aggregate_descriptor_agent.py +100 -0
  12. wink_sdk_travel_agent/models/ancillary_request_agent.py +111 -0
  13. wink_sdk_travel_agent/models/authenticated_user_agent.py +98 -0
  14. wink_sdk_travel_agent/models/bed_agent.py +91 -0
  15. wink_sdk_travel_agent/models/bedroom_agent.py +105 -0
  16. wink_sdk_travel_agent/models/bedroom_configuration_agent.py +100 -0
  17. wink_sdk_travel_agent/models/beneficiary_agent.py +162 -0
  18. wink_sdk_travel_agent/models/beneficiary_charge_agent.py +97 -0
  19. wink_sdk_travel_agent/models/booking_agent.py +378 -0
  20. wink_sdk_travel_agent/models/booking_ancillary_agent.py +153 -0
  21. wink_sdk_travel_agent/models/booking_confirmations_agent.py +109 -0
  22. wink_sdk_travel_agent/models/booking_contract_agent.py +592 -0
  23. wink_sdk_travel_agent/models/booking_contract_item_agent.py +214 -0
  24. wink_sdk_travel_agent/models/booking_contract_payment_details_agent.py +131 -0
  25. wink_sdk_travel_agent/models/booking_itinerary_agent.py +113 -0
  26. wink_sdk_travel_agent/models/booking_itinerary_room_configuration_agent.py +98 -0
  27. wink_sdk_travel_agent/models/booking_itinerary_room_configuration_child_agent.py +90 -0
  28. wink_sdk_travel_agent/models/booking_user_agent.py +100 -0
  29. wink_sdk_travel_agent/models/booking_user_request_agent.py +96 -0
  30. wink_sdk_travel_agent/models/booking_user_session_agent.py +112 -0
  31. wink_sdk_travel_agent/models/booking_view_agent.py +101 -0
  32. wink_sdk_travel_agent/models/boolean_response_agent.py +90 -0
  33. wink_sdk_travel_agent/models/cancellation_detail_agent.py +97 -0
  34. wink_sdk_travel_agent/models/cancellation_policy_agent.py +166 -0
  35. wink_sdk_travel_agent/models/cancellation_policy_exception_agent.py +99 -0
  36. wink_sdk_travel_agent/models/cancellation_policy_exceptions_agent.py +96 -0
  37. wink_sdk_travel_agent/models/child_agent.py +91 -0
  38. wink_sdk_travel_agent/models/commissionable_entry_agent.py +101 -0
  39. wink_sdk_travel_agent/models/company_agent.py +160 -0
  40. wink_sdk_travel_agent/models/company_user_agent.py +114 -0
  41. wink_sdk_travel_agent/models/company_view_agent.py +101 -0
  42. wink_sdk_travel_agent/models/composite_filter_descriptor_agent.py +108 -0
  43. wink_sdk_travel_agent/models/contact_agent.py +104 -0
  44. wink_sdk_travel_agent/models/country_agent.py +100 -0
  45. wink_sdk_travel_agent/models/create_agent_booking400_response.py +141 -0
  46. wink_sdk_travel_agent/models/create_agent_booking_request_agent.py +104 -0
  47. wink_sdk_travel_agent/models/custom_monetary_amount.py +90 -0
  48. wink_sdk_travel_agent/models/daily_rate_agent.py +115 -0
  49. wink_sdk_travel_agent/models/dow_pattern_group_agent.py +102 -0
  50. wink_sdk_travel_agent/models/engine_configuration_booking_report_agent.py +192 -0
  51. wink_sdk_travel_agent/models/engine_configuration_theme_agent.py +108 -0
  52. wink_sdk_travel_agent/models/extra_charge_agent.py +103 -0
  53. wink_sdk_travel_agent/models/extra_charges_agent.py +112 -0
  54. wink_sdk_travel_agent/models/fee_agent.py +105 -0
  55. wink_sdk_travel_agent/models/filter_descriptor_agent.py +101 -0
  56. wink_sdk_travel_agent/models/general_manager_agent.py +104 -0
  57. wink_sdk_travel_agent/models/generic_error_message.py +96 -0
  58. wink_sdk_travel_agent/models/geo_json_point_agent.py +94 -0
  59. wink_sdk_travel_agent/models/geo_name_agent.py +136 -0
  60. wink_sdk_travel_agent/models/group_descriptor_agent.py +110 -0
  61. wink_sdk_travel_agent/models/guest_room_agent.py +258 -0
  62. wink_sdk_travel_agent/models/guest_user_agent.py +106 -0
  63. wink_sdk_travel_agent/models/hotel_on_map_agent.py +272 -0
  64. wink_sdk_travel_agent/models/image_attribution_agent.py +90 -0
  65. wink_sdk_travel_agent/models/localized_description_agent.py +91 -0
  66. wink_sdk_travel_agent/models/localized_price_agent.py +162 -0
  67. wink_sdk_travel_agent/models/page_booking_view_agent.py +128 -0
  68. wink_sdk_travel_agent/models/pageable_object_agent.py +106 -0
  69. wink_sdk_travel_agent/models/payout_agent.py +152 -0
  70. wink_sdk_travel_agent/models/payout_fee_agent.py +114 -0
  71. wink_sdk_travel_agent/models/pending_refund_agent.py +99 -0
  72. wink_sdk_travel_agent/models/personal_agent.py +155 -0
  73. wink_sdk_travel_agent/models/pet_info_dto_agent.py +90 -0
  74. wink_sdk_travel_agent/models/preferences_agent.py +128 -0
  75. wink_sdk_travel_agent/models/profile_agent.py +110 -0
  76. wink_sdk_travel_agent/models/profile_user_agent.py +100 -0
  77. wink_sdk_travel_agent/models/property_policy_agent.py +149 -0
  78. wink_sdk_travel_agent/models/quote_agent.py +94 -0
  79. wink_sdk_travel_agent/models/rate_plan_agent.py +172 -0
  80. wink_sdk_travel_agent/models/rate_plan_level_fee_agent.py +111 -0
  81. wink_sdk_travel_agent/models/refund_agent.py +166 -0
  82. wink_sdk_travel_agent/models/reporting_ancillary_agent.py +108 -0
  83. wink_sdk_travel_agent/models/reporting_daily_rate_agent.py +99 -0
  84. wink_sdk_travel_agent/models/reporting_extra_charge_agent.py +98 -0
  85. wink_sdk_travel_agent/models/review_agent.py +133 -0
  86. wink_sdk_travel_agent/models/review_answer_agent.py +101 -0
  87. wink_sdk_travel_agent/models/review_user_agent.py +98 -0
  88. wink_sdk_travel_agent/models/room_configuration_agent.py +99 -0
  89. wink_sdk_travel_agent/models/room_stay_agent.py +184 -0
  90. wink_sdk_travel_agent/models/simple_date_time_itinerary_agent.py +108 -0
  91. wink_sdk_travel_agent/models/simple_description_agent.py +93 -0
  92. wink_sdk_travel_agent/models/simple_multimedia_agent.py +154 -0
  93. wink_sdk_travel_agent/models/social_agent.py +102 -0
  94. wink_sdk_travel_agent/models/sort_descriptor_agent.py +100 -0
  95. wink_sdk_travel_agent/models/sort_object.py +96 -0
  96. wink_sdk_travel_agent/models/state_agent.py +117 -0
  97. wink_sdk_travel_agent/models/stay_rate_agent.py +209 -0
  98. wink_sdk_travel_agent/models/sub_country_agent.py +92 -0
  99. wink_sdk_travel_agent/models/sub_sub_country_agent.py +92 -0
  100. wink_sdk_travel_agent/models/supplier_contract_item_policy_agent.py +170 -0
  101. wink_sdk_travel_agent/models/travel_agent_agent.py +90 -0
  102. wink_sdk_travel_agent/models/travel_inventory_recognition_agent.py +120 -0
  103. wink_sdk_travel_agent/models/upsert_travel_agent_request_agent.py +90 -0
  104. wink_sdk_travel_agent/py.typed +0 -0
  105. wink_sdk_travel_agent/rest.py +258 -0
  106. wink_sdk_travel_agent-0.0.3.dist-info/LICENSE +201 -0
  107. wink_sdk_travel_agent-0.0.3.dist-info/METADATA +17 -0
  108. wink_sdk_travel_agent-0.0.3.dist-info/RECORD +110 -0
  109. wink_sdk_travel_agent-0.0.3.dist-info/WHEEL +5 -0
  110. wink_sdk_travel_agent-0.0.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,459 @@
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 blocking on the Wink platform. The API gives you all the tools you need to ready your properties and blocking for sale across 1000s of our native sales channels. Integrators, affiliates, travel agents and content creators have the ability search for your travel blocking 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 blocking and get that same blocking 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 blocking and either book it or use it to advertise through one of their Wink affiliate accounts. - [Configuration](/engine-client): A single endpoint to retrieve whitelabel + customization information for the booking engine. - [Lookup](/lookup): All APIs related to locating blocking by region, locale and property flags. - [Inventory](/blocking): All APIs related to retrieve known travel blocking 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 blocking. #### 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 blocking 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 blocking to sell. - [Inventory](/affiliate/blocking): The Inventory API exposes endpoints for affiliates to manage the blocking 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 blocking and need taxonomies of standard and non-standard codes for blocking types, classes, statuses etc. - [Reference](/reactive): 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 blocking. This can be done via the API as a registered Travel Agent or using our API in conjunction with our PCI compliant reactive widget for all other entities. - [TripPay](/reactive): 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.7.10
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 copy
17
+ import logging
18
+ from logging import FileHandler
19
+ import multiprocessing
20
+ import sys
21
+ from typing import Optional
22
+ import urllib3
23
+
24
+ import http.client as httplib
25
+
26
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
27
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
28
+ 'minimum', 'exclusiveMinimum', 'maxLength',
29
+ 'minLength', 'pattern', 'maxItems', 'minItems'
30
+ }
31
+
32
+ class Configuration:
33
+ """This class contains various settings of the API client.
34
+
35
+ :param host: Base url.
36
+ :param ignore_operation_servers
37
+ Boolean to ignore operation servers for the API client.
38
+ Config will use `host` as the base url regardless of the operation servers.
39
+ :param api_key: Dict to store API key(s).
40
+ Each entry in the dict specifies an API key.
41
+ The dict key is the name of the security scheme in the OAS specification.
42
+ The dict value is the API key secret.
43
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
44
+ The dict key is the name of the security scheme in the OAS specification.
45
+ The dict value is an API key prefix when generating the auth data.
46
+ :param username: Username for HTTP basic authentication.
47
+ :param password: Password for HTTP basic authentication.
48
+ :param access_token: Access token.
49
+ :param server_index: Index to servers configuration.
50
+ :param server_variables: Mapping with string values to replace variables in
51
+ templated server configuration. The validation of enums is performed for
52
+ variables with defined enum values before.
53
+ :param server_operation_index: Mapping from operation ID to an index to server
54
+ configuration.
55
+ :param server_operation_variables: Mapping from operation ID to a mapping with
56
+ string values to replace variables in templated server configuration.
57
+ The validation of enums is performed for variables with defined enum
58
+ values before.
59
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
60
+ in PEM format.
61
+ :param retries: Number of retries for API requests.
62
+
63
+ :Example:
64
+ """
65
+
66
+ _default = None
67
+
68
+ def __init__(self, host=None,
69
+ api_key=None, api_key_prefix=None,
70
+ username=None, password=None,
71
+ access_token=None,
72
+ server_index=None, server_variables=None,
73
+ server_operation_index=None, server_operation_variables=None,
74
+ ignore_operation_servers=False,
75
+ ssl_ca_cert=None,
76
+ retries=None,
77
+ *,
78
+ debug: Optional[bool] = None
79
+ ) -> None:
80
+ """Constructor
81
+ """
82
+ self._base_path = "https://api.wink.travel" if host is None else host
83
+ """Default Base url
84
+ """
85
+ self.server_index = 0 if server_index is None and host is None else server_index
86
+ self.server_operation_index = server_operation_index or {}
87
+ """Default server index
88
+ """
89
+ self.server_variables = server_variables or {}
90
+ self.server_operation_variables = server_operation_variables or {}
91
+ """Default server variables
92
+ """
93
+ self.ignore_operation_servers = ignore_operation_servers
94
+ """Ignore operation servers
95
+ """
96
+ self.temp_folder_path = None
97
+ """Temp file folder for downloading files
98
+ """
99
+ # Authentication Settings
100
+ self.api_key = {}
101
+ if api_key:
102
+ self.api_key = api_key
103
+ """dict to store API key(s)
104
+ """
105
+ self.api_key_prefix = {}
106
+ if api_key_prefix:
107
+ self.api_key_prefix = api_key_prefix
108
+ """dict to store API prefix (e.g. Bearer)
109
+ """
110
+ self.refresh_api_key_hook = None
111
+ """function hook to refresh API key if expired
112
+ """
113
+ self.username = username
114
+ """Username for HTTP basic authentication
115
+ """
116
+ self.password = password
117
+ """Password for HTTP basic authentication
118
+ """
119
+ self.access_token = access_token
120
+ """Access token
121
+ """
122
+ self.logger = {}
123
+ """Logging Settings
124
+ """
125
+ self.logger["package_logger"] = logging.getLogger("wink_sdk_travel_agent")
126
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
127
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
128
+ """Log format
129
+ """
130
+ self.logger_stream_handler = None
131
+ """Log stream handler
132
+ """
133
+ self.logger_file_handler: Optional[FileHandler] = None
134
+ """Log file handler
135
+ """
136
+ self.logger_file = None
137
+ """Debug file location
138
+ """
139
+ if debug is not None:
140
+ self.debug = debug
141
+ else:
142
+ self.__debug = False
143
+ """Debug switch
144
+ """
145
+
146
+ self.verify_ssl = True
147
+ """SSL/TLS verification
148
+ Set this to false to skip verifying SSL certificate when calling API
149
+ from https server.
150
+ """
151
+ self.ssl_ca_cert = ssl_ca_cert
152
+ """Set this to customize the certificate file to verify the peer.
153
+ """
154
+ self.cert_file = None
155
+ """client certificate file
156
+ """
157
+ self.key_file = None
158
+ """client key file
159
+ """
160
+ self.assert_hostname = None
161
+ """Set this to True/False to enable/disable SSL hostname verification.
162
+ """
163
+ self.tls_server_name = None
164
+ """SSL/TLS Server Name Indication (SNI)
165
+ Set this to the SNI value expected by the server.
166
+ """
167
+
168
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
169
+ """urllib3 connection pool's maximum number of connections saved
170
+ per pool. urllib3 uses 1 connection as default value, but this is
171
+ not the best value when you are making a lot of possibly parallel
172
+ requests to the same host, which is often the case here.
173
+ cpu_count * 5 is used as default value to increase performance.
174
+ """
175
+
176
+ self.proxy: Optional[str] = None
177
+ """Proxy URL
178
+ """
179
+ self.proxy_headers = None
180
+ """Proxy headers
181
+ """
182
+ self.safe_chars_for_path_param = ''
183
+ """Safe chars for path_param
184
+ """
185
+ self.retries = retries
186
+ """Adding retries to override urllib3 default value 3
187
+ """
188
+ # Enable client side validation
189
+ self.client_side_validation = True
190
+
191
+ self.socket_options = None
192
+ """Options to pass down to the underlying urllib3 socket
193
+ """
194
+
195
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
196
+ """datetime format
197
+ """
198
+
199
+ self.date_format = "%Y-%m-%d"
200
+ """date format
201
+ """
202
+
203
+ def __deepcopy__(self, memo):
204
+ cls = self.__class__
205
+ result = cls.__new__(cls)
206
+ memo[id(self)] = result
207
+ for k, v in self.__dict__.items():
208
+ if k not in ('logger', 'logger_file_handler'):
209
+ setattr(result, k, copy.deepcopy(v, memo))
210
+ # shallow copy of loggers
211
+ result.logger = copy.copy(self.logger)
212
+ # use setters to configure loggers
213
+ result.logger_file = self.logger_file
214
+ result.debug = self.debug
215
+ return result
216
+
217
+ def __setattr__(self, name, value):
218
+ object.__setattr__(self, name, value)
219
+
220
+ @classmethod
221
+ def set_default(cls, default):
222
+ """Set default instance of configuration.
223
+
224
+ It stores default configuration, which can be
225
+ returned by get_default_copy method.
226
+
227
+ :param default: object of Configuration
228
+ """
229
+ cls._default = default
230
+
231
+ @classmethod
232
+ def get_default_copy(cls):
233
+ """Deprecated. Please use `get_default` instead.
234
+
235
+ Deprecated. Please use `get_default` instead.
236
+
237
+ :return: The configuration object.
238
+ """
239
+ return cls.get_default()
240
+
241
+ @classmethod
242
+ def get_default(cls):
243
+ """Return the default configuration.
244
+
245
+ This method returns newly created, based on default constructor,
246
+ object of Configuration class or returns a copy of default
247
+ configuration.
248
+
249
+ :return: The configuration object.
250
+ """
251
+ if cls._default is None:
252
+ cls._default = Configuration()
253
+ return cls._default
254
+
255
+ @property
256
+ def logger_file(self):
257
+ """The logger file.
258
+
259
+ If the logger_file is None, then add stream handler and remove file
260
+ handler. Otherwise, add file handler and remove stream handler.
261
+
262
+ :param value: The logger_file path.
263
+ :type: str
264
+ """
265
+ return self.__logger_file
266
+
267
+ @logger_file.setter
268
+ def logger_file(self, value):
269
+ """The logger file.
270
+
271
+ If the logger_file is None, then add stream handler and remove file
272
+ handler. Otherwise, add file handler and remove stream handler.
273
+
274
+ :param value: The logger_file path.
275
+ :type: str
276
+ """
277
+ self.__logger_file = value
278
+ if self.__logger_file:
279
+ # If set logging file,
280
+ # then add file handler and remove stream handler.
281
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
282
+ self.logger_file_handler.setFormatter(self.logger_formatter)
283
+ for _, logger in self.logger.items():
284
+ logger.addHandler(self.logger_file_handler)
285
+
286
+ @property
287
+ def debug(self):
288
+ """Debug status
289
+
290
+ :param value: The debug status, True or False.
291
+ :type: bool
292
+ """
293
+ return self.__debug
294
+
295
+ @debug.setter
296
+ def debug(self, value):
297
+ """Debug status
298
+
299
+ :param value: The debug status, True or False.
300
+ :type: bool
301
+ """
302
+ self.__debug = value
303
+ if self.__debug:
304
+ # if debug status is True, turn on debug logging
305
+ for _, logger in self.logger.items():
306
+ logger.setLevel(logging.DEBUG)
307
+ # turn on httplib debug
308
+ httplib.HTTPConnection.debuglevel = 1
309
+ else:
310
+ # if debug status is False, turn off debug logging,
311
+ # setting log level to default `logging.WARNING`
312
+ for _, logger in self.logger.items():
313
+ logger.setLevel(logging.WARNING)
314
+ # turn off httplib debug
315
+ httplib.HTTPConnection.debuglevel = 0
316
+
317
+ @property
318
+ def logger_format(self):
319
+ """The logger format.
320
+
321
+ The logger_formatter will be updated when sets logger_format.
322
+
323
+ :param value: The format string.
324
+ :type: str
325
+ """
326
+ return self.__logger_format
327
+
328
+ @logger_format.setter
329
+ def logger_format(self, value):
330
+ """The logger format.
331
+
332
+ The logger_formatter will be updated when sets logger_format.
333
+
334
+ :param value: The format string.
335
+ :type: str
336
+ """
337
+ self.__logger_format = value
338
+ self.logger_formatter = logging.Formatter(self.__logger_format)
339
+
340
+ def get_api_key_with_prefix(self, identifier, alias=None):
341
+ """Gets API key (with prefix if set).
342
+
343
+ :param identifier: The identifier of apiKey.
344
+ :param alias: The alternative identifier of apiKey.
345
+ :return: The token for api key authentication.
346
+ """
347
+ if self.refresh_api_key_hook is not None:
348
+ self.refresh_api_key_hook(self)
349
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
350
+ if key:
351
+ prefix = self.api_key_prefix.get(identifier)
352
+ if prefix:
353
+ return "%s %s" % (prefix, key)
354
+ else:
355
+ return key
356
+
357
+ def get_basic_auth_token(self):
358
+ """Gets HTTP basic authentication header (string).
359
+
360
+ :return: The token for basic HTTP authentication.
361
+ """
362
+ username = ""
363
+ if self.username is not None:
364
+ username = self.username
365
+ password = ""
366
+ if self.password is not None:
367
+ password = self.password
368
+ return urllib3.util.make_headers(
369
+ basic_auth=username + ':' + password
370
+ ).get('authorization')
371
+
372
+ def auth_settings(self):
373
+ """Gets Auth Settings dict for api client.
374
+
375
+ :return: The Auth Settings information dict.
376
+ """
377
+ auth = {}
378
+ if self.access_token is not None:
379
+ auth['oauth2ClientCredentials'] = {
380
+ 'type': 'oauth2',
381
+ 'in': 'header',
382
+ 'key': 'Authorization',
383
+ 'value': 'Bearer ' + self.access_token
384
+ }
385
+ return auth
386
+
387
+ def to_debug_report(self):
388
+ """Gets the essential information for debugging.
389
+
390
+ :return: The report for debugging.
391
+ """
392
+ return "Python SDK Debug Report:\n"\
393
+ "OS: {env}\n"\
394
+ "Python Version: {pyversion}\n"\
395
+ "Version of the API: 30.7.10\n"\
396
+ "SDK Package Version: 0.0.3".\
397
+ format(env=sys.platform, pyversion=sys.version)
398
+
399
+ def get_host_settings(self):
400
+ """Gets an array of host settings
401
+
402
+ :return: An array of host settings
403
+ """
404
+ return [
405
+ {
406
+ 'url': "https://api.wink.travel",
407
+ 'description': "Endpoint",
408
+ }
409
+ ]
410
+
411
+ def get_host_from_settings(self, index, variables=None, servers=None):
412
+ """Gets host URL based on the index and variables
413
+ :param index: array index of the host settings
414
+ :param variables: hash of variable and the corresponding value
415
+ :param servers: an array of host settings or None
416
+ :return: URL based on host settings
417
+ """
418
+ if index is None:
419
+ return self._base_path
420
+
421
+ variables = {} if variables is None else variables
422
+ servers = self.get_host_settings() if servers is None else servers
423
+
424
+ try:
425
+ server = servers[index]
426
+ except IndexError:
427
+ raise ValueError(
428
+ "Invalid index {0} when selecting the host settings. "
429
+ "Must be less than {1}".format(index, len(servers)))
430
+
431
+ url = server['url']
432
+
433
+ # go through variables and replace placeholders
434
+ for variable_name, variable in server.get('variables', {}).items():
435
+ used_value = variables.get(
436
+ variable_name, variable['default_value'])
437
+
438
+ if 'enum_values' in variable \
439
+ and used_value not in variable['enum_values']:
440
+ raise ValueError(
441
+ "The variable `{0}` in the host URL has invalid value "
442
+ "{1}. Must be {2}.".format(
443
+ variable_name, variables[variable_name],
444
+ variable['enum_values']))
445
+
446
+ url = url.replace("{" + variable_name + "}", used_value)
447
+
448
+ return url
449
+
450
+ @property
451
+ def host(self):
452
+ """Return generated host."""
453
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
454
+
455
+ @host.setter
456
+ def host(self, value):
457
+ """Fix base path."""
458
+ self._base_path = value
459
+ self.server_index = None