Skip to content

Add enode link URL endpoint #86

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

Merged
merged 6 commits into from
Apr 23, 2023
Merged

Add enode link URL endpoint #86

merged 6 commits into from
Apr 23, 2023

Conversation

AndrewLester
Copy link
Contributor

@AndrewLester AndrewLester commented Apr 19, 2023

Pull Request

Description

Adds an endpoint for getting a valid Enode link URL for a user.

Fixes #72

Need to use env vars for Enode URLs, but coming in another PR

How Has This Been Tested?

Adds a test for both fake and mock Enode requests.

  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@AndrewLester AndrewLester marked this pull request as ready for review April 19, 2023 18:14
@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #86 (d26af24) into h4i/enode (1a23431) will increase coverage by 5.04%.
The diff coverage is 100.00%.

❗ Current head d26af24 differs from pull request most recent head baa189b. Consider uploading reports for the commit baa189b to get more accurate results

@@              Coverage Diff              @@
##           h4i/enode      #86      +/-   ##
=============================================
+ Coverage      86.93%   91.97%   +5.04%     
=============================================
  Files              9        8       -1     
  Lines            398      324      -74     
=============================================
- Hits             346      298      -48     
+ Misses            52       26      -26     
Impacted Files Coverage Δ
pv_site_api/fake.py 100.00% <100.00%> (ø)
pv_site_api/main.py 90.18% <100.00%> (+0.18%) ⬆️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines +371 to +377
with httpx.Client() as httpx_client:
data = {"vendorType": "inverter", "redirectUri": redirect_uri}
res = httpx_client.post(
f"https://enode-api.production.enode.io/users/{client.client_uuid}/link", data=data
).json()

return res["linkUrl"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can just do this with a fastapi RedirectResponse?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opted for this in the end. On the frontend, we can just use a fetch as usual, we just won't read the response body (Enode Link UI) and instead just history push the page to the Response.url.

@AndrewLester AndrewLester merged commit a4fb461 into h4i/enode Apr 23, 2023
@AndrewLester AndrewLester deleted the al/enode-link branch April 23, 2023 17:30
AndrewLester added a commit that referenced this pull request Apr 23, 2023
* Add enode link URL endpoint

* Fix lint

* Rename test var for clarity

* Add comment to mock urls fixtuer

* Use redirect response
AndrewLester added a commit that referenced this pull request Apr 24, 2023
* Add enode link URL endpoint

* Fix lint

* Rename test var for clarity

* Add comment to mock urls fixtuer

* Use redirect response
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

Successfully merging this pull request may close these issues.

2 participants