lib/twilio-ruby/rest/chat/v1/service/role.rb in twilio-ruby-5.38.0 vs lib/twilio-ruby/rest/chat/v1/service/role.rb in twilio-ruby-5.39.0

- old
+ new

@@ -26,34 +26,29 @@ @solution = {service_sid: service_sid} @uri = "/Services/#{@solution[:service_sid]}/Roles" end ## - # Retrieve a single page of RoleInstance records from the API. - # Request is executed immediately. + # Create the RoleInstance # @param [String] friendly_name A descriptive string that you create to describe # the new resource. It can be up to 64 characters long. # @param [role.RoleType] type The type of role. Can be: `channel` for # [Channel](https://www.twilio.com/docs/chat/api/channels) roles or `deployment` # for [Service](https://www.twilio.com/docs/chat/api/services) roles. # @param [String] permission A permission that you grant to the new role. Only one # permission can be granted per parameter. To assign more than one permission, # repeat this parameter for each permission value. The values for this parameter # depend on the role's `type` and are described in the documentation. - # @return [RoleInstance] Newly created RoleInstance + # @return [RoleInstance] Created RoleInstance def create(friendly_name: nil, type: nil, permission: nil) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'Type' => type, 'Permission' => Twilio.serialize_list(permission) { |e| e }, }) - payload = @version.create( - 'POST', - @uri, - data: data - ) + payload = @version.create('POST', @uri, data: data) RoleInstance.new(@version, payload, service_sid: @solution[:service_sid], ) end ## @@ -115,15 +110,13 @@ params = Twilio::Values.of({ 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) - response = @version.page( - 'GET', - @uri, - params - ) + + response = @version.page('GET', @uri, params) + RolePage.new(@version, response, @solution) end ## # Retrieve a single page of RoleInstance records from the API. @@ -191,29 +184,23 @@ @solution = {service_sid: service_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Roles/#{@solution[:sid]}" end ## - # Fetch a RoleInstance + # Fetch the RoleInstance # @return [RoleInstance] Fetched RoleInstance def fetch - params = Twilio::Values.of({}) + payload = @version.fetch('GET', @uri) - payload = @version.fetch( - 'GET', - @uri, - params, - ) - RoleInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end ## - # Deletes the RoleInstance + # Delete the RoleInstance # @return [Boolean] true if delete succeeds, false otherwise def delete - @version.delete('delete', @uri) + @version.delete('DELETE', @uri) end ## # Update the RoleInstance # @param [String] permission A permission that you grant to the role. Only one @@ -222,15 +209,11 @@ # depend on the role's `type` and are described in the documentation. # @return [RoleInstance] Updated RoleInstance def update(permission: nil) data = Twilio::Values.of({'Permission' => Twilio.serialize_list(permission) { |e| e }, }) - payload = @version.update( - 'POST', - @uri, - data: data, - ) + payload = @version.update('POST', @uri, data: data) RoleInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end ## @@ -344,17 +327,17 @@ def url @properties['url'] end ## - # Fetch a RoleInstance + # Fetch the RoleInstance # @return [RoleInstance] Fetched RoleInstance def fetch context.fetch end ## - # Deletes the RoleInstance + # Delete the RoleInstance # @return [Boolean] true if delete succeeds, false otherwise def delete context.delete end \ No newline at end of file