amazon-orders 4.4.1__tar.gz → 4.4.3__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.
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/CHANGELOG.md +23 -63
- {amazon_orders-4.4.1/amazon_orders.egg-info → amazon_orders-4.4.3}/PKG-INFO +1 -1
- {amazon_orders-4.4.1 → amazon_orders-4.4.3/amazon_orders.egg-info}/PKG-INFO +1 -1
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/__init__.py +1 -1
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/cli.py +66 -1
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/conf.py +2 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/constants.py +1 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/order.py +9 -3
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/orders.py +10 -2
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/session.py +3 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/LICENSE +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/MANIFEST.in +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/README.md +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazon_orders.egg-info/SOURCES.txt +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazon_orders.egg-info/dependency_links.txt +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazon_orders.egg-info/entry_points.txt +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazon_orders.egg-info/requires.txt +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazon_orders.egg-info/top_level.txt +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/banner.txt +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/__init__.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/browser/__init__.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/browser/playwright.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/waf/__init__.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/waf/anticaptcha.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/waf/base.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/waf/capsolver.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/contrib/waf/twocaptcha.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/__init__.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/item.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/parsable.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/recipient.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/seller.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/shipment.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/entity/transaction.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/exception.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/forms.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/selectors.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/transactions.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/amazonorders/util.py +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/pyproject.toml +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/setup.cfg +0 -0
- {amazon_orders-4.4.1 → amazon_orders-4.4.3}/tests/testcase.py +0 -0
|
@@ -4,23 +4,32 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## [Unreleased](https://github.com/alexdlaird/amazon-orders/compare/4.4.
|
|
7
|
+
## [Unreleased](https://github.com/alexdlaird/amazon-orders/compare/4.4.3...HEAD)
|
|
8
8
|
|
|
9
|
-
## [4.4.
|
|
9
|
+
## [4.4.3](https://github.com/alexdlaird/amazon-orders/compare/4.4.2...4.4.3) - 2026-07-06
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Added
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- `AmazonOrders.get_order_history()` `order_filter` parameter to filter by order type via Amazon's `orderFilter` query parameter. `--order-filter` added to the `history` CLI command.
|
|
14
|
+
- `invoice` and `order-transactions` CLI commands, adding parity with `AmazonOrders.get_invoice()` and `AmazonTransactions.get_transactions(order_id=)`.
|
|
14
15
|
|
|
15
|
-
## [4.4.
|
|
16
|
+
## [4.4.2](https://github.com/alexdlaird/amazon-orders/compare/4.4.1...4.4.2) - 2026-07-05
|
|
16
17
|
|
|
17
18
|
### Added
|
|
18
19
|
|
|
19
|
-
- `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
20
|
+
- `request_timeout` config key (defaults to `None`) controlling the timeout passed to each HTTP request.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- `Order.order_number` now uses the caller-supplied value as a fallback when the order number cannot be parsed from the details page; previously documented but unintuitive behavior.
|
|
25
|
+
|
|
26
|
+
## [4.4.1](https://github.com/alexdlaird/amazon-orders/compare/4.4.0...4.4.1) - 2026-07-04
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Parsing of some `Order` fields on older order pages using the `chargeSummary` layout.
|
|
31
|
+
|
|
32
|
+
## [4.4.0](https://github.com/alexdlaird/amazon-orders/compare/4.3.1...4.4.0) - 2026-06-12
|
|
24
33
|
|
|
25
34
|
### Added
|
|
26
35
|
|
|
@@ -36,20 +45,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
36
45
|
- `AmazonOrders.get_invoice()` to fetch an Order's print-friendly invoice page, returning the response (including its parsed HTML) for rendering or printing.
|
|
37
46
|
- `AmazonTransactions.get_transactions()` `order_id` parameter to scope results to a single Order server-side via Amazon's `transactionTag` filter, bypassing the `days` window.
|
|
38
47
|
|
|
39
|
-
### Added
|
|
40
|
-
|
|
41
|
-
- `AmazonOrders.get_invoice()` to fetch an Order's print-friendly invoice page, returning the response (including its parsed HTML) for rendering or printing.
|
|
42
|
-
- `AmazonTransactions.get_transactions()` `order_id` parameter to scope results to a single Order server-side via Amazon's `transactionTag` filter, bypassing the `days` window.
|
|
43
|
-
|
|
44
48
|
## [4.3.0](https://github.com/alexdlaird/amazon-orders/compare/4.2.2...4.3.0) - 2026-06-07
|
|
45
49
|
|
|
46
50
|
### Added
|
|
47
51
|
|
|
48
52
|
- `[browser]` optional extra (`pip install amazon-orders[browser]`) for handling JavaScript-based authentication challenges via a headless browser. See [the docs](https://amazon-orders.readthedocs.io/browser.html) for setup.
|
|
49
|
-
- `PlaywrightAcicForm` handles the ACIC challenge page. If an embedded
|
|
50
|
-
- `PlaywrightJSAuthForm` is a best-effort handler for the JS
|
|
51
|
-
- `PlaywrightManualWafForm` opens a **visible** browser window for
|
|
52
|
-
- `browser` config key and `AMAZON_BROWSER` environment variable to select between `chromium` (default) and `firefox` browser
|
|
53
|
+
- `PlaywrightAcicForm` handles the ACIC challenge page. If an embedded WAF is present, it delegates automatically to any configured WAF solver extra.
|
|
54
|
+
- `PlaywrightJSAuthForm` is a best-effort handler for the JS bot-detection page.
|
|
55
|
+
- `PlaywrightManualWafForm` opens a **visible** browser window for you to solve the challenge yourself, suitable when a display is available.
|
|
56
|
+
- `browser` config key and `AMAZON_BROWSER` environment variable to select between `chromium` (default) and `firefox` browser user agents.
|
|
53
57
|
- `Transaction.payment_method_last_4`, the masked card digits parsed from `payment_method`, mirroring the existing field on `Order`.
|
|
54
58
|
|
|
55
59
|
### Changed
|
|
@@ -57,15 +61,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
57
61
|
- JavaScript-based authentication challenge errors now direct users to the `[browser]` extra rather than reporting the challenge as unsolvable.
|
|
58
62
|
- All user-facing error messages that include install commands now wrap those commands in backticks.
|
|
59
63
|
|
|
60
|
-
### Added
|
|
61
|
-
|
|
62
|
-
- `[browser]` optional extra (`pip install amazon-orders[browser]`) for handling JavaScript-based authentication challenges via a headless browser. See [the docs](https://amazon-orders.readthedocs.io/browser.html) for setup.
|
|
63
|
-
- `PlaywrightAcicForm` handles the ACIC challenge page. If an embedded WAF is present, it delegates automatically to any configured WAF solver extra.
|
|
64
|
-
- `PlaywrightJSAuthForm` is a best-effort handler for the JS bot-detection page.
|
|
65
|
-
- `PlaywrightManualWafForm` opens a **visible** browser window for you to solve the challenge yourself, suitable when a display is available.
|
|
66
|
-
- `browser` config key and `AMAZON_BROWSER` environment variable to select between `chromium` (default) and `firefox` browser user agents.
|
|
67
|
-
- `Transaction.payment_method_last_4`, the masked card digits parsed from `payment_method`, mirroring the existing field on `Order`.
|
|
68
|
-
|
|
69
64
|
## [4.2.2](https://github.com/alexdlaird/amazon-orders/compare/4.2.1...4.2.2) - 2026-06-06
|
|
70
65
|
|
|
71
66
|
### Fixed
|
|
@@ -78,10 +73,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
78
73
|
|
|
79
74
|
- WAF solver API keys can now also be set via `AmazonOrdersConfig` (under the lowercased env var name, e.g. `capsolver_api_key`), matching the precedence pattern used for other credentials.
|
|
80
75
|
|
|
81
|
-
### Changed
|
|
82
|
-
|
|
83
|
-
- WAF solver API keys can now also be set via `AmazonOrdersConfig` (under the lowercased env var name, e.g. `capsolver_api_key`), matching the precedence pattern used for other credentials.
|
|
84
|
-
|
|
85
76
|
## [4.2.0](https://github.com/alexdlaird/amazon-orders/compare/4.1.0...4.2.0) - 2026-05-08
|
|
86
77
|
|
|
87
78
|
### Added
|
|
@@ -92,14 +83,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
92
83
|
- Configurable Amazon domain for non-`.com` sites via the `domain` parameter on `AmazonSession`, the `domain` config field, and the `--domain` CLI flag.
|
|
93
84
|
- Improved currency parsing for English non-`.com` Amazon sites.
|
|
94
85
|
|
|
95
|
-
### Added
|
|
96
|
-
|
|
97
|
-
- Support for AWS WAF solving via third-party providers like CapSolver (`pip install amazon-orders[capsolver]`), Anti-Captcha (`pip install amazon-orders[anticaptcha]`), and 2Captcha (`pip install amazon-orders[2captcha]`). See [the docs](https://amazon-orders.readthedocs.io/waf.html) for setup.
|
|
98
|
-
- `auth_forms_classes` config option for plugging custom `AuthForm` subclasses into the auth chain without code changes.
|
|
99
|
-
- `AmazonSession.default_auth_forms()` static helper that returns the default form chain so callers can more easily extend it.
|
|
100
|
-
- Configurable Amazon domain for non-`.com` sites via the `domain` parameter on `AmazonSession`, the `domain` config field, and the `--domain` CLI flag.
|
|
101
|
-
- Improved currency parsing for English non-`.com` Amazon sites.
|
|
102
|
-
|
|
103
86
|
## [4.1.0](https://github.com/alexdlaird/amazon-orders/compare/4.0.19...4.1.0) - 2026-05-03
|
|
104
87
|
|
|
105
88
|
### Added
|
|
@@ -114,28 +97,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
114
97
|
|
|
115
98
|
- Captcha auto-solve via `amazoncaptcha` is likely to be removed in the future, since Amazon has continued to phase out OCR-style Captchas in favor of WAF.
|
|
116
99
|
|
|
117
|
-
### Added
|
|
118
|
-
|
|
119
|
-
- Python 3.13 support.
|
|
120
|
-
|
|
121
|
-
### Changed
|
|
122
|
-
|
|
123
|
-
- `amazoncaptcha` is now an optional dependency. Install with `pip install amazon-orders[captcha]` to enable Captcha auto-solve (only compatible with Python <=3.12. When not installed, Captcha challenges fall back to manual entry.
|
|
124
|
-
|
|
125
|
-
### Deprecated
|
|
126
|
-
|
|
127
|
-
- Captcha auto-solve via `amazoncaptcha` is likely to be removed in the future, since Amazon has continued to phase out OCR-style Captchas in favor of WAF.
|
|
128
|
-
|
|
129
100
|
## [4.0.19](https://github.com/alexdlaird/amazon-orders/compare/4.0.18...4.0.19) - 2026-04-29
|
|
130
101
|
|
|
131
102
|
### Added
|
|
132
103
|
|
|
133
104
|
- Build and stability improvements.
|
|
134
105
|
|
|
135
|
-
### Added
|
|
136
|
-
|
|
137
|
-
- Build and stability improvements.
|
|
138
|
-
|
|
139
106
|
## [4.0.18](https://github.com/alexdlaird/amazon-orders/compare/4.0.17...4.0.18) - 2025-12-06
|
|
140
107
|
|
|
141
108
|
### Added
|
|
@@ -260,13 +227,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
260
227
|
|
|
261
228
|
### Added
|
|
262
229
|
|
|
263
|
-
- Improvements around auth retry logic.
|
|
264
|
-
- Detect JavaScript-based auth challenges (which can be solved) and give more clear error for them.
|
|
265
|
-
- Stability improvements.
|
|
266
|
-
- Documentation improvements.
|
|
267
|
-
|
|
268
|
-
### Added
|
|
269
|
-
|
|
270
230
|
- Stability improvements for auth flow.
|
|
271
231
|
- Documentation improvements.
|
|
272
232
|
|
|
@@ -126,6 +126,8 @@ def amazon_orders_cli(ctx: Context,
|
|
|
126
126
|
@click.option("--full-details", is_flag=True, default=False,
|
|
127
127
|
help="Get the full details for each Order in the history. "
|
|
128
128
|
"This will execute an additional request per Order.")
|
|
129
|
+
@click.option("--order-filter", "order_filter", default=None,
|
|
130
|
+
help="The order type filter to use.")
|
|
129
131
|
def history(ctx: Context,
|
|
130
132
|
**kwargs: Any) -> None:
|
|
131
133
|
"""
|
|
@@ -142,6 +144,7 @@ def history(ctx: Context,
|
|
|
142
144
|
start_index = kwargs["start_index"]
|
|
143
145
|
single_page = kwargs["single_page"]
|
|
144
146
|
full_details = kwargs["full_details"]
|
|
147
|
+
order_filter = kwargs["order_filter"]
|
|
145
148
|
|
|
146
149
|
exclusive_flags = [year, last_3_months, last_30_days]
|
|
147
150
|
if not all(not item for item in exclusive_flags) and sum(exclusive_flags) == 1:
|
|
@@ -180,7 +183,8 @@ Order History for {filter_description}{optional_start_index}{optional_full_detai
|
|
|
180
183
|
start_index=start_index,
|
|
181
184
|
full_details=full_details,
|
|
182
185
|
keep_paging=not single_page,
|
|
183
|
-
time_filter=time_filter
|
|
186
|
+
time_filter=time_filter,
|
|
187
|
+
order_filter=order_filter):
|
|
184
188
|
click.echo(f"{_order_output(o, config)}\n")
|
|
185
189
|
total += 1
|
|
186
190
|
end_time = time.time()
|
|
@@ -222,6 +226,67 @@ def order(ctx: Context,
|
|
|
222
226
|
ctx.fail(str(e))
|
|
223
227
|
|
|
224
228
|
|
|
229
|
+
@amazon_orders_cli.command()
|
|
230
|
+
@click.pass_context
|
|
231
|
+
@click.argument("order_id")
|
|
232
|
+
def invoice(ctx: Context,
|
|
233
|
+
order_id: str) -> None:
|
|
234
|
+
"""
|
|
235
|
+
Get the invoice for a given Amazon Order ID.
|
|
236
|
+
"""
|
|
237
|
+
amazon_session = ctx.obj["amazon_session"]
|
|
238
|
+
|
|
239
|
+
try:
|
|
240
|
+
_authenticate(amazon_session)
|
|
241
|
+
|
|
242
|
+
config = ctx.obj["conf"]
|
|
243
|
+
amazon_orders = AmazonOrders(amazon_session,
|
|
244
|
+
config=config)
|
|
245
|
+
|
|
246
|
+
invoice_response = amazon_orders.get_invoice(order_id)
|
|
247
|
+
|
|
248
|
+
click.echo(invoice_response.response.text)
|
|
249
|
+
except AmazonOrdersAuthRedirectError:
|
|
250
|
+
_prompt_to_reauth_flow()
|
|
251
|
+
except AmazonOrdersError as e:
|
|
252
|
+
logger.debug("An error occurred.", exc_info=True)
|
|
253
|
+
ctx.fail(str(e))
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@amazon_orders_cli.command("order-transactions")
|
|
257
|
+
@click.pass_context
|
|
258
|
+
@click.argument("order_id")
|
|
259
|
+
def order_transactions(ctx: Context,
|
|
260
|
+
order_id: str) -> None:
|
|
261
|
+
"""
|
|
262
|
+
Get the Transactions for a given Amazon Order ID.
|
|
263
|
+
"""
|
|
264
|
+
amazon_session = ctx.obj["amazon_session"]
|
|
265
|
+
|
|
266
|
+
try:
|
|
267
|
+
_authenticate(amazon_session)
|
|
268
|
+
|
|
269
|
+
config = ctx.obj["conf"]
|
|
270
|
+
amazon_transactions = AmazonTransactions(amazon_session,
|
|
271
|
+
config=config)
|
|
272
|
+
|
|
273
|
+
start_time = time.time()
|
|
274
|
+
total = 0
|
|
275
|
+
for t in amazon_transactions.get_transactions(order_id=order_id):
|
|
276
|
+
click.echo(f"{_transaction_output(t, config)}\n")
|
|
277
|
+
total += 1
|
|
278
|
+
end_time = time.time()
|
|
279
|
+
|
|
280
|
+
click.echo(
|
|
281
|
+
"... {total} Transactions parsed in {time} seconds.\n".format(total=total,
|
|
282
|
+
time=int(end_time - start_time)))
|
|
283
|
+
except AmazonOrdersAuthRedirectError:
|
|
284
|
+
_prompt_to_reauth_flow()
|
|
285
|
+
except AmazonOrdersError as e:
|
|
286
|
+
logger.debug("An error occurred.", exc_info=True)
|
|
287
|
+
ctx.fail(str(e))
|
|
288
|
+
|
|
289
|
+
|
|
225
290
|
@amazon_orders_cli.command()
|
|
226
291
|
@click.pass_context
|
|
227
292
|
@click.option("--days", default=365,
|
|
@@ -60,6 +60,8 @@ class AmazonOrdersConfig:
|
|
|
60
60
|
"auth_forms_classes": [],
|
|
61
61
|
# Timeout in seconds for browser-based challenge detection and resolution
|
|
62
62
|
"browser_timeout": 30,
|
|
63
|
+
# Timeout in seconds for HTTP requests; ``None`` leaves requests with no timeout
|
|
64
|
+
"request_timeout": None,
|
|
63
65
|
"thread_pool_size": (os.cpu_count() or 1) * 4,
|
|
64
66
|
"connection_pool_size": thread_pool_size * 2,
|
|
65
67
|
# The maximum number of failed attempts to allow before failing CLI authentication
|
|
@@ -112,6 +112,7 @@ class Constants:
|
|
|
112
112
|
ORDER_DETAILS_URL = f"{BASE_URL}/gp/your-account/order-details"
|
|
113
113
|
ORDER_INVOICE_URL = f"{BASE_URL}/gp/css/summary/print.html"
|
|
114
114
|
HISTORY_FILTER_QUERY_PARAM = "timeFilter"
|
|
115
|
+
ORDER_FILTER_QUERY_PARAM = "orderFilter"
|
|
115
116
|
|
|
116
117
|
##########################################################################
|
|
117
118
|
# URLs for Transactions
|
|
@@ -58,11 +58,17 @@ class Order(Parsable):
|
|
|
58
58
|
self.items: List[Item] = clone.items if clone and not full_details else self._parse_items()
|
|
59
59
|
#: The Order number. May be ``None`` only when the Order is :attr:`cancelled` and Amazon stripped the order
|
|
60
60
|
#: number from the details page (the ``order_number`` parameter is used as a fallback in that case).
|
|
61
|
-
|
|
61
|
+
# `required` is relaxed only when `order_number` is explicitly supplied (the `get_order()` path), so the
|
|
62
|
+
# fallback is never silently applied when parsing the history list, where the parsed value must be present.
|
|
63
|
+
_parsed_order_number = None if clone else self.safe_simple_parse(
|
|
62
64
|
selector=self.config.selectors.FIELD_ORDER_NUMBER_SELECTOR,
|
|
63
|
-
required=not self.cancelled,
|
|
65
|
+
required=not self.cancelled and order_number is None,
|
|
64
66
|
prefix_split="#",
|
|
65
|
-
prefix_split_fuzzy=True)
|
|
67
|
+
prefix_split_fuzzy=True)
|
|
68
|
+
if _parsed_order_number is None and order_number is not None:
|
|
69
|
+
logger.debug(f"Order number could not be parsed from the page; "
|
|
70
|
+
f"using supplied order_number={order_number}.")
|
|
71
|
+
self.order_number: Optional[str] = clone.order_number if clone else _parsed_order_number or order_number
|
|
66
72
|
#: The Order details link.
|
|
67
73
|
self.order_details_link: Optional[str] = clone.order_details_link if clone else self.safe_parse(
|
|
68
74
|
self._parse_order_details_link)
|
|
@@ -6,6 +6,7 @@ import concurrent.futures
|
|
|
6
6
|
import datetime
|
|
7
7
|
import logging
|
|
8
8
|
from typing import Any, Callable, List, Optional
|
|
9
|
+
from urllib.parse import quote
|
|
9
10
|
|
|
10
11
|
from bs4 import Tag
|
|
11
12
|
|
|
@@ -103,7 +104,8 @@ class AmazonOrders:
|
|
|
103
104
|
start_index: Optional[int] = None,
|
|
104
105
|
full_details: bool = False,
|
|
105
106
|
keep_paging: bool = True,
|
|
106
|
-
time_filter: Optional[str] = None
|
|
107
|
+
time_filter: Optional[str] = None,
|
|
108
|
+
order_filter: Optional[str] = None) -> List[Order]:
|
|
107
109
|
"""
|
|
108
110
|
Get the Amazon Order history for a given time period.
|
|
109
111
|
|
|
@@ -119,6 +121,7 @@ class AmazonOrders:
|
|
|
119
121
|
:param time_filter: The time filter to use. Supported values are ``"last30"`` (last 30 days),
|
|
120
122
|
``"months-3"`` (past 3 months), or ``"year-YYYY"`` (specific year). If provided, this takes
|
|
121
123
|
precedence over the ``year`` parameter.
|
|
124
|
+
:param order_filter: The order type filter to use. If provided, appended alongside the time filter.
|
|
122
125
|
:return: A list of the requested Orders.
|
|
123
126
|
"""
|
|
124
127
|
if not self.amazon_session.is_authenticated:
|
|
@@ -144,12 +147,17 @@ class AmazonOrders:
|
|
|
144
147
|
filter_value = f"year-{year}"
|
|
145
148
|
|
|
146
149
|
optional_start_index = f"&startIndex={start_index}" if start_index else ""
|
|
150
|
+
optional_order_filter = (
|
|
151
|
+
f"&{self.config.constants.ORDER_FILTER_QUERY_PARAM}={quote(order_filter, safe='')}"
|
|
152
|
+
if order_filter else ""
|
|
153
|
+
)
|
|
147
154
|
next_page: Optional[str] = (
|
|
148
|
-
"{url}?{query_param}={filter_value}{optional_start_index}"
|
|
155
|
+
"{url}?{query_param}={filter_value}{optional_order_filter}{optional_start_index}"
|
|
149
156
|
).format(
|
|
150
157
|
url=self.config.constants.ORDER_HISTORY_URL,
|
|
151
158
|
query_param=self.config.constants.HISTORY_FILTER_QUERY_PARAM,
|
|
152
159
|
filter_value=filter_value,
|
|
160
|
+
optional_order_filter=optional_order_filter,
|
|
153
161
|
optional_start_index=optional_start_index
|
|
154
162
|
)
|
|
155
163
|
|
|
@@ -200,6 +200,9 @@ class AmazonSession:
|
|
|
200
200
|
url_to_log += "?" + encoded_params
|
|
201
201
|
logger.debug(f"{method} request: {url_to_log}")
|
|
202
202
|
|
|
203
|
+
if self.config.request_timeout is not None:
|
|
204
|
+
kwargs.setdefault("timeout", self.config.request_timeout)
|
|
205
|
+
|
|
203
206
|
response = self.session.request(method, url, **kwargs)
|
|
204
207
|
amazon_session_response = AmazonSessionResponse(response,
|
|
205
208
|
self.config.bs4_parser)
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|