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

const (
	SourceEbayFulfillmentUpdateAPIHostHTTPSAPIEbayCom        SourceEbayFulfillmentUpdateAPIHost = "https://api.ebay.com"
	SourceEbayFulfillmentUpdateAPIHostHTTPSAPISandboxEbayCom SourceEbayFulfillmentUpdateAPIHost = "https://api.sandbox.ebay.com"
)

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

type SourceEbayFulfillmentUpdateRefreshTokenEndpoint string

const (
	SourceEbayFulfillmentUpdateRefreshTokenEndpointHTTPSAPIEbayComIdentityV1Oauth2Token        SourceEbayFulfillmentUpdateRefreshTokenEndpoint = "https://api.ebay.com/identity/v1/oauth2/token"
	SourceEbayFulfillmentUpdateRefreshTokenEndpointHTTPSAPISandboxEbayComIdentityV1Oauth2Token SourceEbayFulfillmentUpdateRefreshTokenEndpoint = "https://api.sandbox.ebay.com/identity/v1/oauth2/token"
)

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

type SourceEbayFulfillmentUpdate struct {
	APIHost              *SourceEbayFulfillmentUpdateAPIHost              `default:"https://api.ebay.com" json:"api_host"`
	Password             string                                           `json:"password"`
	RedirectURI          string                                           `json:"redirect_uri"`
	RefreshToken         string                                           `json:"refresh_token"`
	RefreshTokenEndpoint *SourceEbayFulfillmentUpdateRefreshTokenEndpoint `default:"https://api.ebay.com/identity/v1/oauth2/token" json:"refresh_token_endpoint"`
	StartDate            time.Time                                        `json:"start_date"`
	Username             string                                           `json:"username"`
}

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

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

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

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

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

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

func (o *SourceEbayFulfillmentUpdate) GetRefreshTokenEndpoint() *SourceEbayFulfillmentUpdateRefreshTokenEndpoint {
	if o == nil {
		return nil
	}
	return o.RefreshTokenEndpoint
}

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

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