=begin #Klaviyo API #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. The version of the OpenAPI document: 2023-02-22 Contact: developers@klaviyo.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module KlaviyoAPI class ProfilesApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Profile # Create a new profile. If you use a phone number as the profile identifier and SMS is not set up in the Klaviyo account, you'll need to include at least one other identifier attribute (`email` or `external_id`) in addition to the `phone_number` attribute for the API call to work.

*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. If you use a phone number as the profile identifier and SMS is not set up in the Klaviyo account, you'll need to include at least one other identifier attribute (`email` or `external_id`) in addition to the `phone_number` attribute for the API call to work.<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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(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 # Get Profile # Get the profile with the given profile ID. Include parameters can be provided to get the following related resource data: `lists` memberships, `segments` memberships\"

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `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/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships # @return [Hash] def get_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. Include parameters can be provided to get the following related resource data: `lists` memberships, `segments` memberships\"<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `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/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_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 = ["name", "created", "updated"] 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", "anonymous_id", "first_name", "last_name", "organization", "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", "properties"] 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", "created", "updated"] 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[:'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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"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 Lists # Get list memberships for a profile with the given profile ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `List Read` `Profiles Read` # @param profile_id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @return [Hash] def get_profile_lists(profile_id, opts = {}) data, _status_code, _headers = get_profile_lists_with_http_info(profile_id, opts) data end # Get Profile Lists # Get list memberships for a profile with the given profile ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `List Read` `Profiles Read` # @param profile_id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_profile_lists_with_http_info(profile_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.get_profile_lists ...' end # verify the required parameter 'profile_id' is set if @api_client.config.client_side_validation && profile_id.nil? fail ArgumentError, "Missing the required parameter 'profile_id' when calling ProfilesApi.get_profile_lists" end allowable_values = ["name", "created", "updated"] 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/{profile_id}/lists/'.sub('{' + 'profile_id' + '}', CGI.escape(profile_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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"ProfilesApi.get_profile_lists", :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_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Profile Relationships # Get list membership or segment membership relationships for a profile with the given profile ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Lists Read` `Profiles Read` `Segments Read` # @param id [String] # @param related_resource [String] # @param [Hash] opts the optional parameters # @return [Hash] def get_profile_relationships(id, related_resource, opts = {}) data, _status_code, _headers = get_profile_relationships_with_http_info(id, related_resource, opts) data end # Get Profile Relationships # Get list membership or segment membership relationships 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` `Segments Read` # @param id [String] # @param related_resource [String] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_profile_relationships_with_http_info(id, related_resource, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.get_profile_relationships ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ProfilesApi.get_profile_relationships" end # verify the required parameter 'related_resource' is set if @api_client.config.client_side_validation && related_resource.nil? fail ArgumentError, "Missing the required parameter 'related_resource' when calling ProfilesApi.get_profile_relationships" end # verify enum value allowable_values = ["lists", "segments"] if @api_client.config.client_side_validation && !allowable_values.include?(related_resource) fail ArgumentError, "invalid value for \"related_resource\", must be one of #{allowable_values}" end # resource path local_var_path = '/api/profiles/{id}/relationships/{related_resource}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'related_resource' + '}', CGI.escape(related_resource.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"ProfilesApi.get_profile_relationships", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ProfilesApi#get_profile_relationships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Profile Segments # 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 profile_id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @return [Hash] def get_profile_segments(profile_id, opts = {}) data, _status_code, _headers = get_profile_segments_with_http_info(profile_id, opts) data end # Get Profile Segments # 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 profile_id [String] # @param [Hash] opts the optional parameters # @option opts [Array] :fields_segment For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_profile_segments_with_http_info(profile_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.get_profile_segments ...' end # verify the required parameter 'profile_id' is set if @api_client.config.client_side_validation && profile_id.nil? fail ArgumentError, "Missing the required parameter 'profile_id' when calling ProfilesApi.get_profile_segments" end allowable_values = ["name", "created", "updated"] 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/{profile_id}/segments/'.sub('{' + 'profile_id' + '}', CGI.escape(profile_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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"ProfilesApi.get_profile_segments", :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_segments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Profiles # Get all profiles in an account. Profiles can be sorted by the following fields in ascending and descending order: `id`, `created`, `email` You can adjust the number of results per page via the `page[size]` query parameter, e.g. `?page[size]=25`. **Default**: 20. **Max**: 100.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `Profiles Read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`external_id`: `any`, `equals`<br>`anonymous_id`: `any`, `equals`<br>`_kx`: `equals`<br>`created`: `greater-than`, `less-than` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting # @return [Hash] def get_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`, `email` You can adjust the number of results per page via the `page[size]` query parameter, e.g. `?page[size]=25`. **Default**: 20. **Max**: 100.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `Profiles Read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`external_id`: `any`, `equals`<br>`anonymous_id`: `any`, `equals`<br>`_kx`: `equals`<br>`created`: `greater-than`, `less-than` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_profiles_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.get_profiles ...' end allowable_values = ["email", "phone_number", "external_id", "anonymous_id", "first_name", "last_name", "organization", "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", "properties"] 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 = ["created", "-created", "email", "-email", "id", "-id"] 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[:'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[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key'] new_options = opts.merge( :operation => :"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 # Subscribe Profiles # Subscribe one or more profiles to email marketing, SMS marketing, or both. If the 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. 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). Maximum number of profile can be submitted for subscription: 100

*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `List 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 subscribe_profiles(subscription_create_job_create_query, opts = {}) subscribe_profiles_with_http_info(subscription_create_job_create_query, opts) nil end # Subscribe Profiles # Subscribe one or more profiles to email marketing, SMS marketing, or both. If the 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. 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). Maximum number of profile can be submitted for subscription: 100<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `List 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 subscribe_profiles_with_http_info(subscription_create_job_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.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.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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(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.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#subscribe_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Suppress Profiles # Manually suppress one or more profiles. Manually suppressed profiles will not receive email marketing. Not supported for SMS marketing. Maximum number of profile can be submitted for suppression: 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 [nil] def suppress_profiles(suppression_create_job_create_query, opts = {}) suppress_profiles_with_http_info(suppression_create_job_create_query, opts) nil end # Suppress Profiles # Manually suppress one or more profiles. Manually suppressed profiles will not receive email marketing. Not supported for SMS marketing. Maximum number of profile can be submitted for suppression: 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<(nil, Integer, Hash)>] nil, response status code and response headers def suppress_profiles_with_http_info(suppression_create_job_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.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.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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(suppression_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.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#suppress_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Unsubscribe Profiles # Unsubscribe one or more profiles to email marketing, SMS marketing, or both. 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:** `List Write` `Profiles Write` `Subscriptions Write` # @param unsubscription_create_job_create_query [UnsubscriptionCreateJobCreateQuery] 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 unsubscribe_profiles(unsubscription_create_job_create_query, opts = {}) unsubscribe_profiles_with_http_info(unsubscription_create_job_create_query, opts) nil end # Unsubscribe Profiles # Unsubscribe one or more profiles to email marketing, SMS marketing, or both. 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:** `List Write` `Profiles Write` `Subscriptions Write` # @param unsubscription_create_job_create_query [UnsubscriptionCreateJobCreateQuery] 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 unsubscribe_profiles_with_http_info(unsubscription_create_job_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.unsubscribe_profiles ...' end # verify the required parameter 'unsubscription_create_job_create_query' is set if @api_client.config.client_side_validation && unsubscription_create_job_create_query.nil? fail ArgumentError, "Missing the required parameter 'unsubscription_create_job_create_query' when calling ProfilesApi.unsubscribe_profiles" end # resource path local_var_path = '/api/profile-unsubscription-bulk-create-jobs/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(unsubscription_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.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#unsubscribe_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Unsuppress Profiles # Unsuppress one or more profiles. Unsuppressed profiles will receive email marketing. Not supported for SMS marketing. Profiles suppressed due to a hard bounced email will not be unsuppressed. Maximum number of profile can be submitted for unsuppression: 100

*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `Subscriptions Write` # @param unsuppression_create_job_create_query [UnsuppressionCreateJobCreateQuery] 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 [nil] def unsuppress_profiles(unsuppression_create_job_create_query, opts = {}) unsuppress_profiles_with_http_info(unsuppression_create_job_create_query, opts) nil end # Unsuppress Profiles # Unsuppress one or more profiles. Unsuppressed profiles will receive email marketing. Not supported for SMS marketing. Profiles suppressed due to a hard bounced email will not be unsuppressed. Maximum number of profile can be submitted for unsuppression: 100<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `Subscriptions Write` # @param unsuppression_create_job_create_query [UnsuppressionCreateJobCreateQuery] 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<(nil, Integer, Hash)>] nil, response status code and response headers def unsuppress_profiles_with_http_info(unsuppression_create_job_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProfilesApi.unsuppress_profiles ...' end # verify the required parameter 'unsuppression_create_job_create_query' is set if @api_client.config.client_side_validation && unsuppression_create_job_create_query.nil? fail ArgumentError, "Missing the required parameter 'unsuppression_create_job_create_query' when calling ProfilesApi.unsuppress_profiles" end # resource path local_var_path = '/api/profile-unsuppression-bulk-create-jobs/' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(unsuppression_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.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#unsuppress_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Profile # Update the profile with the given profile ID. If you use a phone number as the profile identifier and SMS is not set up in the Klaviyo account, you'll need to include at least one other identifier attribute (`email` or `external_id`) in addition to the `phone_number` attribute for the API call to work.

*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. If you use a phone number as the profile identifier and SMS is not set up in the Klaviyo account, you'll need to include at least one other identifier attribute (`email` or `external_id`) in addition to the `phone_number` attribute for the API call to work.<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['API_REVISION'] || "2023-02-22" # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(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