lib/twilio-ruby/rest/ip_messaging/v1/service.rb in twilio-ruby-5.4.2 vs lib/twilio-ruby/rest/ip_messaging/v1/service.rb in twilio-ruby-5.4.3
- old
+ new
@@ -25,24 +25,19 @@
# Retrieve a single page of ServiceInstance records from the API.
# Request is executed immediately.
# @param [String] friendly_name The friendly_name
# @return [ServiceInstance] Newly created ServiceInstance
def create(friendly_name: nil)
- data = Twilio::Values.of({
- 'FriendlyName' => friendly_name,
- })
+ data = Twilio::Values.of({'FriendlyName' => friendly_name,})
payload = @version.create(
'POST',
@uri,
data: data
)
- ServiceInstance.new(
- @version,
- payload,
- )
+ ServiceInstance.new(@version, payload,)
end
##
# Lists ServiceInstance records from the API as a list.
# Unlike stream(), this operation is eager and will load `limit` records into
@@ -53,14 +48,11 @@
# not set will use the default value of 50 records. If no page_size is defined
# but a limit is defined, stream() will attempt to read the limit with the most
# efficient page size, i.e. min(limit, 1000)
# @return [Array] Array of up to limit results
def list(limit: nil, page_size: nil)
- self.stream(
- limit: limit,
- page_size: page_size
- ).entries
+ self.stream(limit: limit, page_size: page_size).entries
end
##
# Streams ServiceInstance records from the API as an Enumerable.
# This operation lazily loads records as efficiently as possible until the limit
@@ -73,13 +65,11 @@
# efficient page size, i.e. min(limit, 1000)
# @return [Enumerable] Enumerable that will yield up to limit results
def stream(limit: nil, page_size: nil)
limits = @version.read_limits(limit, page_size)
- page = self.page(
- page_size: limits[:page_size],
- )
+ page = self.page(page_size: limits[:page_size],)
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end
##
@@ -87,13 +77,11 @@
# This operation lazily loads records as efficiently as possible until the limit
# is reached.
def each
limits = @version.read_limits
- page = self.page(
- page_size: limits[:page_size],
- )
+ page = self.page(page_size: limits[:page_size],)
@version.stream(page,
limit: limits[:limit],
page_limit: limits[:page_limit]).each {|x| yield x}
end
@@ -156,14 +144,11 @@
##
# Build an instance of ServiceInstance
# @param [Hash] payload Payload response from the API
# @return [ServiceInstance] ServiceInstance
def get_instance(payload)
- ServiceInstance.new(
- @version,
- payload,
- )
+ ServiceInstance.new(@version, payload,)
end
##
# Provide a user friendly representation
def to_s
@@ -179,13 +164,11 @@
# @return [ServiceContext] ServiceContext
def initialize(version, sid)
super(version)
# Path Solution
- @solution = {
- sid: sid,
- }
+ @solution = {sid: sid,}
@uri = "/Services/#{@solution[:sid]}"
# Dependents
@channels = nil
@roles = nil
@@ -202,15 +185,11 @@
'GET',
@uri,
params,
)
- ServiceInstance.new(
- @version,
- payload,
- sid: @solution[:sid],
- )
+ ServiceInstance.new(@version, payload, sid: @solution[:sid],)
end
##
# Deletes the ServiceInstance
# @return [Boolean] true if delete succeeds, true otherwise
@@ -417,37 +396,26 @@
'POST',
@uri,
data: data,
)
- ServiceInstance.new(
- @version,
- payload,
- sid: @solution[:sid],
- )
+ ServiceInstance.new(@version, payload, sid: @solution[:sid],)
end
##
# Access the channels
# @return [ChannelList]
# @return [ChannelContext] if sid was passed.
def channels(sid=:unset)
raise ArgumentError, 'sid cannot be nil' if sid.nil?
if sid != :unset
- return ChannelContext.new(
- @version,
- @solution[:sid],
- sid,
- )
+ return ChannelContext.new(@version, @solution[:sid], sid,)
end
unless @channels
- @channels = ChannelList.new(
- @version,
- service_sid: @solution[:sid],
- )
+ @channels = ChannelList.new(@version, service_sid: @solution[:sid],)
end
@channels
end
@@ -457,22 +425,15 @@
# @return [RoleContext] if sid was passed.
def roles(sid=:unset)
raise ArgumentError, 'sid cannot be nil' if sid.nil?
if sid != :unset
- return RoleContext.new(
- @version,
- @solution[:sid],
- sid,
- )
+ return RoleContext.new(@version, @solution[:sid], sid,)
end
unless @roles
- @roles = RoleList.new(
- @version,
- service_sid: @solution[:sid],
- )
+ @roles = RoleList.new(@version, service_sid: @solution[:sid],)
end
@roles
end
@@ -482,22 +443,15 @@
# @return [UserContext] if sid was passed.
def users(sid=:unset)
raise ArgumentError, 'sid cannot be nil' if sid.nil?
if sid != :unset
- return UserContext.new(
- @version,
- @solution[:sid],
- sid,
- )
+ return UserContext.new(@version, @solution[:sid], sid,)
end
unless @users
- @users = UserList.new(
- @version,
- service_sid: @solution[:sid],
- )
+ @users = UserList.new(@version, service_sid: @solution[:sid],)
end
@users
end
@@ -544,24 +498,19 @@
'links' => payload['links'],
}
# Context
@instance_context = nil
- @params = {
- 'sid' => sid || @properties['sid'],
- }
+ @params = {'sid' => sid || @properties['sid'],}
end
##
# Generate an instance context for the instance, the context is capable of
# performing various actions. All instance actions are proxied to the context
# @return [ServiceContext] ServiceContext for this ServiceInstance
def context
unless @instance_context
- @instance_context = ServiceContext.new(
- @version,
- @params['sid'],
- )
+ @instance_context = ServiceContext.new(@version, @params['sid'],)
end
@instance_context
end
##
\ No newline at end of file