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

type Ip2whois string

const (
	Ip2whoisIp2whois Ip2whois = "ip2whois"
)

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

type SourceIp2whois struct {
	// Your API Key. See <a href="https://www.ip2whois.com/developers-api">here</a>.
	APIKey *string `json:"api_key,omitempty"`
	// Domain name. See <a href="https://www.ip2whois.com/developers-api">here</a>.
	Domain     *string  `json:"domain,omitempty"`
	sourceType Ip2whois `const:"ip2whois" json:"sourceType"`
}

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

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

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

func (o *SourceIp2whois) GetDomain() *string {
	if o == nil {
		return nil
	}
	return o.Domain
}

func (o *SourceIp2whois) GetSourceType() Ip2whois {
	return Ip2whoisIp2whois
}
