Class: Twilio::REST::Serverless::V1::ServiceContext::AssetContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/serverless/v1/service/asset.rb,
lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb

Defined Under Namespace

Classes: AssetVersionContext, AssetVersionInstance, AssetVersionList, AssetVersionPage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ AssetContext

Initialize the AssetContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the Service to update the Asset resource from.

  • sid (String)

    The SID that identifies the Asset resource to update.



165
166
167
168
169
170
171
172
173
174
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 165

def initialize(version, service_sid, sid)
    super(version)

    # Path Solution
    @solution = { service_sid: service_sid, sid: sid,  }
    @uri = "/Services/#{@solution[:service_sid]}/Assets/#{@solution[:sid]}"

    # Dependents
    @asset_versions = nil
end

Instance Method Details

#asset_versions(sid = :unset) ⇒ AssetVersionList, AssetVersionContext

Access the asset_versions

Returns:

Raises:

  • (ArgumentError)


238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 238

def asset_versions(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return AssetVersionContext.new(@version, @solution[:service_sid], @solution[:sid],sid )
    end

    unless @asset_versions
        @asset_versions = AssetVersionList.new(
            @version, service_sid: @solution[:service_sid], asset_sid: @solution[:sid], )
    end

 @asset_versions
end

#deleteBoolean

Delete the AssetInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



178
179
180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 178

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchAssetInstance

Fetch the AssetInstance

Returns:



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 190

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



263
264
265
266
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 263

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

#to_sObject

Provide a user friendly representation



256
257
258
259
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 256

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

#update(friendly_name: nil) ⇒ AssetInstance

Update the AssetInstance

Parameters:

  • friendly_name (String) (defaults to: nil)

    A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.

Returns:



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/serverless/v1/service/asset.rb', line 211

def update(
    friendly_name: nil
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
    })

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