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

feat(payments): Atlar connector: Add more bank details to Accounts (internal) and Payments #1607

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

lwagner-getmomo
Copy link
Contributor

We're currently preparing for adding a second bank as partner to work with.

Going forward, we will need to differentiate payments and internal accounts by bank. This PR introduces the metadata necessary to do so.

@lwagner-getmomo lwagner-getmomo requested a review from a team as a code owner July 15, 2024 12:32
Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

Recent updates to the components/payments/cmd/connectors/internal/connectors/atlar directory focus on enhancing account and transaction handling capabilities. Enhancements include additional parameters in function signatures for improved context and client handling, new methods for fetching account and third-party information, and incorporation of new currency support. These changes collectively improve the system's robustness and extend its functionality for better integration with third-party services.

Changes

Files Change Summary
.../connectors/atlar/account_utils.go The ExtractAccountMetadata function now accepts an additional parameter bank *atlar_models.ThirdParty and updated references accordingly.
.../connectors/atlar/client/accounts.go Added the method GetV1AccountsID to the Client struct for retrieving account information based on an ID parameter.
.../connectors/atlar/client/third_parties.go Introduced a new method GetV1BetaThirdPartiesID in the Client struct to fetch V1 beta third parties using parameters passed to it.
.../connectors/atlar/currencies.go Added the currency "DKK" to the supportedCurrenciesWithDecimal map.
.../connectors/atlar/task_fetch_accounts.go Modified ingestAccountsBatch in FetchAccountsTask to include taskID and client parameters, with additional context handling and error logic.
.../connectors/atlar/task_fetch_transactions.go Updated FetchTransactionsTask and associated functions to include additional parameters taskID and client, along with enhanced context handling, timeout management, and improved metadata extraction.
.../connectors/atlar/task_payments.go Updated UpdatePaymentStatusTask and ingestAtlarTransaction functions to include taskID as a parameter and use new context with timeout, with atlarTransactionToPaymentBatchElement also modified to include ctx and taskID.

Sequence Diagram(s)

sequenceDiagram
    participant TaskFetchAccounts
    participant Client
    participant ThirdPartiesService
    participant AccountsService

    TaskFetchAccounts->>Client: ingestAccountsBatch(taskID, client)
    Client->>ThirdPartiesService: GetV1BetaThirdPartiesID(ctx, id)
    ThirdPartiesService-->>Client: Third Party Data
    Client->>AccountsService: GetV1AccountsID(ctx, id)
    AccountsService-->>Client: Account Data
    Client-->>TaskFetchAccounts: Processed Data
Loading
sequenceDiagram
    participant TaskFetchTransactions
    participant Client
    participant TransactionsService
    participant AccountsService
    participant ThirdPartiesService

    TaskFetchTransactions->>Client: ingestPaymentsBatch(ctx, connectorID, taskID, pagedTransactions)
    Client->>TransactionsService: GetV1TransactionsID(ctx, id)
    TransactionsService-->>Client: Transaction Data
    Client->>AccountsService: ExtractPaymentMetadata(account, bank)
    AccountsService-->>Client: Metadata
    Client->>ThirdPartiesService: GetV1BetaThirdPartiesID(ctx, id)
    ThirdPartiesService-->>Client: Third Party Data
    Client-->>TaskFetchTransactions: Processed Payments
Loading

Poem

🐇 In the land of code, changes brew,
Third parties, currencies, all anew,
With IDs and contexts, functions grew,
To fetch accounts and payments too.
🏦 Now DKK joins the fray,
Transactions dance in a new ballet.
🎉 Cheers to the future's debut!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lwagner-getmomo lwagner-getmomo changed the title Add more bank details to Accounts (internal) and Payments feat(payments): Atlar connector: Add more bank details to Accounts (internal) and Payments Jul 15, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (6)
components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_accounts.go (1)

110-113: Update function documentation.

The function signature has changed to include taskID and client parameters. Ensure the function documentation is updated accordingly.

components/payments/cmd/connectors/internal/connectors/atlar/task_payments.go (3)

Line range hint 1-235:
Update function documentation.

The function signature has changed to include taskID and client parameters. Ensure the function documentation is updated accordingly.


360-364: Update function documentation.

The function signature has changed to include taskID and client parameters. Ensure the function documentation is updated accordingly.


Line range hint 96-100:
Update function documentation.

The function signature has changed to include taskID and client parameters. Ensure the function documentation is updated accordingly.

components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_transactions.go (2)

69-71: Update function documentation.

The function signature has changed to include taskID and client parameters. Ensure the function documentation is updated accordingly.


96-100: Update function documentation.

The function signature has changed to include taskID and client parameters. Ensure the function documentation is updated accordingly.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6f8ffa7 and 5280bf1.

Files selected for processing (7)
  • components/payments/cmd/connectors/internal/connectors/atlar/account_utils.go (1 hunks)
  • components/payments/cmd/connectors/internal/connectors/atlar/client/accounts.go (1 hunks)
  • components/payments/cmd/connectors/internal/connectors/atlar/client/third_parties.go (1 hunks)
  • components/payments/cmd/connectors/internal/connectors/atlar/currencies.go (1 hunks)
  • components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_accounts.go (4 hunks)
  • components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_transactions.go (7 hunks)
  • components/payments/cmd/connectors/internal/connectors/atlar/task_payments.go (2 hunks)
Additional comments not posted (19)
components/payments/cmd/connectors/internal/connectors/atlar/currencies.go (1)

8-8: Addition of DKK currency looks good.

The addition of "DKK" to the supportedCurrenciesWithDecimal map is correct and consistent with the existing structure.

components/payments/cmd/connectors/internal/connectors/atlar/client/third_parties.go (1)

11-22: New method GetV1BetaThirdPartiesID looks good.

The method correctly handles context, uses deferred metrics, and constructs the parameters properly before making the API call.

components/payments/cmd/connectors/internal/connectors/atlar/client/accounts.go (1)

11-22: New method GetV1AccountsID looks good.

The method correctly handles context, uses deferred metrics, and constructs the parameters properly before making the API call.

components/payments/cmd/connectors/internal/connectors/atlar/account_utils.go (1)

48-52: Modification of ExtractAccountMetadata looks good.

The function correctly uses the new bank parameter to extract additional metadata. The changes are consistent with the rest of the code.

components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_accounts.go (4)

Line range hint 1-109:
LGTM!

The function FetchAccountsTask has no changes and looks good.


115-120: LGTM!

The span attributes now include taskID, which is useful for tracing.


137-144: Verify the timeout duration.

The timeout duration for the context is set to 30 seconds. Ensure this duration is appropriate for the GetV1BetaThirdPartiesID call.


156-157: LGTM!

The ExtractAccountMetadata function now includes the thirdPartyResponse.Payload parameter, which is correctly used.

components/payments/cmd/connectors/internal/connectors/atlar/task_payments.go (6)

236-237: LGTM!

The ingestAtlarTransaction function call now includes the taskID parameter, which is correctly used.


365-367: Verify the timeout duration.

The timeout duration for the context is set to 30 seconds. Ensure this duration is appropriate for the GetV1TransactionsID call.


372-373: LGTM!

The atlarTransactionToPaymentBatchElement function call now includes the taskID parameter, which is correctly used.


Line range hint 133-140:
Verify the timeout duration.

The timeout duration for the context is set to 30 seconds. Ensure this duration is appropriate for the GetV1AccountsID call.


Line range hint 141-148:
Verify the timeout duration.

The timeout duration for the context is set to 30 seconds. Ensure this duration is appropriate for the GetV1BetaThirdPartiesID call.


Line range hint 169-170:
LGTM!

The ExtractPaymentMetadata function now includes the accountResponse.Payload and thirdPartyResponse.Payload parameters, which are correctly used.

components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_transactions.go (5)

Line range hint 1-68:
LGTM!

The function FetchTransactionsTask has no changes and looks good.


77-78: LGTM!

The atlarTransactionToPaymentBatchElement function call now includes the taskID parameter, which is correctly used.


133-140: Verify the timeout duration.

The timeout duration for the context is set to 30 seconds. Ensure this duration is appropriate for the GetV1AccountsID call.


141-148: Verify the timeout duration.

The timeout duration for the context is set to 30 seconds. Ensure this duration is appropriate for the GetV1BetaThirdPartiesID call.


169-170: LGTM!

The ExtractPaymentMetadata function now includes the accountResponse.Payload and thirdPartyResponse.Payload parameters, which are correctly used.

@@ -5,5 +5,6 @@ import "github.com/formancehq/payments/cmd/connectors/internal/connectors/curren
var (
supportedCurrenciesWithDecimal = map[string]int{
"EUR": currency.ISO4217Currencies["EUR"], // Euro
"DKK": currency.ISO4217Currencies["DKK"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need the DKK currency, because there is only one bank for the EUR currency in the Atlar default sandbox. After asking them for a second EUR bank, they asked us if we could use a DKK accounts for testing multi banking.

Comment on lines +102 to +108
ctx, span := connectors.StartSpan(
ctx,
"atlar.atlarTransactionToPaymentBatchElement",
attribute.String("connectorID", connectorID.String()),
attribute.String("taskID", taskID.String()),
)
defer span.End()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope creating instead of passing a span is the correct thing to do here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep it's good, it's gonna be linked to the parent span thanks to the StartSpan function, so LGTM

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5280bf1 and 0b0cde9.

Files selected for processing (1)
  • components/payments/cmd/connectors/internal/connectors/atlar/task_payments.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • components/payments/cmd/connectors/internal/connectors/atlar/task_payments.go

@paul-nicolas paul-nicolas added this pull request to the merge queue Jul 15, 2024
@paul-nicolas paul-nicolas removed this pull request from the merge queue due to a manual request Jul 15, 2024
@paul-nicolas paul-nicolas added this pull request to the merge queue Jul 15, 2024
Merged via the queue into formancehq:main with commit e4105c9 Jul 15, 2024
35 of 55 checks passed
@paul-nicolas paul-nicolas deleted the atlar-differeintiate-by-bank branch July 15, 2024 14:48
paul-nicolas pushed a commit that referenced this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants