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

Is limit.max optional? #466

Open
kyu-suke opened this issue Jul 18, 2024 · 1 comment
Open

Is limit.max optional? #466

kyu-suke opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels

Comments

@kyu-suke
Copy link

System Informations

  • Go version: go1.22.5 darwin/arm64
  • OS: macOS 14.4.1

Current Behavior

According to send-narrowcast-message, max and upToRemainingQuota are optional. But Max field in Limit is defined Max int32 `json:"max". As a result, when Max is defined zero value, it isn't defined.

If Limit is defined like below.

limit := &messaging_api.Limit{
  UpToRemainingQuota: true,
}

The result of json.MarshalI value is like this.

{
    "max": 0,
    "upToRemainingQuota": true
}

Expected Behavior

It may be needed to add omitempty. If this approach is acceptable, I would like to proceed with submitting a pull request. Please let me know if there are any concerns or suggestions for improvement.

type Limit struct {
	Max int32 `json:"max,omitempty"`
	UpToRemainingQuota bool `json:"upToRemainingQuota"`
}

The value expected is like this.

{
    "upToRemainingQuota": true
}

Steps to Reproduce

limit := &messaging_api.Limit{
  UpToRemainingQuota: true,
}
l, _ := json.MarshalIndent(limit, "", "    ")
fmt.Println(string(l))
@habara-k
Copy link

habara-k commented Aug 8, 2024

Thank you for using the line-bot-sdk-go.

Thank you for your report. We have confirmed the behavior on our end as well. The Limit.max should allow null (as it has a different meaning from int 0), so omitempty should be added. Otherwise, it is not possible to use the Limit object with the sdk-go because the API does not accept max=0 in the request.

We believe this behavior should be fixed. It would be greatly appreciated if you could create a PR for the fix. Thank you very much for your cooperation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants