pluggy-sdk 1.0.0.post2__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 (163) hide show
  1. pluggy_sdk/__init__.py +183 -0
  2. pluggy_sdk/api/__init__.py +26 -0
  3. pluggy_sdk/api/account_api.py +582 -0
  4. pluggy_sdk/api/acquirer_anticipation_api.py +658 -0
  5. pluggy_sdk/api/acquirer_receivable_api.py +658 -0
  6. pluggy_sdk/api/acquirer_sale_api.py +658 -0
  7. pluggy_sdk/api/auth_api.py +599 -0
  8. pluggy_sdk/api/bill_api.py +561 -0
  9. pluggy_sdk/api/bulk_payment_api.py +854 -0
  10. pluggy_sdk/api/category_api.py +1084 -0
  11. pluggy_sdk/api/connector_api.py +970 -0
  12. pluggy_sdk/api/identity_api.py +575 -0
  13. pluggy_sdk/api/income_report_api.py +308 -0
  14. pluggy_sdk/api/investment_api.py +909 -0
  15. pluggy_sdk/api/items_api.py +1441 -0
  16. pluggy_sdk/api/loan_api.py +561 -0
  17. pluggy_sdk/api/payment_customer_api.py +1399 -0
  18. pluggy_sdk/api/payment_intent_api.py +833 -0
  19. pluggy_sdk/api/payment_recipient_api.py +1976 -0
  20. pluggy_sdk/api/payment_request_api.py +1636 -0
  21. pluggy_sdk/api/portfolio_yield_api.py +574 -0
  22. pluggy_sdk/api/smart_account_api.py +1116 -0
  23. pluggy_sdk/api/transaction_api.py +954 -0
  24. pluggy_sdk/api/webhook_api.py +1391 -0
  25. pluggy_sdk/api_client.py +769 -0
  26. pluggy_sdk/api_response.py +21 -0
  27. pluggy_sdk/configuration.py +466 -0
  28. pluggy_sdk/exceptions.py +200 -0
  29. pluggy_sdk/models/__init__.py +145 -0
  30. pluggy_sdk/models/account.py +134 -0
  31. pluggy_sdk/models/accounts_list200_response.py +102 -0
  32. pluggy_sdk/models/acquirer_anticipation.py +117 -0
  33. pluggy_sdk/models/acquirer_anticipation_data.py +101 -0
  34. pluggy_sdk/models/acquirer_data.py +113 -0
  35. pluggy_sdk/models/acquirer_receivable.py +143 -0
  36. pluggy_sdk/models/acquirer_receivable_data.py +108 -0
  37. pluggy_sdk/models/acquirer_receivable_data_establishment.py +96 -0
  38. pluggy_sdk/models/acquirer_receivable_destination_account.py +92 -0
  39. pluggy_sdk/models/acquirer_receivable_related_sale.py +99 -0
  40. pluggy_sdk/models/acquirer_sale.py +171 -0
  41. pluggy_sdk/models/acquirer_sale_data.py +150 -0
  42. pluggy_sdk/models/acquirer_sale_installment.py +93 -0
  43. pluggy_sdk/models/acquirer_sale_installment_data.py +95 -0
  44. pluggy_sdk/models/address.py +110 -0
  45. pluggy_sdk/models/aggregated_portfolio.py +120 -0
  46. pluggy_sdk/models/aggregated_portfolio_response.py +102 -0
  47. pluggy_sdk/models/asset_distribution.py +88 -0
  48. pluggy_sdk/models/auth_request.py +90 -0
  49. pluggy_sdk/models/auth_response.py +88 -0
  50. pluggy_sdk/models/bank_data.py +92 -0
  51. pluggy_sdk/models/bill.py +109 -0
  52. pluggy_sdk/models/bill_finance_charge.py +103 -0
  53. pluggy_sdk/models/bills_list200_response.py +102 -0
  54. pluggy_sdk/models/bulk_payment.py +128 -0
  55. pluggy_sdk/models/bulk_payments_list200_response.py +102 -0
  56. pluggy_sdk/models/category.py +96 -0
  57. pluggy_sdk/models/client_category_rule.py +94 -0
  58. pluggy_sdk/models/company.py +90 -0
  59. pluggy_sdk/models/connect_token_request.py +94 -0
  60. pluggy_sdk/models/connect_token_response.py +88 -0
  61. pluggy_sdk/models/connector.py +141 -0
  62. pluggy_sdk/models/connector_credential.py +121 -0
  63. pluggy_sdk/models/connector_health.py +96 -0
  64. pluggy_sdk/models/connector_health_details.py +90 -0
  65. pluggy_sdk/models/connector_list_response.py +102 -0
  66. pluggy_sdk/models/connector_user_action.py +93 -0
  67. pluggy_sdk/models/create_bulk_payment.py +96 -0
  68. pluggy_sdk/models/create_client_category_rule.py +92 -0
  69. pluggy_sdk/models/create_item.py +111 -0
  70. pluggy_sdk/models/create_item_parameters.py +144 -0
  71. pluggy_sdk/models/create_or_update_payment_customer.py +105 -0
  72. pluggy_sdk/models/create_payment_customer_request_body.py +103 -0
  73. pluggy_sdk/models/create_payment_intent.py +94 -0
  74. pluggy_sdk/models/create_payment_recipient.py +100 -0
  75. pluggy_sdk/models/create_payment_request.py +102 -0
  76. pluggy_sdk/models/create_pix_qr_payment_request.py +96 -0
  77. pluggy_sdk/models/create_smart_account_request.py +102 -0
  78. pluggy_sdk/models/create_webhook.py +99 -0
  79. pluggy_sdk/models/credential_select_option.py +90 -0
  80. pluggy_sdk/models/credit_card_metadata.py +101 -0
  81. pluggy_sdk/models/credit_data.py +127 -0
  82. pluggy_sdk/models/document.py +100 -0
  83. pluggy_sdk/models/email.py +100 -0
  84. pluggy_sdk/models/global_error_response.py +94 -0
  85. pluggy_sdk/models/i_count_response.py +88 -0
  86. pluggy_sdk/models/identity_relation.py +102 -0
  87. pluggy_sdk/models/identity_response.py +149 -0
  88. pluggy_sdk/models/income_report.py +90 -0
  89. pluggy_sdk/models/income_reports_response.py +102 -0
  90. pluggy_sdk/models/investment.py +192 -0
  91. pluggy_sdk/models/investment_expenses.py +108 -0
  92. pluggy_sdk/models/investment_metadata.py +99 -0
  93. pluggy_sdk/models/investment_transaction.py +124 -0
  94. pluggy_sdk/models/investments_list200_response.py +102 -0
  95. pluggy_sdk/models/item.py +148 -0
  96. pluggy_sdk/models/item_creation_error_response.py +102 -0
  97. pluggy_sdk/models/item_error.py +94 -0
  98. pluggy_sdk/models/item_options.py +90 -0
  99. pluggy_sdk/models/loan.py +199 -0
  100. pluggy_sdk/models/loan_contracted_fee.py +118 -0
  101. pluggy_sdk/models/loan_contracted_finance_charge.py +92 -0
  102. pluggy_sdk/models/loan_installment_balloon_payment.py +95 -0
  103. pluggy_sdk/models/loan_installment_balloon_payment_amount.py +90 -0
  104. pluggy_sdk/models/loan_installments.py +130 -0
  105. pluggy_sdk/models/loan_interest_rate.py +136 -0
  106. pluggy_sdk/models/loan_payment_release.py +103 -0
  107. pluggy_sdk/models/loan_payment_release_over_parcel.py +106 -0
  108. pluggy_sdk/models/loan_payment_release_over_parcel_charge.py +92 -0
  109. pluggy_sdk/models/loan_payment_release_over_parcel_fee.py +92 -0
  110. pluggy_sdk/models/loan_payments.py +98 -0
  111. pluggy_sdk/models/loan_warranty.py +94 -0
  112. pluggy_sdk/models/loans_list200_response.py +102 -0
  113. pluggy_sdk/models/merchant.py +96 -0
  114. pluggy_sdk/models/monthly_portfolio.py +100 -0
  115. pluggy_sdk/models/monthly_portfolio_response.py +102 -0
  116. pluggy_sdk/models/not_authenticated_response.py +90 -0
  117. pluggy_sdk/models/page_response_acquirer_anticipations.py +102 -0
  118. pluggy_sdk/models/page_response_acquirer_receivables.py +102 -0
  119. pluggy_sdk/models/page_response_acquirer_sales.py +102 -0
  120. pluggy_sdk/models/page_response_category_rules.py +102 -0
  121. pluggy_sdk/models/page_response_investment_transactions.py +102 -0
  122. pluggy_sdk/models/page_response_transactions.py +102 -0
  123. pluggy_sdk/models/parameter_validation_error.py +92 -0
  124. pluggy_sdk/models/parameter_validation_response.py +98 -0
  125. pluggy_sdk/models/payment_customer.py +105 -0
  126. pluggy_sdk/models/payment_customers_list200_response.py +102 -0
  127. pluggy_sdk/models/payment_data.py +105 -0
  128. pluggy_sdk/models/payment_data_participant.py +101 -0
  129. pluggy_sdk/models/payment_institution.py +101 -0
  130. pluggy_sdk/models/payment_intent.py +145 -0
  131. pluggy_sdk/models/payment_intents_list200_response.py +102 -0
  132. pluggy_sdk/models/payment_recipient.py +106 -0
  133. pluggy_sdk/models/payment_recipient_account.py +99 -0
  134. pluggy_sdk/models/payment_recipients_institution_list200_response.py +102 -0
  135. pluggy_sdk/models/payment_recipients_list200_response.py +102 -0
  136. pluggy_sdk/models/payment_request.py +118 -0
  137. pluggy_sdk/models/payment_request_callback_urls.py +92 -0
  138. pluggy_sdk/models/payment_requests_list200_response.py +102 -0
  139. pluggy_sdk/models/percentage_over_index.py +90 -0
  140. pluggy_sdk/models/phone_number.py +100 -0
  141. pluggy_sdk/models/pix_data.py +90 -0
  142. pluggy_sdk/models/smart_account.py +107 -0
  143. pluggy_sdk/models/smart_account_address.py +112 -0
  144. pluggy_sdk/models/smart_account_balance.py +95 -0
  145. pluggy_sdk/models/smart_accounts_list200_response.py +102 -0
  146. pluggy_sdk/models/status_detail.py +142 -0
  147. pluggy_sdk/models/status_detail_product.py +101 -0
  148. pluggy_sdk/models/status_detail_product_warning.py +92 -0
  149. pluggy_sdk/models/transaction.py +145 -0
  150. pluggy_sdk/models/update_item.py +109 -0
  151. pluggy_sdk/models/update_item_parameters.py +144 -0
  152. pluggy_sdk/models/update_payment_recipient.py +100 -0
  153. pluggy_sdk/models/update_payment_request.py +102 -0
  154. pluggy_sdk/models/update_transaction.py +88 -0
  155. pluggy_sdk/models/webhook.py +106 -0
  156. pluggy_sdk/models/webhook_creation_error_response.py +90 -0
  157. pluggy_sdk/models/webhooks_list200_response.py +102 -0
  158. pluggy_sdk/py.typed +0 -0
  159. pluggy_sdk/rest.py +258 -0
  160. pluggy_sdk-1.0.0.post2.dist-info/METADATA +336 -0
  161. pluggy_sdk-1.0.0.post2.dist-info/RECORD +163 -0
  162. pluggy_sdk-1.0.0.post2.dist-info/WHEEL +5 -0
  163. pluggy_sdk-1.0.0.post2.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,466 @@
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 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 api_key: Dict to store API key(s).
37
+ Each entry in the dict specifies an API key.
38
+ The dict key is the name of the security scheme in the OAS specification.
39
+ The dict value is the API key secret.
40
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
41
+ The dict key is the name of the security scheme in the OAS specification.
42
+ The dict value is an API key prefix when generating the auth data.
43
+ :param username: Username for HTTP basic authentication.
44
+ :param password: Password for HTTP basic authentication.
45
+ :param access_token: Access token.
46
+ :param server_index: Index to servers configuration.
47
+ :param server_variables: Mapping with string values to replace variables in
48
+ templated server configuration. The validation of enums is performed for
49
+ variables with defined enum values before.
50
+ :param server_operation_index: Mapping from operation ID to an index to server
51
+ configuration.
52
+ :param server_operation_variables: Mapping from operation ID to a mapping with
53
+ string values to replace variables in templated server configuration.
54
+ The validation of enums is performed for variables with defined enum
55
+ values before.
56
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
57
+ in PEM format.
58
+
59
+ :Example:
60
+
61
+ API Key Authentication Example.
62
+ Given the following security scheme in the OpenAPI specification:
63
+ components:
64
+ securitySchemes:
65
+ cookieAuth: # name for the security scheme
66
+ type: apiKey
67
+ in: cookie
68
+ name: JSESSIONID # cookie name
69
+
70
+ You can programmatically set the cookie:
71
+
72
+ conf = pluggy_sdk.Configuration(
73
+ api_key={'cookieAuth': 'abc123'}
74
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
75
+ )
76
+
77
+ The following cookie will be added to the HTTP request:
78
+ Cookie: JSESSIONID abc123
79
+ """
80
+
81
+ _default = None
82
+
83
+ def __init__(self, host=None,
84
+ api_key=None, api_key_prefix=None,
85
+ username=None, password=None,
86
+ access_token=None,
87
+ server_index=None, server_variables=None,
88
+ server_operation_index=None, server_operation_variables=None,
89
+ ssl_ca_cert=None,
90
+ ) -> None:
91
+ """Constructor
92
+ """
93
+ self._base_path = "https://api.pluggy.ai" if host is None else host
94
+ """Default Base url
95
+ """
96
+ self.server_index = 0 if server_index is None and host is None else server_index
97
+ self.server_operation_index = server_operation_index or {}
98
+ """Default server index
99
+ """
100
+ self.server_variables = server_variables or {}
101
+ self.server_operation_variables = server_operation_variables or {}
102
+ """Default server variables
103
+ """
104
+ self.temp_folder_path = None
105
+ """Temp file folder for downloading files
106
+ """
107
+ # Authentication Settings
108
+ self.api_key = {}
109
+ if api_key:
110
+ self.api_key = api_key
111
+ """dict to store API key(s)
112
+ """
113
+ self.api_key_prefix = {}
114
+ if api_key_prefix:
115
+ self.api_key_prefix = api_key_prefix
116
+ """dict to store API prefix (e.g. Bearer)
117
+ """
118
+ self.refresh_api_key_hook = None
119
+ """function hook to refresh API key if expired
120
+ """
121
+ self.username = username
122
+ """Username for HTTP basic authentication
123
+ """
124
+ self.password = password
125
+ """Password for HTTP basic authentication
126
+ """
127
+ self.access_token = access_token
128
+ """Access token
129
+ """
130
+ self.logger = {}
131
+ """Logging Settings
132
+ """
133
+ self.logger["package_logger"] = logging.getLogger("pluggy_sdk")
134
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
135
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
136
+ """Log format
137
+ """
138
+ self.logger_stream_handler = None
139
+ """Log stream handler
140
+ """
141
+ self.logger_file_handler: Optional[FileHandler] = None
142
+ """Log file handler
143
+ """
144
+ self.logger_file = None
145
+ """Debug file location
146
+ """
147
+ self.debug = False
148
+ """Debug switch
149
+ """
150
+
151
+ self.verify_ssl = True
152
+ """SSL/TLS verification
153
+ Set this to false to skip verifying SSL certificate when calling API
154
+ from https server.
155
+ """
156
+ self.ssl_ca_cert = ssl_ca_cert
157
+ """Set this to customize the certificate file to verify the peer.
158
+ """
159
+ self.cert_file = None
160
+ """client certificate file
161
+ """
162
+ self.key_file = None
163
+ """client key file
164
+ """
165
+ self.assert_hostname = None
166
+ """Set this to True/False to enable/disable SSL hostname verification.
167
+ """
168
+ self.tls_server_name = None
169
+ """SSL/TLS Server Name Indication (SNI)
170
+ Set this to the SNI value expected by the server.
171
+ """
172
+
173
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
174
+ """urllib3 connection pool's maximum number of connections saved
175
+ per pool. urllib3 uses 1 connection as default value, but this is
176
+ not the best value when you are making a lot of possibly parallel
177
+ requests to the same host, which is often the case here.
178
+ cpu_count * 5 is used as default value to increase performance.
179
+ """
180
+
181
+ self.proxy: Optional[str] = None
182
+ """Proxy URL
183
+ """
184
+ self.proxy_headers = None
185
+ """Proxy headers
186
+ """
187
+ self.safe_chars_for_path_param = ''
188
+ """Safe chars for path_param
189
+ """
190
+ self.retries = None
191
+ """Adding retries to override urllib3 default value 3
192
+ """
193
+ # Enable client side validation
194
+ self.client_side_validation = True
195
+
196
+ self.socket_options = None
197
+ """Options to pass down to the underlying urllib3 socket
198
+ """
199
+
200
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
201
+ """datetime format
202
+ """
203
+
204
+ self.date_format = "%Y-%m-%d"
205
+ """date format
206
+ """
207
+
208
+ def __deepcopy__(self, memo):
209
+ cls = self.__class__
210
+ result = cls.__new__(cls)
211
+ memo[id(self)] = result
212
+ for k, v in self.__dict__.items():
213
+ if k not in ('logger', 'logger_file_handler'):
214
+ setattr(result, k, copy.deepcopy(v, memo))
215
+ # shallow copy of loggers
216
+ result.logger = copy.copy(self.logger)
217
+ # use setters to configure loggers
218
+ result.logger_file = self.logger_file
219
+ result.debug = self.debug
220
+ return result
221
+
222
+ def __setattr__(self, name, value):
223
+ object.__setattr__(self, name, value)
224
+
225
+ @classmethod
226
+ def set_default(cls, default):
227
+ """Set default instance of configuration.
228
+
229
+ It stores default configuration, which can be
230
+ returned by get_default_copy method.
231
+
232
+ :param default: object of Configuration
233
+ """
234
+ cls._default = default
235
+
236
+ @classmethod
237
+ def get_default_copy(cls):
238
+ """Deprecated. Please use `get_default` instead.
239
+
240
+ Deprecated. Please use `get_default` instead.
241
+
242
+ :return: The configuration object.
243
+ """
244
+ return cls.get_default()
245
+
246
+ @classmethod
247
+ def get_default(cls):
248
+ """Return the default configuration.
249
+
250
+ This method returns newly created, based on default constructor,
251
+ object of Configuration class or returns a copy of default
252
+ configuration.
253
+
254
+ :return: The configuration object.
255
+ """
256
+ if cls._default is None:
257
+ cls._default = Configuration()
258
+ return cls._default
259
+
260
+ @property
261
+ def logger_file(self):
262
+ """The logger file.
263
+
264
+ If the logger_file is None, then add stream handler and remove file
265
+ handler. Otherwise, add file handler and remove stream handler.
266
+
267
+ :param value: The logger_file path.
268
+ :type: str
269
+ """
270
+ return self.__logger_file
271
+
272
+ @logger_file.setter
273
+ def logger_file(self, value):
274
+ """The logger file.
275
+
276
+ If the logger_file is None, then add stream handler and remove file
277
+ handler. Otherwise, add file handler and remove stream handler.
278
+
279
+ :param value: The logger_file path.
280
+ :type: str
281
+ """
282
+ self.__logger_file = value
283
+ if self.__logger_file:
284
+ # If set logging file,
285
+ # then add file handler and remove stream handler.
286
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
287
+ self.logger_file_handler.setFormatter(self.logger_formatter)
288
+ for _, logger in self.logger.items():
289
+ logger.addHandler(self.logger_file_handler)
290
+
291
+ @property
292
+ def debug(self):
293
+ """Debug status
294
+
295
+ :param value: The debug status, True or False.
296
+ :type: bool
297
+ """
298
+ return self.__debug
299
+
300
+ @debug.setter
301
+ def debug(self, value):
302
+ """Debug status
303
+
304
+ :param value: The debug status, True or False.
305
+ :type: bool
306
+ """
307
+ self.__debug = value
308
+ if self.__debug:
309
+ # if debug status is True, turn on debug logging
310
+ for _, logger in self.logger.items():
311
+ logger.setLevel(logging.DEBUG)
312
+ # turn on httplib debug
313
+ httplib.HTTPConnection.debuglevel = 1
314
+ else:
315
+ # if debug status is False, turn off debug logging,
316
+ # setting log level to default `logging.WARNING`
317
+ for _, logger in self.logger.items():
318
+ logger.setLevel(logging.WARNING)
319
+ # turn off httplib debug
320
+ httplib.HTTPConnection.debuglevel = 0
321
+
322
+ @property
323
+ def logger_format(self):
324
+ """The logger format.
325
+
326
+ The logger_formatter will be updated when sets logger_format.
327
+
328
+ :param value: The format string.
329
+ :type: str
330
+ """
331
+ return self.__logger_format
332
+
333
+ @logger_format.setter
334
+ def logger_format(self, value):
335
+ """The logger format.
336
+
337
+ The logger_formatter will be updated when sets logger_format.
338
+
339
+ :param value: The format string.
340
+ :type: str
341
+ """
342
+ self.__logger_format = value
343
+ self.logger_formatter = logging.Formatter(self.__logger_format)
344
+
345
+ def get_api_key_with_prefix(self, identifier, alias=None):
346
+ """Gets API key (with prefix if set).
347
+
348
+ :param identifier: The identifier of apiKey.
349
+ :param alias: The alternative identifier of apiKey.
350
+ :return: The token for api key authentication.
351
+ """
352
+ if self.refresh_api_key_hook is not None:
353
+ self.refresh_api_key_hook(self)
354
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
355
+ if key:
356
+ prefix = self.api_key_prefix.get(identifier)
357
+ if prefix:
358
+ return "%s %s" % (prefix, key)
359
+ else:
360
+ return key
361
+
362
+ def get_basic_auth_token(self):
363
+ """Gets HTTP basic authentication header (string).
364
+
365
+ :return: The token for basic HTTP authentication.
366
+ """
367
+ username = ""
368
+ if self.username is not None:
369
+ username = self.username
370
+ password = ""
371
+ if self.password is not None:
372
+ password = self.password
373
+ return urllib3.util.make_headers(
374
+ basic_auth=username + ':' + password
375
+ ).get('authorization')
376
+
377
+ def auth_settings(self):
378
+ """Gets Auth Settings dict for api client.
379
+
380
+ :return: The Auth Settings information dict.
381
+ """
382
+ auth = {}
383
+ if 'default' in self.api_key:
384
+ auth['default'] = {
385
+ 'type': 'api_key',
386
+ 'in': 'header',
387
+ 'key': 'X-API-KEY',
388
+ 'value': self.get_api_key_with_prefix(
389
+ 'default',
390
+ ),
391
+ }
392
+ return auth
393
+
394
+ def to_debug_report(self):
395
+ """Gets the essential information for debugging.
396
+
397
+ :return: The report for debugging.
398
+ """
399
+ return "Python SDK Debug Report:\n"\
400
+ "OS: {env}\n"\
401
+ "Python Version: {pyversion}\n"\
402
+ "Version of the API: 1.0.0\n"\
403
+ "SDK Package Version: 1.0.0.post2".\
404
+ format(env=sys.platform, pyversion=sys.version)
405
+
406
+ def get_host_settings(self):
407
+ """Gets an array of host settings
408
+
409
+ :return: An array of host settings
410
+ """
411
+ return [
412
+ {
413
+ 'url': "https://api.pluggy.ai",
414
+ 'description': "Pluggy API",
415
+ }
416
+ ]
417
+
418
+ def get_host_from_settings(self, index, variables=None, servers=None):
419
+ """Gets host URL based on the index and variables
420
+ :param index: array index of the host settings
421
+ :param variables: hash of variable and the corresponding value
422
+ :param servers: an array of host settings or None
423
+ :return: URL based on host settings
424
+ """
425
+ if index is None:
426
+ return self._base_path
427
+
428
+ variables = {} if variables is None else variables
429
+ servers = self.get_host_settings() if servers is None else servers
430
+
431
+ try:
432
+ server = servers[index]
433
+ except IndexError:
434
+ raise ValueError(
435
+ "Invalid index {0} when selecting the host settings. "
436
+ "Must be less than {1}".format(index, len(servers)))
437
+
438
+ url = server['url']
439
+
440
+ # go through variables and replace placeholders
441
+ for variable_name, variable in server.get('variables', {}).items():
442
+ used_value = variables.get(
443
+ variable_name, variable['default_value'])
444
+
445
+ if 'enum_values' in variable \
446
+ and used_value not in variable['enum_values']:
447
+ raise ValueError(
448
+ "The variable `{0}` in the host URL has invalid value "
449
+ "{1}. Must be {2}.".format(
450
+ variable_name, variables[variable_name],
451
+ variable['enum_values']))
452
+
453
+ url = url.replace("{" + variable_name + "}", used_value)
454
+
455
+ return url
456
+
457
+ @property
458
+ def host(self):
459
+ """Return generated host."""
460
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
461
+
462
+ @host.setter
463
+ def host(self, value):
464
+ """Fix base path."""
465
+ self._base_path = value
466
+ self.server_index = None
@@ -0,0 +1,200 @@
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
+ from typing import Any, Optional
16
+ from typing_extensions import Self
17
+
18
+ class OpenApiException(Exception):
19
+ """The base exception class for all OpenAPIExceptions"""
20
+
21
+
22
+ class ApiTypeError(OpenApiException, TypeError):
23
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
24
+ key_type=None) -> None:
25
+ """ Raises an exception for TypeErrors
26
+
27
+ Args:
28
+ msg (str): the exception message
29
+
30
+ Keyword Args:
31
+ path_to_item (list): a list of keys an indices to get to the
32
+ current_item
33
+ None if unset
34
+ valid_classes (tuple): the primitive classes that current item
35
+ should be an instance of
36
+ None if unset
37
+ key_type (bool): False if our value is a value in a dict
38
+ True if it is a key in a dict
39
+ False if our item is an item in a list
40
+ None if unset
41
+ """
42
+ self.path_to_item = path_to_item
43
+ self.valid_classes = valid_classes
44
+ self.key_type = key_type
45
+ full_msg = msg
46
+ if path_to_item:
47
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
48
+ super(ApiTypeError, self).__init__(full_msg)
49
+
50
+
51
+ class ApiValueError(OpenApiException, ValueError):
52
+ def __init__(self, msg, path_to_item=None) -> None:
53
+ """
54
+ Args:
55
+ msg (str): the exception message
56
+
57
+ Keyword Args:
58
+ path_to_item (list) the path to the exception in the
59
+ received_data dict. None if unset
60
+ """
61
+
62
+ self.path_to_item = path_to_item
63
+ full_msg = msg
64
+ if path_to_item:
65
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
66
+ super(ApiValueError, self).__init__(full_msg)
67
+
68
+
69
+ class ApiAttributeError(OpenApiException, AttributeError):
70
+ def __init__(self, msg, path_to_item=None) -> None:
71
+ """
72
+ Raised when an attribute reference or assignment fails.
73
+
74
+ Args:
75
+ msg (str): the exception message
76
+
77
+ Keyword Args:
78
+ path_to_item (None/list) the path to the exception in the
79
+ received_data dict
80
+ """
81
+ self.path_to_item = path_to_item
82
+ full_msg = msg
83
+ if path_to_item:
84
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
85
+ super(ApiAttributeError, self).__init__(full_msg)
86
+
87
+
88
+ class ApiKeyError(OpenApiException, KeyError):
89
+ def __init__(self, msg, path_to_item=None) -> None:
90
+ """
91
+ Args:
92
+ msg (str): the exception message
93
+
94
+ Keyword Args:
95
+ path_to_item (None/list) the path to the exception in the
96
+ received_data dict
97
+ """
98
+ self.path_to_item = path_to_item
99
+ full_msg = msg
100
+ if path_to_item:
101
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
102
+ super(ApiKeyError, self).__init__(full_msg)
103
+
104
+
105
+ class ApiException(OpenApiException):
106
+
107
+ def __init__(
108
+ self,
109
+ status=None,
110
+ reason=None,
111
+ http_resp=None,
112
+ *,
113
+ body: Optional[str] = None,
114
+ data: Optional[Any] = None,
115
+ ) -> None:
116
+ self.status = status
117
+ self.reason = reason
118
+ self.body = body
119
+ self.data = data
120
+ self.headers = None
121
+
122
+ if http_resp:
123
+ if self.status is None:
124
+ self.status = http_resp.status
125
+ if self.reason is None:
126
+ self.reason = http_resp.reason
127
+ if self.body is None:
128
+ try:
129
+ self.body = http_resp.data.decode('utf-8')
130
+ except Exception:
131
+ pass
132
+ self.headers = http_resp.getheaders()
133
+
134
+ @classmethod
135
+ def from_response(
136
+ cls,
137
+ *,
138
+ http_resp,
139
+ body: Optional[str],
140
+ data: Optional[Any],
141
+ ) -> Self:
142
+ if http_resp.status == 400:
143
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
144
+
145
+ if http_resp.status == 401:
146
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
147
+
148
+ if http_resp.status == 403:
149
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
150
+
151
+ if http_resp.status == 404:
152
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
153
+
154
+ if 500 <= http_resp.status <= 599:
155
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
156
+ raise ApiException(http_resp=http_resp, body=body, data=data)
157
+
158
+ def __str__(self):
159
+ """Custom error messages for exception"""
160
+ error_message = "({0})\n"\
161
+ "Reason: {1}\n".format(self.status, self.reason)
162
+ if self.headers:
163
+ error_message += "HTTP response headers: {0}\n".format(
164
+ self.headers)
165
+
166
+ if self.data or self.body:
167
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
168
+
169
+ return error_message
170
+
171
+
172
+ class BadRequestException(ApiException):
173
+ pass
174
+
175
+
176
+ class NotFoundException(ApiException):
177
+ pass
178
+
179
+
180
+ class UnauthorizedException(ApiException):
181
+ pass
182
+
183
+
184
+ class ForbiddenException(ApiException):
185
+ pass
186
+
187
+
188
+ class ServiceException(ApiException):
189
+ pass
190
+
191
+
192
+ def render_path(path_to_item):
193
+ """Returns a string representation of a path"""
194
+ result = ""
195
+ for pth in path_to_item:
196
+ if isinstance(pth, int):
197
+ result += "[{0}]".format(pth)
198
+ else:
199
+ result += "['{0}']".format(pth)
200
+ return result