Class: Twilio::REST::Preview::Sync::ServiceContext::DocumentContext::DocumentPermissionContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, document_sid, identity) ⇒ DocumentPermissionContext

Initialize the DocumentPermissionContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • document_sid (String)

    Identifier of the Sync Document. Either a SID or a unique name.

  • identity (String)

    Arbitrary string identifier representing a user associated with an FPA token, assigned by the developer.



171
172
173
174
175
176
177
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 171

def initialize(version, service_sid, document_sid, identity)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, document_sid: document_sid, identity: identity, }
  @uri = "/Services/#{@solution[:service_sid]}/Documents/#{@solution[:document_sid]}/Permissions/#{@solution[:identity]}"
end

Instance Method Details

#deleteBoolean

Deletes the DocumentPermissionInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



203
204
205
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 203

def delete
  @version.delete('delete', @uri)
end

#fetchDocumentPermissionInstance

Fetch a DocumentPermissionInstance

Returns:



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 182

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  DocumentPermissionInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      document_sid: @solution[:document_sid],
      identity: @solution[:identity],
  )
end

#inspectObject

Provide a detailed, user friendly representation



243
244
245
246
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 243

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

#to_sObject

Provide a user friendly representation



236
237
238
239
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 236

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

#update(read: nil, write: nil, manage: nil) ⇒ DocumentPermissionInstance

Update the DocumentPermissionInstance

Parameters:

  • read (Boolean) (defaults to: nil)

    Boolean flag specifying whether the identity can read the Sync Document.

  • write (Boolean) (defaults to: nil)

    Boolean flag specifying whether the identity can update the Sync Document.

  • manage (Boolean) (defaults to: nil)

    Boolean flag specifying whether the identity can delete the Sync Document.

Returns:



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 216

def update(read: nil, write: nil, manage: nil)
  data = Twilio::Values.of({'Read' => read, 'Write' => write, 'Manage' => manage, })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  DocumentPermissionInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      document_sid: @solution[:document_sid],
      identity: @solution[:identity],
  )
end