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

// SourceRevolutMerchantEnvironment - The base url of your environment. Either sandbox or production
type SourceRevolutMerchantEnvironment string

const (
	SourceRevolutMerchantEnvironmentSandboxMerchant SourceRevolutMerchantEnvironment = "sandbox-merchant"
	SourceRevolutMerchantEnvironmentMerchant        SourceRevolutMerchantEnvironment = "merchant"
)

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

type RevolutMerchant string

const (
	RevolutMerchantRevolutMerchant RevolutMerchant = "revolut-merchant"
)

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

type SourceRevolutMerchant struct {
	// Specify the API version to use. This is required for certain API calls. Example: '2024-09-01'.
	APIVersion string `json:"api_version"`
	// The base url of your environment. Either sandbox or production
	Environment SourceRevolutMerchantEnvironment `json:"environment"`
	// Secret API key to use for authenticating with the Revolut Merchant API. Find it in your Revolut Business account under APIs > Merchant API.
	SecretAPIKey string          `json:"secret_api_key"`
	StartDate    time.Time       `json:"start_date"`
	sourceType   RevolutMerchant `const:"revolut-merchant" json:"sourceType"`
}

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

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

func (o *SourceRevolutMerchant) GetAPIVersion() string {
	if o == nil {
		return ""
	}
	return o.APIVersion
}

func (o *SourceRevolutMerchant) GetEnvironment() SourceRevolutMerchantEnvironment {
	if o == nil {
		return SourceRevolutMerchantEnvironment("")
	}
	return o.Environment
}

func (o *SourceRevolutMerchant) GetSecretAPIKey() string {
	if o == nil {
		return ""
	}
	return o.SecretAPIKey
}

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

func (o *SourceRevolutMerchant) GetSourceType() RevolutMerchant {
	return RevolutMerchantRevolutMerchant
}
