From 0ba299b26ab091c2d6f75a0203b28928765e0161 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 18:05:32 +0000 Subject: [PATCH] feat: add CalendarDate field to MealInDbBaseClientFacingSource MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new `CalendarDate` string field to `MealInDbBaseClientFacingSource` representing the date of the meal in YYYY-mm-dd format. This is useful for providers that only expose a date rather than a full timestamp. Key changes: - Add `CalendarDate string` field to `MealInDbBaseClientFacingSource` struct - Add `GetCalendarDate()` accessor method on `MealInDbBaseClientFacingSource` - Add `SetCalendarDate()` setter method to mark the field as required during serialization - Shift internal bitmask field indices to accommodate the new field 🌿 Generated with Fern --- .fern/metadata.json | 6 ++-- changelog.md | 4 +++ core/request_option.go | 4 +-- meal.go | 41 ++++++++++++++++++++-------- meal_test.go | 62 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 17 deletions(-) diff --git a/.fern/metadata.json b/.fern/metadata.json index e6e283b..3aeaab2 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,14 +1,14 @@ { - "cliVersion": "5.5.1", + "cliVersion": "5.6.1", "generatorName": "fernapi/fern-go-sdk", "generatorVersion": "1.38.1", "generatorConfig": { "enableWireTests": false }, - "originGitCommit": "05d79dd6ce370cbd029417f59eb71c056d94aa61", + "originGitCommit": "e1c3ceef9f4e6957d1a38d66920fdb58ec00c6d5", "originGitCommitIsDirty": true, "invokedBy": "ci", "requestedVersion": "AUTO", "ciProvider": "unknown", - "sdkVersion": "v0.0.1" + "sdkVersion": "v0.1.0" } \ No newline at end of file diff --git a/changelog.md b/changelog.md index d377f62..c210a6d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +## v0.1.0 - 2026-05-01 +### Added +* **`MealInDbBaseClientFacingSource.CalendarDate`** — new string field representing the meal date in `YYYY-mm-dd` format, along with `GetCalendarDate()` and `SetCalendarDate()` accessor methods. + ## v0.0.1 - 2026-05-01 * Initial SDK generation * 🌿 Generated with Fern diff --git a/core/request_option.go b/core/request_option.go index 62b9f1e..7477bcb 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -58,8 +58,8 @@ func (r *RequestOptions) cloneHeader() http.Header { headers := r.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") headers.Set("X-Fern-SDK-Name", "github.com/junction-api/junction-go") - headers.Set("X-Fern-SDK-Version", "v0.0.1") - headers.Set("User-Agent", "github.com/junction-api/junction-go/v0.0.1") + headers.Set("X-Fern-SDK-Version", "v0.1.0") + headers.Set("User-Agent", "github.com/junction-api/junction-go/v0.1.0") return headers } diff --git a/meal.go b/meal.go index bcfe33f..5091618 100644 --- a/meal.go +++ b/meal.go @@ -746,16 +746,17 @@ var ( mealInDbBaseClientFacingSourceFieldSourceId = big.NewInt(1 << 3) mealInDbBaseClientFacingSourceFieldProviderId = big.NewInt(1 << 4) mealInDbBaseClientFacingSourceFieldTimestamp = big.NewInt(1 << 5) - mealInDbBaseClientFacingSourceFieldName = big.NewInt(1 << 6) - mealInDbBaseClientFacingSourceFieldEnergy = big.NewInt(1 << 7) - mealInDbBaseClientFacingSourceFieldMacros = big.NewInt(1 << 8) - mealInDbBaseClientFacingSourceFieldMicros = big.NewInt(1 << 9) - mealInDbBaseClientFacingSourceFieldData = big.NewInt(1 << 10) - mealInDbBaseClientFacingSourceFieldSource = big.NewInt(1 << 11) - mealInDbBaseClientFacingSourceFieldCreatedAt = big.NewInt(1 << 12) - mealInDbBaseClientFacingSourceFieldUpdatedAt = big.NewInt(1 << 13) - mealInDbBaseClientFacingSourceFieldSourceAppId = big.NewInt(1 << 14) - mealInDbBaseClientFacingSourceFieldSourceDeviceId = big.NewInt(1 << 15) + mealInDbBaseClientFacingSourceFieldCalendarDate = big.NewInt(1 << 6) + mealInDbBaseClientFacingSourceFieldName = big.NewInt(1 << 7) + mealInDbBaseClientFacingSourceFieldEnergy = big.NewInt(1 << 8) + mealInDbBaseClientFacingSourceFieldMacros = big.NewInt(1 << 9) + mealInDbBaseClientFacingSourceFieldMicros = big.NewInt(1 << 10) + mealInDbBaseClientFacingSourceFieldData = big.NewInt(1 << 11) + mealInDbBaseClientFacingSourceFieldSource = big.NewInt(1 << 12) + mealInDbBaseClientFacingSourceFieldCreatedAt = big.NewInt(1 << 13) + mealInDbBaseClientFacingSourceFieldUpdatedAt = big.NewInt(1 << 14) + mealInDbBaseClientFacingSourceFieldSourceAppId = big.NewInt(1 << 15) + mealInDbBaseClientFacingSourceFieldSourceDeviceId = big.NewInt(1 << 16) ) type MealInDbBaseClientFacingSource struct { @@ -766,8 +767,10 @@ type MealInDbBaseClientFacingSource struct { // This value has no meaning. SourceId int `json:"source_id" url:"source_id"` // This value is identical to `id`. - ProviderId string `json:"provider_id" url:"provider_id"` - Timestamp time.Time `json:"timestamp" url:"timestamp"` + ProviderId string `json:"provider_id" url:"provider_id"` + Timestamp time.Time `json:"timestamp" url:"timestamp"` + // Date of the meal in the YYYY-mm-dd format. For providers that only expose a date, this is the calendar date as recorded by the user. + CalendarDate string `json:"calendar_date" url:"calendar_date"` Name string `json:"name" url:"name"` Energy *Energy `json:"energy,omitempty" url:"energy,omitempty"` Macros *Macros `json:"macros,omitempty" url:"macros,omitempty"` @@ -828,6 +831,13 @@ func (m *MealInDbBaseClientFacingSource) GetTimestamp() time.Time { return m.Timestamp } +func (m *MealInDbBaseClientFacingSource) GetCalendarDate() string { + if m == nil { + return "" + } + return m.CalendarDate +} + func (m *MealInDbBaseClientFacingSource) GetName() string { if m == nil { return "" @@ -954,6 +964,13 @@ func (m *MealInDbBaseClientFacingSource) SetTimestamp(timestamp time.Time) { m.require(mealInDbBaseClientFacingSourceFieldTimestamp) } +// SetCalendarDate sets the CalendarDate field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MealInDbBaseClientFacingSource) SetCalendarDate(calendarDate string) { + m.CalendarDate = calendarDate + m.require(mealInDbBaseClientFacingSourceFieldCalendarDate) +} + // SetName sets the Name field and marks it as non-optional; // this prevents an empty or null value for this field from being omitted during serialization. func (m *MealInDbBaseClientFacingSource) SetName(name string) { diff --git a/meal_test.go b/meal_test.go index e2b3dcc..34323de 100644 --- a/meal_test.go +++ b/meal_test.go @@ -1624,6 +1624,14 @@ func TestSettersMealInDbBaseClientFacingSource(t *testing.T) { assert.NotNil(t, obj.explicitFields) }) + t.Run("SetCalendarDate", func(t *testing.T) { + obj := &MealInDbBaseClientFacingSource{} + var fernTestValueCalendarDate string + obj.SetCalendarDate(fernTestValueCalendarDate) + assert.Equal(t, fernTestValueCalendarDate, obj.CalendarDate) + assert.NotNil(t, obj.explicitFields) + }) + t.Run("SetName", func(t *testing.T) { obj := &MealInDbBaseClientFacingSource{} var fernTestValueName string @@ -1845,6 +1853,29 @@ func TestGettersMealInDbBaseClientFacingSource(t *testing.T) { _ = obj.GetTimestamp() // Should return zero value }) + t.Run("GetCalendarDate", func(t *testing.T) { + t.Parallel() + // Arrange + obj := &MealInDbBaseClientFacingSource{} + var expected string + obj.CalendarDate = expected + + // Act & Assert + assert.Equal(t, expected, obj.GetCalendarDate(), "getter should return the property value") + }) + + t.Run("GetCalendarDate_NilReceiver", func(t *testing.T) { + t.Parallel() + var obj *MealInDbBaseClientFacingSource + // Should not panic - getters should handle nil receiver gracefully + defer func() { + if r := recover(); r != nil { + t.Errorf("Getter panicked on nil receiver: %v", r) + } + }() + _ = obj.GetCalendarDate() // Should return zero value + }) + t.Run("GetName", func(t *testing.T) { t.Parallel() // Arrange @@ -2334,6 +2365,37 @@ func TestSettersMarkExplicitMealInDbBaseClientFacingSource(t *testing.T) { // It verifies that setting a field via setter allows successful JSON round-trip }) + t.Run("SetCalendarDate_MarksExplicit", func(t *testing.T) { + t.Parallel() + // Arrange + obj := &MealInDbBaseClientFacingSource{} + var fernTestValueCalendarDate string + + // Act + obj.SetCalendarDate(fernTestValueCalendarDate) + + // Assert - object with explicitly set field can be marshaled/unmarshaled + bytes, err := json.Marshal(obj) + require.NoError(t, err, "marshaling should succeed for test setup") + + // This test ensures JSON marshaling and unmarshaling succeed when the field has a zero/nil value + // Detect if marshaled JSON is an object or primitive to use correct unmarshal target + if len(bytes) > 0 && bytes[0] == '{' { + // JSON object - unmarshal into map + var unmarshaled map[string]interface{} + err = json.Unmarshal(bytes, &unmarshaled) + require.NoError(t, err, "unmarshaling should succeed for test verification") + } else { + // JSON primitive (string, number, boolean, null) - unmarshal into interface{} + var unmarshaled interface{} + err = json.Unmarshal(bytes, &unmarshaled) + require.NoError(t, err, "unmarshaling should succeed for test verification") + } + + // Note: This does not explicitly assert the presence of a specific JSON field + // It verifies that setting a field via setter allows successful JSON round-trip + }) + t.Run("SetName_MarksExplicit", func(t *testing.T) { t.Parallel() // Arrange