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 unique SID identifier of the Sync Service Instance.

  • document_sid (String)

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

  • identity (String)

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



139
140
141
142
143
144
145
146
147
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 139

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



151
152
153
154
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 151

def delete

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

#fetchDocumentPermissionInstance

Fetch the DocumentPermissionInstance

Returns:



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 159

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



209
210
211
212
# File 'lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb', line 209

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

#to_sObject

Provide a user friendly representation



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

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:



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

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