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

const (
	SourceEbayFulfillmentAPIHostHTTPSAPIEbayCom        SourceEbayFulfillmentAPIHost = "https://api.ebay.com"
	SourceEbayFulfillmentAPIHostHTTPSAPISandboxEbayCom SourceEbayFulfillmentAPIHost = "https://api.sandbox.ebay.com"
)

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

type SourceEbayFulfillmentRefreshTokenEndpoint string

const (
	SourceEbayFulfillmentRefreshTokenEndpointHTTPSAPIEbayComIdentityV1Oauth2Token        SourceEbayFulfillmentRefreshTokenEndpoint = "https://api.ebay.com/identity/v1/oauth2/token"
	SourceEbayFulfillmentRefreshTokenEndpointHTTPSAPISandboxEbayComIdentityV1Oauth2Token SourceEbayFulfillmentRefreshTokenEndpoint = "https://api.sandbox.ebay.com/identity/v1/oauth2/token"
)

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

type EbayFulfillment string

const (
	EbayFulfillmentEbayFulfillment EbayFulfillment = "ebay-fulfillment"
)

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

type SourceEbayFulfillment struct {
	APIHost              *SourceEbayFulfillmentAPIHost              `default:"https://api.ebay.com" json:"api_host"`
	Password             string                                     `json:"password"`
	RedirectURI          string                                     `json:"redirect_uri"`
	RefreshToken         string                                     `json:"refresh_token"`
	RefreshTokenEndpoint *SourceEbayFulfillmentRefreshTokenEndpoint `default:"https://api.ebay.com/identity/v1/oauth2/token" json:"refresh_token_endpoint"`
	StartDate            time.Time                                  `json:"start_date"`
	Username             string                                     `json:"username"`
	sourceType           EbayFulfillment                            `const:"ebay-fulfillment" json:"sourceType"`
}

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

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

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

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

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

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

func (o *SourceEbayFulfillment) GetRefreshTokenEndpoint() *SourceEbayFulfillmentRefreshTokenEndpoint {
	if o == nil {
		return nil
	}
	return o.RefreshTokenEndpoint
}

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

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

func (o *SourceEbayFulfillment) GetSourceType() EbayFulfillment {
	return EbayFulfillmentEbayFulfillment
}
