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

// SourceKlarnaUpdateRegion - Base url region (For playground eu https://docs.klarna.com/klarna-payments/api/payments-api/#tag/API-URLs). Supported 'eu', 'na', 'oc'
type SourceKlarnaUpdateRegion string

const (
	SourceKlarnaUpdateRegionEu SourceKlarnaUpdateRegion = "eu"
	SourceKlarnaUpdateRegionNa SourceKlarnaUpdateRegion = "na"
	SourceKlarnaUpdateRegionOc SourceKlarnaUpdateRegion = "oc"
)

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

type SourceKlarnaUpdate struct {
	// A string which is associated with your Merchant ID and is used to authorize use of Klarna's APIs (https://developers.klarna.com/api/#authentication)
	Password string `json:"password"`
	// Propertie defining if connector is used against playground or production environment
	Playground *bool `default:"false" json:"playground"`
	// Base url region (For playground eu https://docs.klarna.com/klarna-payments/api/payments-api/#tag/API-URLs). Supported 'eu', 'na', 'oc'
	Region SourceKlarnaUpdateRegion `json:"region"`
	// Consists of your Merchant ID (eid) - a unique number that identifies your e-store, combined with a random string (https://developers.klarna.com/api/#authentication)
	Username string `json:"username"`
}

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

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

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

func (o *SourceKlarnaUpdate) GetPlayground() *bool {
	if o == nil {
		return nil
	}
	return o.Playground
}

func (o *SourceKlarnaUpdate) GetRegion() SourceKlarnaUpdateRegion {
	if o == nil {
		return SourceKlarnaUpdateRegion("")
	}
	return o.Region
}

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