-
Notifications
You must be signed in to change notification settings - Fork 0
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 journals #1
add journals #1
Conversation
client.go
Outdated
@@ -122,6 +122,85 @@ func (c *Client) postFiles(ctx context.Context, | |||
return c.do(ctx, oauth2Token, req, res) | |||
} | |||
|
|||
func (c *Client) downloadFile(ctx context.Context, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment] client.do()
の実装をコピーしているのであまり良くない(※単に client.do()
内でjson.Decodeしている処理を避けてresponse.Bodyのバイトを取得しているだけ)
queryParams url.Values, | ||
) ([]byte, *oauth2.Token, error) { | ||
// TODO: content-typeはcsv以外もあり得る? | ||
req, err := c.newRequest(ctx, apiPath, method, "text/csv", queryParams, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment] content-typeを text/csv
固定にしてしまっているが、実際にはPDFなどある
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
application/pdf
や image/*
などをダウンロードできるAPIもあるが、
対応したいのはCSVダウンロードのみなので、命名を具体化してTODOを削除。
・downloadFile() -> downloadCSV()
client.go
Outdated
return nil, oauth2Token, res | ||
} | ||
// TODO: bytesではなくBodyをそのまま返した方がいいかも | ||
bytes, err := io.ReadAll(response.Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment] []byteではなくresponse.Bodyを返した方がよいかも
// 受け付けID | ||
ID int32 `json:"id"` | ||
// TODO: 受け付けメッセージ | ||
Messages *[]string `json:"messages,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment] どういう値が入ってくるか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
運用されてからも長く、ここは気にする必要がないとしてTODOを削除した。
(返り値のサンプルでは id でリクエストを受け付けました。
)
apiPath string, method string, | ||
oauth2Token *oauth2.Token, | ||
queryParams url.Values, | ||
) (io.ReadCloser, *oauth2.Token, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment] io.ReadCloserを返すように変更
3386434
to
2892581
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIリファレンス: https://developer.freee.co.jp/docs/accounting/reference#/Journals/