Class: Twilio::REST::Verify::V2::ServiceContext::RateLimitContext::BucketInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, rate_limit_sid: nil, sid: nil) ⇒ BucketInstance

Initialize the BucketInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil)

    The SID of the [Service](www.twilio.com/docs/verify/api/service) the resource is associated with.

  • rate_limit_sid (String) (defaults to: nil)

    The Twilio-provided string that uniquely identifies the Rate Limit resource.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this Bucket.



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 278

def initialize(version, payload, service_sid: nil, rate_limit_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'rate_limit_sid' => payload['rate_limit_sid'],
      'service_sid' => payload['service_sid'],
      'account_sid' => payload['account_sid'],
      'max' => payload['max'].to_i,
      'interval' => payload['interval'].to_i,
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {
      'service_sid' => service_sid,
      'rate_limit_sid' => rate_limit_sid,
      'sid' => sid || @properties['sid'],
  }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



339
340
341
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 339

def 
  @properties['account_sid']
end

#contextBucketContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



307
308
309
310
311
312
313
314
315
316
317
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 307

def context
  unless @instance_context
    @instance_context = BucketContext.new(
        @version,
        @params['service_sid'],
        @params['rate_limit_sid'],
        @params['sid'],
    )
  end
  @instance_context
end

#date_createdTime

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created



357
358
359
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 357

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated



363
364
365
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 363

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the BucketInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



393
394
395
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 393

def delete
  context.delete
end

#fetchBucketInstance

Fetch a BucketInstance

Returns:



386
387
388
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 386

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



406
407
408
409
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 406

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Verify.V2.BucketInstance #{values}>"
end

#intervalString

Returns Number of seconds that the rate limit will be enforced over.

Returns:

  • (String)

    Number of seconds that the rate limit will be enforced over.



351
352
353
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 351

def interval
  @properties['interval']
end

#maxString

Returns Max number of requests.

Returns:

  • (String)

    Max number of requests.



345
346
347
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 345

def max
  @properties['max']
end

#rate_limit_sidString

Returns Rate Limit Sid.

Returns:

  • (String)

    Rate Limit Sid.



327
328
329
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 327

def rate_limit_sid
  @properties['rate_limit_sid']
end

#service_sidString

Returns The SID of the Service that the resource is associated with.

Returns:

  • (String)

    The SID of the Service that the resource is associated with



333
334
335
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 333

def service_sid
  @properties['service_sid']
end

#sidString

Returns A string that uniquely identifies this Bucket.

Returns:

  • (String)

    A string that uniquely identifies this Bucket.



321
322
323
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 321

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



399
400
401
402
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 399

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Verify.V2.BucketInstance #{values}>"
end

#update(max: :unset, interval: :unset) ⇒ BucketInstance

Update the BucketInstance

Parameters:

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

    Maximum number of requests permitted in during the interval.

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

    Number of seconds that the rate limit will be enforced over.

Returns:



379
380
381
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 379

def update(max: :unset, interval: :unset)
  context.update(max: max, interval: interval, )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



369
370
371
# File 'lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb', line 369

def url
  @properties['url']
end