// 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 AuthType string

const (
	AuthTypeOauth20 AuthType = "oauth2.0"
)

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

type Quickbooks string

const (
	QuickbooksQuickbooks Quickbooks = "quickbooks"
)

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

type SourceQuickbooks struct {
	// Access token for making authenticated requests.
	AccessToken string    `json:"access_token"`
	authType    *AuthType `const:"oauth2.0" json:"auth_type,omitempty"`
	// Identifies which app is making the request. Obtain this value from the Keys tab on the app profile via My Apps on the developer site. There are two versions of this key: development and production.
	ClientID string `json:"client_id"`
	//  Obtain this value from the Keys tab on the app profile via My Apps on the developer site. There are two versions of this key: development and production.
	ClientSecret string `json:"client_secret"`
	// Labeled Company ID. The Make API Calls panel is populated with the realm id and the current access token.
	RealmID string `json:"realm_id"`
	// A token used when refreshing the access token.
	RefreshToken string `json:"refresh_token"`
	// Determines whether to use the sandbox or production environment.
	Sandbox *bool `default:"false" json:"sandbox"`
	// The default value to use if no bookmark exists for an endpoint (rfc3339 date string). E.g, 2021-03-20T00:00:00Z. Any data before this date will not be replicated.
	StartDate time.Time `json:"start_date"`
	// The date-time when the access token should be refreshed.
	TokenExpiryDate time.Time  `json:"token_expiry_date"`
	sourceType      Quickbooks `const:"quickbooks" json:"sourceType"`
}

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

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

func (o *SourceQuickbooks) GetAccessToken() string {
	if o == nil {
		return ""
	}
	return o.AccessToken
}

func (o *SourceQuickbooks) GetAuthType() *AuthType {
	return AuthTypeOauth20.ToPointer()
}

func (o *SourceQuickbooks) GetClientID() string {
	if o == nil {
		return ""
	}
	return o.ClientID
}

func (o *SourceQuickbooks) GetClientSecret() string {
	if o == nil {
		return ""
	}
	return o.ClientSecret
}

func (o *SourceQuickbooks) GetRealmID() string {
	if o == nil {
		return ""
	}
	return o.RealmID
}

func (o *SourceQuickbooks) GetRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.RefreshToken
}

func (o *SourceQuickbooks) GetSandbox() *bool {
	if o == nil {
		return nil
	}
	return o.Sandbox
}

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

func (o *SourceQuickbooks) GetTokenExpiryDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.TokenExpiryDate
}

func (o *SourceQuickbooks) GetSourceType() Quickbooks {
	return QuickbooksQuickbooks
}
