// 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"
)

// APIHost - https://apiz.sandbox.ebay.com for sandbox & https://apiz.ebay.com for production
type APIHost string

const (
	APIHostHTTPSApizSandboxEbayCom APIHost = "https://apiz.sandbox.ebay.com"
	APIHostHTTPSApizEbayCom        APIHost = "https://apiz.ebay.com"
)

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

type RefreshTokenEndpoint string

const (
	RefreshTokenEndpointHTTPSAPISandboxEbayComIdentityV1Oauth2Token RefreshTokenEndpoint = "https://api.sandbox.ebay.com/identity/v1/oauth2/token"
	RefreshTokenEndpointHTTPSAPIEbayComIdentityV1Oauth2Token        RefreshTokenEndpoint = "https://api.ebay.com/identity/v1/oauth2/token"
)

func (e RefreshTokenEndpoint) ToPointer() *RefreshTokenEndpoint {
	return &e
}
func (e *RefreshTokenEndpoint) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "https://api.sandbox.ebay.com/identity/v1/oauth2/token":
		fallthrough
	case "https://api.ebay.com/identity/v1/oauth2/token":
		*e = RefreshTokenEndpoint(v)
		return nil
	default:
		return fmt.Errorf("invalid value for RefreshTokenEndpoint: %v", v)
	}
}

type EbayFinance string

const (
	EbayFinanceEbayFinance EbayFinance = "ebay-finance"
)

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

type SourceEbayFinance struct {
	// https://apiz.sandbox.ebay.com for sandbox & https://apiz.ebay.com for production
	APIHost *APIHost `default:"https://apiz.ebay.com" json:"api_host"`
	// Ebay Client Secret
	Password             *string               `json:"password,omitempty"`
	RedirectURI          string                `json:"redirect_uri"`
	RefreshToken         string                `json:"refresh_token"`
	StartDate            time.Time             `json:"start_date"`
	TokenRefreshEndpoint *RefreshTokenEndpoint `default:"https://api.ebay.com/identity/v1/oauth2/token" json:"token_refresh_endpoint"`
	// Ebay Developer Client ID
	Username   string      `json:"username"`
	sourceType EbayFinance `const:"ebay-finance" json:"sourceType"`
}

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

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

func (o *SourceEbayFinance) GetAPIHost() *APIHost {
	if o == nil {
		return nil
	}
	return o.APIHost
}

func (o *SourceEbayFinance) GetPassword() *string {
	if o == nil {
		return nil
	}
	return o.Password
}

func (o *SourceEbayFinance) GetRedirectURI() string {
	if o == nil {
		return ""
	}
	return o.RedirectURI
}

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

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

func (o *SourceEbayFinance) GetTokenRefreshEndpoint() *RefreshTokenEndpoint {
	if o == nil {
		return nil
	}
	return o.TokenRefreshEndpoint
}

func (o *SourceEbayFinance) GetUsername() string {
	if o == nil {
		return ""
	}
	return o.Username
}

func (o *SourceEbayFinance) GetSourceType() EbayFinance {
	return EbayFinanceEbayFinance
}
