Class: Twilio::REST::Intelligence::V2::CustomOperatorContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ CustomOperatorContext

Initialize the CustomOperatorContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this Custom Operator.



243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 243

def initialize(version, sid)
    super(version)
    

    # Path Solution
    @solution = { sid: sid,  }
    @uri = "/Operators/Custom/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the CustomOperatorInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 256

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the CustomOperatorInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 269

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      customOperator_instance = CustomOperatorInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      CustomOperatorInstanceMetadata.new(@version, customOperator_instance, response.headers, response.status_code)
end

#fetchCustomOperatorInstance

Fetch the CustomOperatorInstance

Returns:



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 288

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    CustomOperatorInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#fetch_with_metadataCustomOperatorInstance

Fetch the CustomOperatorInstanceMetadata

Returns:



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 307

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    custom_operator_instance = CustomOperatorInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    CustomOperatorInstanceMetadata.new(
        @version,
        custom_operator_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



407
408
409
410
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 407

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Intelligence.V2.CustomOperatorContext #{context}>"
end

#to_sObject

Provide a user friendly representation



400
401
402
403
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 400

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Intelligence.V2.CustomOperatorContext #{context}>"
end

#update(friendly_name: nil, config: nil, if_match: :unset) ⇒ CustomOperatorInstance

Update the CustomOperatorInstance

Parameters:

  • friendly_name (String) (defaults to: nil)

    A human-readable name of this resource, up to 64 characters.

  • config (Object) (defaults to: nil)

    Operator configuration, following the schema defined by the Operator Type.

  • if_match (String) (defaults to: :unset)

    The If-Match HTTP request header

Returns:



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 335

def update(
    friendly_name: nil, 
    config: nil, 
    if_match: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Config' => Twilio.serialize_object(config),
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    CustomOperatorInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#update_with_metadata(friendly_name: nil, config: nil, if_match: :unset) ⇒ CustomOperatorInstance

Update the CustomOperatorInstanceMetadata

Parameters:

  • friendly_name (String) (defaults to: nil)

    A human-readable name of this resource, up to 64 characters.

  • config (Object) (defaults to: nil)

    Operator configuration, following the schema defined by the Operator Type.

  • if_match (String) (defaults to: :unset)

    The If-Match HTTP request header

Returns:



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
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 366

def (
  friendly_name: nil, 
  config: nil, 
  if_match: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Config' => Twilio.serialize_object(config),
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    custom_operator_instance = CustomOperatorInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    CustomOperatorInstanceMetadata.new(
        @version,
        custom_operator_instance,
        response.headers,
        response.status_code
    )
end