Documentation
¶
Overview ¶
Package types provides shared types used across the Basecamp SDK.
Package types provides shared types used across the Basecamp SDK.
Index ¶
- type Date
- func (d Date) AddDays(n int) Date
- func (d Date) AddMonths(n int) Date
- func (d Date) AddYears(n int) Date
- func (d Date) After(other Date) bool
- func (d Date) Before(other Date) bool
- func (d Date) Compare(other Date) int
- func (d Date) DaysSince(s Date) int
- func (d Date) Equal(other Date) bool
- func (d Date) GoString() string
- func (d Date) In(loc *time.Location) time.Time
- func (d Date) IsValid() bool
- func (d Date) IsZero() bool
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d Date) String() string
- func (d Date) UTC() time.Time
- func (d *Date) UnmarshalJSON(data []byte) error
- func (d *Date) UnmarshalText(data []byte) error
- func (d Date) Weekday() time.Weekday
- type FlexInt
- type FlexibleInt64
- type FlexibleTime
- func (ft FlexibleTime) AppendText(b []byte) ([]byte, error)
- func (ft FlexibleTime) DateOnly() bool
- func (ft FlexibleTime) MarshalJSON() ([]byte, error)
- func (ft FlexibleTime) MarshalText() ([]byte, error)
- func (ft *FlexibleTime) UnmarshalJSON(data []byte) error
- func (ft *FlexibleTime) UnmarshalText(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date struct {
Year int // Year (e.g., 2024)
Month time.Month // Month of the year (January = 1, ...)
Day int // Day of the month, starting at 1
}
Date represents a calendar date (year, month, day) without time or timezone. Use this for date-only fields like due_on and starts_on.
func (Date) Compare ¶
Compare compares d and other. Returns -1 if d < other, 0 if equal, +1 if d > other.
func (Date) In ¶
In returns the time.Time corresponding to midnight of the date in the given location.
func (Date) MarshalJSON ¶
MarshalJSON implements json.Marshaler. Zero dates marshal as null, valid dates as "YYYY-MM-DD".
func (Date) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. Accepts "YYYY-MM-DD" strings and null.
func (*Date) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type FlexInt ¶ added in v0.4.0
type FlexInt int32
FlexInt is an int32 that unmarshals from any JSON number whose value is integral and fits in 32 bits. The BC3 API serializes pixel dimensions as floats (e.g. 1024.0); Go's encoding/json rejects those into plain int fields. FlexInt bridges this wire-format mismatch without lying in the spec.
Non-integral values (1024.5) and out-of-range values (1e20) are rejected to match the int32 schema in openapi.json.
func (FlexInt) MarshalJSON ¶ added in v0.4.0
MarshalJSON writes the value as an integer.
func (*FlexInt) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON accepts any JSON number whose value is an integer within int32 range.
type FlexibleInt64 ¶ added in v0.7.1
type FlexibleInt64 int64
FlexibleInt64 is an int64 that unmarshals from either a JSON number or a JSON string containing an integer. The BC3 API sometimes serializes person IDs as strings (e.g. "12345") in notification responses while returning plain integers elsewhere. FlexibleInt64 bridges this wire-format mismatch without lying in the spec.
Non-integral JSON numbers (1024.5) and values outside int64 range are rejected. Non-numeric strings (e.g. "basecamp" for system-generated entities) unmarshal to zero — the spec declares the field as integer, so a non-numeric value means the entity has no meaningful numeric ID. The number path uses json.Number to avoid float64 precision loss for values beyond 2^53.
func (FlexibleInt64) MarshalJSON ¶ added in v0.7.1
func (fi FlexibleInt64) MarshalJSON() ([]byte, error)
MarshalJSON writes the value as a JSON integer.
func (*FlexibleInt64) UnmarshalJSON ¶ added in v0.7.1
func (fi *FlexibleInt64) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts a JSON number or a JSON string whose value is an integer within int64 range.
type FlexibleTime ¶ added in v0.4.0
FlexibleTime is a time.Time that can unmarshal from RFC3339, RFC3339Nano, or date-only ("2006-01-02") strings. Date-only values are treated as midnight UTC. This supports API responses where all-day schedule entries return dates without times.
It remembers which form it parsed and marshals that form back: a bare date re-emits as a bare date, a timestamp as a timestamp. BC3 re-parses a timestamp in the account's own time zone, so an all-day bound rendered as "2026-08-04T00:00:00Z" lands on the previous day anywhere west of UTC — a read-modify-write that widened the date on input and narrowed it on output moved the entry (#633).
func (FlexibleTime) AppendText ¶ added in v0.19.0
func (ft FlexibleTime) AppendText(b []byte) ([]byte, error)
AppendText implements encoding.TextAppender with the same form MarshalText emits; the promoted time.Time.AppendText would append the RFC3339 form of a bare date.
func (FlexibleTime) DateOnly ¶ added in v0.19.0
func (ft FlexibleTime) DateOnly() bool
DateOnly reports whether the value was parsed from a bare date, in which case it marshals back as one.
func (FlexibleTime) MarshalJSON ¶ added in v0.4.0
func (ft FlexibleTime) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler for FlexibleTime. A value parsed from a bare date marshals as that date, even "0001-01-01", which is Go's zero time and would otherwise collapse to null; a zero time that was never parsed from a date marshals as null; any other time uses time.Time's JSON encoding.
func (FlexibleTime) MarshalText ¶ added in v0.19.0
func (ft FlexibleTime) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler: the bare date when one was parsed, otherwise time.Time's RFC3339 text.
func (*FlexibleTime) UnmarshalJSON ¶ added in v0.4.0
func (ft *FlexibleTime) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for FlexibleTime.
func (*FlexibleTime) UnmarshalText ¶ added in v0.19.0
func (ft *FlexibleTime) UnmarshalText(data []byte) error
UnmarshalText implements encoding.TextUnmarshaler. Defined here rather than promoted from the embedded time.Time so that every decode path, not only JSON, records which form it parsed — a promoted UnmarshalText would replace the time and leave a stale bare-date flag behind.