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

// Subdomain - The subdomain for the Nexio API environment, such as 'nexiopaysandbox' or 'nexiopay'.
type Subdomain string

const (
	SubdomainNexiopaysandbox Subdomain = "nexiopaysandbox"
	SubdomainNexiopay        Subdomain = "nexiopay"
)

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

type Nexiopay string

const (
	NexiopayNexiopay Nexiopay = "nexiopay"
)

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

type SourceNexiopay struct {
	// Your Nexio API key (password). You can find it in the Nexio Dashboard under Settings > User Management. Select the API user and copy the API key.
	APIKey    string    `json:"api_key"`
	StartDate time.Time `json:"start_date"`
	// The subdomain for the Nexio API environment, such as 'nexiopaysandbox' or 'nexiopay'.
	Subdomain *Subdomain `default:"nexiopay" json:"subdomain"`
	// Your Nexio API username. You can find it in the Nexio Dashboard under Settings > User Management. Select the API user and copy the username.
	Username   string   `json:"username"`
	sourceType Nexiopay `const:"nexiopay" json:"sourceType"`
}

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

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

func (o *SourceNexiopay) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

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

func (o *SourceNexiopay) GetSubdomain() *Subdomain {
	if o == nil {
		return nil
	}
	return o.Subdomain
}

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

func (o *SourceNexiopay) GetSourceType() Nexiopay {
	return NexiopayNexiopay
}
