Class: Twilio::REST::Preview::Sync::ServiceContext::SyncListContext::SyncListItemContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.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, list_sid, index) ⇒ SyncListItemContext

Initialize the SyncListItemContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)
  • list_sid (String)
  • index (String)


178
179
180
181
182
183
184
185
186
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb', line 178

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

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

    
end

Instance Method Details

#delete(if_match: :unset) ⇒ Boolean

Delete the SyncListItemInstance

Parameters:

  • if_match (String) (defaults to: :unset)

    The If-Match HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



191
192
193
194
195
196
197
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb', line 191

def delete(
    if_match: :unset
)

    headers = Twilio::Values.of({ 'If-Match' => if_match, })
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchSyncListItemInstance

Fetch the SyncListItemInstance

Returns:



202
203
204
205
206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb', line 202

def fetch

    payload = @version.fetch('GET', @uri)
    SyncListItemInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        index: @solution[:index],
    )
end

#inspectObject

Provide a detailed, user friendly representation



249
250
251
252
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb', line 249

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

#to_sObject

Provide a user friendly representation



242
243
244
245
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb', line 242

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

#update(data: nil, if_match: :unset) ⇒ SyncListItemInstance

Update the SyncListItemInstance

Parameters:

  • data (Object) (defaults to: nil)
  • if_match (String) (defaults to: :unset)

    The If-Match HTTP request header

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb', line 219

def update(
    data: nil, 
    if_match: :unset
)

    data = Twilio::Values.of({
        'Data' => Twilio.serialize_object(data),
    })

    headers = Twilio::Values.of({ 'If-Match' => if_match, })
    payload = @version.update('POST', @uri, data: data, headers: headers)
    SyncListItemInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        index: @solution[:index],
    )
end