class Twilio::REST::Sync::V1::ServiceContext::DocumentContext

Public Class Methods

new(version, service_sid, sid) click to toggle source

Initialize the DocumentContext @param [Version] version Version that contains the resource @param [String] service_sid The SID of the {Sync

Service}[https://www.twilio.com/docs/sync/api/service] with the Document
resource to fetch.

@param [String] sid The SID of the Document resource to fetch. Can be the

Document resource's `sid` or its `unique_name`.

@return [DocumentContext] DocumentContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
178 def initialize(version, service_sid, sid)
179   super(version)
180 
181   # Path Solution
182   @solution = {service_sid: service_sid, sid: sid, }
183   @uri = "/Services/#{@solution[:service_sid]}/Documents/#{@solution[:sid]}"
184 
185   # Dependents
186   @document_permissions = nil
187 end

Public Instance Methods

delete() click to toggle source

Delete the DocumentInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
201 def delete
202    @version.delete('DELETE', @uri)
203 end
document_permissions(identity=:unset) click to toggle source

Access the document_permissions @return [DocumentPermissionList] @return [DocumentPermissionContext] if identity was passed.

    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
227 def document_permissions(identity=:unset)
228   raise ArgumentError, 'identity cannot be nil' if identity.nil?
229 
230   if identity != :unset
231     return DocumentPermissionContext.new(@version, @solution[:service_sid], @solution[:sid], identity, )
232   end
233 
234   unless @document_permissions
235     @document_permissions = DocumentPermissionList.new(
236         @version,
237         service_sid: @solution[:service_sid],
238         document_sid: @solution[:sid],
239     )
240   end
241 
242   @document_permissions
243 end
fetch() click to toggle source

Fetch the DocumentInstance @return [DocumentInstance] Fetched DocumentInstance

    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
192 def fetch
193   payload = @version.fetch('GET', @uri)
194 
195   DocumentInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
196 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
254 def inspect
255   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
256   "#<Twilio.Sync.V1.DocumentContext #{context}>"
257 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
247 def to_s
248   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
249   "#<Twilio.Sync.V1.DocumentContext #{context}>"
250 end
update(data: :unset, ttl: :unset, if_match: :unset) click to toggle source

Update the DocumentInstance @param [Hash] data A JSON string that represents an arbitrary, schema-less

object that the Sync Document stores. Can be up to 16 KiB in length.

@param [String] ttl How long, {in

seconds}[https://www.twilio.com/docs/sync/limits#sync-payload-limits], before
the Sync Document expires and is deleted (time-to-live).

@param [String] if_match The If-Match HTTP request header @return [DocumentInstance] Updated DocumentInstance

    # File lib/twilio-ruby/rest/sync/v1/service/document.rb
214 def update(data: :unset, ttl: :unset, if_match: :unset)
215   data = Twilio::Values.of({'Data' => Twilio.serialize_object(data), 'Ttl' => ttl, })
216   headers = Twilio::Values.of({'If-Match' => if_match, })
217 
218   payload = @version.update('POST', @uri, data: data, headers: headers)
219 
220   DocumentInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
221 end