lib/twilio-ruby/rest/ip_messaging/v2/service.rb in twilio-ruby-5.4.2 vs lib/twilio-ruby/rest/ip_messaging/v2/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,19 +164,18 @@
# @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
@users = nil
+ @bindings = nil
end
##
# Fetch a ServiceInstance
# @return [ServiceInstance] Fetched ServiceInstance
@@ -202,15 +186,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
@@ -303,37 +283,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
@@ -343,22 +312,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
@@ -368,28 +330,39 @@
# @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
##
+ # Access the bindings
+ # @return [BindingList]
+ # @return [BindingContext] if sid was passed.
+ def bindings(sid=:unset)
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
+
+ if sid != :unset
+ return BindingContext.new(@version, @solution[:sid], sid,)
+ end
+
+ unless @bindings
+ @bindings = BindingList.new(@version, service_sid: @solution[:sid],)
+ end
+
+ @bindings
+ end
+
+ ##
# Provide a user friendly representation
def to_s
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
"#<Twilio.IpMessaging.V2.ServiceContext #{context}>"
end
@@ -432,25 +405,20 @@
'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
##
@@ -704,9 +672,16 @@
##
# Access the users
# @return [users] users
def users
context.users
+ end
+
+ ##
+ # Access the bindings
+ # @return [bindings] bindings
+ def bindings
+ context.bindings
end
##
# Provide a user friendly representation
def to_s
\ No newline at end of file