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

// AWSSellerPartnerAccountType - Type of the Account you're going to authorize the Airbyte application by
type AWSSellerPartnerAccountType string

const (
	AWSSellerPartnerAccountTypeSeller AWSSellerPartnerAccountType = "Seller"
	AWSSellerPartnerAccountTypeVendor AWSSellerPartnerAccountType = "Vendor"
)

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

type SourceAmazonSellerPartnerAuthType string

const (
	SourceAmazonSellerPartnerAuthTypeOauth20 SourceAmazonSellerPartnerAuthType = "oauth2.0"
)

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

// AWSEnvironment - Select the AWS Environment.
type AWSEnvironment string

const (
	AWSEnvironmentProduction AWSEnvironment = "PRODUCTION"
	AWSEnvironmentSandbox    AWSEnvironment = "SANDBOX"
)

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

// FinancialEventsStepSizeInDays - The time window size (in days) for fetching financial events data in chunks. Options are 1 day, 7 days, 14 days, 30 days, 60 days, and 190 days, based on API limitations.
//
// - **Smaller step sizes (e.g., 1 day)** are better for large data volumes. They fetch smaller chunks per request, reducing the risk of timeouts or overwhelming the API, though more requests may slow syncing and increase the chance of hitting rate limits.
// - **Larger step sizes (e.g., 14 days)** are better for smaller data volumes. They fetch more data per request, speeding up syncing and reducing the number of API calls, which minimizes strain on rate limits.
//
// Select a step size that matches your data volume to optimize syncing speed and API performance.
type FinancialEventsStepSizeInDays string

const (
	FinancialEventsStepSizeInDaysOne                 FinancialEventsStepSizeInDays = "1"
	FinancialEventsStepSizeInDaysSeven               FinancialEventsStepSizeInDays = "7"
	FinancialEventsStepSizeInDaysFourteen            FinancialEventsStepSizeInDays = "14"
	FinancialEventsStepSizeInDaysThirty              FinancialEventsStepSizeInDays = "30"
	FinancialEventsStepSizeInDaysSixty               FinancialEventsStepSizeInDays = "60"
	FinancialEventsStepSizeInDaysNinety              FinancialEventsStepSizeInDays = "90"
	FinancialEventsStepSizeInDaysOneHundredAndEighty FinancialEventsStepSizeInDays = "180"
)

func (e FinancialEventsStepSizeInDays) ToPointer() *FinancialEventsStepSizeInDays {
	return &e
}
func (e *FinancialEventsStepSizeInDays) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "1":
		fallthrough
	case "7":
		fallthrough
	case "14":
		fallthrough
	case "30":
		fallthrough
	case "60":
		fallthrough
	case "90":
		fallthrough
	case "180":
		*e = FinancialEventsStepSizeInDays(v)
		return nil
	default:
		return fmt.Errorf("invalid value for FinancialEventsStepSizeInDays: %v", v)
	}
}

// AWSRegion - Select the AWS Region.
type AWSRegion string

const (
	AWSRegionAe AWSRegion = "AE"
	AWSRegionAu AWSRegion = "AU"
	AWSRegionBe AWSRegion = "BE"
	AWSRegionBr AWSRegion = "BR"
	AWSRegionCa AWSRegion = "CA"
	AWSRegionDe AWSRegion = "DE"
	AWSRegionEg AWSRegion = "EG"
	AWSRegionEs AWSRegion = "ES"
	AWSRegionFr AWSRegion = "FR"
	AWSRegionGb AWSRegion = "GB"
	AWSRegionIn AWSRegion = "IN"
	AWSRegionIt AWSRegion = "IT"
	AWSRegionJp AWSRegion = "JP"
	AWSRegionMx AWSRegion = "MX"
	AWSRegionNl AWSRegion = "NL"
	AWSRegionPl AWSRegion = "PL"
	AWSRegionSa AWSRegion = "SA"
	AWSRegionSe AWSRegion = "SE"
	AWSRegionSg AWSRegion = "SG"
	AWSRegionTr AWSRegion = "TR"
	AWSRegionUk AWSRegion = "UK"
	AWSRegionUs AWSRegion = "US"
)

func (e AWSRegion) ToPointer() *AWSRegion {
	return &e
}
func (e *AWSRegion) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "AE":
		fallthrough
	case "AU":
		fallthrough
	case "BE":
		fallthrough
	case "BR":
		fallthrough
	case "CA":
		fallthrough
	case "DE":
		fallthrough
	case "EG":
		fallthrough
	case "ES":
		fallthrough
	case "FR":
		fallthrough
	case "GB":
		fallthrough
	case "IN":
		fallthrough
	case "IT":
		fallthrough
	case "JP":
		fallthrough
	case "MX":
		fallthrough
	case "NL":
		fallthrough
	case "PL":
		fallthrough
	case "SA":
		fallthrough
	case "SE":
		fallthrough
	case "SG":
		fallthrough
	case "TR":
		fallthrough
	case "UK":
		fallthrough
	case "US":
		*e = AWSRegion(v)
		return nil
	default:
		return fmt.Errorf("invalid value for AWSRegion: %v", v)
	}
}

type OptionsList struct {
	OptionName  string `json:"option_name"`
	OptionValue string `json:"option_value"`
}

func (o *OptionsList) GetOptionName() string {
	if o == nil {
		return ""
	}
	return o.OptionName
}

func (o *OptionsList) GetOptionValue() string {
	if o == nil {
		return ""
	}
	return o.OptionValue
}

type ReportName string

const (
	ReportNameGetAfnInventoryData                              ReportName = "GET_AFN_INVENTORY_DATA"
	ReportNameGetAfnInventoryDataByCountry                     ReportName = "GET_AFN_INVENTORY_DATA_BY_COUNTRY"
	ReportNameGetAmazonFulfilledShipmentsDataGeneral           ReportName = "GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL"
	ReportNameGetFbaEstimatedFbaFeesTxtData                    ReportName = "GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA"
	ReportNameGetFbaFulfillmentCustomerReturnsData             ReportName = "GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA"
	ReportNameGetFbaFulfillmentCustomerShipmentPromotionData   ReportName = "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA"
	ReportNameGetFbaFulfillmentCustomerShipmentReplacementData ReportName = "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA"
	ReportNameGetFbaFulfillmentRemovalOrderDetailData          ReportName = "GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA"
	ReportNameGetFbaFulfillmentRemovalShipmentDetailData       ReportName = "GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA"
	ReportNameGetFbaInventoryPlanningData                      ReportName = "GET_FBA_INVENTORY_PLANNING_DATA"
	ReportNameGetFbaMyiUnsuppressedInventoryData               ReportName = "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA"
	ReportNameGetFbaReimbursementsData                         ReportName = "GET_FBA_REIMBURSEMENTS_DATA"
	ReportNameGetFbaSnsForecastData                            ReportName = "GET_FBA_SNS_FORECAST_DATA"
	ReportNameGetFbaSnsPerformanceData                         ReportName = "GET_FBA_SNS_PERFORMANCE_DATA"
	ReportNameGetFbaStorageFeeChargesData                      ReportName = "GET_FBA_STORAGE_FEE_CHARGES_DATA"
	ReportNameGetFlatFileActionableOrderDataShipping           ReportName = "GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING"
	ReportNameGetFlatFileAllOrdersDataByLastUpdateGeneral      ReportName = "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL"
	ReportNameGetFlatFileAllOrdersDataByOrderDateGeneral       ReportName = "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL"
	ReportNameGetFlatFileArchivedOrdersDataByOrderDate         ReportName = "GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE"
	ReportNameGetFlatFileOpenListingsData                      ReportName = "GET_FLAT_FILE_OPEN_LISTINGS_DATA"
	ReportNameGetFlatFileReturnsDataByReturnDate               ReportName = "GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE"
	ReportNameGetLedgerDetailViewData                          ReportName = "GET_LEDGER_DETAIL_VIEW_DATA"
	ReportNameGetLedgerSummaryViewData                         ReportName = "GET_LEDGER_SUMMARY_VIEW_DATA"
	ReportNameGetMerchantCancelledListingsData                 ReportName = "GET_MERCHANT_CANCELLED_LISTINGS_DATA"
	ReportNameGetMerchantListingsAllData                       ReportName = "GET_MERCHANT_LISTINGS_ALL_DATA"
	ReportNameGetMerchantListingsData                          ReportName = "GET_MERCHANT_LISTINGS_DATA"
	ReportNameGetMerchantListingsDataBackCompat                ReportName = "GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT"
	ReportNameGetMerchantListingsInactiveData                  ReportName = "GET_MERCHANT_LISTINGS_INACTIVE_DATA"
	ReportNameGetMerchantsListingsFypReport                    ReportName = "GET_MERCHANTS_LISTINGS_FYP_REPORT"
	ReportNameGetOrderReportDataShipping                       ReportName = "GET_ORDER_REPORT_DATA_SHIPPING"
	ReportNameGetRestockInventoryRecommendationsReport         ReportName = "GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT"
	ReportNameGetSellerFeedbackData                            ReportName = "GET_SELLER_FEEDBACK_DATA"
	ReportNameGetStrandedInventoryUIData                       ReportName = "GET_STRANDED_INVENTORY_UI_DATA"
	ReportNameGetV2SettlementReportDataFlatFile                ReportName = "GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE"
	ReportNameGetXMLAllOrdersDataByOrderDateGeneral            ReportName = "GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL"
	ReportNameGetXMLBrowseTreeData                             ReportName = "GET_XML_BROWSE_TREE_DATA"
	ReportNameGetVendorRealTimeInventoryReport                 ReportName = "GET_VENDOR_REAL_TIME_INVENTORY_REPORT"
)

func (e ReportName) ToPointer() *ReportName {
	return &e
}
func (e *ReportName) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "GET_AFN_INVENTORY_DATA":
		fallthrough
	case "GET_AFN_INVENTORY_DATA_BY_COUNTRY":
		fallthrough
	case "GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL":
		fallthrough
	case "GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA":
		fallthrough
	case "GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA":
		fallthrough
	case "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA":
		fallthrough
	case "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA":
		fallthrough
	case "GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA":
		fallthrough
	case "GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA":
		fallthrough
	case "GET_FBA_INVENTORY_PLANNING_DATA":
		fallthrough
	case "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA":
		fallthrough
	case "GET_FBA_REIMBURSEMENTS_DATA":
		fallthrough
	case "GET_FBA_SNS_FORECAST_DATA":
		fallthrough
	case "GET_FBA_SNS_PERFORMANCE_DATA":
		fallthrough
	case "GET_FBA_STORAGE_FEE_CHARGES_DATA":
		fallthrough
	case "GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING":
		fallthrough
	case "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL":
		fallthrough
	case "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL":
		fallthrough
	case "GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE":
		fallthrough
	case "GET_FLAT_FILE_OPEN_LISTINGS_DATA":
		fallthrough
	case "GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE":
		fallthrough
	case "GET_LEDGER_DETAIL_VIEW_DATA":
		fallthrough
	case "GET_LEDGER_SUMMARY_VIEW_DATA":
		fallthrough
	case "GET_MERCHANT_CANCELLED_LISTINGS_DATA":
		fallthrough
	case "GET_MERCHANT_LISTINGS_ALL_DATA":
		fallthrough
	case "GET_MERCHANT_LISTINGS_DATA":
		fallthrough
	case "GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT":
		fallthrough
	case "GET_MERCHANT_LISTINGS_INACTIVE_DATA":
		fallthrough
	case "GET_MERCHANTS_LISTINGS_FYP_REPORT":
		fallthrough
	case "GET_ORDER_REPORT_DATA_SHIPPING":
		fallthrough
	case "GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT":
		fallthrough
	case "GET_SELLER_FEEDBACK_DATA":
		fallthrough
	case "GET_STRANDED_INVENTORY_UI_DATA":
		fallthrough
	case "GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE":
		fallthrough
	case "GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL":
		fallthrough
	case "GET_XML_BROWSE_TREE_DATA":
		fallthrough
	case "GET_VENDOR_REAL_TIME_INVENTORY_REPORT":
		*e = ReportName(v)
		return nil
	default:
		return fmt.Errorf("invalid value for ReportName: %v", v)
	}
}

type ReportOptions struct {
	// List of options
	OptionsList []OptionsList `json:"options_list"`
	ReportName  ReportName    `json:"report_name"`
	StreamName  string        `json:"stream_name"`
}

func (o *ReportOptions) GetOptionsList() []OptionsList {
	if o == nil {
		return []OptionsList{}
	}
	return o.OptionsList
}

func (o *ReportOptions) GetReportName() ReportName {
	if o == nil {
		return ReportName("")
	}
	return o.ReportName
}

func (o *ReportOptions) GetStreamName() string {
	if o == nil {
		return ""
	}
	return o.StreamName
}

type AmazonSellerPartner string

const (
	AmazonSellerPartnerAmazonSellerPartner AmazonSellerPartner = "amazon-seller-partner"
)

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

type SourceAmazonSellerPartner struct {
	// Type of the Account you're going to authorize the Airbyte application by
	AccountType *AWSSellerPartnerAccountType `default:"Seller" json:"account_type"`
	// Your Amazon Application ID.
	AppID    *string                            `json:"app_id,omitempty"`
	authType *SourceAmazonSellerPartnerAuthType `const:"oauth2.0" json:"auth_type,omitempty"`
	// Select the AWS Environment.
	AwsEnvironment *AWSEnvironment `default:"PRODUCTION" json:"aws_environment"`
	// The time window size (in days) for fetching financial events data in chunks. Options are 1 day, 7 days, 14 days, 30 days, 60 days, and 190 days, based on API limitations.
	//
	// - **Smaller step sizes (e.g., 1 day)** are better for large data volumes. They fetch smaller chunks per request, reducing the risk of timeouts or overwhelming the API, though more requests may slow syncing and increase the chance of hitting rate limits.
	// - **Larger step sizes (e.g., 14 days)** are better for smaller data volumes. They fetch more data per request, speeding up syncing and reducing the number of API calls, which minimizes strain on rate limits.
	//
	// Select a step size that matches your data volume to optimize syncing speed and API performance.
	FinancialEventsStep *FinancialEventsStepSizeInDays `default:"180" json:"financial_events_step"`
	// Your Login with Amazon Client ID.
	LwaAppID string `json:"lwa_app_id"`
	// Your Login with Amazon Client Secret.
	LwaClientSecret string `json:"lwa_client_secret"`
	// For syncs spanning a large date range, this option is used to request data in a smaller fixed window to improve sync reliability. This time window can be configured granularly by day.
	PeriodInDays *int64 `default:"90" json:"period_in_days"`
	// The Refresh Token obtained via OAuth flow authorization.
	RefreshToken string `json:"refresh_token"`
	// Select the AWS Region.
	Region *AWSRegion `default:"US" json:"region"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Any data after this date will not be replicated.
	ReplicationEndDate *time.Time `json:"replication_end_date,omitempty"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Any data before this date will not be replicated. If start date is not provided or older than 2 years ago from today, the date 2 years ago from today will be used.
	ReplicationStartDate *time.Time `json:"replication_start_date,omitempty"`
	// Additional information passed to reports. This varies by report type.
	ReportOptionsList []ReportOptions `json:"report_options_list,omitempty"`
	// For report based streams with known amount of requests per time period, this option will use waiting time between requests to avoid fatal statuses in reports. See <a href="https://docs.airbyte.com/integrations/sources/amazon-seller-partner#limitations--troubleshooting" target="_blank">Troubleshooting</a> section for more details
	WaitToAvoidFatalErrors *bool               `default:"false" json:"wait_to_avoid_fatal_errors"`
	sourceType             AmazonSellerPartner `const:"amazon-seller-partner" json:"sourceType"`
}

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

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

func (o *SourceAmazonSellerPartner) GetAccountType() *AWSSellerPartnerAccountType {
	if o == nil {
		return nil
	}
	return o.AccountType
}

func (o *SourceAmazonSellerPartner) GetAppID() *string {
	if o == nil {
		return nil
	}
	return o.AppID
}

func (o *SourceAmazonSellerPartner) GetAuthType() *SourceAmazonSellerPartnerAuthType {
	return SourceAmazonSellerPartnerAuthTypeOauth20.ToPointer()
}

func (o *SourceAmazonSellerPartner) GetAwsEnvironment() *AWSEnvironment {
	if o == nil {
		return nil
	}
	return o.AwsEnvironment
}

func (o *SourceAmazonSellerPartner) GetFinancialEventsStep() *FinancialEventsStepSizeInDays {
	if o == nil {
		return nil
	}
	return o.FinancialEventsStep
}

func (o *SourceAmazonSellerPartner) GetLwaAppID() string {
	if o == nil {
		return ""
	}
	return o.LwaAppID
}

func (o *SourceAmazonSellerPartner) GetLwaClientSecret() string {
	if o == nil {
		return ""
	}
	return o.LwaClientSecret
}

func (o *SourceAmazonSellerPartner) GetPeriodInDays() *int64 {
	if o == nil {
		return nil
	}
	return o.PeriodInDays
}

func (o *SourceAmazonSellerPartner) GetRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.RefreshToken
}

func (o *SourceAmazonSellerPartner) GetRegion() *AWSRegion {
	if o == nil {
		return nil
	}
	return o.Region
}

func (o *SourceAmazonSellerPartner) GetReplicationEndDate() *time.Time {
	if o == nil {
		return nil
	}
	return o.ReplicationEndDate
}

func (o *SourceAmazonSellerPartner) GetReplicationStartDate() *time.Time {
	if o == nil {
		return nil
	}
	return o.ReplicationStartDate
}

func (o *SourceAmazonSellerPartner) GetReportOptionsList() []ReportOptions {
	if o == nil {
		return nil
	}
	return o.ReportOptionsList
}

func (o *SourceAmazonSellerPartner) GetWaitToAvoidFatalErrors() *bool {
	if o == nil {
		return nil
	}
	return o.WaitToAvoidFatalErrors
}

func (o *SourceAmazonSellerPartner) GetSourceType() AmazonSellerPartner {
	return AmazonSellerPartnerAmazonSellerPartner
}
