=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
require 'cgi'
module KlaviyoAPI
class FlowsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Get Flow
# Get a flow with the given flow ID. Include parameters can be provided to get the following related resource data: `flow-actions`
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @return [Hash]
def get_flow(id, opts = {})
data, _status_code, _headers = get_flow_with_http_info(id, opts)
data
end
# Get Flow
# Get a flow with the given flow ID. Include parameters can be provided to get the following related resource data: `flow-actions`<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow ...'
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 FlowsApi.get_flow"
end
allowable_values = ["action_type", "status", "created", "updated", "settings", "tracking_options", "send_options", "send_options.use_smart_sending", "send_options.is_transactional", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language"]
if @api_client.config.client_side_validation && opts[:'fields_flow_action'] && !opts[:'fields_flow_action'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_action\", must include one of #{allowable_values}"
end
allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
end
allowable_values = ["flow-actions"]
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/flows/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-action]'] = @api_client.build_collection_param(opts[:'fields_flow_action'], :csv) if !opts[:'fields_flow_action'].nil?
query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].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-02-22"
# 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 => :"FlowsApi.get_flow",
: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: FlowsApi#get_flow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Action
# Get a flow action from a flow with the given flow action ID. Include parameters can be provided to get the following related resource data: `flows`, `flow-messages`
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow_message For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @return [Hash]
def get_flow_action(id, opts = {})
data, _status_code, _headers = get_flow_action_with_http_info(id, opts)
data
end
# Get Flow Action
# Get a flow action from a flow with the given flow action ID. Include parameters can be provided to get the following related resource data: `flows`, `flow-messages`<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow_message For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_action_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_action ...'
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 FlowsApi.get_flow_action"
end
allowable_values = ["action_type", "status", "created", "updated", "settings", "tracking_options", "send_options", "send_options.use_smart_sending", "send_options.is_transactional", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language"]
if @api_client.config.client_side_validation && opts[:'fields_flow_action'] && !opts[:'fields_flow_action'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_action\", must include one of #{allowable_values}"
end
allowable_values = ["name", "channel", "content", "created", "updated"]
if @api_client.config.client_side_validation && opts[:'fields_flow_message'] && !opts[:'fields_flow_message'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_message\", must include one of #{allowable_values}"
end
allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
end
allowable_values = ["flow-messages", "flows"]
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/flow-actions/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-action]'] = @api_client.build_collection_param(opts[:'fields_flow_action'], :csv) if !opts[:'fields_flow_action'].nil?
query_params[:'fields[flow-message]'] = @api_client.build_collection_param(opts[:'fields_flow_message'], :csv) if !opts[:'fields_flow_message'].nil?
query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].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-02-22"
# 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 => :"FlowsApi.get_flow_action",
: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: FlowsApi#get_flow_action\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow For Flow Action
# Get the flow associated with the given action ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param action_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_flow_action_flow(action_id, opts = {})
data, _status_code, _headers = get_flow_action_flow_with_http_info(action_id, opts)
data
end
# Get Flow For Flow Action
# Get the flow associated with the given action ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param action_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_action_flow_with_http_info(action_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_action_flow ...'
end
# verify the required parameter 'action_id' is set
if @api_client.config.client_side_validation && action_id.nil?
fail ArgumentError, "Missing the required parameter 'action_id' when calling FlowsApi.get_flow_action_flow"
end
allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/flow-actions/{action_id}/flow/'.sub('{' + 'action_id' + '}', CGI.escape(action_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-02-22"
# 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 => :"FlowsApi.get_flow_action_flow",
: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: FlowsApi#get_flow_action_flow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Messages For Flow Action
# Get all flow messages associated with the given flow action ID. Returns a maximum of 50 flow message relationships per request, which can be paginated with cursor-based pagination.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param action_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_message For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Hash]
def get_flow_action_messages(action_id, opts = {})
data, _status_code, _headers = get_flow_action_messages_with_http_info(action_id, opts)
data
end
# Get Messages For Flow Action
# Get all flow messages associated with the given flow action ID. Returns a maximum of 50 flow message relationships per request, which can be paginated with cursor-based pagination.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param action_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_message For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_action_messages_with_http_info(action_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_action_messages ...'
end
# verify the required parameter 'action_id' is set
if @api_client.config.client_side_validation && action_id.nil?
fail ArgumentError, "Missing the required parameter 'action_id' when calling FlowsApi.get_flow_action_messages"
end
allowable_values = ["name", "channel", "content", "created", "updated"]
if @api_client.config.client_side_validation && opts[:'fields_flow_message'] && !opts[:'fields_flow_message'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_message\", must include one of #{allowable_values}"
end
allowable_values = ["created", "-created", "id", "-id", "name", "-name", "updated", "-updated"]
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/flow-actions/{action_id}/flow-messages/'.sub('{' + 'action_id' + '}', CGI.escape(action_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-message]'] = @api_client.build_collection_param(opts[:'fields_flow_message'], :csv) if !opts[:'fields_flow_message'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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-02-22"
# 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 => :"FlowsApi.get_flow_action_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: FlowsApi#get_flow_action_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Action Relationships
# Get all relationships for flow messages associated with the given flow action ID. Returns a maximum of 50 flow message relationships per request, which can be paginated with cursor-based pagination.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param related_resource [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Hash]
def get_flow_action_relationships(id, related_resource, opts = {})
data, _status_code, _headers = get_flow_action_relationships_with_http_info(id, related_resource, opts)
data
end
# Get Flow Action Relationships
# Get all relationships for flow messages associated with the given flow action ID. Returns a maximum of 50 flow message relationships per request, which can be paginated with cursor-based pagination.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param related_resource [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_action_relationships_with_http_info(id, related_resource, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_action_relationships ...'
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 FlowsApi.get_flow_action_relationships"
end
# verify the required parameter 'related_resource' is set
if @api_client.config.client_side_validation && related_resource.nil?
fail ArgumentError, "Missing the required parameter 'related_resource' when calling FlowsApi.get_flow_action_relationships"
end
# verify enum value
allowable_values = ["flow", "flow-messages"]
if @api_client.config.client_side_validation && !allowable_values.include?(related_resource)
fail ArgumentError, "invalid value for \"related_resource\", must be one of #{allowable_values}"
end
allowable_values = ["created", "-created", "id", "-id", "name", "-name", "updated", "-updated"]
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/flow-actions/{id}/relationships/{related_resource}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'related_resource' + '}', CGI.escape(related_resource.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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-02-22"
# 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 => :"FlowsApi.get_flow_action_relationships",
: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: FlowsApi#get_flow_action_relationships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Actions For Flow
# Get all flow actions associated with the given flow ID. Returns a maximum of 50 flows per request, which can be paginated with cursor-based pagination.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param flow_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<br>`action_type`: `any`, `equals`<br>`status`: `equals`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Hash]
def get_flow_flow_actions(flow_id, opts = {})
data, _status_code, _headers = get_flow_flow_actions_with_http_info(flow_id, opts)
data
end
# Get Flow Actions For Flow
# Get all flow actions associated with the given flow ID. Returns a maximum of 50 flows per request, which can be paginated with cursor-based pagination.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param flow_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<br>`action_type`: `any`, `equals`<br>`status`: `equals`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_flow_actions_with_http_info(flow_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_flow_actions ...'
end
# verify the required parameter 'flow_id' is set
if @api_client.config.client_side_validation && flow_id.nil?
fail ArgumentError, "Missing the required parameter 'flow_id' when calling FlowsApi.get_flow_flow_actions"
end
allowable_values = ["action_type", "status", "created", "updated", "settings", "tracking_options", "send_options", "send_options.use_smart_sending", "send_options.is_transactional", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language"]
if @api_client.config.client_side_validation && opts[:'fields_flow_action'] && !opts[:'fields_flow_action'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_action\", must include one of #{allowable_values}"
end
allowable_values = ["action_type", "-action_type", "created", "-created", "id", "-id", "status", "-status", "updated", "-updated"]
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/flows/{flow_id}/flow-actions/'.sub('{' + 'flow_id' + '}', CGI.escape(flow_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-action]'] = @api_client.build_collection_param(opts[:'fields_flow_action'], :csv) if !opts[:'fields_flow_action'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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-02-22"
# 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 => :"FlowsApi.get_flow_flow_actions",
: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: FlowsApi#get_flow_flow_actions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Message
# Get the flow message of a flow with the given message ID. Include parameters can be provided to get the following related resource data: 'flow-actions'
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow_message For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @return [Hash]
def get_flow_message(id, opts = {})
data, _status_code, _headers = get_flow_message_with_http_info(id, opts)
data
end
# Get Flow Message
# Get the flow message of a flow with the given message ID. Include parameters can be provided to get the following related resource data: 'flow-actions'<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow_message For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_message_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_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 FlowsApi.get_flow_message"
end
allowable_values = ["action_type", "status", "created", "updated", "settings", "tracking_options", "send_options", "send_options.use_smart_sending", "send_options.is_transactional", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language"]
if @api_client.config.client_side_validation && opts[:'fields_flow_action'] && !opts[:'fields_flow_action'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_action\", must include one of #{allowable_values}"
end
allowable_values = ["name", "channel", "content", "created", "updated"]
if @api_client.config.client_side_validation && opts[:'fields_flow_message'] && !opts[:'fields_flow_message'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_message\", must include one of #{allowable_values}"
end
allowable_values = ["flow-action"]
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/flow-messages/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-action]'] = @api_client.build_collection_param(opts[:'fields_flow_action'], :csv) if !opts[:'fields_flow_action'].nil?
query_params[:'fields[flow-message]'] = @api_client.build_collection_param(opts[:'fields_flow_message'], :csv) if !opts[:'fields_flow_message'].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-02-22"
# 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 => :"FlowsApi.get_flow_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: FlowsApi#get_flow_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Action For Message
# Get the flow action for a flow message with the given message ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param message_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_flow_message_action(message_id, opts = {})
data, _status_code, _headers = get_flow_message_action_with_http_info(message_id, opts)
data
end
# Get Flow Action For Message
# Get the flow action for a flow message with the given message ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param message_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_message_action_with_http_info(message_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_message_action ...'
end
# verify the required parameter 'message_id' is set
if @api_client.config.client_side_validation && message_id.nil?
fail ArgumentError, "Missing the required parameter 'message_id' when calling FlowsApi.get_flow_message_action"
end
allowable_values = ["action_type", "status", "created", "updated", "settings", "tracking_options", "send_options", "send_options.use_smart_sending", "send_options.is_transactional", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language"]
if @api_client.config.client_side_validation && opts[:'fields_flow_action'] && !opts[:'fields_flow_action'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_action\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/flow-messages/{message_id}/flow-action/'.sub('{' + 'message_id' + '}', CGI.escape(message_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-action]'] = @api_client.build_collection_param(opts[:'fields_flow_action'], :csv) if !opts[:'fields_flow_action'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-02-22"
# 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 => :"FlowsApi.get_flow_message_action",
: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: FlowsApi#get_flow_message_action\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Message Relationships
# Get the [relationship](https://developers.klaviyo.com/en/reference/api_overview#relationships) for a flow message's flow action, given the flow ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param related_resource [String]
# @param [Hash] opts the optional parameters
# @return [Hash]
def get_flow_message_relationships(id, related_resource, opts = {})
data, _status_code, _headers = get_flow_message_relationships_with_http_info(id, related_resource, opts)
data
end
# Get Flow Message Relationships
# Get the [relationship](https://developers.klaviyo.com/en/reference/api_overview#relationships) for a flow message's flow action, given the flow ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param id [String]
# @param related_resource [String]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_message_relationships_with_http_info(id, related_resource, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_message_relationships ...'
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 FlowsApi.get_flow_message_relationships"
end
# verify the required parameter 'related_resource' is set
if @api_client.config.client_side_validation && related_resource.nil?
fail ArgumentError, "Missing the required parameter 'related_resource' when calling FlowsApi.get_flow_message_relationships"
end
# verify enum value
allowable_values = ["flow-action"]
if @api_client.config.client_side_validation && !allowable_values.include?(related_resource)
fail ArgumentError, "invalid value for \"related_resource\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/api/flow-messages/{id}/relationships/{related_resource}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'related_resource' + '}', CGI.escape(related_resource.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-02-22"
# 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 => :"FlowsApi.get_flow_message_relationships",
: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: FlowsApi#get_flow_message_relationships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Relationships
# If the `related_resource` is `tags`, returns the tag IDs of all tags associated with the given flow.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read` `Tags Read`
# @param id [String]
# @param related_resource [String]
# @param [Hash] opts the optional parameters
# @return [Hash]
def get_flow_relationships(id, related_resource, opts = {})
data, _status_code, _headers = get_flow_relationships_with_http_info(id, related_resource, opts)
data
end
# Get Flow Relationships
# If the `related_resource` is `tags`, returns the tag IDs of all tags associated with the given flow.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read` `Tags Read`
# @param id [String]
# @param related_resource [String]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_relationships_with_http_info(id, related_resource, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_relationships ...'
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 FlowsApi.get_flow_relationships"
end
# verify the required parameter 'related_resource' is set
if @api_client.config.client_side_validation && related_resource.nil?
fail ArgumentError, "Missing the required parameter 'related_resource' when calling FlowsApi.get_flow_relationships"
end
# verify enum value
allowable_values = ["flow-actions", "tags"]
if @api_client.config.client_side_validation && !allowable_values.include?(related_resource)
fail ArgumentError, "invalid value for \"related_resource\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/api/flows/{id}/relationships/{related_resource}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'related_resource' + '}', CGI.escape(related_resource.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-02-22"
# 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 => :"FlowsApi.get_flow_relationships",
: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: FlowsApi#get_flow_relationships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flow Tags
# Return all tags associated with the given flow ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read` `Tags Read`
# @param flow_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_flow_tags(flow_id, opts = {})
data, _status_code, _headers = get_flow_tags_with_http_info(flow_id, opts)
data
end
# Get Flow Tags
# Return all tags associated with the given flow ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read` `Tags Read`
# @param flow_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flow_tags_with_http_info(flow_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flow_tags ...'
end
# verify the required parameter 'flow_id' is set
if @api_client.config.client_side_validation && flow_id.nil?
fail ArgumentError, "Missing the required parameter 'flow_id' when calling FlowsApi.get_flow_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/flows/{flow_id}/tags/'.sub('{' + 'flow_id' + '}', CGI.escape(flow_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-02-22"
# 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 => :"FlowsApi.get_flow_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: FlowsApi#get_flow_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Flows
# Get all flows in an account. Returns a maximum of 50 flows per request, which can be paginated with cursor-based pagination.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`status`: `equals`<br>`archived`: `equals`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`trigger_type`: `equals`
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Hash]
def get_flows(opts = {})
data, _status_code, _headers = get_flows_with_http_info(opts)
data
end
# Get Flows
# Get all flows in an account. Returns a maximum of 50 flows per request, which can be paginated with cursor-based pagination.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_flow_action For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`status`: `equals`<br>`archived`: `equals`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`trigger_type`: `equals`
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_flows_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.get_flows ...'
end
allowable_values = ["action_type", "status", "created", "updated", "settings", "tracking_options", "send_options", "send_options.use_smart_sending", "send_options.is_transactional", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language"]
if @api_client.config.client_side_validation && opts[:'fields_flow_action'] && !opts[:'fields_flow_action'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow_action\", must include one of #{allowable_values}"
end
allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
end
allowable_values = ["flow-actions"]
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", "-created", "id", "-id", "name", "-name", "status", "-status", "trigger_type", "-trigger_type", "updated", "-updated"]
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/flows/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[flow-action]'] = @api_client.build_collection_param(opts[:'fields_flow_action'], :csv) if !opts[:'fields_flow_action'].nil?
query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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-02-22"
# 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 => :"FlowsApi.get_flows",
: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: FlowsApi#get_flows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update Flow Status
# Update the status of a flow with the given flow ID, and all actions in that flow.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Flows Write`
# @param id [String]
# @param flow_update_query [FlowUpdateQuery]
# @param [Hash] opts the optional parameters
# @return [Hash]
def update_flow(id, flow_update_query, opts = {})
data, _status_code, _headers = update_flow_with_http_info(id, flow_update_query, opts)
data
end
# Update Flow Status
# Update the status of a flow with the given flow ID, and all actions in that flow.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Flows Write`
# @param id [String]
# @param flow_update_query [FlowUpdateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def update_flow_with_http_info(id, flow_update_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FlowsApi.update_flow ...'
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 FlowsApi.update_flow"
end
# verify the required parameter 'flow_update_query' is set
if @api_client.config.client_side_validation && flow_update_query.nil?
fail ArgumentError, "Missing the required parameter 'flow_update_query' when calling FlowsApi.update_flow"
end
# resource path
local_var_path = '/api/flows/{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-02-22"
# 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(flow_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 => :"FlowsApi.update_flow",
: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: FlowsApi#update_flow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end