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 GET /api/trades #2

Merged
merged 2 commits into from
Aug 3, 2024
Merged

Add GET /api/trades #2

merged 2 commits into from
Aug 3, 2024

Conversation

nao1215
Copy link
Owner

@nao1215 nao1215 commented Aug 3, 2024

Summary by CodeRabbit

  • New Features

    • Added a new API method for retrieving current order transactions (GET /api/trades).
  • Documentation

    • Updated the README to include new API method descriptions and enhanced clarity on existing methods.
  • Refactor

    • Streamlined existing methods by centralizing HTTP request handling, improving code maintainability.

Copy link

coderabbitai bot commented Aug 3, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent updates to the Coincheck API client enhance its functionality by introducing new features for trade retrieval and improving HTTP request handling. Key changes include the addition of pagination support, a dedicated method for managing requests, and refined documentation. These modifications aim to boost code readability, maintainability, and robustness, ultimately enriching the client's usability.

Changes

Files Change Summary
README.md Updated documentation with a new API method GET /api/trades, added source references, and improved clarity and grammar throughout.
coincheck.go Introduced a new method do in the Client struct for streamlined HTTP request handling and error management.
order.go Added OrderType and constants for representing order types, enhancing clarity in trading operations.
pagenation.go Created a new Pagination struct and PaginationOrder type for managing API pagination, including constants for order direction.
ticker.go Refactored GetTicker method to utilize the new do method, enhancing readability and centralizing error handling.
trade.go Established functionality for trade data retrieval, including structures for input and response handling. Introduced GetTrades method to initiate trade requests.
trade_test.go Added unit tests for GetTrades method, validating both successful and failed API requests.
withdraw.go Refactored GetBankAccounts method to leverage the do method for improved error handling and response processing.

Poem

In the garden where rabbits play,
Code hops and dances, brightening the day.
With trades and pages, all neatly aligned,
Our API's magic, wonderfully designed!
Let's leap with joy, for changes are grand,
A fluffy new world, crafted by hand! 🐇✨


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 Configuration 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.

Copy link

@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: 4

Outside diff range, codebase verification and nitpick comments (1)
coincheck.go (1)

114-115: Add a comment to explain the purpose of the do method.

Adding a brief comment to explain the purpose of this method would improve readability and maintainability.

+ // do sends an HTTP request and processes the response.
func (c *Client) do(req *http.Request, output any) error {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5bebda3 and e567ad5.

Files selected for processing (8)
  • README.md (2 hunks)
  • coincheck.go (2 hunks)
  • order.go (1 hunks)
  • pagenation.go (1 hunks)
  • ticker.go (2 hunks)
  • trade.go (1 hunks)
  • trade_test.go (1 hunks)
  • withdraw.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • README.md
Additional context used
golangci-lint
pagenation.go

9-9: json(snake): got 'order' want 'pagination_order'

(tagliatelle)

Additional comments not posted (10)
order.go (1)

1-11: LGTM!

The code correctly defines the OrderType type and constants for buy and sell order types. It is clear and follows Go conventions.

pagenation.go (1)

18-26: LGTM!

The code correctly defines the PaginationOrder type and constants for ascending and descending order. It is clear and follows Go conventions.

withdraw.go (1)

48-49: LGTM! But verify c.do method.

The refactoring using c.do method is approved. It simplifies the GetBankAccounts method.

However, ensure that c.do properly handles errors and responses.

Verification successful

LGTM! The c.do method handles errors and responses correctly.

The c.do method implementation in coincheck.go properly handles HTTP requests, checks for errors, verifies the status code, and decodes the response body. The refactoring using this method is approved.

  • coincheck.go:115-130: Implementation of c.do method.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `c.do` method handles errors and responses correctly.

# Test: Search for the `c.do` method implementation. Expect: Proper error and response handling.
rg --type go -A 10 'func (c *Client) do'

Length of output: 42


Script:

#!/bin/bash
# Description: Verify the `c.do` method handles errors and responses correctly.

# Test: Search for the `c.do` method implementation using ast-grep. Expect: Proper error and response handling.
ast-grep --lang go --pattern 'func (c *Client) do($_, $_) $_'

Length of output: 776

trade.go (4)

8-12: LGTM!

The GetTradesInput struct is straightforward and correctly defined.


14-22: LGTM!

The GetTradesResponse struct is well-defined with appropriate JSON tags.


24-37: LGTM!

The Trade struct is well-defined with appropriate JSON tags.


40-60: LGTM!

The GetTrades function is well-structured, handles errors appropriately, and promotes reusability and maintainability by using createRequest and do methods.

ticker.go (1)

78-79: LGTM!

The refactoring of the GetTicker method to use the do method for HTTP handling improves readability and maintainability.

trade_test.go (2)

13-106: LGTM!

The test case "In the case of a successful GET /api/trades request" is well-structured and covers various aspects of the GetTrades function, including HTTP method, endpoint, query parameters, and response data.


108-124: LGTM!

The test case "In the case of a failed GET /api/trades request" is well-structured and verifies the error handling of the GetTrades function.

coincheck.go Show resolved Hide resolved
coincheck.go Show resolved Hide resolved
coincheck.go Show resolved Hide resolved
pagenation.go Show resolved Hide resolved
@nao1215 nao1215 merged commit da9d111 into main Aug 3, 2024
17 checks passed
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