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.



251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 251

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



264
265
266
267
268
269
270
271
272
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 264

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



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 277

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:



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 296

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:



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 315

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



415
416
417
418
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 415

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

#to_sObject

Provide a user friendly representation



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

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:



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/intelligence/v2/custom_operator.rb', line 343

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:



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

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