// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
	"time"
)

type Orb string

const (
	OrbOrb Orb = "orb"
)

func (e Orb) ToPointer() *Orb {
	return &e
}
func (e *Orb) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "orb":
		*e = Orb(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Orb: %v", v)
	}
}

type SourceOrb struct {
	// Orb API Key, issued from the Orb admin console.
	APIKey string `json:"api_key"`
	// UTC date and time in the format 2022-03-01T00:00:00Z. Any data with created_at after this data will not be synced. For Subscription Usage, this becomes the `timeframe_start` API parameter.
	EndDate *string `json:"end_date,omitempty"`
	// When set to N, the connector will always refresh resources created within the past N days. By default, updated objects that are not newly created are not incrementally synced.
	LookbackWindowDays *int64 `default:"0" json:"lookback_window_days"`
	// Property key names to extract from all events, in order to enrich ledger entries corresponding to an event deduction.
	NumericEventPropertiesKeys []string `json:"numeric_event_properties_keys,omitempty"`
	// Orb Plan ID to filter subscriptions that should have usage fetched.
	PlanID *string `json:"plan_id,omitempty"`
	// UTC date and time in the format 2022-03-01T00:00:00Z. Any data with created_at before this data will not be synced. For Subscription Usage, this becomes the `timeframe_start` API parameter.
	StartDate time.Time `json:"start_date"`
	// Property key names to extract from all events, in order to enrich ledger entries corresponding to an event deduction.
	StringEventPropertiesKeys []string `json:"string_event_properties_keys,omitempty"`
	// Property key name to group subscription usage by.
	SubscriptionUsageGroupingKey *string `json:"subscription_usage_grouping_key,omitempty"`
	sourceType                   Orb     `const:"orb" json:"sourceType"`
}

func (s SourceOrb) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

func (s *SourceOrb) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *SourceOrb) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

func (o *SourceOrb) GetEndDate() *string {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceOrb) GetLookbackWindowDays() *int64 {
	if o == nil {
		return nil
	}
	return o.LookbackWindowDays
}

func (o *SourceOrb) GetNumericEventPropertiesKeys() []string {
	if o == nil {
		return nil
	}
	return o.NumericEventPropertiesKeys
}

func (o *SourceOrb) GetPlanID() *string {
	if o == nil {
		return nil
	}
	return o.PlanID
}

func (o *SourceOrb) GetStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate
}

func (o *SourceOrb) GetStringEventPropertiesKeys() []string {
	if o == nil {
		return nil
	}
	return o.StringEventPropertiesKeys
}

func (o *SourceOrb) GetSubscriptionUsageGroupingKey() *string {
	if o == nil {
		return nil
	}
	return o.SubscriptionUsageGroupingKey
}

func (o *SourceOrb) GetSourceType() Orb {
	return OrbOrb
}
