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

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

const (
	SourceEbayFinanceUpdateAPIHostHTTPSApizSandboxEbayCom SourceEbayFinanceUpdateAPIHost = "https://apiz.sandbox.ebay.com"
	SourceEbayFinanceUpdateAPIHostHTTPSApizEbayCom        SourceEbayFinanceUpdateAPIHost = "https://apiz.ebay.com"
)

func (e SourceEbayFinanceUpdateAPIHost) ToPointer() *SourceEbayFinanceUpdateAPIHost {
	return &e
}
func (e *SourceEbayFinanceUpdateAPIHost) 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 = SourceEbayFinanceUpdateAPIHost(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceEbayFinanceUpdateAPIHost: %v", v)
	}
}

type SourceEbayFinanceUpdateRefreshTokenEndpoint string

const (
	SourceEbayFinanceUpdateRefreshTokenEndpointHTTPSAPISandboxEbayComIdentityV1Oauth2Token SourceEbayFinanceUpdateRefreshTokenEndpoint = "https://api.sandbox.ebay.com/identity/v1/oauth2/token"
	SourceEbayFinanceUpdateRefreshTokenEndpointHTTPSAPIEbayComIdentityV1Oauth2Token        SourceEbayFinanceUpdateRefreshTokenEndpoint = "https://api.ebay.com/identity/v1/oauth2/token"
)

func (e SourceEbayFinanceUpdateRefreshTokenEndpoint) ToPointer() *SourceEbayFinanceUpdateRefreshTokenEndpoint {
	return &e
}
func (e *SourceEbayFinanceUpdateRefreshTokenEndpoint) 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 = SourceEbayFinanceUpdateRefreshTokenEndpoint(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceEbayFinanceUpdateRefreshTokenEndpoint: %v", v)
	}
}

type SourceEbayFinanceUpdate struct {
	// https://apiz.sandbox.ebay.com for sandbox & https://apiz.ebay.com for production
	APIHost *SourceEbayFinanceUpdateAPIHost `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 *SourceEbayFinanceUpdateRefreshTokenEndpoint `default:"https://api.ebay.com/identity/v1/oauth2/token" json:"token_refresh_endpoint"`
	// Ebay Developer Client ID
	Username string `json:"username"`
}

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

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

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

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

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

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

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

func (o *SourceEbayFinanceUpdate) GetTokenRefreshEndpoint() *SourceEbayFinanceUpdateRefreshTokenEndpoint {
	if o == nil {
		return nil
	}
	return o.TokenRefreshEndpoint
}

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