Class: Twilio::REST::Sync::V1::ServiceContext::SyncListContext::SyncListPermissionContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, list_sid, identity) ⇒ SyncListPermissionContext

Initialize the SyncListPermissionContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the [Sync Service](www.twilio.com/docs/sync/api/service) with the Sync List Permission resource to update.

  • list_sid (String)

    The SID of the Sync List with the Sync List Permission resource to update. Can be the Sync List resource’s ‘sid` or its `unique_name`.

  • identity (String)

    The application-defined string that uniquely identifies the User’s Sync List Permission resource to update.



172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 172

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

    # Path Solution
    @solution = { service_sid: service_sid, list_sid: list_sid, identity: identity,  }
    @uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:list_sid]}/Permissions/#{@solution[:identity]}"

    
end

Instance Method Details

#deleteBoolean

Delete the SyncListPermissionInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



185
186
187
188
189
190
191
192
193
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 185

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 SyncListPermissionInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 198

def 

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

#fetchSyncListPermissionInstance

Fetch the SyncListPermissionInstance

Returns:



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 217

def fetch

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

#fetch_with_metadataSyncListPermissionInstance

Fetch the SyncListPermissionInstanceMetadata

Returns:



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 238

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    sync_list_permission_instance = SyncListPermissionInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        identity: @solution[:identity],
    )
    SyncListPermissionInstanceMetadata.new(
        @version,
        sync_list_permission_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



346
347
348
349
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 346

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

#to_sObject

Provide a user friendly representation



339
340
341
342
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 339

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

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

Update the SyncListPermissionInstance

Parameters:

  • read (Boolean) (defaults to: nil)

    Whether the identity can read the Sync List and its Items. Default value is ‘false`.

  • write (Boolean) (defaults to: nil)

    Whether the identity can create, update, and delete Items in the Sync List. Default value is ‘false`.

  • manage (Boolean) (defaults to: nil)

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

Returns:



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 268

def update(
  read: nil, 
  write: nil, 
  manage: nil
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    SyncListPermissionInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        identity: @solution[:identity],
    )
end

#update_with_metadata(read: nil, write: nil, manage: nil) ⇒ SyncListPermissionInstance

Update the SyncListPermissionInstanceMetadata

Parameters:

  • read (Boolean) (defaults to: nil)

    Whether the identity can read the Sync List and its Items. Default value is ‘false`.

  • write (Boolean) (defaults to: nil)

    Whether the identity can create, update, and delete Items in the Sync List. Default value is ‘false`.

  • manage (Boolean) (defaults to: nil)

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

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb', line 302

def (
  read: nil, 
  write: nil, 
  manage: nil
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    sync_list_permission_instance = SyncListPermissionInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        identity: @solution[:identity],
    )
    SyncListPermissionInstanceMetadata.new(
        @version,
        sync_list_permission_instance,
        response.headers,
        response.status_code
    )
end