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

fix(core): do not omit empty Money fields #288

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scw/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ func (f *File) UnmarshalJSON(b []byte) error {
// Money represents an amount of money with its currency type.
type Money struct {
// CurrencyCode is the 3-letter currency code defined in ISO 4217.
CurrencyCode string `json:"currency_code,omitempty"`
CurrencyCode string `json:"currency_code"`

// Units is the whole units of the amount.
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
Units int64 `json:"units,omitempty"`
Units int64 `json:"units"`

// Nanos is the number of nano (10^-9) units of the amount.
// The value must be between -999,999,999 and +999,999,999 inclusive.
// If `units` is positive, `nanos` must be positive or zero.
// If `units` is zero, `nanos` can be positive, zero, or negative.
// If `units` is negative, `nanos` must be negative or zero.
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
Nanos int32 `json:"nanos,omitempty"`
Nanos int32 `json:"nanos"`
}

// NewMoneyFromFloat conerts a float with currency to a Money object.
Expand Down