// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
)

type SourceRdStationMarketingUpdateAuthType string

const (
	SourceRdStationMarketingUpdateAuthTypeClient SourceRdStationMarketingUpdateAuthType = "Client"
)

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

type SourceRDStationMarketingUpdateSignInViaRDStationOAuth struct {
	authType SourceRdStationMarketingUpdateAuthType `const:"Client" json:"auth_type"`
	// The Client ID of your RD Station developer application.
	ClientID *string `json:"client_id,omitempty"`
	// The Client Secret of your RD Station developer application
	ClientSecret *string `json:"client_secret,omitempty"`
	// The token for obtaining the new access token.
	RefreshToken *string `json:"refresh_token,omitempty"`
}

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

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

func (o *SourceRDStationMarketingUpdateSignInViaRDStationOAuth) GetAuthType() SourceRdStationMarketingUpdateAuthType {
	return SourceRdStationMarketingUpdateAuthTypeClient
}

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

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

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

type SourceRdStationMarketingUpdateAuthenticationTypeType string

const (
	SourceRdStationMarketingUpdateAuthenticationTypeTypeSourceRDStationMarketingUpdateSignInViaRDStationOAuth SourceRdStationMarketingUpdateAuthenticationTypeType = "source-rd-station-marketing-update_Sign in via RD Station (OAuth)"
)

// SourceRdStationMarketingUpdateAuthenticationType - Choose one of the possible authorization method
type SourceRdStationMarketingUpdateAuthenticationType struct {
	SourceRDStationMarketingUpdateSignInViaRDStationOAuth *SourceRDStationMarketingUpdateSignInViaRDStationOAuth `queryParam:"inline"`

	Type SourceRdStationMarketingUpdateAuthenticationTypeType
}

func CreateSourceRdStationMarketingUpdateAuthenticationTypeSourceRDStationMarketingUpdateSignInViaRDStationOAuth(sourceRDStationMarketingUpdateSignInViaRDStationOAuth SourceRDStationMarketingUpdateSignInViaRDStationOAuth) SourceRdStationMarketingUpdateAuthenticationType {
	typ := SourceRdStationMarketingUpdateAuthenticationTypeTypeSourceRDStationMarketingUpdateSignInViaRDStationOAuth

	return SourceRdStationMarketingUpdateAuthenticationType{
		SourceRDStationMarketingUpdateSignInViaRDStationOAuth: &sourceRDStationMarketingUpdateSignInViaRDStationOAuth,
		Type: typ,
	}
}

func (u *SourceRdStationMarketingUpdateAuthenticationType) UnmarshalJSON(data []byte) error {

	var sourceRDStationMarketingUpdateSignInViaRDStationOAuth SourceRDStationMarketingUpdateSignInViaRDStationOAuth = SourceRDStationMarketingUpdateSignInViaRDStationOAuth{}
	if err := utils.UnmarshalJSON(data, &sourceRDStationMarketingUpdateSignInViaRDStationOAuth, "", true, true); err == nil {
		u.SourceRDStationMarketingUpdateSignInViaRDStationOAuth = &sourceRDStationMarketingUpdateSignInViaRDStationOAuth
		u.Type = SourceRdStationMarketingUpdateAuthenticationTypeTypeSourceRDStationMarketingUpdateSignInViaRDStationOAuth
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for SourceRdStationMarketingUpdateAuthenticationType", string(data))
}

func (u SourceRdStationMarketingUpdateAuthenticationType) MarshalJSON() ([]byte, error) {
	if u.SourceRDStationMarketingUpdateSignInViaRDStationOAuth != nil {
		return utils.MarshalJSON(u.SourceRDStationMarketingUpdateSignInViaRDStationOAuth, "", true)
	}

	return nil, errors.New("could not marshal union type SourceRdStationMarketingUpdateAuthenticationType: all fields are null")
}

type SourceRdStationMarketingUpdate struct {
	// Choose one of the possible authorization method
	Authorization *SourceRdStationMarketingUpdateAuthenticationType `json:"authorization,omitempty"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Any data before this date will not be replicated. When specified and not None, then stream will behave as incremental
	StartDate string `json:"start_date"`
}

func (o *SourceRdStationMarketingUpdate) GetAuthorization() *SourceRdStationMarketingUpdateAuthenticationType {
	if o == nil {
		return nil
	}
	return o.Authorization
}

func (o *SourceRdStationMarketingUpdate) GetStartDate() string {
	if o == nil {
		return ""
	}
	return o.StartDate
}
