danieledwardgeorgehitchcock / ripple-energy

Python Module For Ripple Energy
MIT License
5 stars 1 forks source link

Member query fails (HTTP 400) #22

Closed devachnid closed 2 weeks ago

devachnid commented 3 weeks ago

Using your sample script on the readme I get a server error (HTTP 400 Bad Request).

FAQs, Me, and Version queries seem to work ok, but member and cumulative_savings don't

[FaqsFaqs(id='5', question='What if I want to leave/ can I sell my shares?', answer='<div>You cannot sell your shares but if you no longer want to own part of a project, you can request to withdraw your membership. Ripple will then seek to match your request with members seeking to increase their ownership. Please note: you will not be able to withdraw your membership of the co-operative until the project has been operating for two years and after that you may not be able to withdraw your shares immediately.</div>', tags=[FaqsFaqsTags(id='3', name='the co-op'), FaqsFaqsTags(id='5', name='my account'), FaqsFaqsTags(id='8', name='popular'), FaqsFaqsTags(id='35', name='dashboard'), FaqsFaqsTags(id='232', name='business'), FaqsFaqsTags(id='1', name='my projects')]), FaqsFaqs(id='166', question="What's the maximum I can own?", answer='<div>The maximum you can own across all Ripple-managed projects, is the amount that would generate 120% of your electricity consumption each year.<div>', tags=[FaqsFaqsTags(id='1', name='my projects'), FaqsFaqsTags(id='232', name='business')]), FaqsFaqs(id='35', question='How do I withdraw my shares?', answer="<div>You will be able to request to withdraw your shares via Ripple's customer services. This will terminate your membership of the co-op. Equally, if you terminate your electricity supply agreement, this will automatically terminate your membership of the co-op. At that point, Ripple will calculate the value of any remaining shares you own in the co-op.<br /><br />Using a windfarm as an example, if you withdraw your shares 5 years into the project’s expected 25-year operating life and the co-op has withdrawn 5% of the shares each year to return your share capital, you would be entitled to receive 75% of your original share capital back. If you withdraw your shares 15 years into the project’s 25-year operating life you would be entitled to receive back 25% of your original share value.<br/><br />Please note: you will not be able to withdraw your membership of the co-operative until the project has been operating for two years and after that you may not be able to withdraw your shares immediately. More details are described in the Customer Agreement for your project.</div>", tags=[FaqsFaqsTags(id='3', name='the co-op'), FaqsFaqsTags(id='5', name='my account'), FaqsFaqsTags(id='35', name='dashboard'), FaqsFaqsTags(id='232', name='business'), FaqsFaqsTags(id='1', name='my projects')]), FaqsFaqs(id='171', question='What happens if my business changes address?', answer="<div>If you move premises you can get your savings applied to your new premises' bill, provided you remain supplied by one of our partner suppliers. If you won't be supplied by one of our partners you will need to withdraw your membership of the co-op. We will then make your watts of the project available to people on our waiting list. Provided there are sufficient people wanting to buy more watts, you will get the residual value of your shares back.</div>", tags=[FaqsFaqsTags(id='67', name='ripple for business'), FaqsFaqsTags(id='232', name='business'), FaqsFaqsTags(id='335', name='reservation address'), FaqsFaqsTags(id='503', name='sign up address')])]

Traceback (most recent call last):
  File "/root/venv/ripple.py", line 36, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/root/venv/ripple.py", line 20, in main
    member = await ripple.member()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/root/venv/lib/python3.11/site-packages/ripple_energy/helpers.py", line 42, in wrapper
    return await function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/venv/lib/python3.11/site-packages/ripple_energy/ripple_energy.py", line 168, in member
    data = await self.client.member()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/venv/lib/python3.11/site-packages/ripple_energy/graphql_client/client.py", line 426, in member
    data = self.get_data(response)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/venv/lib/python3.11/site-packages/ripple_energy/graphql_client/async_base_client.py", line 101, in get_data
    raise GraphQLClientHttpError(
ripple_energy.graphql_client.exceptions.GraphQLClientHttpError: HTTP status code: 400

With logging set to debug:

INFO:ripple_energy.helpers:Checked Token Expiry: 2024-07-18 21:54:32 Against Now: 2024-07-11 21:54:32.293316. Result: False
DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'POST']>
DEBUG:httpcore.http11:send_request_headers.complete
DEBUG:httpcore.http11:send_request_body.started request=<Request [b'POST']>
DEBUG:httpcore.http11:send_request_body.complete
DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'POST']>
DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 400, b'Bad Request', [(b'Content-Type', b'application/json'), (b'Content-Length', b'123'), (b'Connection', b'keep-alive'), (b'Date', b'Thu, 11 Jul 2024 20:54:32 GMT'), (b'Server', b'gunicorn'), (b'Vary', b'Cookie, Origin'), (b'X-Frame-Options', b'DENY'), (b'x-sessionid', b'None'), (b'X-Content-Type-Options', b'nosniff'), (b'Referrer-Policy', b'strict-origin-when-cross-origin'), (b'Cross-Origin-Opener-Policy', b'same-origin'), (b'Set-Cookie', b'csrftoken=s0Y1FB3pbBd55osDZhkLkj3hyNn3c1aa; expires=Thu, 10 Jul 2025 20:54:32 GMT; Max-Age=31449600; Path=/; SameSite=Lax; Secure'), (b'X-Cache', b'Error from cloudfront'), (b'Via', b'1.1 759d447e04dad48878f29ac5fabe9524.cloudfront.net (CloudFront)'), (b'X-Amz-Cf-Pop', b'LHR50-P7'), (b'X-Amz-Cf-Id', b'C1fX6njYTKCr76Jco1OZvU1vut_cybUV5a3n4X8plXU_FjRP6tTTPg==')])
INFO:httpx:HTTP Request: POST https://rippleenergy.com/graphql "HTTP/1.1 400 Bad Request"
danieledwardgeorgehitchcock commented 3 weeks ago

Thanks!

Will look into this tomorrow!

danieledwardgeorgehitchcock commented 2 weeks ago

Hi,

It looks like some of the fields have been removed / renamed between new versions of the Ripple Energy GraphQL endpoint.

I am currently reviewing the changes and will be pushing a new version soon.

for now, if you would like to build a working version of the member query, remove the percentageFunded field from src\ripple_energy\graphql_queries\custom_fragments\coop.graphql and re-run the codegen as documented in the readme