Skip to content

Conversation

@connorads
Copy link

@connorads connorads commented Dec 14, 2024

I don't expect you to merge this PR, I guess there's either a data issue or something wrong with the OpenAPI spec or Speakeasy ... However, I'm using this PR to demonstrate this issue.

When calling this endpoint https://docs.codat.io/bank-feeds-api#/operations/get-bank-account-mapping

import os
import codat_bankfeeds
import base64

COMPANY_ID = "insert-company-id"
CONNECTION_ID = "insert-connection-id"

codat_api_key = os.environ.get("CODAT_API_KEY")
if codat_api_key is None:
    raise ValueError("CODAT_API_KEY environment variable is not set")
encoded_api_key = base64.b64encode(codat_api_key.encode()).decode()


bankfeeds_client = codat_bankfeeds.CodatBankFeeds(
    security=codat_bankfeeds.shared.Security(
        auth_header=f"Basic {encoded_api_key}",
    ),
)

bank_feed_accounts = bankfeeds_client.account_mapping.get(
    request={
        "company_id": COMPANY_ID,
        "connection_id": CONNECTION_ID,
    }
)

Pydantic gets upset because the sourceBalance is not a str.

ValidationError: 1 validation error for Unmarshaller
body.0.sourceBalance
  Input should be a valid string [type=string_type, input_value=0.0, input_type=float]
    For further information visit https://errors.pydantic.dev/2.10/v/string_type

If I edit the type to int as per this PR then it works.

Here's an example of the JSON returned from the API when calling via CURL or Postman etc. Notice that sourceBalance is 0 and not a string

[
  {
    "sourceAccountId": "acc-567",
    "targetAccountId": "d129850c-af5c-4e0c-90a9-9b3f3eb2d5b4",
    "feedStartDate": "2024-11-15T11:42:16.0000000",
    "status": "connected",
    "targetAccountOptions": [
      {
        "name": "Seller Bank Account",
        "id": "4ad73daa-8b4d-4d84-9a5e-ad1a2d4f3f7f",
        "accountNumber": "56",
        "bankCode": "987654"
      },
      {
        "name": "Lender Bank Account",
        "id": "56bbed02-93c5-4769-8c6f-5af8ed7b98c7",
        "accountNumber": "98765432",
        "bankCode": "765432"
      }
    ],
    "sourceAccountName": "account-123",
    "sourceAccountNumber": "11111111",
    "sourceBalance": 0,
    "sourceCurrency": "GBP",
    "targetAccountName": "Lender Bank Account",
    "targetAccountNumber": "98765432"
  }
]

@connorads connorads marked this pull request as ready for review December 14, 2024 19:54
@connorads connorads requested a review from dcoplowe as a code owner December 14, 2024 19:54
@connorads
Copy link
Author

Fixed by #629

@connorads connorads closed this Dec 16, 2024
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.

1 participant