Class: Twilio::REST::Content::V1::ContentContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/content/v1/content.rb,
lib/twilio-ruby/rest/content/v1/content/approval_fetch.rb,
lib/twilio-ruby/rest/content/v1/content/approval_create.rb

Defined Under Namespace

Classes: ApprovalCreateInstance, ApprovalCreateList, ApprovalCreateListResponse, ApprovalCreatePage, ApprovalCreatePageMetadata, ApprovalFetchContext, ApprovalFetchInstance, ApprovalFetchInstanceMetadata, ApprovalFetchList, ApprovalFetchListResponse, ApprovalFetchPage, ApprovalFetchPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ContentContext

Initialize the ContentContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Twilio-provided string that uniquely identifies the Content resource to update.



1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1457

def initialize(version, sid)
    super(version)
    

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

    # Dependents
    @approval_create = nil
    @approval_fetch = nil
end

Instance Method Details

#approval_createApprovalCreateList, ApprovalCreateContext

Access the approval_create

Returns:



1597
1598
1599
1600
1601
1602
1603
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1597

def approval_create
  unless @approval_create
    @approval_create = ApprovalCreateList.new(
            @version, content_sid: @solution[:sid], )
  end
  @approval_create
end

#approval_fetchApprovalFetchList, ApprovalFetchContext

Access the approval_fetch



1608
1609
1610
1611
1612
1613
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1608

def approval_fetch
    ApprovalFetchContext.new(
            @version,
            @solution[:sid]
            )
end

#deleteBoolean

Delete the ContentInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



1472
1473
1474
1475
1476
1477
1478
1479
1480
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1472

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 ContentInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1485

def 

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

#fetchContentInstance

Fetch the ContentInstance

Returns:



1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1504

def fetch

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

#fetch_with_metadataContentInstance

Fetch the ContentInstanceMetadata

Returns:



1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1523

def 

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

#inspectObject

Provide a detailed, user friendly representation



1624
1625
1626
1627
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1624

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

#to_sObject

Provide a user friendly representation



1617
1618
1619
1620
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1617

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

#update(content_update_request: nil) ⇒ ContentInstance

Update the ContentInstance

Parameters:

  • content_update_request (ContentUpdateRequest) (defaults to: nil)

Returns:



1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1549

def update(content_update_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.update('PUT', @uri, headers: headers, data: content_update_request.to_json)
    ContentInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#update_with_metadata(content_update_request: nil) ⇒ ContentInstance

Update the ContentInstanceMetadata

Parameters:

  • content_update_request (ContentUpdateRequest) (defaults to: nil)

Returns:



1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
# File 'lib/twilio-ruby/rest/content/v1/content.rb', line 1570

def (content_update_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PUT', @uri, headers: headers, data: content_update_request.to_json)
    content_instance = ContentInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    ContentInstanceMetadata.new(
        @version,
        content_instance,
        response.headers,
        response.status_code
    )
end