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.
- wink_sdk_travel_agent/__init__.py +229 -0
- wink_sdk_travel_agent/api/__init__.py +6 -0
- wink_sdk_travel_agent/api/analytics_api.py +671 -0
- wink_sdk_travel_agent/api/travel_agent_api.py +1668 -0
- wink_sdk_travel_agent/api_client.py +805 -0
- wink_sdk_travel_agent/api_response.py +21 -0
- wink_sdk_travel_agent/configuration.py +582 -0
- wink_sdk_travel_agent/exceptions.py +217 -0
- wink_sdk_travel_agent/models/__init__.py +106 -0
- wink_sdk_travel_agent/models/address_agent.py +111 -0
- wink_sdk_travel_agent/models/affiliate_account_agent.py +181 -0
- wink_sdk_travel_agent/models/affiliate_account_user_agent.py +115 -0
- wink_sdk_travel_agent/models/agent_booking_request_agent.py +130 -0
- wink_sdk_travel_agent/models/aggregate_descriptor_agent.py +100 -0
- wink_sdk_travel_agent/models/ancillary_request_agent.py +111 -0
- wink_sdk_travel_agent/models/authenticated_user_agent.py +100 -0
- wink_sdk_travel_agent/models/bed_agent.py +91 -0
- wink_sdk_travel_agent/models/bedroom_agent.py +106 -0
- wink_sdk_travel_agent/models/bedroom_configuration_agent.py +102 -0
- wink_sdk_travel_agent/models/beneficiary_agent.py +156 -0
- wink_sdk_travel_agent/models/beneficiary_charge_agent.py +97 -0
- wink_sdk_travel_agent/models/booking_agent.py +342 -0
- wink_sdk_travel_agent/models/booking_analytics_supplier.py +96 -0
- wink_sdk_travel_agent/models/booking_ancillary_agent.py +155 -0
- wink_sdk_travel_agent/models/booking_confirmations_agent.py +101 -0
- wink_sdk_travel_agent/models/booking_contract_agent.py +697 -0
- wink_sdk_travel_agent/models/booking_contract_item_agent.py +206 -0
- wink_sdk_travel_agent/models/booking_contract_payment_details_agent.py +124 -0
- wink_sdk_travel_agent/models/booking_itinerary_agent.py +113 -0
- wink_sdk_travel_agent/models/booking_itinerary_room_configuration_agent.py +98 -0
- wink_sdk_travel_agent/models/booking_itinerary_room_configuration_child_agent.py +90 -0
- wink_sdk_travel_agent/models/booking_overview_request_supplier.py +97 -0
- wink_sdk_travel_agent/models/booking_user_agent.py +102 -0
- wink_sdk_travel_agent/models/booking_user_request_agent.py +96 -0
- wink_sdk_travel_agent/models/booking_user_session_agent.py +112 -0
- wink_sdk_travel_agent/models/booking_view_agent.py +101 -0
- wink_sdk_travel_agent/models/boolean_response_agent.py +90 -0
- wink_sdk_travel_agent/models/cancellation_detail_agent.py +98 -0
- wink_sdk_travel_agent/models/cancellation_policy_agent.py +166 -0
- wink_sdk_travel_agent/models/cancellation_policy_exception_agent.py +100 -0
- wink_sdk_travel_agent/models/cancellation_policy_exceptions_agent.py +97 -0
- wink_sdk_travel_agent/models/cancellation_policy_lightweight_agent.py +167 -0
- wink_sdk_travel_agent/models/chart_category_axis_supplier.py +88 -0
- wink_sdk_travel_agent/models/chart_legend_supplier.py +88 -0
- wink_sdk_travel_agent/models/chart_series_supplier.py +90 -0
- wink_sdk_travel_agent/models/chart_title_supplier.py +88 -0
- wink_sdk_travel_agent/models/child_agent.py +91 -0
- wink_sdk_travel_agent/models/commissionable_entry_agent.py +102 -0
- wink_sdk_travel_agent/models/company_agent.py +176 -0
- wink_sdk_travel_agent/models/company_user_agent.py +114 -0
- wink_sdk_travel_agent/models/company_view_agent.py +101 -0
- wink_sdk_travel_agent/models/composite_filter_descriptor_agent.py +108 -0
- wink_sdk_travel_agent/models/contact_agent.py +104 -0
- wink_sdk_travel_agent/models/country_agent.py +100 -0
- wink_sdk_travel_agent/models/country_lightweight_agent.py +100 -0
- wink_sdk_travel_agent/models/create_agent_booking400_response.py +141 -0
- wink_sdk_travel_agent/models/create_agent_booking_request_agent.py +105 -0
- wink_sdk_travel_agent/models/custom_monetary_amount.py +91 -0
- wink_sdk_travel_agent/models/customization_lightweight_agent.py +232 -0
- wink_sdk_travel_agent/models/customization_theme_colors_agent.py +108 -0
- wink_sdk_travel_agent/models/daily_rate_agent.py +115 -0
- wink_sdk_travel_agent/models/dow_pattern_group_agent.py +102 -0
- wink_sdk_travel_agent/models/engine_configuration_booking_report_agent.py +230 -0
- wink_sdk_travel_agent/models/engine_configuration_theme_agent.py +108 -0
- wink_sdk_travel_agent/models/engine_configuration_theme_colors_agent.py +108 -0
- wink_sdk_travel_agent/models/extra_charge_agent.py +103 -0
- wink_sdk_travel_agent/models/extra_charges_agent.py +112 -0
- wink_sdk_travel_agent/models/fee_agent.py +105 -0
- wink_sdk_travel_agent/models/filter_descriptor_agent.py +107 -0
- wink_sdk_travel_agent/models/general_manager_agent.py +104 -0
- wink_sdk_travel_agent/models/generic_error_message.py +94 -0
- wink_sdk_travel_agent/models/geo_json_point_agent.py +94 -0
- wink_sdk_travel_agent/models/geo_name_agent.py +136 -0
- wink_sdk_travel_agent/models/geo_name_lightweight_agent.py +136 -0
- wink_sdk_travel_agent/models/group_descriptor_agent.py +110 -0
- wink_sdk_travel_agent/models/grouped_booking_sales_metrics_supplier_details.py +110 -0
- wink_sdk_travel_agent/models/guest_room_agent.py +258 -0
- wink_sdk_travel_agent/models/guest_room_lightweight_agent.py +259 -0
- wink_sdk_travel_agent/models/guest_user_agent.py +108 -0
- wink_sdk_travel_agent/models/hotel_on_map_agent.py +270 -0
- wink_sdk_travel_agent/models/image_attribution_agent.py +91 -0
- wink_sdk_travel_agent/models/line_chart_supplier.py +122 -0
- wink_sdk_travel_agent/models/localized_description_agent.py +109 -0
- wink_sdk_travel_agent/models/localized_price_agent.py +162 -0
- wink_sdk_travel_agent/models/managed_by_entity_agent.py +103 -0
- wink_sdk_travel_agent/models/managed_by_entity_rules_agent.py +95 -0
- wink_sdk_travel_agent/models/media_author_attribution_agent.py +91 -0
- wink_sdk_travel_agent/models/online_presence_agent.py +112 -0
- wink_sdk_travel_agent/models/page_booking_agent.py +124 -0
- wink_sdk_travel_agent/models/page_booking_view_agent.py +124 -0
- wink_sdk_travel_agent/models/pageable_object_agent.py +102 -0
- wink_sdk_travel_agent/models/payout_agent.py +158 -0
- wink_sdk_travel_agent/models/payout_fee_agent.py +116 -0
- wink_sdk_travel_agent/models/pending_refund_agent.py +99 -0
- wink_sdk_travel_agent/models/perk_lightweight_agent.py +105 -0
- wink_sdk_travel_agent/models/personal_agent.py +139 -0
- wink_sdk_travel_agent/models/pet_info_dto_agent.py +90 -0
- wink_sdk_travel_agent/models/preferences_agent.py +128 -0
- wink_sdk_travel_agent/models/profile_agent.py +110 -0
- wink_sdk_travel_agent/models/profile_lightweight_agent.py +111 -0
- wink_sdk_travel_agent/models/profile_user_agent.py +100 -0
- wink_sdk_travel_agent/models/property_aggregate_lightweight_agent.py +245 -0
- wink_sdk_travel_agent/models/property_policy_agent.py +150 -0
- wink_sdk_travel_agent/models/quote_agent.py +94 -0
- wink_sdk_travel_agent/models/quote_lightweight_agent.py +95 -0
- wink_sdk_travel_agent/models/rate_plan_agent.py +172 -0
- wink_sdk_travel_agent/models/rate_plan_level_fee_agent.py +112 -0
- wink_sdk_travel_agent/models/refund_agent.py +167 -0
- wink_sdk_travel_agent/models/reporting_ancillary_agent.py +108 -0
- wink_sdk_travel_agent/models/reporting_daily_rate_agent.py +99 -0
- wink_sdk_travel_agent/models/reporting_extra_charge_agent.py +98 -0
- wink_sdk_travel_agent/models/review_agent.py +133 -0
- wink_sdk_travel_agent/models/review_answer_agent.py +102 -0
- wink_sdk_travel_agent/models/review_lightweight_agent.py +134 -0
- wink_sdk_travel_agent/models/review_user_agent.py +99 -0
- wink_sdk_travel_agent/models/room_configuration_agent.py +99 -0
- wink_sdk_travel_agent/models/room_configuration_price_rate_plan_agent.py +130 -0
- wink_sdk_travel_agent/models/room_stay_agent.py +183 -0
- wink_sdk_travel_agent/models/simple_address_agent.py +109 -0
- wink_sdk_travel_agent/models/simple_date_time_itinerary_agent.py +108 -0
- wink_sdk_travel_agent/models/simple_description_agent.py +111 -0
- wink_sdk_travel_agent/models/simple_multimedia_agent.py +156 -0
- wink_sdk_travel_agent/models/social_agent.py +100 -0
- wink_sdk_travel_agent/models/sort_descriptor_agent.py +100 -0
- wink_sdk_travel_agent/models/sort_object.py +96 -0
- wink_sdk_travel_agent/models/sort_object_agent.py +92 -0
- wink_sdk_travel_agent/models/state_agent.py +117 -0
- wink_sdk_travel_agent/models/stay_rate_agent.py +209 -0
- wink_sdk_travel_agent/models/sub_country_agent.py +92 -0
- wink_sdk_travel_agent/models/sub_country_lightweight_agent.py +92 -0
- wink_sdk_travel_agent/models/sub_sub_country_agent.py +92 -0
- wink_sdk_travel_agent/models/sub_sub_country_lightweight_agent.py +92 -0
- wink_sdk_travel_agent/models/supplier_contract_item_policy_agent.py +170 -0
- wink_sdk_travel_agent/models/travel_agent_agent.py +90 -0
- wink_sdk_travel_agent/models/travel_inventory_recognition_agent.py +121 -0
- wink_sdk_travel_agent/models/upsert_travel_agent_request_agent.py +90 -0
- wink_sdk_travel_agent/models/wink_booking_contract_agent.py +697 -0
- wink_sdk_travel_agent/py.typed +0 -0
- wink_sdk_travel_agent/rest.py +259 -0
- wink_sdk_travel_agent-0.0.55.dist-info/METADATA +539 -0
- wink_sdk_travel_agent-0.0.55.dist-info/RECORD +144 -0
- wink_sdk_travel_agent-0.0.55.dist-info/WHEEL +5 -0
- wink_sdk_travel_agent-0.0.55.dist-info/licenses/LICENSE +201 -0
- wink_sdk_travel_agent-0.0.55.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,582 @@
|
|
|
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 copy
|
|
17
|
+
import http.client as httplib
|
|
18
|
+
import logging
|
|
19
|
+
from logging import FileHandler
|
|
20
|
+
import multiprocessing
|
|
21
|
+
import sys
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
|
|
23
|
+
from typing_extensions import NotRequired, Self
|
|
24
|
+
|
|
25
|
+
import urllib3
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSON_SCHEMA_VALIDATION_KEYWORDS = {
|
|
29
|
+
'multipleOf', 'maximum', 'exclusiveMaximum',
|
|
30
|
+
'minimum', 'exclusiveMinimum', 'maxLength',
|
|
31
|
+
'minLength', 'pattern', 'maxItems', 'minItems'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ServerVariablesT = Dict[str, str]
|
|
35
|
+
|
|
36
|
+
GenericAuthSetting = TypedDict(
|
|
37
|
+
"GenericAuthSetting",
|
|
38
|
+
{
|
|
39
|
+
"type": str,
|
|
40
|
+
"in": str,
|
|
41
|
+
"key": str,
|
|
42
|
+
"value": str,
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
OAuth2AuthSetting = TypedDict(
|
|
48
|
+
"OAuth2AuthSetting",
|
|
49
|
+
{
|
|
50
|
+
"type": Literal["oauth2"],
|
|
51
|
+
"in": Literal["header"],
|
|
52
|
+
"key": Literal["Authorization"],
|
|
53
|
+
"value": str,
|
|
54
|
+
},
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
APIKeyAuthSetting = TypedDict(
|
|
59
|
+
"APIKeyAuthSetting",
|
|
60
|
+
{
|
|
61
|
+
"type": Literal["api_key"],
|
|
62
|
+
"in": str,
|
|
63
|
+
"key": str,
|
|
64
|
+
"value": Optional[str],
|
|
65
|
+
},
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
BasicAuthSetting = TypedDict(
|
|
70
|
+
"BasicAuthSetting",
|
|
71
|
+
{
|
|
72
|
+
"type": Literal["basic"],
|
|
73
|
+
"in": Literal["header"],
|
|
74
|
+
"key": Literal["Authorization"],
|
|
75
|
+
"value": Optional[str],
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
BearerFormatAuthSetting = TypedDict(
|
|
81
|
+
"BearerFormatAuthSetting",
|
|
82
|
+
{
|
|
83
|
+
"type": Literal["bearer"],
|
|
84
|
+
"in": Literal["header"],
|
|
85
|
+
"format": Literal["JWT"],
|
|
86
|
+
"key": Literal["Authorization"],
|
|
87
|
+
"value": str,
|
|
88
|
+
},
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
BearerAuthSetting = TypedDict(
|
|
93
|
+
"BearerAuthSetting",
|
|
94
|
+
{
|
|
95
|
+
"type": Literal["bearer"],
|
|
96
|
+
"in": Literal["header"],
|
|
97
|
+
"key": Literal["Authorization"],
|
|
98
|
+
"value": str,
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
HTTPSignatureAuthSetting = TypedDict(
|
|
104
|
+
"HTTPSignatureAuthSetting",
|
|
105
|
+
{
|
|
106
|
+
"type": Literal["http-signature"],
|
|
107
|
+
"in": Literal["header"],
|
|
108
|
+
"key": Literal["Authorization"],
|
|
109
|
+
"value": None,
|
|
110
|
+
},
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
AuthSettings = TypedDict(
|
|
115
|
+
"AuthSettings",
|
|
116
|
+
{
|
|
117
|
+
"oauth2ClientCredentials": OAuth2AuthSetting,
|
|
118
|
+
},
|
|
119
|
+
total=False,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class HostSettingVariable(TypedDict):
|
|
124
|
+
description: str
|
|
125
|
+
default_value: str
|
|
126
|
+
enum_values: List[str]
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class HostSetting(TypedDict):
|
|
130
|
+
url: str
|
|
131
|
+
description: str
|
|
132
|
+
variables: NotRequired[Dict[str, HostSettingVariable]]
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class Configuration:
|
|
136
|
+
"""This class contains various settings of the API client.
|
|
137
|
+
|
|
138
|
+
:param host: Base url.
|
|
139
|
+
:param ignore_operation_servers
|
|
140
|
+
Boolean to ignore operation servers for the API client.
|
|
141
|
+
Config will use `host` as the base url regardless of the operation servers.
|
|
142
|
+
:param api_key: Dict to store API key(s).
|
|
143
|
+
Each entry in the dict specifies an API key.
|
|
144
|
+
The dict key is the name of the security scheme in the OAS specification.
|
|
145
|
+
The dict value is the API key secret.
|
|
146
|
+
:param api_key_prefix: Dict to store API prefix (e.g. Bearer).
|
|
147
|
+
The dict key is the name of the security scheme in the OAS specification.
|
|
148
|
+
The dict value is an API key prefix when generating the auth data.
|
|
149
|
+
:param username: Username for HTTP basic authentication.
|
|
150
|
+
:param password: Password for HTTP basic authentication.
|
|
151
|
+
:param access_token: Access token.
|
|
152
|
+
:param server_index: Index to servers configuration.
|
|
153
|
+
:param server_variables: Mapping with string values to replace variables in
|
|
154
|
+
templated server configuration. The validation of enums is performed for
|
|
155
|
+
variables with defined enum values before.
|
|
156
|
+
:param server_operation_index: Mapping from operation ID to an index to server
|
|
157
|
+
configuration.
|
|
158
|
+
:param server_operation_variables: Mapping from operation ID to a mapping with
|
|
159
|
+
string values to replace variables in templated server configuration.
|
|
160
|
+
The validation of enums is performed for variables with defined enum
|
|
161
|
+
values before.
|
|
162
|
+
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
|
163
|
+
in PEM format.
|
|
164
|
+
:param retries: Number of retries for API requests.
|
|
165
|
+
:param ca_cert_data: verify the peer using concatenated CA certificate data
|
|
166
|
+
in PEM (str) or DER (bytes) format.
|
|
167
|
+
|
|
168
|
+
:Example:
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
_default: ClassVar[Optional[Self]] = None
|
|
172
|
+
|
|
173
|
+
def __init__(
|
|
174
|
+
self,
|
|
175
|
+
host: Optional[str]=None,
|
|
176
|
+
api_key: Optional[Dict[str, str]]=None,
|
|
177
|
+
api_key_prefix: Optional[Dict[str, str]]=None,
|
|
178
|
+
username: Optional[str]=None,
|
|
179
|
+
password: Optional[str]=None,
|
|
180
|
+
access_token: Optional[str]=None,
|
|
181
|
+
server_index: Optional[int]=None,
|
|
182
|
+
server_variables: Optional[ServerVariablesT]=None,
|
|
183
|
+
server_operation_index: Optional[Dict[int, int]]=None,
|
|
184
|
+
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
|
|
185
|
+
ignore_operation_servers: bool=False,
|
|
186
|
+
ssl_ca_cert: Optional[str]=None,
|
|
187
|
+
retries: Optional[int] = None,
|
|
188
|
+
ca_cert_data: Optional[Union[str, bytes]] = None,
|
|
189
|
+
*,
|
|
190
|
+
debug: Optional[bool] = None,
|
|
191
|
+
) -> None:
|
|
192
|
+
"""Constructor
|
|
193
|
+
"""
|
|
194
|
+
self._base_path = "https://api.wink.travel" if host is None else host
|
|
195
|
+
"""Default Base url
|
|
196
|
+
"""
|
|
197
|
+
self.server_index = 0 if server_index is None and host is None else server_index
|
|
198
|
+
self.server_operation_index = server_operation_index or {}
|
|
199
|
+
"""Default server index
|
|
200
|
+
"""
|
|
201
|
+
self.server_variables = server_variables or {}
|
|
202
|
+
self.server_operation_variables = server_operation_variables or {}
|
|
203
|
+
"""Default server variables
|
|
204
|
+
"""
|
|
205
|
+
self.ignore_operation_servers = ignore_operation_servers
|
|
206
|
+
"""Ignore operation servers
|
|
207
|
+
"""
|
|
208
|
+
self.temp_folder_path = None
|
|
209
|
+
"""Temp file folder for downloading files
|
|
210
|
+
"""
|
|
211
|
+
# Authentication Settings
|
|
212
|
+
self.api_key = {}
|
|
213
|
+
if api_key:
|
|
214
|
+
self.api_key = api_key
|
|
215
|
+
"""dict to store API key(s)
|
|
216
|
+
"""
|
|
217
|
+
self.api_key_prefix = {}
|
|
218
|
+
if api_key_prefix:
|
|
219
|
+
self.api_key_prefix = api_key_prefix
|
|
220
|
+
"""dict to store API prefix (e.g. Bearer)
|
|
221
|
+
"""
|
|
222
|
+
self.refresh_api_key_hook = None
|
|
223
|
+
"""function hook to refresh API key if expired
|
|
224
|
+
"""
|
|
225
|
+
self.username = username
|
|
226
|
+
"""Username for HTTP basic authentication
|
|
227
|
+
"""
|
|
228
|
+
self.password = password
|
|
229
|
+
"""Password for HTTP basic authentication
|
|
230
|
+
"""
|
|
231
|
+
self.access_token = access_token
|
|
232
|
+
"""Access token
|
|
233
|
+
"""
|
|
234
|
+
self.logger = {}
|
|
235
|
+
"""Logging Settings
|
|
236
|
+
"""
|
|
237
|
+
self.logger["package_logger"] = logging.getLogger("wink_sdk_travel_agent")
|
|
238
|
+
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
|
239
|
+
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
|
|
240
|
+
"""Log format
|
|
241
|
+
"""
|
|
242
|
+
self.logger_stream_handler = None
|
|
243
|
+
"""Log stream handler
|
|
244
|
+
"""
|
|
245
|
+
self.logger_file_handler: Optional[FileHandler] = None
|
|
246
|
+
"""Log file handler
|
|
247
|
+
"""
|
|
248
|
+
self.logger_file = None
|
|
249
|
+
"""Debug file location
|
|
250
|
+
"""
|
|
251
|
+
if debug is not None:
|
|
252
|
+
self.debug = debug
|
|
253
|
+
else:
|
|
254
|
+
self.__debug = False
|
|
255
|
+
"""Debug switch
|
|
256
|
+
"""
|
|
257
|
+
|
|
258
|
+
self.verify_ssl = True
|
|
259
|
+
"""SSL/TLS verification
|
|
260
|
+
Set this to false to skip verifying SSL certificate when calling API
|
|
261
|
+
from https server.
|
|
262
|
+
"""
|
|
263
|
+
self.ssl_ca_cert = ssl_ca_cert
|
|
264
|
+
"""Set this to customize the certificate file to verify the peer.
|
|
265
|
+
"""
|
|
266
|
+
self.ca_cert_data = ca_cert_data
|
|
267
|
+
"""Set this to verify the peer using PEM (str) or DER (bytes)
|
|
268
|
+
certificate data.
|
|
269
|
+
"""
|
|
270
|
+
self.cert_file = None
|
|
271
|
+
"""client certificate file
|
|
272
|
+
"""
|
|
273
|
+
self.key_file = None
|
|
274
|
+
"""client key file
|
|
275
|
+
"""
|
|
276
|
+
self.assert_hostname = None
|
|
277
|
+
"""Set this to True/False to enable/disable SSL hostname verification.
|
|
278
|
+
"""
|
|
279
|
+
self.tls_server_name = None
|
|
280
|
+
"""SSL/TLS Server Name Indication (SNI)
|
|
281
|
+
Set this to the SNI value expected by the server.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
|
|
285
|
+
"""urllib3 connection pool's maximum number of connections saved
|
|
286
|
+
per pool. urllib3 uses 1 connection as default value, but this is
|
|
287
|
+
not the best value when you are making a lot of possibly parallel
|
|
288
|
+
requests to the same host, which is often the case here.
|
|
289
|
+
cpu_count * 5 is used as default value to increase performance.
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
self.proxy: Optional[str] = None
|
|
293
|
+
"""Proxy URL
|
|
294
|
+
"""
|
|
295
|
+
self.proxy_headers = None
|
|
296
|
+
"""Proxy headers
|
|
297
|
+
"""
|
|
298
|
+
self.safe_chars_for_path_param = ''
|
|
299
|
+
"""Safe chars for path_param
|
|
300
|
+
"""
|
|
301
|
+
self.retries = retries
|
|
302
|
+
"""Adding retries to override urllib3 default value 3
|
|
303
|
+
"""
|
|
304
|
+
# Enable client side validation
|
|
305
|
+
self.client_side_validation = True
|
|
306
|
+
|
|
307
|
+
self.socket_options = None
|
|
308
|
+
"""Options to pass down to the underlying urllib3 socket
|
|
309
|
+
"""
|
|
310
|
+
|
|
311
|
+
self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
|
|
312
|
+
"""datetime format
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
self.date_format = "%Y-%m-%d"
|
|
316
|
+
"""date format
|
|
317
|
+
"""
|
|
318
|
+
|
|
319
|
+
def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
|
|
320
|
+
cls = self.__class__
|
|
321
|
+
result = cls.__new__(cls)
|
|
322
|
+
memo[id(self)] = result
|
|
323
|
+
for k, v in self.__dict__.items():
|
|
324
|
+
if k not in ('logger', 'logger_file_handler'):
|
|
325
|
+
setattr(result, k, copy.deepcopy(v, memo))
|
|
326
|
+
# shallow copy of loggers
|
|
327
|
+
result.logger = copy.copy(self.logger)
|
|
328
|
+
# use setters to configure loggers
|
|
329
|
+
result.logger_file = self.logger_file
|
|
330
|
+
result.debug = self.debug
|
|
331
|
+
return result
|
|
332
|
+
|
|
333
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
334
|
+
object.__setattr__(self, name, value)
|
|
335
|
+
|
|
336
|
+
@classmethod
|
|
337
|
+
def set_default(cls, default: Optional[Self]) -> None:
|
|
338
|
+
"""Set default instance of configuration.
|
|
339
|
+
|
|
340
|
+
It stores default configuration, which can be
|
|
341
|
+
returned by get_default_copy method.
|
|
342
|
+
|
|
343
|
+
:param default: object of Configuration
|
|
344
|
+
"""
|
|
345
|
+
cls._default = default
|
|
346
|
+
|
|
347
|
+
@classmethod
|
|
348
|
+
def get_default_copy(cls) -> Self:
|
|
349
|
+
"""Deprecated. Please use `get_default` instead.
|
|
350
|
+
|
|
351
|
+
Deprecated. Please use `get_default` instead.
|
|
352
|
+
|
|
353
|
+
:return: The configuration object.
|
|
354
|
+
"""
|
|
355
|
+
return cls.get_default()
|
|
356
|
+
|
|
357
|
+
@classmethod
|
|
358
|
+
def get_default(cls) -> Self:
|
|
359
|
+
"""Return the default configuration.
|
|
360
|
+
|
|
361
|
+
This method returns newly created, based on default constructor,
|
|
362
|
+
object of Configuration class or returns a copy of default
|
|
363
|
+
configuration.
|
|
364
|
+
|
|
365
|
+
:return: The configuration object.
|
|
366
|
+
"""
|
|
367
|
+
if cls._default is None:
|
|
368
|
+
cls._default = cls()
|
|
369
|
+
return cls._default
|
|
370
|
+
|
|
371
|
+
@property
|
|
372
|
+
def logger_file(self) -> Optional[str]:
|
|
373
|
+
"""The logger file.
|
|
374
|
+
|
|
375
|
+
If the logger_file is None, then add stream handler and remove file
|
|
376
|
+
handler. Otherwise, add file handler and remove stream handler.
|
|
377
|
+
|
|
378
|
+
:param value: The logger_file path.
|
|
379
|
+
:type: str
|
|
380
|
+
"""
|
|
381
|
+
return self.__logger_file
|
|
382
|
+
|
|
383
|
+
@logger_file.setter
|
|
384
|
+
def logger_file(self, value: Optional[str]) -> None:
|
|
385
|
+
"""The logger file.
|
|
386
|
+
|
|
387
|
+
If the logger_file is None, then add stream handler and remove file
|
|
388
|
+
handler. Otherwise, add file handler and remove stream handler.
|
|
389
|
+
|
|
390
|
+
:param value: The logger_file path.
|
|
391
|
+
:type: str
|
|
392
|
+
"""
|
|
393
|
+
self.__logger_file = value
|
|
394
|
+
if self.__logger_file:
|
|
395
|
+
# If set logging file,
|
|
396
|
+
# then add file handler and remove stream handler.
|
|
397
|
+
self.logger_file_handler = logging.FileHandler(self.__logger_file)
|
|
398
|
+
self.logger_file_handler.setFormatter(self.logger_formatter)
|
|
399
|
+
for _, logger in self.logger.items():
|
|
400
|
+
logger.addHandler(self.logger_file_handler)
|
|
401
|
+
|
|
402
|
+
@property
|
|
403
|
+
def debug(self) -> bool:
|
|
404
|
+
"""Debug status
|
|
405
|
+
|
|
406
|
+
:param value: The debug status, True or False.
|
|
407
|
+
:type: bool
|
|
408
|
+
"""
|
|
409
|
+
return self.__debug
|
|
410
|
+
|
|
411
|
+
@debug.setter
|
|
412
|
+
def debug(self, value: bool) -> None:
|
|
413
|
+
"""Debug status
|
|
414
|
+
|
|
415
|
+
:param value: The debug status, True or False.
|
|
416
|
+
:type: bool
|
|
417
|
+
"""
|
|
418
|
+
self.__debug = value
|
|
419
|
+
if self.__debug:
|
|
420
|
+
# if debug status is True, turn on debug logging
|
|
421
|
+
for _, logger in self.logger.items():
|
|
422
|
+
logger.setLevel(logging.DEBUG)
|
|
423
|
+
# turn on httplib debug
|
|
424
|
+
httplib.HTTPConnection.debuglevel = 1
|
|
425
|
+
else:
|
|
426
|
+
# if debug status is False, turn off debug logging,
|
|
427
|
+
# setting log level to default `logging.WARNING`
|
|
428
|
+
for _, logger in self.logger.items():
|
|
429
|
+
logger.setLevel(logging.WARNING)
|
|
430
|
+
# turn off httplib debug
|
|
431
|
+
httplib.HTTPConnection.debuglevel = 0
|
|
432
|
+
|
|
433
|
+
@property
|
|
434
|
+
def logger_format(self) -> str:
|
|
435
|
+
"""The logger format.
|
|
436
|
+
|
|
437
|
+
The logger_formatter will be updated when sets logger_format.
|
|
438
|
+
|
|
439
|
+
:param value: The format string.
|
|
440
|
+
:type: str
|
|
441
|
+
"""
|
|
442
|
+
return self.__logger_format
|
|
443
|
+
|
|
444
|
+
@logger_format.setter
|
|
445
|
+
def logger_format(self, value: str) -> None:
|
|
446
|
+
"""The logger format.
|
|
447
|
+
|
|
448
|
+
The logger_formatter will be updated when sets logger_format.
|
|
449
|
+
|
|
450
|
+
:param value: The format string.
|
|
451
|
+
:type: str
|
|
452
|
+
"""
|
|
453
|
+
self.__logger_format = value
|
|
454
|
+
self.logger_formatter = logging.Formatter(self.__logger_format)
|
|
455
|
+
|
|
456
|
+
def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
|
|
457
|
+
"""Gets API key (with prefix if set).
|
|
458
|
+
|
|
459
|
+
:param identifier: The identifier of apiKey.
|
|
460
|
+
:param alias: The alternative identifier of apiKey.
|
|
461
|
+
:return: The token for api key authentication.
|
|
462
|
+
"""
|
|
463
|
+
if self.refresh_api_key_hook is not None:
|
|
464
|
+
self.refresh_api_key_hook(self)
|
|
465
|
+
key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
|
|
466
|
+
if key:
|
|
467
|
+
prefix = self.api_key_prefix.get(identifier)
|
|
468
|
+
if prefix:
|
|
469
|
+
return "%s %s" % (prefix, key)
|
|
470
|
+
else:
|
|
471
|
+
return key
|
|
472
|
+
|
|
473
|
+
return None
|
|
474
|
+
|
|
475
|
+
def get_basic_auth_token(self) -> Optional[str]:
|
|
476
|
+
"""Gets HTTP basic authentication header (string).
|
|
477
|
+
|
|
478
|
+
:return: The token for basic HTTP authentication.
|
|
479
|
+
"""
|
|
480
|
+
username = ""
|
|
481
|
+
if self.username is not None:
|
|
482
|
+
username = self.username
|
|
483
|
+
password = ""
|
|
484
|
+
if self.password is not None:
|
|
485
|
+
password = self.password
|
|
486
|
+
return urllib3.util.make_headers(
|
|
487
|
+
basic_auth=username + ':' + password
|
|
488
|
+
).get('authorization')
|
|
489
|
+
|
|
490
|
+
def auth_settings(self)-> AuthSettings:
|
|
491
|
+
"""Gets Auth Settings dict for api client.
|
|
492
|
+
|
|
493
|
+
:return: The Auth Settings information dict.
|
|
494
|
+
"""
|
|
495
|
+
auth: AuthSettings = {}
|
|
496
|
+
if self.access_token is not None:
|
|
497
|
+
auth['oauth2ClientCredentials'] = {
|
|
498
|
+
'type': 'oauth2',
|
|
499
|
+
'in': 'header',
|
|
500
|
+
'key': 'Authorization',
|
|
501
|
+
'value': 'Bearer ' + self.access_token
|
|
502
|
+
}
|
|
503
|
+
return auth
|
|
504
|
+
|
|
505
|
+
def to_debug_report(self) -> str:
|
|
506
|
+
"""Gets the essential information for debugging.
|
|
507
|
+
|
|
508
|
+
:return: The report for debugging.
|
|
509
|
+
"""
|
|
510
|
+
return "Python SDK Debug Report:\n"\
|
|
511
|
+
"OS: {env}\n"\
|
|
512
|
+
"Python Version: {pyversion}\n"\
|
|
513
|
+
"Version of the API: 30.29.0\n"\
|
|
514
|
+
"SDK Package Version: 0.0.55".\
|
|
515
|
+
format(env=sys.platform, pyversion=sys.version)
|
|
516
|
+
|
|
517
|
+
def get_host_settings(self) -> List[HostSetting]:
|
|
518
|
+
"""Gets an array of host settings
|
|
519
|
+
|
|
520
|
+
:return: An array of host settings
|
|
521
|
+
"""
|
|
522
|
+
return [
|
|
523
|
+
{
|
|
524
|
+
'url': "https://api.wink.travel",
|
|
525
|
+
'description': "Endpoint",
|
|
526
|
+
}
|
|
527
|
+
]
|
|
528
|
+
|
|
529
|
+
def get_host_from_settings(
|
|
530
|
+
self,
|
|
531
|
+
index: Optional[int],
|
|
532
|
+
variables: Optional[ServerVariablesT]=None,
|
|
533
|
+
servers: Optional[List[HostSetting]]=None,
|
|
534
|
+
) -> str:
|
|
535
|
+
"""Gets host URL based on the index and variables
|
|
536
|
+
:param index: array index of the host settings
|
|
537
|
+
:param variables: hash of variable and the corresponding value
|
|
538
|
+
:param servers: an array of host settings or None
|
|
539
|
+
:return: URL based on host settings
|
|
540
|
+
"""
|
|
541
|
+
if index is None:
|
|
542
|
+
return self._base_path
|
|
543
|
+
|
|
544
|
+
variables = {} if variables is None else variables
|
|
545
|
+
servers = self.get_host_settings() if servers is None else servers
|
|
546
|
+
|
|
547
|
+
try:
|
|
548
|
+
server = servers[index]
|
|
549
|
+
except IndexError:
|
|
550
|
+
raise ValueError(
|
|
551
|
+
"Invalid index {0} when selecting the host settings. "
|
|
552
|
+
"Must be less than {1}".format(index, len(servers)))
|
|
553
|
+
|
|
554
|
+
url = server['url']
|
|
555
|
+
|
|
556
|
+
# go through variables and replace placeholders
|
|
557
|
+
for variable_name, variable in server.get('variables', {}).items():
|
|
558
|
+
used_value = variables.get(
|
|
559
|
+
variable_name, variable['default_value'])
|
|
560
|
+
|
|
561
|
+
if 'enum_values' in variable \
|
|
562
|
+
and used_value not in variable['enum_values']:
|
|
563
|
+
raise ValueError(
|
|
564
|
+
"The variable `{0}` in the host URL has invalid value "
|
|
565
|
+
"{1}. Must be {2}.".format(
|
|
566
|
+
variable_name, variables[variable_name],
|
|
567
|
+
variable['enum_values']))
|
|
568
|
+
|
|
569
|
+
url = url.replace("{" + variable_name + "}", used_value)
|
|
570
|
+
|
|
571
|
+
return url
|
|
572
|
+
|
|
573
|
+
@property
|
|
574
|
+
def host(self) -> str:
|
|
575
|
+
"""Return generated host."""
|
|
576
|
+
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
|
|
577
|
+
|
|
578
|
+
@host.setter
|
|
579
|
+
def host(self, value: str) -> None:
|
|
580
|
+
"""Fix base path."""
|
|
581
|
+
self._base_path = value
|
|
582
|
+
self.server_index = None
|