Class: SmoochApi::ConversationApi

Inherits:
Object
  • Object
show all
Defined in:
lib/smooch-api/api/conversation_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ConversationApi

Returns a new instance of ConversationApi.



19
20
21
# File 'lib/smooch-api/api/conversation_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/smooch-api/api/conversation_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#delete_message(appId, userId, messageId, opts = {}) ⇒ nil

Deletes a single message.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

  • messageId

    Identifies the message.

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

    the optional parameters

Returns:

  • (nil)


30
31
32
33
# File 'lib/smooch-api/api/conversation_api.rb', line 30

def delete_message(appId, userId, messageId, opts = {})
  delete_message_with_http_info(appId, userId, messageId, opts)
  return nil
end

#delete_message_with_http_info(appId, userId, messageId, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Deletes a single message.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

  • messageId

    Identifies the message.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
# File 'lib/smooch-api/api/conversation_api.rb', line 42

def delete_message_with_http_info(appId, userId, messageId, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ConversationApi.delete_message ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling ConversationApi.delete_message"
  end
  # verify the required parameter 'userId' is set
  if @api_client.config.client_side_validation && userId.nil?
    fail ArgumentError, "Missing the required parameter 'userId' when calling ConversationApi.delete_message"
  end
  # verify the required parameter 'messageId' is set
  if @api_client.config.client_side_validation && messageId.nil?
    fail ArgumentError, "Missing the required parameter 'messageId' when calling ConversationApi.delete_message"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/appusers/{userId}/messages/{messageId}".sub('{' + 'appId' + '}', appId.to_s).sub('{' + 'userId' + '}', userId.to_s).sub('{' + 'messageId' + '}', messageId.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['jwt']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationApi#delete_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_messages(appId, userId, opts = {}) ⇒ nil

Clears the message history for a user, permanently deleting all messages, but leaving any connections to Messaging Channels and Business Systems intact. These connections allow for the conversation to continue in the future, while still being associated to the same appUser.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

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

    the optional parameters

Returns:

  • (nil)


95
96
97
98
# File 'lib/smooch-api/api/conversation_api.rb', line 95

def delete_messages(appId, userId, opts = {})
  delete_messages_with_http_info(appId, userId, opts)
  return nil
end

#delete_messages_with_http_info(appId, userId, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Clears the message history for a user, permanently deleting all messages, but leaving any connections to Messaging Channels and Business Systems intact. These connections allow for the conversation to continue in the future, while still being associated to the same appUser.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



106
107
108
109
110
111
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
141
142
143
144
145
146
147
# File 'lib/smooch-api/api/conversation_api.rb', line 106

def delete_messages_with_http_info(appId, userId, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ConversationApi.delete_messages ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling ConversationApi.delete_messages"
  end
  # verify the required parameter 'userId' is set
  if @api_client.config.client_side_validation && userId.nil?
    fail ArgumentError, "Missing the required parameter 'userId' when calling ConversationApi.delete_messages"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/appusers/{userId}/messages".sub('{' + 'appId' + '}', appId.to_s).sub('{' + 'userId' + '}', userId.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['jwt']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationApi#delete_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_messages(appId, userId, opts = {}) ⇒ GetMessagesResponse

Get the specified app user’s messages.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

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

    the optional parameters

Options Hash (opts):

  • :before (String)

    Timestamp of message. The API will return 100 messages before the specified timestamp (excluding any messages with the provided timestamp).

  • :after (String)

    Timestamp of message. The API will return 100 messages after the specified timestamp (excluding any messages with the provided timestamp).

Returns:

  • (GetMessagesResponse)


157
158
159
160
# File 'lib/smooch-api/api/conversation_api.rb', line 157

def get_messages(appId, userId, opts = {})
  data, _status_code, _headers = get_messages_with_http_info(appId, userId, opts)
  return data
end

#get_messages_with_http_info(appId, userId, opts = {}) ⇒ Array<(GetMessagesResponse, Fixnum, Hash)>

Get the specified app user&#39;s messages.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

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

    the optional parameters

Options Hash (opts):

  • :before (String)

    Timestamp of message. The API will return 100 messages before the specified timestamp (excluding any messages with the provided timestamp).

  • :after (String)

    Timestamp of message. The API will return 100 messages after the specified timestamp (excluding any messages with the provided timestamp).

Returns:

  • (Array<(GetMessagesResponse, Fixnum, Hash)>)

    GetMessagesResponse data, response status code and response headers



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/smooch-api/api/conversation_api.rb', line 170

def get_messages_with_http_info(appId, userId, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ConversationApi.get_messages ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling ConversationApi.get_messages"
  end
  # verify the required parameter 'userId' is set
  if @api_client.config.client_side_validation && userId.nil?
    fail ArgumentError, "Missing the required parameter 'userId' when calling ConversationApi.get_messages"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/appusers/{userId}/messages".sub('{' + 'appId' + '}', appId.to_s).sub('{' + 'userId' + '}', userId.to_s)

  # query parameters
  query_params = {}
  query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['jwt']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetMessagesResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationApi#get_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_message(appId, userId, messagePostBody, opts = {}) ⇒ MessageResponse

Post a message to or from the app user.

Parameters:

Returns:



223
224
225
226
# File 'lib/smooch-api/api/conversation_api.rb', line 223

def post_message(appId, userId, messagePostBody, opts = {})
  data, _status_code, _headers = post_message_with_http_info(appId, userId, messagePostBody, opts)
  return data
end

#post_message_with_http_info(appId, userId, messagePostBody, opts = {}) ⇒ Array<(MessageResponse, Fixnum, Hash)>

Post a message to or from the app user.

Parameters:

Returns:

  • (Array<(MessageResponse, Fixnum, Hash)>)

    MessageResponse data, response status code and response headers



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
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
# File 'lib/smooch-api/api/conversation_api.rb', line 235

def post_message_with_http_info(appId, userId, messagePostBody, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ConversationApi.post_message ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling ConversationApi.post_message"
  end
  # verify the required parameter 'userId' is set
  if @api_client.config.client_side_validation && userId.nil?
    fail ArgumentError, "Missing the required parameter 'userId' when calling ConversationApi.post_message"
  end
  # verify the required parameter 'messagePostBody' is set
  if @api_client.config.client_side_validation && messagePostBody.nil?
    fail ArgumentError, "Missing the required parameter 'messagePostBody' when calling ConversationApi.post_message"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/appusers/{userId}/messages".sub('{' + 'appId' + '}', appId.to_s).sub('{' + 'userId' + '}', userId.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(messagePostBody)
  auth_names = ['jwt']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'MessageResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationApi#post_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#reset_unread_count(appId, userId, opts = {}) ⇒ nil

Reset the unread count of the conversation to 0.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

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

    the optional parameters

Returns:

  • (nil)


289
290
291
292
# File 'lib/smooch-api/api/conversation_api.rb', line 289

def reset_unread_count(appId, userId, opts = {})
  reset_unread_count_with_http_info(appId, userId, opts)
  return nil
end

#reset_unread_count_with_http_info(appId, userId, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Reset the unread count of the conversation to 0.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



300
301
302
303
304
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
332
333
334
335
336
337
338
339
340
341
# File 'lib/smooch-api/api/conversation_api.rb', line 300

def reset_unread_count_with_http_info(appId, userId, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ConversationApi.reset_unread_count ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling ConversationApi.reset_unread_count"
  end
  # verify the required parameter 'userId' is set
  if @api_client.config.client_side_validation && userId.nil?
    fail ArgumentError, "Missing the required parameter 'userId' when calling ConversationApi.reset_unread_count"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/appusers/{userId}/conversation/read".sub('{' + 'appId' + '}', appId.to_s).sub('{' + 'userId' + '}', userId.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['jwt']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationApi#reset_unread_count\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#trigger_typing_activity(appId, userId, typingActivityTriggerBody, opts = {}) ⇒ nil

Notify Smooch when an app maker starts or stops typing a response.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

  • typingActivityTriggerBody

    Body for a triggerTypingActivity request.

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

    the optional parameters

Returns:

  • (nil)


350
351
352
353
# File 'lib/smooch-api/api/conversation_api.rb', line 350

def trigger_typing_activity(appId, userId, typingActivityTriggerBody, opts = {})
  trigger_typing_activity_with_http_info(appId, userId, typingActivityTriggerBody, opts)
  return nil
end

#trigger_typing_activity_with_http_info(appId, userId, typingActivityTriggerBody, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Notify Smooch when an app maker starts or stops typing a response.

Parameters:

  • appId

    Identifies the app.

  • userId

    Identifies the user. Can be either the smoochId or the userId.

  • typingActivityTriggerBody

    Body for a triggerTypingActivity request.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



362
363
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/smooch-api/api/conversation_api.rb', line 362

def trigger_typing_activity_with_http_info(appId, userId, typingActivityTriggerBody, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ConversationApi.trigger_typing_activity ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling ConversationApi.trigger_typing_activity"
  end
  # verify the required parameter 'userId' is set
  if @api_client.config.client_side_validation && userId.nil?
    fail ArgumentError, "Missing the required parameter 'userId' when calling ConversationApi.trigger_typing_activity"
  end
  # verify the required parameter 'typingActivityTriggerBody' is set
  if @api_client.config.client_side_validation && typingActivityTriggerBody.nil?
    fail ArgumentError, "Missing the required parameter 'typingActivityTriggerBody' when calling ConversationApi.trigger_typing_activity"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/appusers/{userId}/conversation/activity".sub('{' + 'appId' + '}', appId.to_s).sub('{' + 'userId' + '}', userId.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(typingActivityTriggerBody)
  auth_names = ['jwt']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationApi#trigger_typing_activity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end