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

Add Function to Retrieve Currency Code by Numeric Code #152

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rbenatti8
Copy link

@rbenatti8 rbenatti8 commented Nov 14, 2024

This PR adds a static function, GetCurrencyCodeByNumericCode, to allow retrieval of a currency code based on its ISO-4217 numeric code.

Purpose:

Simplifies the process of finding a currency code without manually iterating through the currency list.
Provides a more efficient and straightforward method for users needing to convert numeric codes to currency codes.
This function will help streamline workflows that rely on numeric codes for currency identification

Summary by Sourcery

Add a new function GetCurrencyByNumericCode to facilitate retrieving currency codes by their numeric ISO-4217 codes, and include a corresponding test to verify its functionality.

New Features:

  • Introduce a static function GetCurrencyByNumericCode to retrieve a currency code using its ISO-4217 numeric code.

Tests:

  • Add a test case for the GetCurrencyByNumericCode function to ensure it returns the correct currency for a given numeric code.

Copy link

sourcery-ai bot commented Nov 14, 2024

Reviewer's Guide by Sourcery

This PR introduces a new function GetCurrencyByNumericCode that allows retrieving currency information using ISO-4217 numeric codes. The implementation adds a simple wrapper function that delegates to the existing currencies package functionality, along with corresponding test coverage.

Class diagram for the new GetCurrencyByNumericCode function

classDiagram
    class Currency {
        +Formatter() *Formatter
    }
    class Currencies {
        +CurrencyByCode(code string) *Currency
        +CurrencyByNumericCode(code string) *Currency
    }
    class CurrencyUtils {
        +GetCurrency(code string) *Currency
        +GetCurrencyByNumericCode(code string) *Currency
    }
    CurrencyUtils --> Currencies: uses
    Currency --> Formatter
Loading

File-Level Changes

Change Details Files
Added new function to retrieve currency by numeric code
  • Added GetCurrencyByNumericCode function that wraps currencies.CurrencyByNumericCode
  • Function accepts a string parameter for the numeric code and returns a Currency pointer
currency.go
Added test coverage for the new numeric code lookup function
  • Created test case using Brazilian Real (BRL/986) as an example
  • Verifies that currency lookup by numeric code matches the expected currency object
currency_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @rbenatti8 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding error handling tests for invalid numeric codes (e.g., non-existent codes, malformed inputs)
  • Please document the expected format of the numeric code parameter (number of digits, zero-padding requirements, etc.)
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rbenatti8
Copy link
Author

@Rhymond please take a look on that when you have time.

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