alexdlaird / amazon-orders

A CLI and library for interacting with Amazon order history
https://amazon-orders.readthedocs.io
MIT License
23 stars 9 forks source link

Update links #11

Closed JamesOsborn-SE closed 10 months ago

JamesOsborn-SE commented 10 months ago

Description change links to what works on my account

Issues

10

Type of Change

Testing Done any manual testing done. Need to add new test Need to fix existing test

Checklist

JamesOsborn-SE commented 10 months ago

I have a "household", so maybe that's the difference? do you have this? https://www.amazon.com/myh/households

alexdlaird commented 10 months ago

I have a "household", so maybe that's the difference? do you have this? https://www.amazon.com/myh/households

Yes, I have a household with one other adult to share Prime benefits, no teens/children. Sounds like we're the same on that front?

JamesOsborn-SE commented 10 months ago

I have a "household", so maybe that's the difference? do you have this? https://www.amazon.com/myh/households

Yes, I have a household with one other adult to share Prime benefits, no teens/children. Sounds like we're the same on that front?

I have a teen... 🤷🏻

alexdlaird commented 10 months ago

I have a "household", so maybe that's the difference? do you have this? https://www.amazon.com/myh/households

Yes, I have a household with one other adult to share Prime benefits, no teens/children. Sounds like we're the same on that front?

I have a teen... 🤷🏻

Curious, does having a teen effect your my orders page? For instance, I can't see on my My Orders page what the other adult in my house buys. Maybe having a teen you can, and thus it effects which page they're rendering?

JamesOsborn-SE commented 10 months ago

I have a "household", so maybe that's the difference? do you have this? https://www.amazon.com/myh/households

Yes, I have a household with one other adult to share Prime benefits, no teens/children. Sounds like we're the same on that front?

I have a teen... 🤷🏻

Curious, does having a teen effect your my orders page? For instance, I can't see on my My Orders page what the other adult in my house buys. Maybe having a teen you can, and thus it effects which page they're rendering?

Yes, I can see their orders, so that would be a difference.

Do you have the duck that says (meow) at the bottom of the HTML?

alexdlaird commented 10 months ago

I have a "household", so maybe that's the difference? do you have this? https://www.amazon.com/myh/households

Yes, I have a household with one other adult to share Prime benefits, no teens/children. Sounds like we're the same on that front?

I have a teen... 🤷🏻

Curious, does having a teen effect your my orders page? For instance, I can't see on my My Orders page what the other adult in my house buys. Maybe having a teen you can, and thus it effects which page they're rendering?

Yes, I can see their orders, so that would be a difference.

Do you have the duck that says (meow) at the bottom of the HTML?

I do. Several of the test resources I've committed are obfuscated versions of a couple of my orders and order history pages.

alexdlaird commented 10 months ago

With you having a household, I'm curious if you have more than just the year filter? Maybe you have a way to filter to just your orders, and perhaps in that case the pages would match.

Longer term I think the sustainable solution is to always have a chain of selectors, because inevitably we're going to run in to different pages for different people (regionality), Amazon A/B testing, and/or new pages (but still needing to support legacy pages). For instance, see the develop branch for how I've modified the auth flow to support multiple form class types, which others can easily add. We won't need a class for each field, but I migrate entity fields to use CSS selectors instead of the find() method likes they do now, I think every one should iterate over a list of selectors (and by default they'll all just start with 1) to see if any of them work for the field. Then when someone finds a new flow, they can just append to that field's list without causing any regressions.

JamesOsborn-SE commented 10 months ago

With you having a household, I'm curious if you have more than just the year filter? Maybe you have a way to filter to just your orders, and perhaps in that case the pages would match.

Here is a scrubbed URL if you're interested: https://www.amazon.com/gp/your-account/order-history?opt=ab&delegatedCustId=AMAZON_CID&digitalOrders=1&unifiedOrders=1&returnTo=&householdCid=DIFFERENT_AMAZON_ID&orderFilter=year-2023

I also have a dropdown above the year dropdown name="householdCid" with option values of the AMAZON_CID and inner text of FULL_NAME's Orders

These are also on the page when looking at the teen orders:

alexdlaird commented 10 months ago

With you having a household, I'm curious if you have more than just the year filter? Maybe you have a way to filter to just your orders, and perhaps in that case the pages would match.

Here is a scrubbed URL if you're interested: https://www.amazon.com/gp/your-account/order-history?opt=ab&delegatedCustId=AMAZON_CID&digitalOrders=1&unifiedOrders=1&returnTo=&householdCid=DIFFERENT_AMAZON_ID&orderFilter=year-2023

I also have a dropdown above the year dropdown name="householdCid" with option values of the AMAZON_CID and inner text of FULL_NAME's Orders

These are also on the page when looking at the teen orders:

Alright, try this out. Hope over to develop branch, then change constants.TIME_FILTER_QUERY_PARAM to have the value of orderFilter instead. What does that give you? If that works, I can also add the optional householdCid param, which I think will let you filter individual's orders.

Also, if you run get_order() to get a single order instead of the history, does that work for you?

JamesOsborn-SE commented 10 months ago

Alright, try this out. Hope over to develop branch, then change constants.TIME_FILTER_QUERY_PARAM to have the value of orderFilter instead. What does that give you? If that works, I can also add the optional householdCid param, which I think will let you filter individual's orders.

That worked, except items don't have prices.

Also, if you run get_order() to get a single order instead of the history, does that work for you?

this works and it gets the price.

alexdlaird commented 10 months ago

Great, that's progress! If you have a look at Item._parse_price(), you can compare that to what you see on your history page, and if you find the difference, let me know or feel free to contribute another PR. Looking at how I currently do it, it's not surprising it's finicky.

Now I just need to think of a way to automagically detect which query parameter to use.

We should be good to close out this PR then, yes? Or you can leave it open if you want to use it to fiddle around with parsing the price still. Once I stabilize what I have in develop with tests and a few more changes, I'll merge it in to main and cut a new release.

JamesOsborn-SE commented 10 months ago

Great, that's progress! If you have a look at Item._parse_price(), you can compare that to what you see on your history page, and if you find the difference, let me know or feel free to contribute another PR. Looking at how I currently do it, it's not surprising it's finicky.

yeah

Now I just need to think of a way to automagically detect which query parameter to use. It may be another page load, but if your "drop down" says "timeFilter*" compared to mine that says "orderFilter*".

Basing qurey string filter name on that should work.. here is an example from my orders:

<div class="a-popover-wrapper"><div class="a-popover-inner a-lgtbox-vertical-scroll" style="height: 575px; overflow-y: auto; min-width: 124.617px; width: auto;"><ul tabindex="-1" class="a-nostyle a-list-link" role="listbox" aria-multiselectable="false"><li tabindex="0" role="option" aria-labelledby="orderFilter_0" class="a-dropdown-item"><a tabindex="-1" href="javascript:void(0)" aria-hidden="true" data-value="{&quot;stringVal&quot;:&quot;last30&quot;}" id="orderFilter_0" class="a-dropdown-link">
                last 30 days
            </a></li><li tabindex="0" role="option" aria-checked="true" aria-labelledby="orderFilter_1" class="a-dropdown-item"><a tabindex="-1" href="javascript:void(0)" aria-hidden="true" data-value="{&quot;stringVal&quot;:&quot;months-3&quot;}" id="orderFilter_1" class="a-dropdown-link a-active">
                past 3 months
            </a></li><li tabindex="0" role="option" aria-labelledby="orderFilter_2" class="a-dropdown-item"><a tabindex="-1" href="javascript:void(0)" aria-hidden="true" data-value="{&quot;stringVal&quot;:&quot;year-2024&quot;}" id="orderFilter_2" class="a-dropdown-link">
                2024
            </a></li><li tabindex="0" role="option" aria-labelledby="orderFilter_3" class="a-dropdown-item"><a tabindex="-1" href="javascript:void(0)" aria-hidden="true" data-value="{&quot;stringVal&quot;:&quot;year-2023&quot;}" id="orderFilter_3" class="a-dropdown-link">
                2023
            </a></li><li tabindex="0" role="option" aria-labelledby="orderFilter_4" class="a-dropdown-item"><a tabindex="-1" href="javascript:void(0)" aria-hidden="true" data-value="{&quot;stringVal&quot;:&quot;year-2022&quot;}" id="orderFilter_4" class="a-dropdown-link">
                2022
            </a></li>
</ul></div></div>

We should be good to close out this PR then, yes? Or you can leave it open if you want to use it to fiddle around with parsing the price still. Once I stabilize what I have in develop with tests and a few more changes, I'll merge it in to main and cut a new release.

yeah.

alexdlaird commented 10 months ago

@JamesOsborn-SE Thanks for your help here, it was invaluable! The latest on develop attempts to dynamically get the timeFilter or orderFilter query parameter based on the form that's on the order history landing page, let me know if it works for you!