=begin
#Klaviyo API
#The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
The version of the OpenAPI document: 2024-10-15
Contact: developers@klaviyo.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module KlaviyoAPI
class ProfilesApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Bulk Subscribe Profiles
# Subscribe one or more profiles to email marketing, SMS marketing, or both. If the provided list has double opt-in enabled, profiles will receive a message requiring their confirmation before subscribing. Otherwise, profiles will be immediately subscribed without receiving a confirmation message. Learn more about [consent in this guide](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). If a list is not provided, the opt-in process used will be determined by the [account-level default opt-in setting](https://www.klaviyo.com/settings/account/api-keys). To add someone to a list without changing their subscription status, use [Add Profile to List](https://developers.klaviyo.com/en/reference/create_list_relationships). This API will remove any `UNSUBSCRIBE`, `SPAM_REPORT` or `USER_SUPPRESSED` suppressions from the provided profiles. Learn more about [suppressed profiles](https://help.klaviyo.com/hc/en-us/articles/115005246108-Understanding-suppressed-email-profiles#what-is-a-suppressed-profile-1). Maximum number of profiles can be submitted for subscription: 1000 This endpoint now supports a `historical_import` flag. If this flag is set `true`, profiles being subscribed will bypass double opt-in emails and be subscribed immediately. They will also bypass any associated \"Added to list\" flows. This is useful for importing historical data where you have already collected consent. If `historical_import` is set to true, the `consented_at` field is required and must be in the past.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `lists:write` `profiles:write` `subscriptions:write`
# @param subscription_create_job_create_query [SubscriptionCreateJobCreateQuery] Subscribes one or more profiles to marketing. Currently, supports email and SMS only. All profiles will be added to the provided list. Either email or phone number is required. Both may be specified to subscribe to both channels. If a profile cannot be found matching the given identifier(s), a new profile will be created and then subscribed.
# @param [Hash] opts the optional parameters
# @return [nil]
def bulk_subscribe_profiles(subscription_create_job_create_query, opts = {})
bulk_subscribe_profiles_with_http_info(subscription_create_job_create_query, opts)
nil
end
# alias of `bulk_subscribe_profiles`
alias subscribe_profiles bulk_subscribe_profiles
# alias of `bulk_subscribe_profiles`
alias create_profile_subscription_bulk_create_job bulk_subscribe_profiles
# Bulk Subscribe Profiles
# Subscribe one or more profiles to email marketing, SMS marketing, or both. If the provided list has double opt-in enabled, profiles will receive a message requiring their confirmation before subscribing. Otherwise, profiles will be immediately subscribed without receiving a confirmation message. Learn more about [consent in this guide](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). If a list is not provided, the opt-in process used will be determined by the [account-level default opt-in setting](https://www.klaviyo.com/settings/account/api-keys). To add someone to a list without changing their subscription status, use [Add Profile to List](https://developers.klaviyo.com/en/reference/create_list_relationships). This API will remove any `UNSUBSCRIBE`, `SPAM_REPORT` or `USER_SUPPRESSED` suppressions from the provided profiles. Learn more about [suppressed profiles](https://help.klaviyo.com/hc/en-us/articles/115005246108-Understanding-suppressed-email-profiles#what-is-a-suppressed-profile-1). Maximum number of profiles can be submitted for subscription: 1000 This endpoint now supports a `historical_import` flag. If this flag is set `true`, profiles being subscribed will bypass double opt-in emails and be subscribed immediately. They will also bypass any associated \"Added to list\" flows. This is useful for importing historical data where you have already collected consent. If `historical_import` is set to true, the `consented_at` field is required and must be in the past.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `lists:write` `profiles:write` `subscriptions:write`
# @param subscription_create_job_create_query [SubscriptionCreateJobCreateQuery] Subscribes one or more profiles to marketing. Currently, supports email and SMS only. All profiles will be added to the provided list. Either email or phone number is required. Both may be specified to subscribe to both channels. If a profile cannot be found matching the given identifier(s), a new profile will be created and then subscribed.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def bulk_subscribe_profiles_with_http_info(subscription_create_job_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.bulk_subscribe_profiles ...'
end
# verify the required parameter 'subscription_create_job_create_query' is set
if @api_client.config.client_side_validation && subscription_create_job_create_query.nil?
fail ArgumentError, "Missing the required parameter 'subscription_create_job_create_query' when calling ProfilesApi.bulk_subscribe_profiles"
end
# resource path
local_var_path = '/api/profile-subscription-bulk-create-jobs'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(subscription_create_job_create_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 => :"ProfilesApi.bulk_subscribe_profiles",
: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: ProfilesApi#bulk_subscribe_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `bulk_subscribe_profiles_with_http_info`
alias subscribe_profiles_with_http_info bulk_subscribe_profiles_with_http_info
# alias of `bulk_subscribe_profiles_with_http_info`
alias create_profile_subscription_bulk_create_job_with_http_info bulk_subscribe_profiles_with_http_info
# Bulk Suppress Profiles
# Manually suppress profiles by email address or specify a segment/list ID to suppress all current members of a segment/list. Suppressed profiles cannot receive email marketing, independent of their consent status. To learn more, see our guides on [email suppressions](https://help.klaviyo.com/hc/en-us/articles/115005246108#what-is-a-suppressed-profile-1) and [collecting consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). Email address per request limit: 100
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `profiles:write` `subscriptions:write`
# @param suppression_create_job_create_query [SuppressionCreateJobCreateQuery] Suppresses one or more profiles from receiving marketing. Currently, supports email only. If a profile is not found with the given email, one will be created and immediately suppressed.
# @param [Hash] opts the optional parameters
# @return [Hash]
def bulk_suppress_profiles(suppression_create_job_create_query, opts = {})
data, _status_code, _headers = bulk_suppress_profiles_with_http_info(suppression_create_job_create_query, opts)
data
end
# alias of `bulk_suppress_profiles`
alias suppress_profiles bulk_suppress_profiles
# alias of `bulk_suppress_profiles`
alias create_profile_suppression_bulk_create_job bulk_suppress_profiles
# Bulk Suppress Profiles
# Manually suppress profiles by email address or specify a segment/list ID to suppress all current members of a segment/list. Suppressed profiles cannot receive email marketing, independent of their consent status. To learn more, see our guides on [email suppressions](https://help.klaviyo.com/hc/en-us/articles/115005246108#what-is-a-suppressed-profile-1) and [collecting consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). Email address per request limit: 100<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `profiles:write` `subscriptions:write`
# @param suppression_create_job_create_query [SuppressionCreateJobCreateQuery] Suppresses one or more profiles from receiving marketing. Currently, supports email only. If a profile is not found with the given email, one will be created and immediately suppressed.
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def bulk_suppress_profiles_with_http_info(suppression_create_job_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.bulk_suppress_profiles ...'
end
# verify the required parameter 'suppression_create_job_create_query' is set
if @api_client.config.client_side_validation && suppression_create_job_create_query.nil?
fail ArgumentError, "Missing the required parameter 'suppression_create_job_create_query' when calling ProfilesApi.bulk_suppress_profiles"
end
# resource path
local_var_path = '/api/profile-suppression-bulk-create-jobs'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(suppression_create_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 => :"ProfilesApi.bulk_suppress_profiles",
: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: ProfilesApi#bulk_suppress_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `bulk_suppress_profiles_with_http_info`
alias suppress_profiles_with_http_info bulk_suppress_profiles_with_http_info
# alias of `bulk_suppress_profiles_with_http_info`
alias create_profile_suppression_bulk_create_job_with_http_info bulk_suppress_profiles_with_http_info
# Bulk Unsubscribe Profiles
# Unsubscribe one or more profiles to email marketing, SMS marketing, or both. Learn more about [consent in this guide](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). To remove someone from a list without changing their subscription status, use [Remove Profile from List](https://developers.klaviyo.com/en/reference/delete_list_relationships). Maximum number of profile can be submitted for unsubscription: 100
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `lists:write` `profiles:write` `subscriptions:write`
# @param subscription_delete_job_create_query [SubscriptionDeleteJobCreateQuery] Unsubscribes one or more profiles from marketing. Currently, supports email and SMS only. All profiles will be removed from the provided list. Either email or phone number is required. If a profile cannot be found matching the given identifier(s), a new profile will be created and then unsubscribed.
# @param [Hash] opts the optional parameters
# @return [nil]
def bulk_unsubscribe_profiles(subscription_delete_job_create_query, opts = {})
bulk_unsubscribe_profiles_with_http_info(subscription_delete_job_create_query, opts)
nil
end
# alias of `bulk_unsubscribe_profiles`
alias unsubscribe_profiles bulk_unsubscribe_profiles
# alias of `bulk_unsubscribe_profiles`
alias create_profile_subscription_bulk_delete_job bulk_unsubscribe_profiles
# Bulk Unsubscribe Profiles
# Unsubscribe one or more profiles to email marketing, SMS marketing, or both. Learn more about [consent in this guide](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). To remove someone from a list without changing their subscription status, use [Remove Profile from List](https://developers.klaviyo.com/en/reference/delete_list_relationships). Maximum number of profile can be submitted for unsubscription: 100<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `lists:write` `profiles:write` `subscriptions:write`
# @param subscription_delete_job_create_query [SubscriptionDeleteJobCreateQuery] Unsubscribes one or more profiles from marketing. Currently, supports email and SMS only. All profiles will be removed from the provided list. Either email or phone number is required. If a profile cannot be found matching the given identifier(s), a new profile will be created and then unsubscribed.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def bulk_unsubscribe_profiles_with_http_info(subscription_delete_job_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.bulk_unsubscribe_profiles ...'
end
# verify the required parameter 'subscription_delete_job_create_query' is set
if @api_client.config.client_side_validation && subscription_delete_job_create_query.nil?
fail ArgumentError, "Missing the required parameter 'subscription_delete_job_create_query' when calling ProfilesApi.bulk_unsubscribe_profiles"
end
# resource path
local_var_path = '/api/profile-subscription-bulk-delete-jobs'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(subscription_delete_job_create_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 => :"ProfilesApi.bulk_unsubscribe_profiles",
: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: ProfilesApi#bulk_unsubscribe_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `bulk_unsubscribe_profiles_with_http_info`
alias unsubscribe_profiles_with_http_info bulk_unsubscribe_profiles_with_http_info
# alias of `bulk_unsubscribe_profiles_with_http_info`
alias create_profile_subscription_bulk_delete_job_with_http_info bulk_unsubscribe_profiles_with_http_info
# Bulk Unsuppress Profiles
# Manually unsuppress profiles by email address or specify a segment/list ID to unsuppress all current members of a segment/list. This only removes suppressions with reason USER_SUPPRESSED ; unsubscribed profiles and suppressed profiles with reason INVALID_EMAIL or HARD_BOUNCE remain unchanged. To learn more, see our guides on [email suppressions](https://help.klaviyo.com/hc/en-us/articles/115005246108#what-is-a-suppressed-profile-1) and [collecting consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). Email address per request limit: 100
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `subscriptions:write`
# @param suppression_delete_job_create_query [SuppressionDeleteJobCreateQuery] Unsuppresses one or more profiles from receiving marketing. Currently, supports email only. If a profile is not found with the given email, no action will be taken.
# @param [Hash] opts the optional parameters
# @return [Hash]
def bulk_unsuppress_profiles(suppression_delete_job_create_query, opts = {})
data, _status_code, _headers = bulk_unsuppress_profiles_with_http_info(suppression_delete_job_create_query, opts)
data
end
# alias of `bulk_unsuppress_profiles`
alias unsuppress_profiles bulk_unsuppress_profiles
# alias of `bulk_unsuppress_profiles`
alias create_profile_suppression_bulk_delete_job bulk_unsuppress_profiles
# Bulk Unsuppress Profiles
# Manually unsuppress profiles by email address or specify a segment/list ID to unsuppress all current members of a segment/list. This only removes suppressions with reason USER_SUPPRESSED ; unsubscribed profiles and suppressed profiles with reason INVALID_EMAIL or HARD_BOUNCE remain unchanged. To learn more, see our guides on [email suppressions](https://help.klaviyo.com/hc/en-us/articles/115005246108#what-is-a-suppressed-profile-1) and [collecting consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api). Email address per request limit: 100<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `subscriptions:write`
# @param suppression_delete_job_create_query [SuppressionDeleteJobCreateQuery] Unsuppresses one or more profiles from receiving marketing. Currently, supports email only. If a profile is not found with the given email, no action will be taken.
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def bulk_unsuppress_profiles_with_http_info(suppression_delete_job_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.bulk_unsuppress_profiles ...'
end
# verify the required parameter 'suppression_delete_job_create_query' is set
if @api_client.config.client_side_validation && suppression_delete_job_create_query.nil?
fail ArgumentError, "Missing the required parameter 'suppression_delete_job_create_query' when calling ProfilesApi.bulk_unsuppress_profiles"
end
# resource path
local_var_path = '/api/profile-suppression-bulk-delete-jobs'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(suppression_delete_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 => :"ProfilesApi.bulk_unsuppress_profiles",
: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: ProfilesApi#bulk_unsuppress_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `bulk_unsuppress_profiles_with_http_info`
alias unsuppress_profiles_with_http_info bulk_unsuppress_profiles_with_http_info
# alias of `bulk_unsuppress_profiles_with_http_info`
alias create_profile_suppression_bulk_delete_job_with_http_info bulk_unsuppress_profiles_with_http_info
# Create or Update Profile
# Given a set of profile attributes and optionally an ID, create or update a profile. Returns 201 if a new profile was created, 200 if an existing profile was updated. Note that setting a field to `null` will clear out the field, whereas not including a field in your request will leave it unchanged.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `profiles:write`
# @param profile_upsert_query [ProfileUpsertQuery]
# @param [Hash] opts the optional parameters
# @return [Hash]
def create_or_update_profile(profile_upsert_query, opts = {})
data, _status_code, _headers = create_or_update_profile_with_http_info(profile_upsert_query, opts)
data
end
# alias of `create_or_update_profile`
alias create_profile_import create_or_update_profile
# Create or Update Profile
# Given a set of profile attributes and optionally an ID, create or update a profile. Returns 201 if a new profile was created, 200 if an existing profile was updated. Note that setting a field to `null` will clear out the field, whereas not including a field in your request will leave it unchanged.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `profiles:write`
# @param profile_upsert_query [ProfileUpsertQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def create_or_update_profile_with_http_info(profile_upsert_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.create_or_update_profile ...'
end
# verify the required parameter 'profile_upsert_query' is set
if @api_client.config.client_side_validation && profile_upsert_query.nil?
fail ArgumentError, "Missing the required parameter 'profile_upsert_query' when calling ProfilesApi.create_or_update_profile"
end
# resource path
local_var_path = '/api/profile-import'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(profile_upsert_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 => :"ProfilesApi.create_or_update_profile",
: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: ProfilesApi#create_or_update_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `create_or_update_profile_with_http_info`
alias create_profile_import_with_http_info create_or_update_profile_with_http_info
# Create Profile
# Create a new profile.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `profiles:write`
# @param profile_create_query [ProfileCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Hash]
def create_profile(profile_create_query, opts = {})
data, _status_code, _headers = create_profile_with_http_info(profile_create_query, opts)
data
end
# Create Profile
# Create a new profile.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `profiles:write`
# @param profile_create_query [ProfileCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def create_profile_with_http_info(profile_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.create_profile ...'
end
# verify the required parameter 'profile_create_query' is set
if @api_client.config.client_side_validation && profile_create_query.nil?
fail ArgumentError, "Missing the required parameter 'profile_create_query' when calling ProfilesApi.create_profile"
end
# resource path
local_var_path = '/api/profiles'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(profile_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 => :"ProfilesApi.create_profile",
: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: ProfilesApi#create_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create or Update Push Token
# Create or update a push token. This endpoint can be used to migrate push tokens from another platform to Klaviyo. Please use our mobile SDKs ([iOS](https://github.com/klaviyo/klaviyo-swift-sdk) and [Android](https://github.com/klaviyo/klaviyo-android-sdk)) to create push tokens from users' devices.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `profiles:write` `push-tokens:write`
# @param push_token_create_query [PushTokenCreateQuery]
# @param [Hash] opts the optional parameters
# @return [nil]
def create_push_token(push_token_create_query, opts = {})
create_push_token_with_http_info(push_token_create_query, opts)
nil
end
# Create or Update Push Token
# Create or update a push token. This endpoint can be used to migrate push tokens from another platform to Klaviyo. Please use our mobile SDKs ([iOS](https://github.com/klaviyo/klaviyo-swift-sdk) and [Android](https://github.com/klaviyo/klaviyo-android-sdk)) to create push tokens from users' devices.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `profiles:write` `push-tokens:write`
# @param push_token_create_query [PushTokenCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def create_push_token_with_http_info(push_token_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.create_push_token ...'
end
# verify the required parameter 'push_token_create_query' is set
if @api_client.config.client_side_validation && push_token_create_query.nil?
fail ArgumentError, "Missing the required parameter 'push_token_create_query' when calling ProfilesApi.create_push_token"
end
# resource path
local_var_path = '/api/push-tokens'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(push_token_create_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 => :"ProfilesApi.create_push_token",
: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: ProfilesApi#create_push_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Bulk Import Profiles Job
# Get a bulk profile import job with the given job ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:read` `profiles:read`
# @param job_id [String] ID of the job to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_profile_bulk_import_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships
# @return [Hash]
def get_bulk_import_profiles_job(job_id, opts = {})
data, _status_code, _headers = get_bulk_import_profiles_job_with_http_info(job_id, opts)
data
end
# alias of `get_bulk_import_profiles_job`
alias get_bulk_profile_import_job get_bulk_import_profiles_job
# alias of `get_bulk_import_profiles_job`
alias get_profile_bulk_import_job get_bulk_import_profiles_job
# Get Bulk Import Profiles Job
# Get a bulk profile import job with the given job ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:read` `profiles:read`
# @param job_id [String] ID of the job to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_profile_bulk_import_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_bulk_import_profiles_job_with_http_info(job_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_bulk_import_profiles_job ...'
end
# verify the required parameter 'job_id' is set
if @api_client.config.client_side_validation && job_id.nil?
fail ArgumentError, "Missing the required parameter 'job_id' when calling ProfilesApi.get_bulk_import_profiles_job"
end
allowable_values = ["name", "created", "updated", "opt_in_process"]
if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_list\", must include one of #{allowable_values}"
end
allowable_values = ["status", "created_at", "total_count", "completed_count", "failed_count", "completed_at", "expires_at", "started_at"]
if @api_client.config.client_side_validation && opts[:'fields_profile_bulk_import_job'] && !opts[:'fields_profile_bulk_import_job'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile_bulk_import_job\", must include one of #{allowable_values}"
end
allowable_values = ["lists"]
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/profile-bulk-import-jobs/{job_id}'.sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].nil?
query_params[:'fields[profile-bulk-import-job]'] = @api_client.build_collection_param(opts[:'fields_profile_bulk_import_job'], :csv) if !opts[:'fields_profile_bulk_import_job'].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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_bulk_import_profiles_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: ProfilesApi#get_bulk_import_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_bulk_import_profiles_job_with_http_info`
alias get_bulk_profile_import_job_with_http_info get_bulk_import_profiles_job_with_http_info
# alias of `get_bulk_import_profiles_job_with_http_info`
alias get_profile_bulk_import_job_with_http_info get_bulk_import_profiles_job_with_http_info
# Get Bulk Import Profiles Jobs
# Get all bulk profile import jobs. Returns a maximum of 100 jobs per request.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:read` `profiles:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_bulk_import_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `any`, `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Hash]
def get_bulk_import_profiles_jobs(opts = {})
data, _status_code, _headers = get_bulk_import_profiles_jobs_with_http_info(opts)
data
end
# alias of `get_bulk_import_profiles_jobs`
alias get_bulk_profile_import_jobs get_bulk_import_profiles_jobs
# alias of `get_bulk_import_profiles_jobs`
alias get_profile_bulk_import_jobs get_bulk_import_profiles_jobs
# Get Bulk Import Profiles Jobs
# Get all bulk profile import jobs. Returns a maximum of 100 jobs per request.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:read` `profiles:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_bulk_import_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `any`, `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_bulk_import_profiles_jobs_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_bulk_import_profiles_jobs ...'
end
allowable_values = ["status", "created_at", "total_count", "completed_count", "failed_count", "completed_at", "expires_at", "started_at"]
if @api_client.config.client_side_validation && opts[:'fields_profile_bulk_import_job'] && !opts[:'fields_profile_bulk_import_job'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile_bulk_import_job\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_bulk_import_profiles_jobs, must be smaller than or equal to 100.'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_bulk_import_profiles_jobs, must be greater than or equal to 1.'
end
allowable_values = ["created_at", "-created_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/profile-bulk-import-jobs'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[profile-bulk-import-job]'] = @api_client.build_collection_param(opts[:'fields_profile_bulk_import_job'], :csv) if !opts[:'fields_profile_bulk_import_job'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_bulk_import_profiles_jobs",
: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: ProfilesApi#get_bulk_import_profiles_jobs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_bulk_import_profiles_jobs_with_http_info`
alias get_bulk_profile_import_jobs_with_http_info get_bulk_import_profiles_jobs_with_http_info
# alias of `get_bulk_import_profiles_jobs_with_http_info`
alias get_profile_bulk_import_jobs_with_http_info get_bulk_import_profiles_jobs_with_http_info
# Get Bulk Suppress Profiles Job
# Get the bulk suppress profiles job with the given job ID.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `subscriptions:read`
# @param job_id [String] ID of the job to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_create_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_bulk_suppress_profiles_job(job_id, opts = {})
data, _status_code, _headers = get_bulk_suppress_profiles_job_with_http_info(job_id, opts)
data
end
# alias of `get_bulk_suppress_profiles_job`
alias get_profile_suppression_bulk_create_job get_bulk_suppress_profiles_job
# Get Bulk Suppress Profiles Job
# Get the bulk suppress profiles job with the given job ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `subscriptions:read`
# @param job_id [String] ID of the job to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_create_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_bulk_suppress_profiles_job_with_http_info(job_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_bulk_suppress_profiles_job ...'
end
# verify the required parameter 'job_id' is set
if @api_client.config.client_side_validation && job_id.nil?
fail ArgumentError, "Missing the required parameter 'job_id' when calling ProfilesApi.get_bulk_suppress_profiles_job"
end
allowable_values = ["status", "created_at", "total_count", "completed_count", "completed_at", "skipped_count"]
if @api_client.config.client_side_validation && opts[:'fields_profile_suppression_bulk_create_job'] && !opts[:'fields_profile_suppression_bulk_create_job'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile_suppression_bulk_create_job\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/profile-suppression-bulk-create-jobs/{job_id}'.sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[profile-suppression-bulk-create-job]'] = @api_client.build_collection_param(opts[:'fields_profile_suppression_bulk_create_job'], :csv) if !opts[:'fields_profile_suppression_bulk_create_job'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_bulk_suppress_profiles_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: ProfilesApi#get_bulk_suppress_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_bulk_suppress_profiles_job_with_http_info`
alias get_profile_suppression_bulk_create_job_with_http_info get_bulk_suppress_profiles_job_with_http_info
# Get Bulk Suppress Profiles Jobs
# Get the status of all bulk profile suppression jobs.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `subscriptions:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_create_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `equals`<br>`list_id`: `equals`<br>`segment_id`: `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Hash]
def get_bulk_suppress_profiles_jobs(opts = {})
data, _status_code, _headers = get_bulk_suppress_profiles_jobs_with_http_info(opts)
data
end
# alias of `get_bulk_suppress_profiles_jobs`
alias get_profile_suppression_bulk_create_jobs get_bulk_suppress_profiles_jobs
# Get Bulk Suppress Profiles Jobs
# Get the status of all bulk profile suppression jobs.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `subscriptions:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_create_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `equals`<br>`list_id`: `equals`<br>`segment_id`: `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_bulk_suppress_profiles_jobs_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_bulk_suppress_profiles_jobs ...'
end
allowable_values = ["status", "created_at", "total_count", "completed_count", "completed_at", "skipped_count"]
if @api_client.config.client_side_validation && opts[:'fields_profile_suppression_bulk_create_job'] && !opts[:'fields_profile_suppression_bulk_create_job'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile_suppression_bulk_create_job\", must include one of #{allowable_values}"
end
allowable_values = ["created", "-created"]
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/profile-suppression-bulk-create-jobs'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[profile-suppression-bulk-create-job]'] = @api_client.build_collection_param(opts[:'fields_profile_suppression_bulk_create_job'], :csv) if !opts[:'fields_profile_suppression_bulk_create_job'].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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_bulk_suppress_profiles_jobs",
: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: ProfilesApi#get_bulk_suppress_profiles_jobs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_bulk_suppress_profiles_jobs_with_http_info`
alias get_profile_suppression_bulk_create_jobs_with_http_info get_bulk_suppress_profiles_jobs_with_http_info
# Get Bulk Unsuppress Profiles Job
# Get the bulk unsuppress profiles job with the given job ID.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `subscriptions:read`
# @param job_id [String] ID of the job to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_delete_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_bulk_unsuppress_profiles_job(job_id, opts = {})
data, _status_code, _headers = get_bulk_unsuppress_profiles_job_with_http_info(job_id, opts)
data
end
# alias of `get_bulk_unsuppress_profiles_job`
alias get_profile_suppression_bulk_delete_job get_bulk_unsuppress_profiles_job
# Get Bulk Unsuppress Profiles Job
# Get the bulk unsuppress profiles job with the given job ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `subscriptions:read`
# @param job_id [String] ID of the job to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_delete_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_bulk_unsuppress_profiles_job_with_http_info(job_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_bulk_unsuppress_profiles_job ...'
end
# verify the required parameter 'job_id' is set
if @api_client.config.client_side_validation && job_id.nil?
fail ArgumentError, "Missing the required parameter 'job_id' when calling ProfilesApi.get_bulk_unsuppress_profiles_job"
end
allowable_values = ["status", "created_at", "total_count", "completed_count", "completed_at", "skipped_count"]
if @api_client.config.client_side_validation && opts[:'fields_profile_suppression_bulk_delete_job'] && !opts[:'fields_profile_suppression_bulk_delete_job'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile_suppression_bulk_delete_job\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/profile-suppression-bulk-delete-jobs/{job_id}'.sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[profile-suppression-bulk-delete-job]'] = @api_client.build_collection_param(opts[:'fields_profile_suppression_bulk_delete_job'], :csv) if !opts[:'fields_profile_suppression_bulk_delete_job'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_bulk_unsuppress_profiles_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: ProfilesApi#get_bulk_unsuppress_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_bulk_unsuppress_profiles_job_with_http_info`
alias get_profile_suppression_bulk_delete_job_with_http_info get_bulk_unsuppress_profiles_job_with_http_info
# Get Bulk Unsuppress Profiles Jobs
# Get all bulk unsuppress profiles jobs.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `subscriptions:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_delete_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `equals`<br>`list_id`: `equals`<br>`segment_id`: `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Hash]
def get_bulk_unsuppress_profiles_jobs(opts = {})
data, _status_code, _headers = get_bulk_unsuppress_profiles_jobs_with_http_info(opts)
data
end
# alias of `get_bulk_unsuppress_profiles_jobs`
alias get_profile_suppression_bulk_delete_jobs get_bulk_unsuppress_profiles_jobs
# Get Bulk Unsuppress Profiles Jobs
# Get all bulk unsuppress profiles jobs.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `subscriptions:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_profile_suppression_bulk_delete_job For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `equals`<br>`list_id`: `equals`<br>`segment_id`: `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_bulk_unsuppress_profiles_jobs_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_bulk_unsuppress_profiles_jobs ...'
end
allowable_values = ["status", "created_at", "total_count", "completed_count", "completed_at", "skipped_count"]
if @api_client.config.client_side_validation && opts[:'fields_profile_suppression_bulk_delete_job'] && !opts[:'fields_profile_suppression_bulk_delete_job'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile_suppression_bulk_delete_job\", must include one of #{allowable_values}"
end
allowable_values = ["created", "-created"]
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/profile-suppression-bulk-delete-jobs'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[profile-suppression-bulk-delete-job]'] = @api_client.build_collection_param(opts[:'fields_profile_suppression_bulk_delete_job'], :csv) if !opts[:'fields_profile_suppression_bulk_delete_job'].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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_bulk_unsuppress_profiles_jobs",
: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: ProfilesApi#get_bulk_unsuppress_profiles_jobs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_bulk_unsuppress_profiles_jobs_with_http_info`
alias get_profile_suppression_bulk_delete_jobs_with_http_info get_bulk_unsuppress_profiles_jobs_with_http_info
# Get Errors for Bulk Import Profiles Job
# Get import errors for the bulk profile import job with the given ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_import_error For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Hash]
def get_errors_for_bulk_import_profiles_job(id, opts = {})
data, _status_code, _headers = get_errors_for_bulk_import_profiles_job_with_http_info(id, opts)
data
end
# alias of `get_errors_for_bulk_import_profiles_job`
alias get_bulk_profile_import_job_import_errors get_errors_for_bulk_import_profiles_job
# alias of `get_errors_for_bulk_import_profiles_job`
alias get_profile_bulk_import_job_import_errors get_errors_for_bulk_import_profiles_job
# Get Errors for Bulk Import Profiles Job
# Get import errors for the bulk profile import job with the given ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_import_error For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_errors_for_bulk_import_profiles_job_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_errors_for_bulk_import_profiles_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 ProfilesApi.get_errors_for_bulk_import_profiles_job"
end
allowable_values = ["code", "title", "detail", "source", "source.pointer", "original_payload"]
if @api_client.config.client_side_validation && opts[:'fields_import_error'] && !opts[:'fields_import_error'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_import_error\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_errors_for_bulk_import_profiles_job, must be smaller than or equal to 100.'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_errors_for_bulk_import_profiles_job, must be greater than or equal to 1.'
end
# resource path
local_var_path = '/api/profile-bulk-import-jobs/{id}/import-errors'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[import-error]'] = @api_client.build_collection_param(opts[:'fields_import_error'], :csv) if !opts[:'fields_import_error'].nil?
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_errors_for_bulk_import_profiles_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: ProfilesApi#get_errors_for_bulk_import_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_errors_for_bulk_import_profiles_job_with_http_info`
alias get_bulk_profile_import_job_import_errors_with_http_info get_errors_for_bulk_import_profiles_job_with_http_info
# alias of `get_errors_for_bulk_import_profiles_job_with_http_info`
alias get_profile_bulk_import_job_import_errors_with_http_info get_errors_for_bulk_import_profiles_job_with_http_info
# Get List for Bulk Import Profiles Job
# Get list for the bulk profile import job with the given ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_list_for_bulk_import_profiles_job(id, opts = {})
data, _status_code, _headers = get_list_for_bulk_import_profiles_job_with_http_info(id, opts)
data
end
# alias of `get_list_for_bulk_import_profiles_job`
alias get_bulk_profile_import_job_lists get_list_for_bulk_import_profiles_job
# alias of `get_list_for_bulk_import_profiles_job`
alias get_profile_bulk_import_job_lists get_list_for_bulk_import_profiles_job
# Get List for Bulk Import Profiles Job
# Get list for the bulk profile import job with the given ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_list_for_bulk_import_profiles_job_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_list_for_bulk_import_profiles_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 ProfilesApi.get_list_for_bulk_import_profiles_job"
end
allowable_values = ["name", "created", "updated", "opt_in_process"]
if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_list\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/profile-bulk-import-jobs/{id}/lists'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_list_for_bulk_import_profiles_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: ProfilesApi#get_list_for_bulk_import_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_list_for_bulk_import_profiles_job_with_http_info`
alias get_bulk_profile_import_job_lists_with_http_info get_list_for_bulk_import_profiles_job_with_http_info
# alias of `get_list_for_bulk_import_profiles_job_with_http_info`
alias get_profile_bulk_import_job_lists_with_http_info get_list_for_bulk_import_profiles_job_with_http_info
# Get List IDs for Bulk Import Profiles Job
# Get list relationship for the bulk profile import job with the given ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [Hash]
def get_list_ids_for_bulk_import_profiles_job(id, opts = {})
data, _status_code, _headers = get_list_ids_for_bulk_import_profiles_job_with_http_info(id, opts)
data
end
# alias of `get_list_ids_for_bulk_import_profiles_job`
alias get_bulk_profile_import_job_relationships_lists get_list_ids_for_bulk_import_profiles_job
# alias of `get_list_ids_for_bulk_import_profiles_job`
alias get_profile_bulk_import_job_relationships_lists get_list_ids_for_bulk_import_profiles_job
# Get List IDs for Bulk Import Profiles Job
# Get list relationship for the bulk profile import job with the given ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists: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_list_ids_for_bulk_import_profiles_job_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_list_ids_for_bulk_import_profiles_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 ProfilesApi.get_list_ids_for_bulk_import_profiles_job"
end
# resource path
local_var_path = '/api/profile-bulk-import-jobs/{id}/relationships/lists'.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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_list_ids_for_bulk_import_profiles_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: ProfilesApi#get_list_ids_for_bulk_import_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_list_ids_for_bulk_import_profiles_job_with_http_info`
alias get_bulk_profile_import_job_relationships_lists_with_http_info get_list_ids_for_bulk_import_profiles_job_with_http_info
# alias of `get_list_ids_for_bulk_import_profiles_job_with_http_info`
alias get_profile_bulk_import_job_relationships_lists_with_http_info get_list_ids_for_bulk_import_profiles_job_with_http_info
# Get List IDs for Profile
# Get list memberships for a profile with the given profile ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [Hash]
def get_list_ids_for_profile(id, opts = {})
data, _status_code, _headers = get_list_ids_for_profile_with_http_info(id, opts)
data
end
# alias of `get_list_ids_for_profile`
alias get_profile_relationships_lists get_list_ids_for_profile
# Get List IDs for Profile
# Get list memberships for a profile with the given profile ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:read` `profiles: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_list_ids_for_profile_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_list_ids_for_profile ...'
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 ProfilesApi.get_list_ids_for_profile"
end
# resource path
local_var_path = '/api/profiles/{id}/relationships/lists'.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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_list_ids_for_profile",
: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: ProfilesApi#get_list_ids_for_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_list_ids_for_profile_with_http_info`
alias get_profile_relationships_lists_with_http_info get_list_ids_for_profile_with_http_info
# Get Lists for Profile
# Get list memberships for a profile with the given profile ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_lists_for_profile(id, opts = {})
data, _status_code, _headers = get_lists_for_profile_with_http_info(id, opts)
data
end
# alias of `get_lists_for_profile`
alias get_profile_lists get_lists_for_profile
# Get Lists for Profile
# Get list memberships for a profile with the given profile ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_lists_for_profile_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_lists_for_profile ...'
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 ProfilesApi.get_lists_for_profile"
end
allowable_values = ["name", "created", "updated", "opt_in_process"]
if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_list\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/profiles/{id}/lists'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_lists_for_profile",
: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: ProfilesApi#get_lists_for_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_lists_for_profile_with_http_info`
alias get_profile_lists_with_http_info get_lists_for_profile_with_http_info
# Get Profile
# Get the profile with the given profile ID.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics'
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships
# @return [Hash]
def get_profile(id, opts = {})
data, _status_code, _headers = get_profile_with_http_info(id, opts)
data
end
# Get Profile
# Get the profile with the given profile ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics'
# @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_profile_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_profile ...'
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 ProfilesApi.get_profile"
end
allowable_values = ["subscriptions", "predictive_analytics"]
if @api_client.config.client_side_validation && opts[:'additional_fields_profile'] && !opts[:'additional_fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"additional_fields_profile\", must include one of #{allowable_values}"
end
allowable_values = ["name", "created", "updated", "opt_in_process"]
if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_list\", must include one of #{allowable_values}"
end
allowable_values = ["email", "phone_number", "external_id", "first_name", "last_name", "organization", "locale", "title", "image", "created", "updated", "last_event_date", "location", "location.address1", "location.address2", "location.city", "location.country", "location.latitude", "location.longitude", "location.region", "location.zip", "location.timezone", "location.ip", "properties", "subscriptions", "subscriptions.email", "subscriptions.email.marketing", "subscriptions.email.marketing.can_receive_email_marketing", "subscriptions.email.marketing.consent", "subscriptions.email.marketing.consent_timestamp", "subscriptions.email.marketing.last_updated", "subscriptions.email.marketing.method", "subscriptions.email.marketing.method_detail", "subscriptions.email.marketing.custom_method_detail", "subscriptions.email.marketing.double_optin", "subscriptions.email.marketing.suppression", "subscriptions.email.marketing.list_suppressions", "subscriptions.sms", "subscriptions.sms.marketing", "subscriptions.sms.marketing.can_receive_sms_marketing", "subscriptions.sms.marketing.consent", "subscriptions.sms.marketing.consent_timestamp", "subscriptions.sms.marketing.method", "subscriptions.sms.marketing.method_detail", "subscriptions.sms.marketing.last_updated", "subscriptions.sms.transactional", "subscriptions.sms.transactional.can_receive_sms_transactional", "subscriptions.sms.transactional.consent", "subscriptions.sms.transactional.consent_timestamp", "subscriptions.sms.transactional.method", "subscriptions.sms.transactional.method_detail", "subscriptions.sms.transactional.last_updated", "subscriptions.mobile_push", "subscriptions.mobile_push.marketing", "subscriptions.mobile_push.marketing.can_receive_push_marketing", "subscriptions.mobile_push.marketing.consent", "subscriptions.mobile_push.marketing.consent_timestamp", "predictive_analytics", "predictive_analytics.historic_clv", "predictive_analytics.predicted_clv", "predictive_analytics.total_clv", "predictive_analytics.historic_number_of_orders", "predictive_analytics.predicted_number_of_orders", "predictive_analytics.average_days_between_orders", "predictive_analytics.average_order_value", "predictive_analytics.churn_probability", "predictive_analytics.expected_date_of_next_order"]
if @api_client.config.client_side_validation && opts[:'fields_profile'] && !opts[:'fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile\", must include one of #{allowable_values}"
end
allowable_values = ["name", "definition", "definition.condition_groups", "created", "updated", "is_active", "is_processing", "is_starred"]
if @api_client.config.client_side_validation && opts[:'fields_segment'] && !opts[:'fields_segment'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_segment\", must include one of #{allowable_values}"
end
allowable_values = ["lists", "segments"]
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/profiles/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'additional-fields[profile]'] = @api_client.build_collection_param(opts[:'additional_fields_profile'], :csv) if !opts[:'additional_fields_profile'].nil?
query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].nil?
query_params[:'fields[profile]'] = @api_client.build_collection_param(opts[:'fields_profile'], :csv) if !opts[:'fields_profile'].nil?
query_params[:'fields[segment]'] = @api_client.build_collection_param(opts[:'fields_segment'], :csv) if !opts[:'fields_segment'].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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_profile",
: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: ProfilesApi#get_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Profile IDs for Bulk Import Profiles Job
# Get profile relationships for the bulk profile import job with the given ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Hash]
def get_profile_ids_for_bulk_import_profiles_job(id, opts = {})
data, _status_code, _headers = get_profile_ids_for_bulk_import_profiles_job_with_http_info(id, opts)
data
end
# alias of `get_profile_ids_for_bulk_import_profiles_job`
alias get_bulk_profile_import_job_relationships_profiles get_profile_ids_for_bulk_import_profiles_job
# alias of `get_profile_ids_for_bulk_import_profiles_job`
alias get_profile_bulk_import_job_relationships_profiles get_profile_ids_for_bulk_import_profiles_job
# Get Profile IDs for Bulk Import Profiles Job
# Get profile relationships for the bulk profile import job with the given ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_profile_ids_for_bulk_import_profiles_job_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_profile_ids_for_bulk_import_profiles_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 ProfilesApi.get_profile_ids_for_bulk_import_profiles_job"
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_profile_ids_for_bulk_import_profiles_job, must be smaller than or equal to 100.'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_profile_ids_for_bulk_import_profiles_job, must be greater than or equal to 1.'
end
# resource path
local_var_path = '/api/profile-bulk-import-jobs/{id}/relationships/profiles'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_profile_ids_for_bulk_import_profiles_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: ProfilesApi#get_profile_ids_for_bulk_import_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_profile_ids_for_bulk_import_profiles_job_with_http_info`
alias get_bulk_profile_import_job_relationships_profiles_with_http_info get_profile_ids_for_bulk_import_profiles_job_with_http_info
# alias of `get_profile_ids_for_bulk_import_profiles_job_with_http_info`
alias get_profile_bulk_import_job_relationships_profiles_with_http_info get_profile_ids_for_bulk_import_profiles_job_with_http_info
# Get Profiles
# Get all profiles in an account. Profiles can be sorted by the following fields in ascending and descending order: `id`, `created`, `updated`, `email`, `subscriptions.email.marketing.suppression.timestamp`, `subscriptions.email.marketing.list_suppressions.timestamp`
*Rate limits*:
Burst: `75/s`
Steady: `700/m`
Rate limits when using the `additional-fields[profile]=predictive_analytics` parameter in your API request:
Burst: `10/s`
Steady: `150/m`
To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide. **Scopes:** `profiles:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics'
# @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`external_id`: `any`, `equals`<br>`_kx`: `equals`<br>`created`: `greater-than`, `less-than`<br>`updated`: `greater-than`, `less-than`<br>`subscriptions.email.marketing.list_suppressions.reason`: `equals`<br>`subscriptions.email.marketing.list_suppressions.timestamp`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`subscriptions.email.marketing.list_suppressions.list_id`: `equals`<br>`subscriptions.email.marketing.suppression.reason`: `equals`<br>`subscriptions.email.marketing.suppression.timestamp`: `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/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Hash]
def get_profiles(opts = {})
data, _status_code, _headers = get_profiles_with_http_info(opts)
data
end
# Get Profiles
# Get all profiles in an account. Profiles can be sorted by the following fields in ascending and descending order: `id`, `created`, `updated`, `email`, `subscriptions.email.marketing.suppression.timestamp`, `subscriptions.email.marketing.list_suppressions.timestamp`<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m`<br><br>Rate limits when using the `additional-fields[profile]=predictive_analytics` parameter in your API request:<br>Burst: `10/s`<br>Steady: `150/m`<br><br>To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide. **Scopes:** `profiles:read`
# @param [Hash] opts the optional parameters
# @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics'
# @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`external_id`: `any`, `equals`<br>`_kx`: `equals`<br>`created`: `greater-than`, `less-than`<br>`updated`: `greater-than`, `less-than`<br>`subscriptions.email.marketing.list_suppressions.reason`: `equals`<br>`subscriptions.email.marketing.list_suppressions.timestamp`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`subscriptions.email.marketing.list_suppressions.list_id`: `equals`<br>`subscriptions.email.marketing.suppression.reason`: `equals`<br>`subscriptions.email.marketing.suppression.timestamp`: `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/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_profiles_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_profiles ...'
end
allowable_values = ["subscriptions", "predictive_analytics"]
if @api_client.config.client_side_validation && opts[:'additional_fields_profile'] && !opts[:'additional_fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"additional_fields_profile\", must include one of #{allowable_values}"
end
allowable_values = ["email", "phone_number", "external_id", "first_name", "last_name", "organization", "locale", "title", "image", "created", "updated", "last_event_date", "location", "location.address1", "location.address2", "location.city", "location.country", "location.latitude", "location.longitude", "location.region", "location.zip", "location.timezone", "location.ip", "properties", "subscriptions", "subscriptions.email", "subscriptions.email.marketing", "subscriptions.email.marketing.can_receive_email_marketing", "subscriptions.email.marketing.consent", "subscriptions.email.marketing.consent_timestamp", "subscriptions.email.marketing.last_updated", "subscriptions.email.marketing.method", "subscriptions.email.marketing.method_detail", "subscriptions.email.marketing.custom_method_detail", "subscriptions.email.marketing.double_optin", "subscriptions.email.marketing.suppression", "subscriptions.email.marketing.list_suppressions", "subscriptions.sms", "subscriptions.sms.marketing", "subscriptions.sms.marketing.can_receive_sms_marketing", "subscriptions.sms.marketing.consent", "subscriptions.sms.marketing.consent_timestamp", "subscriptions.sms.marketing.method", "subscriptions.sms.marketing.method_detail", "subscriptions.sms.marketing.last_updated", "subscriptions.sms.transactional", "subscriptions.sms.transactional.can_receive_sms_transactional", "subscriptions.sms.transactional.consent", "subscriptions.sms.transactional.consent_timestamp", "subscriptions.sms.transactional.method", "subscriptions.sms.transactional.method_detail", "subscriptions.sms.transactional.last_updated", "subscriptions.mobile_push", "subscriptions.mobile_push.marketing", "subscriptions.mobile_push.marketing.can_receive_push_marketing", "subscriptions.mobile_push.marketing.consent", "subscriptions.mobile_push.marketing.consent_timestamp", "predictive_analytics", "predictive_analytics.historic_clv", "predictive_analytics.predicted_clv", "predictive_analytics.total_clv", "predictive_analytics.historic_number_of_orders", "predictive_analytics.predicted_number_of_orders", "predictive_analytics.average_days_between_orders", "predictive_analytics.average_order_value", "predictive_analytics.churn_probability", "predictive_analytics.expected_date_of_next_order"]
if @api_client.config.client_side_validation && opts[:'fields_profile'] && !opts[:'fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_profiles, must be smaller than or equal to 100.'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_profiles, must be greater than or equal to 1.'
end
allowable_values = ["created", "-created", "email", "-email", "id", "-id", "updated", "-updated", "subscriptions.email.marketing.list_suppressions.timestamp", "-subscriptions.email.marketing.list_suppressions.timestamp", "subscriptions.email.marketing.suppression.timestamp", "-subscriptions.email.marketing.suppression.timestamp"]
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/profiles'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'additional-fields[profile]'] = @api_client.build_collection_param(opts[:'additional_fields_profile'], :csv) if !opts[:'additional_fields_profile'].nil?
query_params[:'fields[profile]'] = @api_client.build_collection_param(opts[:'fields_profile'], :csv) if !opts[:'fields_profile'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_profiles",
: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: ProfilesApi#get_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Profiles for Bulk Import Profiles Job
# Get profiles for the bulk profile import job with the given ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics'
# @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Hash]
def get_profiles_for_bulk_import_profiles_job(id, opts = {})
data, _status_code, _headers = get_profiles_for_bulk_import_profiles_job_with_http_info(id, opts)
data
end
# alias of `get_profiles_for_bulk_import_profiles_job`
alias get_bulk_profile_import_job_profiles get_profiles_for_bulk_import_profiles_job
# alias of `get_profiles_for_bulk_import_profiles_job`
alias get_profile_bulk_import_job_profiles get_profiles_for_bulk_import_profiles_job
# Get Profiles for Bulk Import Profiles Job
# Get profiles for the bulk profile import job with the given ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics'
# @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_profiles_for_bulk_import_profiles_job_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_profiles_for_bulk_import_profiles_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 ProfilesApi.get_profiles_for_bulk_import_profiles_job"
end
allowable_values = ["subscriptions", "predictive_analytics"]
if @api_client.config.client_side_validation && opts[:'additional_fields_profile'] && !opts[:'additional_fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"additional_fields_profile\", must include one of #{allowable_values}"
end
allowable_values = ["email", "phone_number", "external_id", "first_name", "last_name", "organization", "locale", "title", "image", "created", "updated", "last_event_date", "location", "location.address1", "location.address2", "location.city", "location.country", "location.latitude", "location.longitude", "location.region", "location.zip", "location.timezone", "location.ip", "properties", "subscriptions", "subscriptions.email", "subscriptions.email.marketing", "subscriptions.email.marketing.can_receive_email_marketing", "subscriptions.email.marketing.consent", "subscriptions.email.marketing.consent_timestamp", "subscriptions.email.marketing.last_updated", "subscriptions.email.marketing.method", "subscriptions.email.marketing.method_detail", "subscriptions.email.marketing.custom_method_detail", "subscriptions.email.marketing.double_optin", "subscriptions.email.marketing.suppression", "subscriptions.email.marketing.list_suppressions", "subscriptions.sms", "subscriptions.sms.marketing", "subscriptions.sms.marketing.can_receive_sms_marketing", "subscriptions.sms.marketing.consent", "subscriptions.sms.marketing.consent_timestamp", "subscriptions.sms.marketing.method", "subscriptions.sms.marketing.method_detail", "subscriptions.sms.marketing.last_updated", "subscriptions.sms.transactional", "subscriptions.sms.transactional.can_receive_sms_transactional", "subscriptions.sms.transactional.consent", "subscriptions.sms.transactional.consent_timestamp", "subscriptions.sms.transactional.method", "subscriptions.sms.transactional.method_detail", "subscriptions.sms.transactional.last_updated", "subscriptions.mobile_push", "subscriptions.mobile_push.marketing", "subscriptions.mobile_push.marketing.can_receive_push_marketing", "subscriptions.mobile_push.marketing.consent", "subscriptions.mobile_push.marketing.consent_timestamp", "predictive_analytics", "predictive_analytics.historic_clv", "predictive_analytics.predicted_clv", "predictive_analytics.total_clv", "predictive_analytics.historic_number_of_orders", "predictive_analytics.predicted_number_of_orders", "predictive_analytics.average_days_between_orders", "predictive_analytics.average_order_value", "predictive_analytics.churn_probability", "predictive_analytics.expected_date_of_next_order"]
if @api_client.config.client_side_validation && opts[:'fields_profile'] && !opts[:'fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_profiles_for_bulk_import_profiles_job, must be smaller than or equal to 100.'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ProfilesApi.get_profiles_for_bulk_import_profiles_job, must be greater than or equal to 1.'
end
# resource path
local_var_path = '/api/profile-bulk-import-jobs/{id}/profiles'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'additional-fields[profile]'] = @api_client.build_collection_param(opts[:'additional_fields_profile'], :csv) if !opts[:'additional_fields_profile'].nil?
query_params[:'fields[profile]'] = @api_client.build_collection_param(opts[:'fields_profile'], :csv) if !opts[:'fields_profile'].nil?
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_profiles_for_bulk_import_profiles_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: ProfilesApi#get_profiles_for_bulk_import_profiles_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_profiles_for_bulk_import_profiles_job_with_http_info`
alias get_bulk_profile_import_job_profiles_with_http_info get_profiles_for_bulk_import_profiles_job_with_http_info
# alias of `get_profiles_for_bulk_import_profiles_job_with_http_info`
alias get_profile_bulk_import_job_profiles_with_http_info get_profiles_for_bulk_import_profiles_job_with_http_info
# Get Segment IDs for Profile
# Get segment membership relationships for a profile with the given profile ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `profiles:read` `segments:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [Hash]
def get_segment_ids_for_profile(id, opts = {})
data, _status_code, _headers = get_segment_ids_for_profile_with_http_info(id, opts)
data
end
# alias of `get_segment_ids_for_profile`
alias get_profile_relationships_segments get_segment_ids_for_profile
# Get Segment IDs for Profile
# Get segment membership relationships for a profile with the given profile ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `profiles:read` `segments: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_segment_ids_for_profile_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_segment_ids_for_profile ...'
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 ProfilesApi.get_segment_ids_for_profile"
end
# resource path
local_var_path = '/api/profiles/{id}/relationships/segments'.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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_segment_ids_for_profile",
: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: ProfilesApi#get_segment_ids_for_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_segment_ids_for_profile_with_http_info`
alias get_profile_relationships_segments_with_http_info get_segment_ids_for_profile_with_http_info
# Get Segments for Profile
# Get segment memberships for a profile with the given profile ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `profiles:read` `segments:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Hash]
def get_segments_for_profile(id, opts = {})
data, _status_code, _headers = get_segments_for_profile_with_http_info(id, opts)
data
end
# alias of `get_segments_for_profile`
alias get_profile_segments get_segments_for_profile
# Get Segments for Profile
# Get segment memberships for a profile with the given profile ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `profiles:read` `segments:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def get_segments_for_profile_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.get_segments_for_profile ...'
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 ProfilesApi.get_segments_for_profile"
end
allowable_values = ["name", "definition", "definition.condition_groups", "created", "updated", "is_active", "is_processing", "is_starred"]
if @api_client.config.client_side_validation && opts[:'fields_segment'] && !opts[:'fields_segment'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_segment\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/profiles/{id}/segments'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[segment]'] = @api_client.build_collection_param(opts[:'fields_segment'], :csv) if !opts[:'fields_segment'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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 => :"ProfilesApi.get_segments_for_profile",
: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: ProfilesApi#get_segments_for_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `get_segments_for_profile_with_http_info`
alias get_profile_segments_with_http_info get_segments_for_profile_with_http_info
# Merge Profiles
# Merge a given related profile into a profile with the given profile ID. The profile provided under `relationships` (the \"source\" profile) will be merged into the profile provided by the ID in the base data object (the \"destination\" profile). This endpoint queues an asynchronous task which will merge data from the source profile into the destination profile, deleting the source profile in the process. This endpoint accepts only one source profile. To learn more about how profile data is preserved or overwritten during a merge, please [visit our Help Center](https://help.klaviyo.com/hc/en-us/articles/115005073847#merge-2-profiles3).
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `profiles:write`
# @param profile_merge_query [ProfileMergeQuery]
# @param [Hash] opts the optional parameters
# @return [Hash]
def merge_profiles(profile_merge_query, opts = {})
data, _status_code, _headers = merge_profiles_with_http_info(profile_merge_query, opts)
data
end
# alias of `merge_profiles`
alias create_profile_merge merge_profiles
# Merge Profiles
# Merge a given related profile into a profile with the given profile ID. The profile provided under `relationships` (the \"source\" profile) will be merged into the profile provided by the ID in the base data object (the \"destination\" profile). This endpoint queues an asynchronous task which will merge data from the source profile into the destination profile, deleting the source profile in the process. This endpoint accepts only one source profile. To learn more about how profile data is preserved or overwritten during a merge, please [visit our Help Center](https://help.klaviyo.com/hc/en-us/articles/115005073847#merge-2-profiles3).<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `profiles:write`
# @param profile_merge_query [ProfileMergeQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def merge_profiles_with_http_info(profile_merge_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.merge_profiles ...'
end
# verify the required parameter 'profile_merge_query' is set
if @api_client.config.client_side_validation && profile_merge_query.nil?
fail ArgumentError, "Missing the required parameter 'profile_merge_query' when calling ProfilesApi.merge_profiles"
end
# resource path
local_var_path = '/api/profile-merge'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(profile_merge_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 => :"ProfilesApi.merge_profiles",
: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: ProfilesApi#merge_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `merge_profiles_with_http_info`
alias create_profile_merge_with_http_info merge_profiles_with_http_info
# Spawn Bulk Profile Import Job
# Create a bulk profile import job to create or update a batch of profiles. Accepts up to 10,000 profiles per request. The maximum allowed payload size is 5MB. To learn more, see our [Bulk Profile Import API guide](https://developers.klaviyo.com/en/docs/use_klaviyos_bulk_profile_import_api).
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:write` `profiles:write`
# @param profile_import_job_create_query [ProfileImportJobCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Hash]
def spawn_bulk_profile_import_job(profile_import_job_create_query, opts = {})
data, _status_code, _headers = spawn_bulk_profile_import_job_with_http_info(profile_import_job_create_query, opts)
data
end
# alias of `spawn_bulk_profile_import_job`
alias bulk_import_profiles spawn_bulk_profile_import_job
# alias of `spawn_bulk_profile_import_job`
alias create_profile_bulk_import_job spawn_bulk_profile_import_job
# Spawn Bulk Profile Import Job
# Create a bulk profile import job to create or update a batch of profiles. Accepts up to 10,000 profiles per request. The maximum allowed payload size is 5MB. To learn more, see our [Bulk Profile Import API guide](https://developers.klaviyo.com/en/docs/use_klaviyos_bulk_profile_import_api).<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:write` `profiles:write`
# @param profile_import_job_create_query [ProfileImportJobCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def spawn_bulk_profile_import_job_with_http_info(profile_import_job_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.spawn_bulk_profile_import_job ...'
end
# verify the required parameter 'profile_import_job_create_query' is set
if @api_client.config.client_side_validation && profile_import_job_create_query.nil?
fail ArgumentError, "Missing the required parameter 'profile_import_job_create_query' when calling ProfilesApi.spawn_bulk_profile_import_job"
end
# resource path
local_var_path = '/api/profile-bulk-import-jobs'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(profile_import_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 => :"ProfilesApi.spawn_bulk_profile_import_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: ProfilesApi#spawn_bulk_profile_import_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# alias of `spawn_bulk_profile_import_job_with_http_info`
alias bulk_import_profiles_with_http_info spawn_bulk_profile_import_job_with_http_info
# alias of `spawn_bulk_profile_import_job_with_http_info`
alias create_profile_bulk_import_job_with_http_info spawn_bulk_profile_import_job_with_http_info
# Update Profile
# Update the profile with the given profile ID. Note that setting a field to `null` will clear out the field, whereas not including a field in your request will leave it unchanged.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `profiles:write`
# @param id [String] Primary key that uniquely identifies this profile. Generated by Klaviyo.
# @param profile_partial_update_query [ProfilePartialUpdateQuery]
# @param [Hash] opts the optional parameters
# @return [Hash]
def update_profile(id, profile_partial_update_query, opts = {})
data, _status_code, _headers = update_profile_with_http_info(id, profile_partial_update_query, opts)
data
end
# Update Profile
# Update the profile with the given profile ID. Note that setting a field to `null` will clear out the field, whereas not including a field in your request will leave it unchanged.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `profiles:write`
# @param id [String] Primary key that uniquely identifies this profile. Generated by Klaviyo.
# @param profile_partial_update_query [ProfilePartialUpdateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers
def update_profile_with_http_info(id, profile_partial_update_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ProfilesApi.update_profile ...'
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 ProfilesApi.update_profile"
end
# verify the required parameter 'profile_partial_update_query' is set
if @api_client.config.client_side_validation && profile_partial_update_query.nil?
fail ArgumentError, "Missing the required parameter 'profile_partial_update_query' when calling ProfilesApi.update_profile"
end
# resource path
local_var_path = '/api/profiles/{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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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(profile_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 => :"ProfilesApi.update_profile",
: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: ProfilesApi#update_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end