Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purchases API has changed #153

Closed
SVNKoch opened this issue Nov 22, 2022 · 2 comments
Closed

Purchases API has changed #153

SVNKoch opened this issue Nov 22, 2022 · 2 comments

Comments

@SVNKoch
Copy link

SVNKoch commented Nov 22, 2022

Currently you get an Internal Server Error when using the Purchases API.
I already found that the API endpoint changed
ikea_api/endpoints/purchases.py > _get_session_info() must now use
https://cssom-prod.ingka.com/purchase-history/graphql

However I still get this JSON response:

{
    "data": {
        "history": []
    }
}

When I use a browser I however am able to see my history.
From the network tab it appears that there is another request made before the one that returns the history
First one:
Request:

[
  {
    "operationName": "Authenticated",
    "query": "query Authenticated {\n  authenticated\n}",
    "variables": {}
  }
]

Response:

[
  {
    "data": {
      "authenticated": true
    }
  }
]

Second one:
Request:

[
  {
    "operationName": "History",
    "query": "query History($skip: Int!, $take: Int!) {\n  history(skip: $skip, take: $take) {\n    id\n    dateAndTime {\n      ...DateAndTime\n      __typename\n    }\n    status\n    eventStatus\n    storeName\n    totalCost {\n      code\n      value\n      formatted\n      __typename\n    }\n    type\n    __typename\n  }\n}\n\nfragment DateAndTime on DateAndTime {\n  time\n  date\n  formattedLocal\n  formattedShortDate\n  formattedLongDate\n  formattedShortDateTime\n  formattedLongDateTime\n  __typename\n}",
    "variables": {
      "skip": 0,
      "take": 5
    }
  }
]

Response:

[
  {
    "data": {
      "history": [
        {
          "id": "100",
          "status": "IN_PROGRESS"
          "more fields": "..."
          
        },
        {
          "id": "101",
          "status": "COMPLETED"
          "more fields": "..."
          
        }
      ]
    }
  }
]

I'm not too familiar with these requests yet and couldn't figure out how to fix it :/

@SVNKoch
Copy link
Author

SVNKoch commented Nov 22, 2022

This is the code I used:

import ikea_api
import json

constants = ikea_api.Constants(country="de", language="de")
token = "eyJhbGciO ..."

purchases = ikea_api.Purchases(constants, token=token)

historyEndpoint = purchases.history(take=5, skip=0)
res = ikea_api.run(historyEndpoint)

json_formatted_str = json.dumps(res, indent=4)
print(json_formatted_str)

@vrslev
Copy link
Owner

vrslev commented Nov 23, 2022

Hey there! Too bad it did :( I'm not ready to make any changes to the library though, since I don't use it in production anymore. Pull Requests are welcome.

@vrslev vrslev closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants