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

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

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 SID of the Sync Service with the Document Permission resource to fetch.

  • document_sid (String)

    The SID of the Sync Document with the Document Permission resource to fetch. Can be the Document resource's `sid` or its `unique_name`.

  • identity (String)

    The application-defined string that uniquely identifies the User's Document Permission resource to fetch.


167
168
169
170
171
172
173
# File 'lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb', line 167

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

Delete the DocumentPermissionInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


193
194
195
# File 'lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb', line 193

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

#fetchDocumentPermissionInstance

Fetch the DocumentPermissionInstance

Returns:


178
179
180
181
182
183
184
185
186
187
188
# File 'lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb', line 178

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

  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


229
230
231
232
# File 'lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb', line 229

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

#to_sObject

Provide a user friendly representation


222
223
224
225
# File 'lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb', line 222

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

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

Update the DocumentPermissionInstance

Parameters:

  • read (Boolean) (defaults to: nil)

    Whether the identity can read the Sync Document. Default value is `false`.

  • write (Boolean) (defaults to: nil)

    Whether the identity can update the Sync Document. Default value is `false`.

  • manage (Boolean) (defaults to: nil)

    Whether the identity can delete the Sync Document. Default value is `false`.

Returns:


206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb', line 206

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