Class: KlaviyoAPI::ClientApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-sdk/api/client_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ClientApi

Returns a new instance of ClientApi.



19
20
21
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_client_event(company_id, event_create_query, opts = {}) ⇒ nil

Create Client Event Create a new event to track a profile’s activity. This endpoint is specifically designed to be called from publicly-browseable, client-side environments only. To create [events] from server-based applications, please use [POST /api/events](developers.klaviyo.com/en/v2022-10-17/reference/create_event)
*Rate limits*:
Burst: 350/s
Steady: 3500/m Scopes: ‘Events Write`

Parameters:

  • company_id (String)
  • event_create_query (EventCreateQuery)

    Event to create.

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

    the optional parameters

Returns:

  • (nil)


28
29
30
31
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 28

def create_client_event(company_id, event_create_query, opts = {})
  create_client_event_with_http_info(company_id, event_create_query, opts)
  nil
end

#create_client_event_with_http_info(company_id, event_create_query, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Create Client Event Create a new event to track a profile&#39;s activity. This endpoint is specifically designed to be called from publicly-browseable, client-side environments only. To create [events] from server-based applications, please use [POST /api/events](developers.klaviyo.com/en/v2022-10-17/reference/create_event)&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;Events Write&#x60;

Parameters:

  • company_id (String)
  • event_create_query (EventCreateQuery)

    Event to create.

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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

def create_client_event_with_http_info(company_id, event_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ClientApi.create_client_event ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling ClientApi.create_client_event"
  end
  # verify the required parameter 'event_create_query' is set
  if @api_client.config.client_side_validation && event_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'event_create_query' when calling ClientApi.create_client_event"
  end
  # resource path
  local_var_path = '/client/events/'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'company_id'] = company_id

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2022-10-17"
  # 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(event_create_query)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"ClientApi.create_client_event",
    :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: ClientApi#create_client_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_client_profile(company_id, onsite_profile_create_query, opts = {}) ⇒ nil

Create Client Profile Create and update properties about a profile without tracking an associated event. This endpoint is specifically designed to be called from publicly-browseable, client-side environments only. To create profiles from server applications (e.g. custom server-side scripts / applications), please use [POST /api/profiles](developers.klaviyo.com/en/reference/create_profile)
*Rate limits*:
Burst: 350/s
Steady: 3500/m Scopes: ‘Profiles Write`

Parameters:

  • company_id (String)
  • onsite_profile_create_query (OnsiteProfileCreateQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


105
106
107
108
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 105

def create_client_profile(company_id, onsite_profile_create_query, opts = {})
  create_client_profile_with_http_info(company_id, onsite_profile_create_query, opts)
  nil
end

#create_client_profile_with_http_info(company_id, onsite_profile_create_query, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Create Client Profile Create and update properties about a profile without tracking an associated event. This endpoint is specifically designed to be called from publicly-browseable, client-side environments only. To create profiles from server applications (e.g. custom server-side scripts / applications), please use [POST /api/profiles](developers.klaviyo.com/en/reference/create_profile)&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;Profiles Write&#x60;

Parameters:

  • company_id (String)
  • onsite_profile_create_query (OnsiteProfileCreateQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 116

def create_client_profile_with_http_info(company_id, onsite_profile_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ClientApi.create_client_profile ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling ClientApi.create_client_profile"
  end
  # verify the required parameter 'onsite_profile_create_query' is set
  if @api_client.config.client_side_validation && onsite_profile_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'onsite_profile_create_query' when calling ClientApi.create_client_profile"
  end
  # resource path
  local_var_path = '/client/profiles/'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'company_id'] = company_id

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2022-10-17"
  # 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(onsite_profile_create_query)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"ClientApi.create_client_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: ClientApi#create_client_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_client_subscription(company_id, onsite_subscription_create_query, opts = {}) ⇒ nil

Create Client Subscription Create a new subscription for the given list ID and channel: * Email email * SMS phone_number This endpoint is specifically designed to be called from publicly-browseable, client-side environments only. To create subscriptions from server-based applications, please use [POST /api/profile-subscription-bulk-create-jobs](developers.klaviyo.com/en/reference/subscribe_profiles)
*Rate limits*:
Burst: 100/s
Steady: 100/m Scopes: ‘Subscriptions Write`

Parameters:

  • company_id (String)
  • onsite_subscription_create_query (OnsiteSubscriptionCreateQuery)

    Creates a subscription and consent records for Email and or SMS channels based on the provided email and phone_number attributes respectively. One of either email or phone_number must be provided. To create a subscription and consent record for only one channel but still include the other channel as a profile property the consent channel can be provided as a top level attribute and the other channel can be included in the properties object.

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

    the optional parameters

Returns:

  • (nil)


182
183
184
185
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 182

def create_client_subscription(company_id, onsite_subscription_create_query, opts = {})
  create_client_subscription_with_http_info(company_id, onsite_subscription_create_query, opts)
  nil
end

#create_client_subscription_with_http_info(company_id, onsite_subscription_create_query, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Create Client Subscription Create a new subscription for the given list ID and channel: * Email &#x60;email&#x60; * SMS &#x60;phone_number&#x60; This endpoint is specifically designed to be called from publicly-browseable, client-side environments only. To create subscriptions from server-based applications, please use [POST /api/profile-subscription-bulk-create-jobs](developers.klaviyo.com/en/reference/subscribe_profiles)&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;100/s&#x60;&lt;br&gt;Steady: &#x60;100/m&#x60; Scopes: &#x60;Subscriptions Write&#x60;

Parameters:

  • company_id (String)
  • onsite_subscription_create_query (OnsiteSubscriptionCreateQuery)

    Creates a subscription and consent records for Email and or SMS channels based on the provided email and phone_number attributes respectively. One of either email or phone_number must be provided. To create a subscription and consent record for only one channel but still include the other channel as a profile property the consent channel can be provided as a top level attribute and the other channel can be included in the properties object.

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/klaviyo-api-sdk/api/client_api.rb', line 193

def create_client_subscription_with_http_info(company_id, onsite_subscription_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ClientApi.create_client_subscription ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling ClientApi.create_client_subscription"
  end
  # verify the required parameter 'onsite_subscription_create_query' is set
  if @api_client.config.client_side_validation && onsite_subscription_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'onsite_subscription_create_query' when calling ClientApi.create_client_subscription"
  end
  # resource path
  local_var_path = '/client/subscriptions/'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'company_id'] = company_id

  # header parameters
  header_params = opts[:header_params] || {}
  # 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(onsite_subscription_create_query)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"ClientApi.create_client_subscription",
    :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: ClientApi#create_client_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end