=begin #Klaviyo API #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. The version of the OpenAPI document: 2023-02-22 Contact: developers@klaviyo.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end # Common files require 'klaviyo-api-sdk/api_client' require 'klaviyo-api-sdk/api_error' require 'klaviyo-api-sdk/version' require 'klaviyo-api-sdk/configuration' # Models require 'klaviyo-api-sdk/models/audiences_sub_object' require 'klaviyo-api-sdk/models/campaign_clone_query' require 'klaviyo-api-sdk/models/campaign_clone_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_clone_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_create_query' require 'klaviyo-api-sdk/models/campaign_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_message_assign_template_query' require 'klaviyo-api-sdk/models/campaign_message_assign_template_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_message_assign_template_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_message_partial_update_query' require 'klaviyo-api-sdk/models/campaign_message_partial_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_message_partial_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_partial_update_query' require 'klaviyo-api-sdk/models/campaign_partial_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_partial_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_recipient_estimation_job_create_query' require 'klaviyo-api-sdk/models/campaign_recipient_estimation_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_recipient_estimation_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_send_job_create_query' require 'klaviyo-api-sdk/models/campaign_send_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_send_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/campaign_send_job_partial_update_query' require 'klaviyo-api-sdk/models/campaign_send_job_partial_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/campaign_send_job_partial_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_category_create_job_create_query' require 'klaviyo-api-sdk/models/catalog_category_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_category_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_category_create_query' require 'klaviyo-api-sdk/models/catalog_category_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_category_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_category_delete_job_create_query' require 'klaviyo-api-sdk/models/catalog_category_delete_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_category_delete_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_category_delete_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_category_item_op' require 'klaviyo-api-sdk/models/catalog_category_update_job_create_query' require 'klaviyo-api-sdk/models/catalog_category_update_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_category_update_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_category_update_query' require 'klaviyo-api-sdk/models/catalog_category_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_category_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_item_category_op' require 'klaviyo-api-sdk/models/catalog_item_create_job_create_query' require 'klaviyo-api-sdk/models/catalog_item_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_item_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_item_create_query' require 'klaviyo-api-sdk/models/catalog_item_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_item_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_item_create_query_as_sub_resource_relationships' require 'klaviyo-api-sdk/models/catalog_item_create_query_as_sub_resource_relationships_categories' require 'klaviyo-api-sdk/models/catalog_item_create_query_as_sub_resource_relationships_categories_data_inner' require 'klaviyo-api-sdk/models/catalog_item_delete_job_create_query' require 'klaviyo-api-sdk/models/catalog_item_delete_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_item_delete_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_item_delete_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_item_update_job_create_query' require 'klaviyo-api-sdk/models/catalog_item_update_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_item_update_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_item_update_query' require 'klaviyo-api-sdk/models/catalog_item_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_item_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_job_error_payload' require 'klaviyo-api-sdk/models/catalog_variant_create_job_create_query' require 'klaviyo-api-sdk/models/catalog_variant_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_variant_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_variant_create_query' require 'klaviyo-api-sdk/models/catalog_variant_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_variant_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_variant_create_query_as_sub_resource_relationships' require 'klaviyo-api-sdk/models/catalog_variant_create_query_as_sub_resource_relationships_items' require 'klaviyo-api-sdk/models/catalog_variant_create_query_as_sub_resource_relationships_items_data_inner' require 'klaviyo-api-sdk/models/catalog_variant_delete_job_create_query' require 'klaviyo-api-sdk/models/catalog_variant_delete_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_variant_delete_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_variant_delete_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_variant_update_job_create_query' require 'klaviyo-api-sdk/models/catalog_variant_update_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_variant_update_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/catalog_variant_update_query' require 'klaviyo-api-sdk/models/catalog_variant_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/catalog_variant_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/content_sub_object' require 'klaviyo-api-sdk/models/data_privacy_create_deletion_job_query' require 'klaviyo-api-sdk/models/data_privacy_create_deletion_job_query_as_sub_resource' require 'klaviyo-api-sdk/models/data_privacy_create_deletion_job_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/email_message_content' require 'klaviyo-api-sdk/models/email_tracking_options' require 'klaviyo-api-sdk/models/error_source' require 'klaviyo-api-sdk/models/event_create_query' require 'klaviyo-api-sdk/models/event_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/event_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/flow_update_query' require 'klaviyo-api-sdk/models/flow_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/flow_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/get_campaigns4_xx_response' require 'klaviyo-api-sdk/models/get_campaigns4_xx_response_errors_inner' require 'klaviyo-api-sdk/models/get_campaigns4_xx_response_errors_inner_source' require 'klaviyo-api-sdk/models/included_categories' require 'klaviyo-api-sdk/models/included_categories_attributes' require 'klaviyo-api-sdk/models/included_flow_action' require 'klaviyo-api-sdk/models/included_flow_actions' require 'klaviyo-api-sdk/models/included_flow_actions_attributes' require 'klaviyo-api-sdk/models/included_flow_actions_attributes_tracking_options' require 'klaviyo-api-sdk/models/included_flow_messages' require 'klaviyo-api-sdk/models/included_flow_messages_attributes' require 'klaviyo-api-sdk/models/included_flow_messages_attributes_content' require 'klaviyo-api-sdk/models/included_flows' require 'klaviyo-api-sdk/models/included_flows_attributes' require 'klaviyo-api-sdk/models/included_items' require 'klaviyo-api-sdk/models/included_items_attributes' require 'klaviyo-api-sdk/models/included_lists' require 'klaviyo-api-sdk/models/included_lists_attributes' require 'klaviyo-api-sdk/models/included_metrics' require 'klaviyo-api-sdk/models/included_metrics_attributes' require 'klaviyo-api-sdk/models/included_profiles' require 'klaviyo-api-sdk/models/included_profiles_attributes' require 'klaviyo-api-sdk/models/included_segments' require 'klaviyo-api-sdk/models/included_segments_attributes' require 'klaviyo-api-sdk/models/included_tags' require 'klaviyo-api-sdk/models/included_variants' require 'klaviyo-api-sdk/models/included_variants_attributes' require 'klaviyo-api-sdk/models/included_variants_links' require 'klaviyo-api-sdk/models/list_create_query' require 'klaviyo-api-sdk/models/list_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/list_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/list_members_add_query' require 'klaviyo-api-sdk/models/list_members_add_query_data_inner' require 'klaviyo-api-sdk/models/list_members_delete_query' require 'klaviyo-api-sdk/models/list_partial_update_query' require 'klaviyo-api-sdk/models/list_partial_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/metric_aggregate_query' require 'klaviyo-api-sdk/models/metric_aggregate_query_as_sub_resource' require 'klaviyo-api-sdk/models/metric_aggregate_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/metric_aggregate_row_dto' require 'klaviyo-api-sdk/models/metric_create_query' require 'klaviyo-api-sdk/models/onsite_profile_create_query' require 'klaviyo-api-sdk/models/onsite_profile_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/onsite_profile_meta' require 'klaviyo-api-sdk/models/onsite_profile_meta_identifiers' require 'klaviyo-api-sdk/models/onsite_subscription_create_query' require 'klaviyo-api-sdk/models/onsite_subscription_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/onsite_subscription_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/profile_create_query' require 'klaviyo-api-sdk/models/profile_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/profile_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/profile_location' require 'klaviyo-api-sdk/models/profile_location_latitude' require 'klaviyo-api-sdk/models/profile_location_longitude' require 'klaviyo-api-sdk/models/profile_partial_update_query' require 'klaviyo-api-sdk/models/profile_partial_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/sms_message_content' require 'klaviyo-api-sdk/models/sms_render_options' require 'klaviyo-api-sdk/models/sms_tracking_options' require 'klaviyo-api-sdk/models/sto_schedule_options' require 'klaviyo-api-sdk/models/segment_partial_update_query' require 'klaviyo-api-sdk/models/segment_partial_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/segment_partial_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/send_options' require 'klaviyo-api-sdk/models/send_options_sub_object' require 'klaviyo-api-sdk/models/send_strategy_sub_object' require 'klaviyo-api-sdk/models/send_time_sub_object' require 'klaviyo-api-sdk/models/static_schedule_options' require 'klaviyo-api-sdk/models/subscription' require 'klaviyo-api-sdk/models/subscription_channels' require 'klaviyo-api-sdk/models/subscription_create_job_create_query' require 'klaviyo-api-sdk/models/subscription_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/subscription_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/suppression' require 'klaviyo-api-sdk/models/suppression_create_job_create_query' require 'klaviyo-api-sdk/models/suppression_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/suppression_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/tag_create_query' require 'klaviyo-api-sdk/models/tag_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/tag_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/tag_group_create_query' require 'klaviyo-api-sdk/models/tag_group_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/tag_group_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/tag_group_update_query' require 'klaviyo-api-sdk/models/tag_group_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/tag_group_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/tag_segment_op' require 'klaviyo-api-sdk/models/tag_segment_op_data_inner' require 'klaviyo-api-sdk/models/tag_update_query' require 'klaviyo-api-sdk/models/tag_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/tag_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/template_clone_query' require 'klaviyo-api-sdk/models/template_clone_query_as_sub_resource' require 'klaviyo-api-sdk/models/template_clone_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/template_create_query' require 'klaviyo-api-sdk/models/template_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/template_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/template_render_query' require 'klaviyo-api-sdk/models/template_render_query_as_sub_resource' require 'klaviyo-api-sdk/models/template_render_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/template_update_query' require 'klaviyo-api-sdk/models/template_update_query_as_sub_resource' require 'klaviyo-api-sdk/models/template_update_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/throttled_schedule_options' require 'klaviyo-api-sdk/models/tracking_options_sub_object' require 'klaviyo-api-sdk/models/utm_params_sub_object' require 'klaviyo-api-sdk/models/unsubscription_create_job_create_query' require 'klaviyo-api-sdk/models/unsubscription_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/unsubscription_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/unsuppression_create_job_create_query' require 'klaviyo-api-sdk/models/unsuppression_create_job_create_query_as_sub_resource' require 'klaviyo-api-sdk/models/unsuppression_create_job_create_query_as_sub_resource_attributes' require 'klaviyo-api-sdk/models/utm_param_info' # APIs require 'klaviyo-api-sdk/api/campaigns_api' require 'klaviyo-api-sdk/api/catalogs_api' require 'klaviyo-api-sdk/api/client_api' require 'klaviyo-api-sdk/api/data_privacy_api' require 'klaviyo-api-sdk/api/events_api' require 'klaviyo-api-sdk/api/flows_api' require 'klaviyo-api-sdk/api/lists_api' require 'klaviyo-api-sdk/api/metrics_api' require 'klaviyo-api-sdk/api/profiles_api' require 'klaviyo-api-sdk/api/segments_api' require 'klaviyo-api-sdk/api/tags_api' require 'klaviyo-api-sdk/api/templates_api' # retry logic require 'retriable' module KlaviyoAPI @is_initialized = false class << self # Customize default settings for the SDK using block. # KlaviyoAPI.configure do |config| # config.username = "xxx" # config.password = "xxx" # end # If no block given, return the default Configuration object. # add retriable config # todo: check how slow this is Configuration.default.class.module_eval { attr_accessor :max_retries, :max_delay } def configure if block_given? yield(Configuration.default) else Configuration.default end # create wrapper classes if !@is_initialized # run this only once self.constants.each do |c| if c[-3..-1] == "Api" attributes = [:attr1] wrapper_class = KlaviyoAPI.const_set(c[0..-4], Struct.new(*attributes)) original_class = KlaviyoAPI.const_get(c) # recreate methods original_class.public_instance_methods(false).each do |m| wrapper_class.class_eval { define_singleton_method m do |*arg| # max_delay=60, max_retries=3 # retry_codes = [429,503,504] # only add retriable if both of these are not set max_retries = Configuration.default.max_retries max_delay = Configuration.default.max_delay if (max_retries != nil && max_delay != nil) Retriable.configure do |c| c.tries = max_retries c.max_elapsed_time = max_delay c.on = { KlaviyoAPI::ApiError => [/429/, /503/, /504/] } end Retriable.retriable do KlaviyoAPI.const_get(c).new.send(m, *arg) end else KlaviyoAPI.const_get(c).new.send(m, *arg) end end } end end end @is_initialized = true end end end end