Class: UltracartClient::ConversationEmbedApi

Inherits:
Object
  • Object
show all
Defined in:
lib/ultracart_api/api/conversation_embed_api.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ConversationEmbedApi

Returns a new instance of ConversationEmbedApi.



19
20
21
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 19

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

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



17
18
19
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 17

def api_client
  @api_client
end

Class Method Details

.new_using_api_key(simple_key, verify_ssl = true, debugging = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 23

def self.new_using_api_key(simple_key, verify_ssl = true, debugging = false)
  api_config = Configuration.new
  api_config.api_key_prefix['x-ultracart-simple-key'] = simple_key
  api_config.api_version = '2017-03-01'
  api_config.verify_ssl = verify_ssl

  api_client = ApiClient.new(api_config)
  api_client.config.debugging = debugging

  UltracartClient::ConversationEmbedApi.new(api_client)
end

Instance Method Details

#embed_oauth_device_authorize(client_id, scope, opts = {}) ⇒ nil

Initiate a device authorization flow for an embed widget. RFC 8628 device authorization. Only the embed widget's client_id and the crm_embed scope are accepted.

Parameters:

  • client_id (String) —

    The embed widget OAuth client_id.

  • scope (String) —

    The application-level scope (must be 'crm_embed').

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

    the optional parameters

Returns:

  • (nil)


41
42
43
44
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 41

def embed_oauth_device_authorize(client_id, scope, opts = {})
  embed_oauth_device_authorize_with_http_info(client_id, scope, opts)
  nil
end

#embed_oauth_device_authorize_with_http_info(client_id, scope, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Initiate a device authorization flow for an embed widget. RFC 8628 device authorization. Only the embed widget's client_id and the crm_embed scope are accepted.

Parameters:

  • client_id (String) —

    The embed widget OAuth client_id.

  • scope (String) —

    The application-level scope (must be 'crm_embed').

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 52

def embed_oauth_device_authorize_with_http_info(client_id, scope, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.embed_oauth_device_authorize ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling ConversationEmbedApi.embed_oauth_device_authorize"
  end
  # verify the required parameter 'scope' is set
  if @api_client.config.client_side_validation && scope.nil?
    fail ArgumentError, "Missing the required parameter 'scope' when calling ConversationEmbedApi.embed_oauth_device_authorize"
  end
  # resource path
  local_var_path = '/conversation_embed/oauth/device/authorize'

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

  # header parameters
  header_params = opts[:header_params] || {}
  header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['client_id'] = client_id
  form_params['scope'] = scope

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey']

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

#embed_oauth_revoke(client_id, token, opts = {}) ⇒ nil

Revoke an embed widget access or refresh token. RFC 7009 style — the token itself is proof of possession. Accepts either an access token or a refresh token in the 'token' parameter.

Parameters:

  • client_id (String) —

    The embed widget OAuth client_id.

  • token (String) —

    The token to revoke (access token or refresh token).

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

    the optional parameters

Returns:

  • (nil)


118
119
120
121
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 118

def embed_oauth_revoke(client_id, token, opts = {})
  embed_oauth_revoke_with_http_info(client_id, token, opts)
  nil
end

#embed_oauth_revoke_with_http_info(client_id, token, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Revoke an embed widget access or refresh token. RFC 7009 style — the token itself is proof of possession. Accepts either an access token or a refresh token in the 'token' parameter.

Parameters:

  • client_id (String) —

    The embed widget OAuth client_id.

  • token (String) —

    The token to revoke (access token or refresh token).

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 129

def embed_oauth_revoke_with_http_info(client_id, token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.embed_oauth_revoke ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling ConversationEmbedApi.embed_oauth_revoke"
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling ConversationEmbedApi.embed_oauth_revoke"
  end
  # resource path
  local_var_path = '/conversation_embed/oauth/device/revoke'

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

  # header parameters
  header_params = opts[:header_params] || {}
  header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['client_id'] = client_id
  form_params['token'] = token

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey']

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

#embed_oauth_token(client_id, grant_type, opts = {}) ⇒ nil

Exchange a device_code or refresh_token for an access token (embed widget). Accepts grant_type=urn:ietf:params:oauth:grant-type:device_code or grant_type=refresh_token. Other grant types are rejected. Access tokens issued here expire in 60 minutes.

Parameters:

  • client_id (String) —

    The embed widget OAuth client_id.

  • grant_type (String) —

    Grant type.

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

    the optional parameters

Options Hash (opts):

  • :device_code (String) —

    The device code received from /oauth/device/authorize (required for device_code grant).

  • :refresh_token (String) —

    The refresh token (required for refresh_token grant).

Returns:

  • (nil)


197
198
199
200
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 197

def embed_oauth_token(client_id, grant_type, opts = {})
  embed_oauth_token_with_http_info(client_id, grant_type, opts)
  nil
end

#embed_oauth_token_with_http_info(client_id, grant_type, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Exchange a device_code or refresh_token for an access token (embed widget). Accepts grant_type=urn:ietf:params:oauth:grant-type:device_code or grant_type=refresh_token. Other grant types are rejected. Access tokens issued here expire in 60 minutes.

Parameters:

  • client_id (String) —

    The embed widget OAuth client_id.

  • grant_type (String) —

    Grant type.

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

    the optional parameters

Options Hash (opts):

  • :device_code (String) —

    The device code received from /oauth/device/authorize (required for device_code grant).

  • :refresh_token (String) —

    The refresh token (required for refresh_token grant).

Returns:

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

    nil, response status code and response headers



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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 210

def embed_oauth_token_with_http_info(client_id, grant_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.embed_oauth_token ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling ConversationEmbedApi.embed_oauth_token"
  end
  # verify the required parameter 'grant_type' is set
  if @api_client.config.client_side_validation && grant_type.nil?
    fail ArgumentError, "Missing the required parameter 'grant_type' when calling ConversationEmbedApi.embed_oauth_token"
  end
  # resource path
  local_var_path = '/conversation_embed/oauth/device/token'

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

  # header parameters
  header_params = opts[:header_params] || {}
  header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['client_id'] = client_id
  form_params['grant_type'] = grant_type
  form_params['device_code'] = opts[:'device_code'] if !opts[:'device_code'].nil?
  form_params['refresh_token'] = opts[:'refresh_token'] if !opts[:'refresh_token'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey']

  new_options = opts.merge(
    :operation => :"ConversationEmbedApi.embed_oauth_token",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationEmbedApi#embed_oauth_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_embed_pbx_auth(opts = {}) ⇒ ConversationEmbedPbxAuthResponse

Get PBX authorization for the embedded softphone widget. Returns a narrow subset of agent auth fields — only what the softphone widget needs to connect to the PBX relay. Twilio tokens, conversation JWTs, and chat/customer permissions are intentionally excluded.

Parameters:

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

    the optional parameters

Returns:



276
277
278
279
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 276

def get_embed_pbx_auth(opts = {})
  data, _status_code, _headers = get_embed_pbx_auth_with_http_info(opts)
  data
end

#get_embed_pbx_auth_with_http_info(opts = {}) ⇒ Array<(ConversationEmbedPbxAuthResponse, Integer, Hash)>

Get PBX authorization for the embedded softphone widget. Returns a narrow subset of agent auth fields — only what the softphone widget needs to connect to the PBX relay. Twilio tokens, conversation JWTs, and chat/customer permissions are intentionally excluded.

Parameters:

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

    the optional parameters

Returns:



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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
# File 'lib/ultracart_api/api/conversation_embed_api.rb', line 285

def get_embed_pbx_auth_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.get_embed_pbx_auth ...'
  end
  # resource path
  local_var_path = '/conversation_embed/pbx-auth'

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

  # header parameters
  header_params = opts[:header_params] || {}
  header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
  # 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] || 'ConversationEmbedPbxAuthResponse'

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

  new_options = opts.merge(
    :operation => :"ConversationEmbedApi.get_embed_pbx_auth",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationEmbedApi#get_embed_pbx_auth\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end