Skip to content

Conversation

@pantherale0
Copy link
Owner

This PR adds support to retrieve the associated accounts of a business partner number.

We extract the BP number from the access token and therefore this is one less item a user will need to identify.

An example response:

{
  "result": {
    "property_count": 1,
    "active": [
      {
        "business_partner_number": 00000,
        "account_number": 00000,
        "address": {
          "company_name": "",
          "building_name": "",
          "sub_building_name": "",
          "house_number": "",
          "street": "",
          "locality": "",
          "city": "",
          "postcode": ""
        }
      }
    ],
    "inactive": []
  }
}

Related discussion: home-assistant/core#156225 (comment)

@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pantherale0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the pyanglianwater library by introducing the capability to fetch associated accounts for a given business partner. The core improvement lies in automatically deriving the business partner number from the user's access token, streamlining the process for consumers of the API. This change provides a more robust and user-friendly way to manage and access account-related data.

Highlights

  • New API Endpoint: Added a new asynchronous method get_associated_accounts to the AnglianWater API client, allowing retrieval of associated accounts for a business partner.
  • Business Partner Number Extraction: Implemented a new property business_partner_number in the authentication handler to extract the business partner number directly from the decoded access token, reducing the need for manual identification.
  • Dynamic URL Construction: Modified the send_request method to incorporate the BUSINESS_PARTNER_ID into the API endpoint URL, enabling requests that are specific to a business partner.
  • Endpoint Definition: Defined the new get_associated_accounts endpoint in pyanglianwater/const.py, specifying its HTTP method (GET) and URL path.
  • Test Script Updates: Updated the test.py script to demonstrate the usage of the new get_associated_accounts method and to pass an aiohttp.ClientSession to the authenticator for improved session management. Also updated a meter property name from get_yesterday_cost to yesterday_water_cost.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for retrieving associated accounts by leveraging the business partner number from the access token. The changes are logical and well-contained, introducing a new API method, updating the authentication flow to include the business partner ID in requests, and adjusting the test script accordingly. One area for improvement is a type hint mismatch where None is passed for a parameter typed as dict. Additionally, I've noticed that send_request in pyanglianwater/auth.py creates a new aiohttp.ClientSession for each call, which is inefficient. It would be better to reuse the session stored in self._auth_session to benefit from connection pooling.

@pantherale0 pantherale0 added the enhancement New feature or request label Nov 13, 2025
@pantherale0 pantherale0 merged commit f5f1e60 into main Nov 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants