Class: StickyIoRestfulApiV2025731::CustomersController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb

Overview

CustomersController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from StickyIoRestfulApiV2025731::BaseController

Instance Method Details

#add_custom_field_values(body, domain, v2_ext, customer_id) ⇒ ApiResponse

Attach an existing customer’s custom fields and assign values for them to the customer. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | - | - | - | - | - | | custom_fields | Required | - | Array | Array of custom fields. | custom_fields.*.id | Required | - | Integer | The custom field ID. | custom_fields.*.value | Required | - | String | The custom field desired value. description here here

Parameters:

  • body (AddCustomFieldValuesRequest)

    Required parameter: TODO: type

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 66

def add_custom_field_values(body,
                            domain,
                            v2_ext,
                            customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/.{domain}{v2_ext}customers/{customer_id}/custom_fields',
                                 Server::SERVER_1)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(AddCustomFieldValues.method(:from_hash))
                .is_api_response(true))
    .execute
end

#create_customer_interest(body, domain, v2_ext, customer_id) ⇒ ApiResponse

TODO: type endpoint description here description here here

Parameters:

  • body (CreateCustomerInterestRequest)

    Required parameter: TODO: type

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 305

def create_customer_interest(body,
                             domain,
                             v2_ext,
                             customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/.{domain}{v2_ext}customers/{customer_id}/interests',
                                 Server::SERVER_1)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true))
    .execute
end

#delete_custom_field_values(domain, v2_ext, customer_id, custom_field_id) ⇒ ApiResponse

Delete an existing custom field from the list attached to the customer here here

Parameters:

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

  • custom_field_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
175
176
177
178
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 150

def delete_custom_field_values(domain,
                               v2_ext,
                               customer_id,
                               custom_field_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/.{domain}{v2_ext}customers/{customer_id}/custom_fields/{custom_field_id}',
                                 Server::SERVER_1)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(custom_field_id, key: 'custom_field_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DeleteCustomFieldValues.method(:from_hash))
                .is_api_response(true))
    .execute
end

#get_customer_custom_fields(domain, v2_ext) ⇒ ApiResponse

Fetch a list of all custom fields created for customers **Response Data**\ Response parameters expected in custom field object contained within the ‘data` field array: | Field | Data Type | Description | - | - | - | | id | Integer | The custom field ID. | field_type_id | Integer | The custom field’s field type ID. | name | String | The custom field name. | token_key | String | The custom field email token field. | is_multi | Integer Flag | Allow for multiple options to be selected. | options | Array | Array of option objects associated with the custom field. | options.*.id | Integer | The option ID. | options.*.value | String | The option value. | type_id | Integer | The custom field’s type ID.

Parameters:

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 28

def get_customer_custom_fields(domain,
                               v2_ext)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/.{domain}{v2_ext}custom_fields/customers',
                                 Server::SERVER_1)
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetCustomerCustomFields.method(:from_hash))
                .is_api_response(true))
    .execute
end

#get_customer_interests(domain, v2_ext, customer_id) ⇒ ApiResponse

TODO: type endpoint description here here

Parameters:

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 186

def get_customer_interests(domain,
                           v2_ext,
                           customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/.{domain}{v2_ext}customers/{customer_id}/interests',
                                 Server::SERVER_1)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .auth(Single.new('basic')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true))
    .execute
end

#get_customer_subscriptions(search_is_recurring, search_is_archived, search_is_hold, search_recur_at, search_next_product_id, search_billing_model_id, domain, v2_ext, customer_id) ⇒ ApiResponse

This method is used to get subscriptions for a given customer using the customer_id. **Max Requests Per Minute**: 120 ## Request Parameters |Parameter|Required|Type|Description|Example| |:-|-|-|-|-| |‘search`|optional|Boolean|Search only for subscriptions that are recurring, or not recurring|1| |`search`|optional|Boolean|Search only for subscriptions that are archived, or not archived|0| |`search`|optional|Boolean|Search only for subscriptions that are on hold, or not on hold|0| |`search`|optional|JSON Object|Search only for subscriptions with the specified `recur_at` date. A date range is also accepted by passing a JSON object with a `start` and `end` tag.|`“2021-06-05, ”end“: ”2021-06-06“`| |`search`|optional|Integer|Search only for subscriptions with the specified `next_product_id`|4| |`search`|optional|Integer|Search only for subscriptions with the specified `billing_model_id`|7| ## Response Parameters |Parameter|Description| |:-|-| |`data`|Data object containing customer subscriptions to match request| |`response_code`|See [Code Definitions](#2266962e-ffc8-46b1-a6ad-f0f02e6f30d9) for definitions| description here description here here here description here description here here

Parameters:

  • search_is_recurring (Integer)

    Required parameter: TODO: type

  • search_is_archived (Integer)

    Required parameter: TODO: type

  • search_is_hold (Integer)

    Required parameter: TODO: type description

  • search_recur_at (String)

    Required parameter: TODO: type description

  • search_next_product_id (Integer)

    Required parameter: TODO: type

  • search_billing_model_id (Integer)

    Required parameter: TODO: type

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 253

def get_customer_subscriptions(search_is_recurring,
                               search_is_archived,
                               search_is_hold,
                               search_recur_at,
                               search_next_product_id,
                               search_billing_model_id,
                               domain,
                               v2_ext,
                               customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/.{domain}{v2_ext}customers/{customer_id}/subscriptions',
                                 Server::SERVER_1)
               .query_param(new_parameter(search_is_recurring, key: 'search[is_recurring]')
                             .is_required(true))
               .query_param(new_parameter(search_is_archived, key: 'search[is_archived]')
                             .is_required(true))
               .query_param(new_parameter(search_is_hold, key: 'search[is_hold]')
                             .is_required(true))
               .query_param(new_parameter(search_recur_at, key: 'search[recur_at]')
                             .is_required(true))
               .query_param(new_parameter(search_next_product_id, key: 'search[next_product_id]')
                             .is_required(true))
               .query_param(new_parameter(search_billing_model_id, key: 'search[billing_model_id]')
                             .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetCustomerSubscriptions.method(:from_hash))
                .is_api_response(true))
    .execute
end

#update_custom_field_values(body, domain, v2_ext, customer_id) ⇒ ApiResponse

Update custom fields list that attached to the customer. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | - | - | - | - | - | | custom_fields | Required | - | Array | Array of custom fields. | custom_fields.*.id | Required | - | Integer | The custom field ID. | custom_fields.*.value | Required | - | String | The custom field desired value. type description here here

Parameters:

  • body (UpdateCustomFieldValuesRequest)

    Required parameter: TODO:

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



112
113
114
115
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
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 112

def update_custom_field_values(body,
                               domain,
                               v2_ext,
                               customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/.{domain}{v2_ext}customers/{customer_id}/custom_fields',
                                 Server::SERVER_1)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(UpdateCustomFieldValues.method(:from_hash))
                .is_api_response(true))
    .execute
end

#update_customer(body, domain, v2_ext, customer_id) ⇒ ApiResponse

This method is used to update an existing customer record that match an ID provided in the API endpoint. These fields values of a customer record can be updated with this API. ‘dob’, ‘gender’, ‘first_name’, ‘last_name’, ‘nick_name’, ‘email’, ‘phone’, ‘tax_exemption’, ‘custom_fields’ In response you will get: A status of request for customer pre-defined fields and a status of custom fields along with customer and custom fields object. See the reqeuest parameters definition for customer record update. | Request Params | Example Values | Data Format | Comments | | — | — | — | — | | ‘first_name` | John | string | First name of the customer to update | | `last_name` | Doe | string | Last name of the customer to update | | `gender` | m | string | Gender of the customer:
m = Male
f = Female
o = Other | | `dob` | 1986-12-22 | date string | Date of birth of the customer in date string | | `nick_name` | John | string | Nick name of the customer | | `custom_fields` | [
{
id: 1,
value: my own field
}
] | object | Depends on Custom Fields section. Pass JSON object of custom fields in request. | | `phone` | 8135551212 | string | Phone number | | `email` | [johndoe@test.com](mailto:johndoe@test.com) | string | Email address | description here here

Parameters:

  • body (UpdateCustomerRequest)

    Required parameter: TODO: type

  • domain (String)

    Required parameter: TODO: type description here

  • v2_ext (String)

    Required parameter: TODO: type description here

  • customer_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/sticky_io_restful_api_v2025731/controllers/customers_controller.rb', line 364

def update_customer(body,
                    domain,
                    v2_ext,
                    customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/.{domain}{v2_ext}customers/{customer_id}',
                                 Server::SERVER_1)
               .body_param(new_parameter(body)
                            .is_required(true))
               .template_param(new_parameter(domain, key: 'domain')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(v2_ext, key: 'v2_ext')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json; charset=utf-8', key: 'content-type'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true))
    .execute
end