Method: KlaviyoAPI::FlowsApi#create_flow_with_http_info

Defined in:
lib/klaviyo-api-sdk/api/flows_api.rb

#create_flow_with_http_info(flow_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Create Flow Create a new flow using an encoded flow definition. New objects within the flow definition, such as actions, will need to use a &#x60;temporary_id&#x60; field for identification. These will be replaced with traditional &#x60;id&#x60; fields after successful creation. A successful request will return the new definition to you.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60;&lt;br&gt;Daily: &#x60;100/d&#x60; Scopes: &#x60;flows:write&#x60;

Parameters:

  • flow_create_query (FlowCreateQuery)

    Creates a Flow from parameters

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :additional_fields_flow (Array<String>)

    Request additional fields not included by default in the response. Supported values: &#39;definition&#39;

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/klaviyo-api-sdk/api/flows_api.rb', line 39

def create_flow_with_http_info(flow_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FlowsApi.create_flow ...'
  end
  # verify the required parameter 'flow_create_query' is set
  if @api_client.config.client_side_validation && flow_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'flow_create_query' when calling FlowsApi.create_flow"
  end
  allowable_values = ["definition"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_flow'] && !opts[:'additional_fields_flow'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_flow\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/flows'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[flow]'] = @api_client.build_collection_param(opts[:'additional_fields_flow'], :csv) if !opts[:'additional_fields_flow'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+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_create_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"FlowsApi.create_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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FlowsApi#create_flow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end