=begin #Klaviyo API #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. The version of the OpenAPI document: 2023-10-15 Contact: developers@klaviyo.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module KlaviyoAPI class CampaignsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Campaign # Creates a campaign given a set of parameters, then returns it.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_create_query [CampaignCreateQuery] Creates a campaign from parameters # @param [Hash] opts the optional parameters # @return [Hash] def create_campaign(campaign_create_query, opts = {}) data, _status_code, _headers = create_campaign_with_http_info(campaign_create_query, opts) data end # Create Campaign # Creates a campaign given a set of parameters, then returns it.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_create_query [CampaignCreateQuery] Creates a campaign from parameters # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_campaign_with_http_info(campaign_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign ...' end # verify the required parameter 'campaign_create_query' is set if @api_client.config.client_side_validation && campaign_create_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_create_query' when calling CampaignsApi.create_campaign" end # resource path local_var_path = '/api/campaigns/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_create_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.create_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#create_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Campaign Clone # Clones an existing campaign, returning a new campaign based on the original with a new ID and name.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_clone_query [CampaignCloneQuery] Clones a campaign from an existing campaign # @param [Hash] opts the optional parameters # @return [Hash] def create_campaign_clone(campaign_clone_query, opts = {}) data, _status_code, _headers = create_campaign_clone_with_http_info(campaign_clone_query, opts) data end # Create Campaign Clone # Clones an existing campaign, returning a new campaign based on the original with a new ID and name.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_clone_query [CampaignCloneQuery] Clones a campaign from an existing campaign # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_campaign_clone_with_http_info(campaign_clone_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_clone ...' end # verify the required parameter 'campaign_clone_query' is set if @api_client.config.client_side_validation && campaign_clone_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_clone_query' when calling CampaignsApi.create_campaign_clone" end # resource path local_var_path = '/api/campaign-clone/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_clone_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.create_campaign_clone", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#create_campaign_clone\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Assign Campaign Message Template # Creates a non-reusable version of the template and assigns it to the message.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_message_assign_template_query [CampaignMessageAssignTemplateQuery] Takes a reusable template, clones it, and assigns the non-reusable clone to the message. # @param [Hash] opts the optional parameters # @return [Hash] def create_campaign_message_assign_template(campaign_message_assign_template_query, opts = {}) data, _status_code, _headers = create_campaign_message_assign_template_with_http_info(campaign_message_assign_template_query, opts) data end # Assign Campaign Message Template # Creates a non-reusable version of the template and assigns it to the message.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_message_assign_template_query [CampaignMessageAssignTemplateQuery] Takes a reusable template, clones it, and assigns the non-reusable clone to the message. # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_campaign_message_assign_template_with_http_info(campaign_message_assign_template_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_message_assign_template ...' end # verify the required parameter 'campaign_message_assign_template_query' is set if @api_client.config.client_side_validation && campaign_message_assign_template_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_message_assign_template_query' when calling CampaignsApi.create_campaign_message_assign_template" end # resource path local_var_path = '/api/campaign-message-assign-template/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_message_assign_template_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.create_campaign_message_assign_template", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#create_campaign_message_assign_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Campaign Recipient Estimation Job # Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_recipient_estimation_job_create_query [CampaignRecipientEstimationJobCreateQuery] Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign. # @param [Hash] opts the optional parameters # @return [Hash] def create_campaign_recipient_estimation_job(campaign_recipient_estimation_job_create_query, opts = {}) data, _status_code, _headers = create_campaign_recipient_estimation_job_with_http_info(campaign_recipient_estimation_job_create_query, opts) data end # Create Campaign Recipient Estimation Job # Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_recipient_estimation_job_create_query [CampaignRecipientEstimationJobCreateQuery] Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign. # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_campaign_recipient_estimation_job_with_http_info(campaign_recipient_estimation_job_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_recipient_estimation_job ...' end # verify the required parameter 'campaign_recipient_estimation_job_create_query' is set if @api_client.config.client_side_validation && campaign_recipient_estimation_job_create_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_recipient_estimation_job_create_query' when calling CampaignsApi.create_campaign_recipient_estimation_job" end # resource path local_var_path = '/api/campaign-recipient-estimation-jobs/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_recipient_estimation_job_create_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.create_campaign_recipient_estimation_job", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#create_campaign_recipient_estimation_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Campaign Send Job # Trigger a campaign to send asynchronously

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_send_job_create_query [CampaignSendJobCreateQuery] Trigger the campaign to send asynchronously # @param [Hash] opts the optional parameters # @return [Hash] def create_campaign_send_job(campaign_send_job_create_query, opts = {}) data, _status_code, _headers = create_campaign_send_job_with_http_info(campaign_send_job_create_query, opts) data end # Create Campaign Send Job # Trigger a campaign to send asynchronously<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param campaign_send_job_create_query [CampaignSendJobCreateQuery] Trigger the campaign to send asynchronously # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_campaign_send_job_with_http_info(campaign_send_job_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_send_job ...' end # verify the required parameter 'campaign_send_job_create_query' is set if @api_client.config.client_side_validation && campaign_send_job_create_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_send_job_create_query' when calling CampaignsApi.create_campaign_send_job" end # resource path local_var_path = '/api/campaign-send-jobs/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_send_job_create_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.create_campaign_send_job", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#create_campaign_send_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Campaign # Delete a campaign with the given campaign ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The campaign ID to be deleted # @param [Hash] opts the optional parameters # @return [nil] def delete_campaign(id, opts = {}) delete_campaign_with_http_info(id, opts) nil end # Delete Campaign # Delete a campaign with the given campaign ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The campaign ID to be deleted # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_campaign_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.delete_campaign ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.delete_campaign" end # resource path local_var_path = '/api/campaigns/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.delete_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#delete_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign # Returns a specific campaign based on a required id.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The campaign ID to be retrieved # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @return [Hash] def get_campaign(id, opts = {}) data, _status_code, _headers = get_campaign_with_http_info(id, opts) data end # Get Campaign # Returns a specific campaign based on a required id.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The campaign ID to be retrieved # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign" end allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"] if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}" end allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"] if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}" end allowable_values = ["name"] if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}" end allowable_values = ["campaign-messages", "tags"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaigns/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil? query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil? query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Campaign Messages # Return all messages that belong to the given campaign.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_template For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @return [Hash] def get_campaign_campaign_messages(id, opts = {}) data, _status_code, _headers = get_campaign_campaign_messages_with_http_info(id, opts) data end # Get Campaign Campaign Messages # Return all messages that belong to the given campaign.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_template For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_campaign_messages_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_campaign_messages ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_campaign_messages" end allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"] if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}" end allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"] if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}" end allowable_values = ["name", "editor_type", "html", "text", "created", "updated"] if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}" end allowable_values = ["campaign", "template"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaigns/{id}/campaign-messages/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil? query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil? query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_campaign_messages", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_campaign_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Message # Returns a specific message based on a required id.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The message ID to be retrieved # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_template For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @return [Hash] def get_campaign_message(id, opts = {}) data, _status_code, _headers = get_campaign_message_with_http_info(id, opts) data end # Get Campaign Message # Returns a specific message based on a required id.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The message ID to be retrieved # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_template For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_message_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_message" end allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"] if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}" end allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"] if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}" end allowable_values = ["name", "editor_type", "html", "text", "created", "updated"] if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}" end allowable_values = ["campaign", "template"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaign-messages/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil? query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil? query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_message", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Message Campaign # Return the related campaign

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_campaign_message_campaign(id, opts = {}) data, _status_code, _headers = get_campaign_message_campaign_with_http_info(id, opts) data end # Get Campaign Message Campaign # Return the related campaign<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_message_campaign_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_campaign ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_message_campaign" end allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"] if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaign-messages/{id}/campaign/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_message_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Message Relationships Campaign # Returns the ID of the related campaign

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Hash] def get_campaign_message_relationships_campaign(id, opts = {}) data, _status_code, _headers = get_campaign_message_relationships_campaign_with_http_info(id, opts) data end # Get Campaign Message Relationships Campaign # Returns the ID of the related campaign<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_message_relationships_campaign_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_relationships_campaign ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_message_relationships_campaign" end # resource path local_var_path = '/api/campaign-messages/{id}/relationships/campaign/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_message_relationships_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message_relationships_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Message Relationships Template # Returns the ID of the related template

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `templates:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Hash] def get_campaign_message_relationships_template(id, opts = {}) data, _status_code, _headers = get_campaign_message_relationships_template_with_http_info(id, opts) data end # Get Campaign Message Relationships Template # Returns the ID of the related template<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` `templates:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_message_relationships_template_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_relationships_template ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_message_relationships_template" end # resource path local_var_path = '/api/campaign-messages/{id}/relationships/template/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_message_relationships_template", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message_relationships_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Message Template # Return the related template

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `templates:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_template For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_campaign_message_template(id, opts = {}) data, _status_code, _headers = get_campaign_message_template_with_http_info(id, opts) data end # Get Campaign Message Template # Return the related template<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` `templates:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_template For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_message_template_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_template ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_message_template" end allowable_values = ["name", "editor_type", "html", "text", "created", "updated"] if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaign-messages/{id}/template/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_message_template", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Recipient Estimation # Get the estimated recipient count for a campaign with the provided campaign ID. You can refresh this count by using the `Create Campaign Recipient Estimation Job` endpoint.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The ID of the campaign for which to get the estimated number of recipients # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_recipient_estimation For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_campaign_recipient_estimation(id, opts = {}) data, _status_code, _headers = get_campaign_recipient_estimation_with_http_info(id, opts) data end # Get Campaign Recipient Estimation # Get the estimated recipient count for a campaign with the provided campaign ID. You can refresh this count by using the `Create Campaign Recipient Estimation Job` endpoint.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The ID of the campaign for which to get the estimated number of recipients # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_recipient_estimation For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_recipient_estimation_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_recipient_estimation ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_recipient_estimation" end allowable_values = ["estimated_recipient_count"] if @api_client.config.client_side_validation && opts[:'fields_campaign_recipient_estimation'] && !opts[:'fields_campaign_recipient_estimation'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_recipient_estimation\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaign-recipient-estimations/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-recipient-estimation]'] = @api_client.build_collection_param(opts[:'fields_campaign_recipient_estimation'], :csv) if !opts[:'fields_campaign_recipient_estimation'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_recipient_estimation", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_recipient_estimation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Recipient Estimation Job # Retrieve the status of a recipient estimation job triggered with the `Create Campaign Recipient Estimation Job` endpoint.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The ID of the campaign to get recipient estimation status # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_recipient_estimation_job For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_campaign_recipient_estimation_job(id, opts = {}) data, _status_code, _headers = get_campaign_recipient_estimation_job_with_http_info(id, opts) data end # Get Campaign Recipient Estimation Job # Retrieve the status of a recipient estimation job triggered with the `Create Campaign Recipient Estimation Job` endpoint.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The ID of the campaign to get recipient estimation status # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_recipient_estimation_job For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_recipient_estimation_job_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_recipient_estimation_job ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_recipient_estimation_job" end allowable_values = ["status"] if @api_client.config.client_side_validation && opts[:'fields_campaign_recipient_estimation_job'] && !opts[:'fields_campaign_recipient_estimation_job'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_recipient_estimation_job\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaign-recipient-estimation-jobs/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-recipient-estimation-job]'] = @api_client.build_collection_param(opts[:'fields_campaign_recipient_estimation_job'], :csv) if !opts[:'fields_campaign_recipient_estimation_job'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_recipient_estimation_job", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_recipient_estimation_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Relationships Campaign Messages # Returns the IDs of all messages associated with the given campaign.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Hash] def get_campaign_relationships_campaign_messages(id, opts = {}) data, _status_code, _headers = get_campaign_relationships_campaign_messages_with_http_info(id, opts) data end # Get Campaign Relationships Campaign Messages # Returns the IDs of all messages associated with the given campaign.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_relationships_campaign_messages_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_relationships_campaign_messages ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_relationships_campaign_messages" end # resource path local_var_path = '/api/campaigns/{id}/relationships/campaign-messages/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_relationships_campaign_messages", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_relationships_campaign_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Relationships Tags # Returns the IDs of all tags associated with the given campaign.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Hash] def get_campaign_relationships_tags(id, opts = {}) data, _status_code, _headers = get_campaign_relationships_tags_with_http_info(id, opts) data end # Get Campaign Relationships Tags # Returns the IDs of all tags associated with the given campaign.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_relationships_tags_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_relationships_tags ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_relationships_tags" end # resource path local_var_path = '/api/campaigns/{id}/relationships/tags/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_relationships_tags", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_relationships_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Send Job # Get a campaign send job

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The ID of the campaign to send # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_send_job For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_campaign_send_job(id, opts = {}) data, _status_code, _headers = get_campaign_send_job_with_http_info(id, opts) data end # Get Campaign Send Job # Get a campaign send job<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param id [String] The ID of the campaign to send # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_send_job For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_send_job_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_send_job ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_send_job" end allowable_values = ["status"] if @api_client.config.client_side_validation && opts[:'fields_campaign_send_job'] && !opts[:'fields_campaign_send_job'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_send_job\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaign-send-jobs/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[campaign-send-job]'] = @api_client.build_collection_param(opts[:'fields_campaign_send_job'], :csv) if !opts[:'fields_campaign_send_job'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_send_job", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_send_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Tags # Return all tags that belong to the given campaign.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_campaign_tags(id, opts = {}) data, _status_code, _headers = get_campaign_tags_with_http_info(id, opts) data end # Get Campaign Tags # Return all tags that belong to the given campaign.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` # @param id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_tags_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_tags ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.get_campaign_tags" end allowable_values = ["name"] if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/campaigns/{id}/tags/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign_tags", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaigns # Returns some or all campaigns based on filters. A channel filter is required to list campaigns. Please provide either: `?filter=equals(messages.channel,'email')` to list email campaigns, or `?filter=equals(messages.channel,'sms')` to list SMS campaigns.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` # @param filter [String] For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`messages.channel`: `equals`<br>`name`: `contains`<br>`status`: `any`, `equals`<br>`archived`: `equals`<br>`created_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`scheduled_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sorting # @return [Hash] def get_campaigns(filter, opts = {}) data, _status_code, _headers = get_campaigns_with_http_info(filter, opts) data end # Get Campaigns # Returns some or all campaigns based on filters. A channel filter is required to list campaigns. Please provide either: `?filter=equals(messages.channel,'email')` to list email campaigns, or `?filter=equals(messages.channel,'sms')` to list SMS campaigns.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:read` # @param filter [String] For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`messages.channel`: `equals`<br>`name`: `contains`<br>`status`: `any`, `equals`<br>`archived`: `equals`<br>`created_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`scheduled_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_campaign_message For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_campaign For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#relationships # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaigns_with_http_info(filter, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaigns ...' end # verify the required parameter 'filter' is set if @api_client.config.client_side_validation && filter.nil? fail ArgumentError, "Missing the required parameter 'filter' when calling CampaignsApi.get_campaigns" end allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"] if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}" end allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"] if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}" end allowable_values = ["name"] if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}" end allowable_values = ["campaign-messages", "tags"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end allowable_values = ["created_at", "-created_at", "id", "-id", "name", "-name", "scheduled_at", "-scheduled_at", "updated_at", "-updated_at"] if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort']) fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}" end # resource path local_var_path = '/api/campaigns/' # query parameters query_params = opts[:query_params] || {} query_params[:'filter'] = filter query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil? query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil? query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil? query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaigns", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Campaign # Update a campaign with the given campaign ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The campaign ID to be retrieved # @param campaign_partial_update_query [CampaignPartialUpdateQuery] Update a campaign and return it # @param [Hash] opts the optional parameters # @return [Hash] def update_campaign(id, campaign_partial_update_query, opts = {}) data, _status_code, _headers = update_campaign_with_http_info(id, campaign_partial_update_query, opts) data end # Update Campaign # Update a campaign with the given campaign ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The campaign ID to be retrieved # @param campaign_partial_update_query [CampaignPartialUpdateQuery] Update a campaign and return it # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def update_campaign_with_http_info(id, campaign_partial_update_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.update_campaign" end # verify the required parameter 'campaign_partial_update_query' is set if @api_client.config.client_side_validation && campaign_partial_update_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_partial_update_query' when calling CampaignsApi.update_campaign" end # resource path local_var_path = '/api/campaigns/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_partial_update_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.update_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#update_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Campaign Message # Update a campaign message

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The message ID to be retrieved # @param campaign_message_partial_update_query [CampaignMessagePartialUpdateQuery] Update a message and return it # @param [Hash] opts the optional parameters # @return [Hash] def update_campaign_message(id, campaign_message_partial_update_query, opts = {}) data, _status_code, _headers = update_campaign_message_with_http_info(id, campaign_message_partial_update_query, opts) data end # Update Campaign Message # Update a campaign message<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The message ID to be retrieved # @param campaign_message_partial_update_query [CampaignMessagePartialUpdateQuery] Update a message and return it # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def update_campaign_message_with_http_info(id, campaign_message_partial_update_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign_message ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.update_campaign_message" end # verify the required parameter 'campaign_message_partial_update_query' is set if @api_client.config.client_side_validation && campaign_message_partial_update_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_message_partial_update_query' when calling CampaignsApi.update_campaign_message" end # resource path local_var_path = '/api/campaign-messages/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_message_partial_update_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.update_campaign_message", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#update_campaign_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Campaign Send Job # Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The ID of the currently sending campaign to cancel or revert # @param campaign_send_job_partial_update_query [CampaignSendJobPartialUpdateQuery] Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT # @param [Hash] opts the optional parameters # @return [nil] def update_campaign_send_job(id, campaign_send_job_partial_update_query, opts = {}) update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query, opts) nil end # Update Campaign Send Job # Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `campaigns:write` # @param id [String] The ID of the currently sending campaign to cancel or revert # @param campaign_send_job_partial_update_query [CampaignSendJobPartialUpdateQuery] Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign_send_job ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CampaignsApi.update_campaign_send_job" end # verify the required parameter 'campaign_send_job_partial_update_query' is set if @api_client.config.client_side_validation && campaign_send_job_partial_update_query.nil? fail ArgumentError, "Missing the required parameter 'campaign_send_job_partial_update_query' when calling CampaignsApi.update_campaign_send_job" end # resource path local_var_path = '/api/campaign-send-jobs/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-10-15" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(campaign_send_job_partial_update_query) # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"CampaignsApi.update_campaign_send_job", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#update_campaign_send_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end