vtexpy 0.0.0b28__tar.gz → 0.0.0b29__tar.gz

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 (31) hide show
  1. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/PKG-INFO +1 -1
  2. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/pyproject.toml +1 -1
  3. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/base.py +29 -10
  4. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/orders.py +7 -0
  5. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/payments_gateway.py +1 -0
  6. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/LICENSE +0 -0
  7. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/README.md +0 -0
  8. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/__init__.py +0 -0
  9. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/__init__.py +0 -0
  10. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/catalog.py +0 -0
  11. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/checkout.py +0 -0
  12. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/custom.py +0 -0
  13. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/license_manager.py +0 -0
  14. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/logistics.py +0 -0
  15. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/master_data.py +0 -0
  16. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/pricing.py +0 -0
  17. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/promotions_and_taxes.py +0 -0
  18. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/types/__init__.py +0 -0
  19. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/types/catalog.py +0 -0
  20. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/types/generic.py +0 -0
  21. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_api/types/license_manager.py +0 -0
  22. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_config.py +0 -0
  23. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_constants.py +0 -0
  24. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_dto.py +0 -0
  25. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_exceptions.py +0 -0
  26. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_logging.py +0 -0
  27. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_sentinels.py +0 -0
  28. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_types.py +0 -0
  29. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_utils.py +0 -0
  30. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/_vtex.py +0 -0
  31. {vtexpy-0.0.0b28 → vtexpy-0.0.0b29}/vtex/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vtexpy
3
- Version: 0.0.0b28
3
+ Version: 0.0.0b29
4
4
  Summary: Unofficial VTEX API's Python SDK
5
5
  Home-page: https://github.com/lvieirajr/vtex-python
6
6
  License: Apache
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
5
5
  [tool.poetry]
6
6
  name = "vtexpy"
7
7
  description = "Unofficial VTEX API's Python SDK"
8
- version = "0.0.0b28"
8
+ version = "0.0.0b29"
9
9
  readme = "README.md"
10
10
  license = "Apache"
11
11
  authors = [
@@ -62,6 +62,7 @@ class BaseAPI:
62
62
  files: Union[RequestFiles, None] = None,
63
63
  config: Union[VTEXConfig, None] = None,
64
64
  rate_limit: Union[RateLimitItem, None] = None,
65
+ rate_limit_key: Union[str, None] = None,
65
66
  response_class: Union[Type[VTEXResponseType], None] = None,
66
67
  **kwargs: Any,
67
68
  ) -> VTEXResponseType:
@@ -87,7 +88,9 @@ class BaseAPI:
87
88
 
88
89
  rate_limiter = (
89
90
  None
90
- if not (rate_limit and request_config.rate_limit_storage_url)
91
+ if not (
92
+ rate_limit and rate_limit_key and request_config.rate_limit_storage_url
93
+ )
91
94
  else strategies.MovingWindowRateLimiter(
92
95
  storage.storage_from_string(request_config.rate_limit_storage_url),
93
96
  )
@@ -120,23 +123,27 @@ class BaseAPI:
120
123
  with Client(timeout=request_config.timeout) as client:
121
124
  with disable_loggers(["httpcore", "httpx"]):
122
125
  while (
123
- rate_limiter
124
- and rate_limit
126
+ rate_limit
127
+ and rate_limit_key
128
+ and rate_limiter
125
129
  and not rate_limiter.test(
126
130
  rate_limit,
127
131
  request_config.account_name,
128
- endpoint,
132
+ rate_limit_key,
129
133
  )
130
134
  ):
131
135
  sleep(1)
132
136
  self.logger.info(
133
137
  f"{rate_limiter} limited {request_config.account_name} on "
134
- f"{endpoint}",
138
+ f"{rate_limit_key}",
135
139
  extra={
136
- "endpoint": endpoint,
137
140
  "account_name": request_config.account_name,
138
- "rate_limiter": rate_limiter,
139
- "rate_limit": rate_limit,
141
+ "rate_limit_key": rate_limit_key,
142
+ "remaining": rate_limiter.get_window_stats(
143
+ rate_limit,
144
+ request_config.account_name,
145
+ rate_limit_key,
146
+ ).remaining,
140
147
  },
141
148
  )
142
149
 
@@ -153,11 +160,23 @@ class BaseAPI:
153
160
  files=files,
154
161
  )
155
162
  finally:
156
- if rate_limiter and rate_limit:
163
+ if rate_limit and rate_limit_key and rate_limiter:
157
164
  rate_limiter.hit(
158
165
  rate_limit,
159
166
  request_config.account_name,
160
- endpoint,
167
+ rate_limit_key,
168
+ )
169
+ self.logger.info(
170
+ "Rate limit updated!",
171
+ extra={
172
+ "account_name": request_config.account_name,
173
+ "rate_limit_key": rate_limit_key,
174
+ "remaining": rate_limiter.get_window_stats(
175
+ rate_limit,
176
+ request_config.account_name,
177
+ rate_limit_key,
178
+ ).remaining,
179
+ },
161
180
  )
162
181
 
163
182
  response.request.headers = Headers(
@@ -89,6 +89,7 @@ class OrdersAPI(BaseAPI):
89
89
  params=params,
90
90
  config=self.client.config.with_overrides(**kwargs),
91
91
  rate_limit=parse("4500 per minute"),
92
+ rate_limit_key="orders",
92
93
  response_class=VTEXPaginatedItemsResponse[Any, Any],
93
94
  )
94
95
 
@@ -104,6 +105,8 @@ class OrdersAPI(BaseAPI):
104
105
  endpoint=f"/api/oms/pvt/orders/{order_id}",
105
106
  environment=self.ENVIRONMENT,
106
107
  config=self.client.config.with_overrides(**kwargs),
108
+ rate_limit=parse("4500 per minute"),
109
+ rate_limit_key="orders",
107
110
  response_class=VTEXDataResponse[Any],
108
111
  )
109
112
 
@@ -123,6 +126,8 @@ class OrdersAPI(BaseAPI):
123
126
  ),
124
127
  },
125
128
  config=self.client.config.with_overrides(**kwargs),
129
+ rate_limit=parse("4500 per minute"),
130
+ rate_limit_key="orders",
126
131
  response_class=VTEXItemsResponse[Any, Any],
127
132
  )
128
133
 
@@ -147,5 +152,7 @@ class OrdersAPI(BaseAPI):
147
152
  environment=self.ENVIRONMENT,
148
153
  json={"handles": handles},
149
154
  config=self.client.config.with_overrides(**kwargs),
155
+ rate_limit=parse("4500 per minute"),
156
+ rate_limit_key="orders",
150
157
  response_class=VTEXDataResponse[Any],
151
158
  )
@@ -38,6 +38,7 @@ class PaymentsGatewayAPI(BaseAPI):
38
38
  environment=self.ENVIRONMENT,
39
39
  config=self.client.config.with_overrides(**kwargs),
40
40
  rate_limit=parse("3500 per minute"),
41
+ rate_limit_key="list_transaction_interactions",
41
42
  response_class=VTEXItemsResponse[Any, Any],
42
43
  )
43
44
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes