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

type Poplar string

const (
	PoplarPoplar Poplar = "poplar"
)

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

type SourcePoplar struct {
	// Your Poplar API Access Token. Generate it from the [API Credentials page](https://app.heypoplar.com/credentials) in your account. Use a production token for live data or a test token for testing purposes.
	AccessToken string    `json:"access_token"`
	StartDate   time.Time `json:"start_date"`
	sourceType  Poplar    `const:"poplar" json:"sourceType"`
}

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

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

func (o *SourcePoplar) GetAccessToken() string {
	if o == nil {
		return ""
	}
	return o.AccessToken
}

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

func (o *SourcePoplar) GetSourceType() Poplar {
	return PoplarPoplar
}
