pluggy-sdk 1.0.0.post34__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 (221) hide show
  1. pluggy_sdk/__init__.py +200 -0
  2. pluggy_sdk/api/__init__.py +25 -0
  3. pluggy_sdk/api/account_api.py +588 -0
  4. pluggy_sdk/api/acquirer_anticipation_api.py +664 -0
  5. pluggy_sdk/api/acquirer_receivable_api.py +664 -0
  6. pluggy_sdk/api/acquirer_sale_api.py +664 -0
  7. pluggy_sdk/api/auth_api.py +605 -0
  8. pluggy_sdk/api/benefit_api.py +567 -0
  9. pluggy_sdk/api/bill_api.py +567 -0
  10. pluggy_sdk/api/bulk_payment_api.py +1127 -0
  11. pluggy_sdk/api/category_api.py +1096 -0
  12. pluggy_sdk/api/connector_api.py +979 -0
  13. pluggy_sdk/api/consent_api.py +576 -0
  14. pluggy_sdk/api/identity_api.py +581 -0
  15. pluggy_sdk/api/income_report_api.py +311 -0
  16. pluggy_sdk/api/investment_api.py +918 -0
  17. pluggy_sdk/api/items_api.py +1456 -0
  18. pluggy_sdk/api/loan_api.py +567 -0
  19. pluggy_sdk/api/payment_customer_api.py +1414 -0
  20. pluggy_sdk/api/payment_intent_api.py +842 -0
  21. pluggy_sdk/api/payment_receipts_api.py +842 -0
  22. pluggy_sdk/api/payment_recipient_api.py +1997 -0
  23. pluggy_sdk/api/payment_request_api.py +2739 -0
  24. pluggy_sdk/api/payment_schedule_api.py +823 -0
  25. pluggy_sdk/api/payroll_loan_api.py +561 -0
  26. pluggy_sdk/api/portfolio_yield_api.py +580 -0
  27. pluggy_sdk/api/smart_account_api.py +1704 -0
  28. pluggy_sdk/api/smart_account_transfer_api.py +610 -0
  29. pluggy_sdk/api/smart_transfer_api.py +1406 -0
  30. pluggy_sdk/api/transaction_api.py +963 -0
  31. pluggy_sdk/api/webhook_api.py +1406 -0
  32. pluggy_sdk/api_client.py +798 -0
  33. pluggy_sdk/api_response.py +21 -0
  34. pluggy_sdk/configuration.py +596 -0
  35. pluggy_sdk/exceptions.py +217 -0
  36. pluggy_sdk/models/__init__.py +163 -0
  37. pluggy_sdk/models/account.py +134 -0
  38. pluggy_sdk/models/accounts_list200_response.py +102 -0
  39. pluggy_sdk/models/acquirer_anticipation.py +117 -0
  40. pluggy_sdk/models/acquirer_anticipation_data.py +101 -0
  41. pluggy_sdk/models/acquirer_data.py +113 -0
  42. pluggy_sdk/models/acquirer_receivable.py +143 -0
  43. pluggy_sdk/models/acquirer_receivable_data.py +108 -0
  44. pluggy_sdk/models/acquirer_receivable_data_establishment.py +96 -0
  45. pluggy_sdk/models/acquirer_receivable_destination_account.py +92 -0
  46. pluggy_sdk/models/acquirer_receivable_related_sale.py +99 -0
  47. pluggy_sdk/models/acquirer_sale.py +171 -0
  48. pluggy_sdk/models/acquirer_sale_data.py +150 -0
  49. pluggy_sdk/models/acquirer_sale_installment.py +93 -0
  50. pluggy_sdk/models/acquirer_sale_installment_data.py +95 -0
  51. pluggy_sdk/models/address.py +110 -0
  52. pluggy_sdk/models/aggregated_portfolio.py +120 -0
  53. pluggy_sdk/models/aggregated_portfolio_response.py +102 -0
  54. pluggy_sdk/models/asset_distribution.py +88 -0
  55. pluggy_sdk/models/auth_request.py +90 -0
  56. pluggy_sdk/models/auth_response.py +88 -0
  57. pluggy_sdk/models/bank_data.py +92 -0
  58. pluggy_sdk/models/benefit_loan.py +121 -0
  59. pluggy_sdk/models/benefit_loan_client.py +102 -0
  60. pluggy_sdk/models/benefit_response.py +118 -0
  61. pluggy_sdk/models/benefit_response_paying_institution.py +94 -0
  62. pluggy_sdk/models/benefits_list200_response.py +102 -0
  63. pluggy_sdk/models/bill.py +109 -0
  64. pluggy_sdk/models/bill_finance_charge.py +103 -0
  65. pluggy_sdk/models/bills_list200_response.py +102 -0
  66. pluggy_sdk/models/boleto.py +121 -0
  67. pluggy_sdk/models/boleto_payer.py +90 -0
  68. pluggy_sdk/models/boleto_recipient.py +90 -0
  69. pluggy_sdk/models/bulk_payment.py +128 -0
  70. pluggy_sdk/models/bulk_payments_list200_response.py +102 -0
  71. pluggy_sdk/models/category.py +96 -0
  72. pluggy_sdk/models/client_category_rule.py +98 -0
  73. pluggy_sdk/models/company.py +90 -0
  74. pluggy_sdk/models/connect_token_request.py +94 -0
  75. pluggy_sdk/models/connect_token_response.py +88 -0
  76. pluggy_sdk/models/connector.py +145 -0
  77. pluggy_sdk/models/connector_credential.py +121 -0
  78. pluggy_sdk/models/connector_health.py +96 -0
  79. pluggy_sdk/models/connector_health_details.py +90 -0
  80. pluggy_sdk/models/connector_list_response.py +102 -0
  81. pluggy_sdk/models/connector_user_action.py +93 -0
  82. pluggy_sdk/models/consent.py +120 -0
  83. pluggy_sdk/models/create_boleto_payment_request.py +98 -0
  84. pluggy_sdk/models/create_bulk_payment.py +96 -0
  85. pluggy_sdk/models/create_client_category_rule.py +96 -0
  86. pluggy_sdk/models/create_item.py +115 -0
  87. pluggy_sdk/models/create_item_parameters.py +144 -0
  88. pluggy_sdk/models/create_or_update_payment_customer.py +105 -0
  89. pluggy_sdk/models/create_payment_customer_request_body.py +103 -0
  90. pluggy_sdk/models/create_payment_intent.py +110 -0
  91. pluggy_sdk/models/create_payment_recipient.py +104 -0
  92. pluggy_sdk/models/create_payment_request.py +115 -0
  93. pluggy_sdk/models/create_payment_request_schedule.py +189 -0
  94. pluggy_sdk/models/create_pix_qr_payment_request.py +96 -0
  95. pluggy_sdk/models/create_smart_account_request.py +104 -0
  96. pluggy_sdk/models/create_smart_account_transfer_request.py +92 -0
  97. pluggy_sdk/models/create_smart_transfer_payment.py +96 -0
  98. pluggy_sdk/models/create_smart_transfer_preauthorization.py +104 -0
  99. pluggy_sdk/models/create_webhook.py +99 -0
  100. pluggy_sdk/models/credential_select_option.py +90 -0
  101. pluggy_sdk/models/credit_card_metadata.py +101 -0
  102. pluggy_sdk/models/credit_data.py +127 -0
  103. pluggy_sdk/models/custom.py +100 -0
  104. pluggy_sdk/models/daily.py +101 -0
  105. pluggy_sdk/models/document.py +100 -0
  106. pluggy_sdk/models/email.py +100 -0
  107. pluggy_sdk/models/global_error_response.py +94 -0
  108. pluggy_sdk/models/i_count_response.py +88 -0
  109. pluggy_sdk/models/identity_relation.py +102 -0
  110. pluggy_sdk/models/identity_response.py +173 -0
  111. pluggy_sdk/models/identity_response_financial_relationships.py +111 -0
  112. pluggy_sdk/models/identity_response_financial_relationships_accounts_inner.py +98 -0
  113. pluggy_sdk/models/identity_response_financial_relationships_procurators_inner.py +101 -0
  114. pluggy_sdk/models/identity_response_qualifications.py +112 -0
  115. pluggy_sdk/models/identity_response_qualifications_informed_income.py +100 -0
  116. pluggy_sdk/models/identity_response_qualifications_informed_patrimony.py +90 -0
  117. pluggy_sdk/models/income_report.py +90 -0
  118. pluggy_sdk/models/income_reports_response.py +102 -0
  119. pluggy_sdk/models/investment.py +192 -0
  120. pluggy_sdk/models/investment_expenses.py +108 -0
  121. pluggy_sdk/models/investment_metadata.py +100 -0
  122. pluggy_sdk/models/investment_transaction.py +124 -0
  123. pluggy_sdk/models/investments_list200_response.py +102 -0
  124. pluggy_sdk/models/item.py +150 -0
  125. pluggy_sdk/models/item_creation_error_response.py +102 -0
  126. pluggy_sdk/models/item_error.py +94 -0
  127. pluggy_sdk/models/item_options.py +94 -0
  128. pluggy_sdk/models/loan.py +199 -0
  129. pluggy_sdk/models/loan_contracted_fee.py +118 -0
  130. pluggy_sdk/models/loan_contracted_finance_charge.py +92 -0
  131. pluggy_sdk/models/loan_installment_balloon_payment.py +95 -0
  132. pluggy_sdk/models/loan_installment_balloon_payment_amount.py +90 -0
  133. pluggy_sdk/models/loan_installments.py +130 -0
  134. pluggy_sdk/models/loan_interest_rate.py +136 -0
  135. pluggy_sdk/models/loan_payment_release.py +103 -0
  136. pluggy_sdk/models/loan_payment_release_over_parcel.py +106 -0
  137. pluggy_sdk/models/loan_payment_release_over_parcel_charge.py +92 -0
  138. pluggy_sdk/models/loan_payment_release_over_parcel_fee.py +92 -0
  139. pluggy_sdk/models/loan_payments.py +98 -0
  140. pluggy_sdk/models/loan_warranty.py +94 -0
  141. pluggy_sdk/models/loans_list200_response.py +102 -0
  142. pluggy_sdk/models/merchant.py +96 -0
  143. pluggy_sdk/models/monthly.py +103 -0
  144. pluggy_sdk/models/monthly_portfolio.py +100 -0
  145. pluggy_sdk/models/monthly_portfolio_response.py +102 -0
  146. pluggy_sdk/models/not_authenticated_response.py +90 -0
  147. pluggy_sdk/models/page_response_acquirer_anticipations.py +102 -0
  148. pluggy_sdk/models/page_response_acquirer_receivables.py +102 -0
  149. pluggy_sdk/models/page_response_acquirer_sales.py +102 -0
  150. pluggy_sdk/models/page_response_category_rules.py +102 -0
  151. pluggy_sdk/models/page_response_consents.py +102 -0
  152. pluggy_sdk/models/page_response_investment_transactions.py +102 -0
  153. pluggy_sdk/models/page_response_transactions.py +102 -0
  154. pluggy_sdk/models/parameter_validation_error.py +92 -0
  155. pluggy_sdk/models/parameter_validation_response.py +98 -0
  156. pluggy_sdk/models/payment_customer.py +105 -0
  157. pluggy_sdk/models/payment_customers_list200_response.py +102 -0
  158. pluggy_sdk/models/payment_data.py +111 -0
  159. pluggy_sdk/models/payment_data_boleto_metadata.py +98 -0
  160. pluggy_sdk/models/payment_data_participant.py +102 -0
  161. pluggy_sdk/models/payment_institution.py +101 -0
  162. pluggy_sdk/models/payment_intent.py +145 -0
  163. pluggy_sdk/models/payment_intent_parameter.py +90 -0
  164. pluggy_sdk/models/payment_intents_list200_response.py +102 -0
  165. pluggy_sdk/models/payment_receipt.py +120 -0
  166. pluggy_sdk/models/payment_receipt_bank_account.py +92 -0
  167. pluggy_sdk/models/payment_receipt_person.py +96 -0
  168. pluggy_sdk/models/payment_recipient.py +110 -0
  169. pluggy_sdk/models/payment_recipient_account.py +92 -0
  170. pluggy_sdk/models/payment_recipients_institution_list200_response.py +102 -0
  171. pluggy_sdk/models/payment_recipients_list200_response.py +102 -0
  172. pluggy_sdk/models/payment_request.py +132 -0
  173. pluggy_sdk/models/payment_request_callback_urls.py +92 -0
  174. pluggy_sdk/models/payment_request_receipt_list200_response.py +102 -0
  175. pluggy_sdk/models/payment_request_schedule.py +183 -0
  176. pluggy_sdk/models/payment_requests_list200_response.py +102 -0
  177. pluggy_sdk/models/payment_schedules_list200_response.py +102 -0
  178. pluggy_sdk/models/payroll_loan.py +121 -0
  179. pluggy_sdk/models/payroll_loan_client.py +102 -0
  180. pluggy_sdk/models/payroll_loan_response.py +125 -0
  181. pluggy_sdk/models/payroll_loan_response_client.py +102 -0
  182. pluggy_sdk/models/payroll_loans_list200_response.py +102 -0
  183. pluggy_sdk/models/percentage_over_index.py +90 -0
  184. pluggy_sdk/models/phone_number.py +100 -0
  185. pluggy_sdk/models/pix_data.py +90 -0
  186. pluggy_sdk/models/schedule_payment.py +102 -0
  187. pluggy_sdk/models/schedule_type_custom.py +100 -0
  188. pluggy_sdk/models/schedule_type_daily.py +101 -0
  189. pluggy_sdk/models/schedule_type_monthly.py +103 -0
  190. pluggy_sdk/models/schedule_type_single.py +98 -0
  191. pluggy_sdk/models/schedule_type_weekly.py +110 -0
  192. pluggy_sdk/models/single.py +98 -0
  193. pluggy_sdk/models/smart_account.py +107 -0
  194. pluggy_sdk/models/smart_account_address.py +112 -0
  195. pluggy_sdk/models/smart_account_balance.py +95 -0
  196. pluggy_sdk/models/smart_account_transfer.py +123 -0
  197. pluggy_sdk/models/smart_accounts_list200_response.py +102 -0
  198. pluggy_sdk/models/smart_tranfers_preauthorizations_list200_response.py +102 -0
  199. pluggy_sdk/models/smart_transfer_callback_urls.py +90 -0
  200. pluggy_sdk/models/smart_transfer_payment.py +116 -0
  201. pluggy_sdk/models/smart_transfer_preauthorization.py +128 -0
  202. pluggy_sdk/models/smart_transfer_preauthorization_parameter.py +90 -0
  203. pluggy_sdk/models/status_detail.py +127 -0
  204. pluggy_sdk/models/status_detail_product.py +101 -0
  205. pluggy_sdk/models/status_detail_product_warning.py +92 -0
  206. pluggy_sdk/models/transaction.py +141 -0
  207. pluggy_sdk/models/update_item.py +109 -0
  208. pluggy_sdk/models/update_item_parameters.py +144 -0
  209. pluggy_sdk/models/update_payment_recipient.py +102 -0
  210. pluggy_sdk/models/update_payment_request.py +102 -0
  211. pluggy_sdk/models/update_transaction.py +88 -0
  212. pluggy_sdk/models/webhook.py +106 -0
  213. pluggy_sdk/models/webhook_creation_error_response.py +90 -0
  214. pluggy_sdk/models/webhooks_list200_response.py +102 -0
  215. pluggy_sdk/models/weekly.py +110 -0
  216. pluggy_sdk/py.typed +0 -0
  217. pluggy_sdk/rest.py +258 -0
  218. pluggy_sdk-1.0.0.post34.dist-info/METADATA +373 -0
  219. pluggy_sdk-1.0.0.post34.dist-info/RECORD +221 -0
  220. pluggy_sdk-1.0.0.post34.dist-info/WHEEL +5 -0
  221. pluggy_sdk-1.0.0.post34.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,596 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Pluggy API
5
+
6
+ Pluggy's main API to review data and execute connectors
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: hello@pluggy.ai
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
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
+ "default": APIKeyAuthSetting,
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
+
166
+ :Example:
167
+
168
+ API Key Authentication Example.
169
+ Given the following security scheme in the OpenAPI specification:
170
+ components:
171
+ securitySchemes:
172
+ cookieAuth: # name for the security scheme
173
+ type: apiKey
174
+ in: cookie
175
+ name: JSESSIONID # cookie name
176
+
177
+ You can programmatically set the cookie:
178
+
179
+ conf = pluggy_sdk.Configuration(
180
+ api_key={'cookieAuth': 'abc123'}
181
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
182
+ )
183
+
184
+ The following cookie will be added to the HTTP request:
185
+ Cookie: JSESSIONID abc123
186
+ """
187
+
188
+ _default: ClassVar[Optional[Self]] = None
189
+
190
+ def __init__(
191
+ self,
192
+ host: Optional[str]=None,
193
+ api_key: Optional[Dict[str, str]]=None,
194
+ api_key_prefix: Optional[Dict[str, str]]=None,
195
+ username: Optional[str]=None,
196
+ password: Optional[str]=None,
197
+ access_token: Optional[str]=None,
198
+ server_index: Optional[int]=None,
199
+ server_variables: Optional[ServerVariablesT]=None,
200
+ server_operation_index: Optional[Dict[int, int]]=None,
201
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
202
+ ignore_operation_servers: bool=False,
203
+ ssl_ca_cert: Optional[str]=None,
204
+ retries: Optional[int] = None,
205
+ *,
206
+ debug: Optional[bool] = None,
207
+ ) -> None:
208
+ """Constructor
209
+ """
210
+ self._base_path = "https://api.pluggy.ai" if host is None else host
211
+ """Default Base url
212
+ """
213
+ self.server_index = 0 if server_index is None and host is None else server_index
214
+ self.server_operation_index = server_operation_index or {}
215
+ """Default server index
216
+ """
217
+ self.server_variables = server_variables or {}
218
+ self.server_operation_variables = server_operation_variables or {}
219
+ """Default server variables
220
+ """
221
+ self.ignore_operation_servers = ignore_operation_servers
222
+ """Ignore operation servers
223
+ """
224
+ self.temp_folder_path = None
225
+ """Temp file folder for downloading files
226
+ """
227
+ # Authentication Settings
228
+ self.api_key = {}
229
+ if api_key:
230
+ self.api_key = api_key
231
+ """dict to store API key(s)
232
+ """
233
+ self.api_key_prefix = {}
234
+ if api_key_prefix:
235
+ self.api_key_prefix = api_key_prefix
236
+ """dict to store API prefix (e.g. Bearer)
237
+ """
238
+ self.refresh_api_key_hook = None
239
+ """function hook to refresh API key if expired
240
+ """
241
+ self.username = username
242
+ """Username for HTTP basic authentication
243
+ """
244
+ self.password = password
245
+ """Password for HTTP basic authentication
246
+ """
247
+ self.access_token = access_token
248
+ """Access token
249
+ """
250
+ self.logger = {}
251
+ """Logging Settings
252
+ """
253
+ self.logger["package_logger"] = logging.getLogger("pluggy_sdk")
254
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
255
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
256
+ """Log format
257
+ """
258
+ self.logger_stream_handler = None
259
+ """Log stream handler
260
+ """
261
+ self.logger_file_handler: Optional[FileHandler] = None
262
+ """Log file handler
263
+ """
264
+ self.logger_file = None
265
+ """Debug file location
266
+ """
267
+ if debug is not None:
268
+ self.debug = debug
269
+ else:
270
+ self.__debug = False
271
+ """Debug switch
272
+ """
273
+
274
+ self.verify_ssl = True
275
+ """SSL/TLS verification
276
+ Set this to false to skip verifying SSL certificate when calling API
277
+ from https server.
278
+ """
279
+ self.ssl_ca_cert = ssl_ca_cert
280
+ """Set this to customize the certificate file to verify the peer.
281
+ """
282
+ self.cert_file = None
283
+ """client certificate file
284
+ """
285
+ self.key_file = None
286
+ """client key file
287
+ """
288
+ self.assert_hostname = None
289
+ """Set this to True/False to enable/disable SSL hostname verification.
290
+ """
291
+ self.tls_server_name = None
292
+ """SSL/TLS Server Name Indication (SNI)
293
+ Set this to the SNI value expected by the server.
294
+ """
295
+
296
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
297
+ """urllib3 connection pool's maximum number of connections saved
298
+ per pool. urllib3 uses 1 connection as default value, but this is
299
+ not the best value when you are making a lot of possibly parallel
300
+ requests to the same host, which is often the case here.
301
+ cpu_count * 5 is used as default value to increase performance.
302
+ """
303
+
304
+ self.proxy: Optional[str] = None
305
+ """Proxy URL
306
+ """
307
+ self.proxy_headers = None
308
+ """Proxy headers
309
+ """
310
+ self.safe_chars_for_path_param = ''
311
+ """Safe chars for path_param
312
+ """
313
+ self.retries = retries
314
+ """Adding retries to override urllib3 default value 3
315
+ """
316
+ # Enable client side validation
317
+ self.client_side_validation = True
318
+
319
+ self.socket_options = None
320
+ """Options to pass down to the underlying urllib3 socket
321
+ """
322
+
323
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
324
+ """datetime format
325
+ """
326
+
327
+ self.date_format = "%Y-%m-%d"
328
+ """date format
329
+ """
330
+
331
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
332
+ cls = self.__class__
333
+ result = cls.__new__(cls)
334
+ memo[id(self)] = result
335
+ for k, v in self.__dict__.items():
336
+ if k not in ('logger', 'logger_file_handler'):
337
+ setattr(result, k, copy.deepcopy(v, memo))
338
+ # shallow copy of loggers
339
+ result.logger = copy.copy(self.logger)
340
+ # use setters to configure loggers
341
+ result.logger_file = self.logger_file
342
+ result.debug = self.debug
343
+ return result
344
+
345
+ def __setattr__(self, name: str, value: Any) -> None:
346
+ object.__setattr__(self, name, value)
347
+
348
+ @classmethod
349
+ def set_default(cls, default: Optional[Self]) -> None:
350
+ """Set default instance of configuration.
351
+
352
+ It stores default configuration, which can be
353
+ returned by get_default_copy method.
354
+
355
+ :param default: object of Configuration
356
+ """
357
+ cls._default = default
358
+
359
+ @classmethod
360
+ def get_default_copy(cls) -> Self:
361
+ """Deprecated. Please use `get_default` instead.
362
+
363
+ Deprecated. Please use `get_default` instead.
364
+
365
+ :return: The configuration object.
366
+ """
367
+ return cls.get_default()
368
+
369
+ @classmethod
370
+ def get_default(cls) -> Self:
371
+ """Return the default configuration.
372
+
373
+ This method returns newly created, based on default constructor,
374
+ object of Configuration class or returns a copy of default
375
+ configuration.
376
+
377
+ :return: The configuration object.
378
+ """
379
+ if cls._default is None:
380
+ cls._default = cls()
381
+ return cls._default
382
+
383
+ @property
384
+ def logger_file(self) -> Optional[str]:
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
+ return self.__logger_file
394
+
395
+ @logger_file.setter
396
+ def logger_file(self, value: Optional[str]) -> None:
397
+ """The logger file.
398
+
399
+ If the logger_file is None, then add stream handler and remove file
400
+ handler. Otherwise, add file handler and remove stream handler.
401
+
402
+ :param value: The logger_file path.
403
+ :type: str
404
+ """
405
+ self.__logger_file = value
406
+ if self.__logger_file:
407
+ # If set logging file,
408
+ # then add file handler and remove stream handler.
409
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
410
+ self.logger_file_handler.setFormatter(self.logger_formatter)
411
+ for _, logger in self.logger.items():
412
+ logger.addHandler(self.logger_file_handler)
413
+
414
+ @property
415
+ def debug(self) -> bool:
416
+ """Debug status
417
+
418
+ :param value: The debug status, True or False.
419
+ :type: bool
420
+ """
421
+ return self.__debug
422
+
423
+ @debug.setter
424
+ def debug(self, value: bool) -> None:
425
+ """Debug status
426
+
427
+ :param value: The debug status, True or False.
428
+ :type: bool
429
+ """
430
+ self.__debug = value
431
+ if self.__debug:
432
+ # if debug status is True, turn on debug logging
433
+ for _, logger in self.logger.items():
434
+ logger.setLevel(logging.DEBUG)
435
+ # turn on httplib debug
436
+ httplib.HTTPConnection.debuglevel = 1
437
+ else:
438
+ # if debug status is False, turn off debug logging,
439
+ # setting log level to default `logging.WARNING`
440
+ for _, logger in self.logger.items():
441
+ logger.setLevel(logging.WARNING)
442
+ # turn off httplib debug
443
+ httplib.HTTPConnection.debuglevel = 0
444
+
445
+ @property
446
+ def logger_format(self) -> str:
447
+ """The logger format.
448
+
449
+ The logger_formatter will be updated when sets logger_format.
450
+
451
+ :param value: The format string.
452
+ :type: str
453
+ """
454
+ return self.__logger_format
455
+
456
+ @logger_format.setter
457
+ def logger_format(self, value: str) -> None:
458
+ """The logger format.
459
+
460
+ The logger_formatter will be updated when sets logger_format.
461
+
462
+ :param value: The format string.
463
+ :type: str
464
+ """
465
+ self.__logger_format = value
466
+ self.logger_formatter = logging.Formatter(self.__logger_format)
467
+
468
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
469
+ """Gets API key (with prefix if set).
470
+
471
+ :param identifier: The identifier of apiKey.
472
+ :param alias: The alternative identifier of apiKey.
473
+ :return: The token for api key authentication.
474
+ """
475
+ if self.refresh_api_key_hook is not None:
476
+ self.refresh_api_key_hook(self)
477
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
478
+ if key:
479
+ prefix = self.api_key_prefix.get(identifier)
480
+ if prefix:
481
+ return "%s %s" % (prefix, key)
482
+ else:
483
+ return key
484
+
485
+ return None
486
+
487
+ def get_basic_auth_token(self) -> Optional[str]:
488
+ """Gets HTTP basic authentication header (string).
489
+
490
+ :return: The token for basic HTTP authentication.
491
+ """
492
+ username = ""
493
+ if self.username is not None:
494
+ username = self.username
495
+ password = ""
496
+ if self.password is not None:
497
+ password = self.password
498
+ return urllib3.util.make_headers(
499
+ basic_auth=username + ':' + password
500
+ ).get('authorization')
501
+
502
+ def auth_settings(self)-> AuthSettings:
503
+ """Gets Auth Settings dict for api client.
504
+
505
+ :return: The Auth Settings information dict.
506
+ """
507
+ auth: AuthSettings = {}
508
+ if 'default' in self.api_key:
509
+ auth['default'] = {
510
+ 'type': 'api_key',
511
+ 'in': 'header',
512
+ 'key': 'X-API-KEY',
513
+ 'value': self.get_api_key_with_prefix(
514
+ 'default',
515
+ ),
516
+ }
517
+ return auth
518
+
519
+ def to_debug_report(self) -> str:
520
+ """Gets the essential information for debugging.
521
+
522
+ :return: The report for debugging.
523
+ """
524
+ return "Python SDK Debug Report:\n"\
525
+ "OS: {env}\n"\
526
+ "Python Version: {pyversion}\n"\
527
+ "Version of the API: 1.0.0\n"\
528
+ "SDK Package Version: 1.0.0.post34".\
529
+ format(env=sys.platform, pyversion=sys.version)
530
+
531
+ def get_host_settings(self) -> List[HostSetting]:
532
+ """Gets an array of host settings
533
+
534
+ :return: An array of host settings
535
+ """
536
+ return [
537
+ {
538
+ 'url': "https://api.pluggy.ai",
539
+ 'description': "Pluggy API",
540
+ }
541
+ ]
542
+
543
+ def get_host_from_settings(
544
+ self,
545
+ index: Optional[int],
546
+ variables: Optional[ServerVariablesT]=None,
547
+ servers: Optional[List[HostSetting]]=None,
548
+ ) -> str:
549
+ """Gets host URL based on the index and variables
550
+ :param index: array index of the host settings
551
+ :param variables: hash of variable and the corresponding value
552
+ :param servers: an array of host settings or None
553
+ :return: URL based on host settings
554
+ """
555
+ if index is None:
556
+ return self._base_path
557
+
558
+ variables = {} if variables is None else variables
559
+ servers = self.get_host_settings() if servers is None else servers
560
+
561
+ try:
562
+ server = servers[index]
563
+ except IndexError:
564
+ raise ValueError(
565
+ "Invalid index {0} when selecting the host settings. "
566
+ "Must be less than {1}".format(index, len(servers)))
567
+
568
+ url = server['url']
569
+
570
+ # go through variables and replace placeholders
571
+ for variable_name, variable in server.get('variables', {}).items():
572
+ used_value = variables.get(
573
+ variable_name, variable['default_value'])
574
+
575
+ if 'enum_values' in variable \
576
+ and used_value not in variable['enum_values']:
577
+ raise ValueError(
578
+ "The variable `{0}` in the host URL has invalid value "
579
+ "{1}. Must be {2}.".format(
580
+ variable_name, variables[variable_name],
581
+ variable['enum_values']))
582
+
583
+ url = url.replace("{" + variable_name + "}", used_value)
584
+
585
+ return url
586
+
587
+ @property
588
+ def host(self) -> str:
589
+ """Return generated host."""
590
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
591
+
592
+ @host.setter
593
+ def host(self, value: str) -> None:
594
+ """Fix base path."""
595
+ self._base_path = value
596
+ self.server_index = None