lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb in twilio-ruby-5.0.0.rc21 vs lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb in twilio-ruby-5.0.0.rc22

- old
+ new

@@ -33,24 +33,24 @@ # Request is executed immediately. # @param [String] body The body # @param [String] from The from # @param [String] attributes The attributes # @return [MessageInstance] Newly created MessageInstance - def create(body: nil, from: nil, attributes: nil) - data = { + def create(body: nil, from: :unset, attributes: :unset) + data = Twilio::Values.of({ 'Body' => body, 'From' => from, 'Attributes' => attributes, - } + }) payload = @version.create( 'POST', @uri, data: data ) - return MessageInstance.new( + MessageInstance.new( @version, payload, service_sid: @solution[:service_sid], channel_sid: @solution[:channel_sid], ) @@ -66,11 +66,11 @@ # @param [Integer] page_size Number of records to fetch per request, when 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(order: nil, limit: nil, page_size: nil) + def list(order: :unset, limit: nil, page_size: nil) self.stream( order: order, limit: limit, page_size: page_size ).entries @@ -86,11 +86,11 @@ # @param [Integer] page_size Number of records to fetch per request, when 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 [Enumerable] Enumerable that will yield up to limit results - def stream(order: nil, limit: nil, page_size: nil) + def stream(order: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( order: order, page_size: limits[:page_size], @@ -128,26 +128,39 @@ # @param [message.OrderType] order The order # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 # @return [Page] Page of MessageInstance - def page(order: nil, page_token: nil, page_number: nil, page_size: nil) - params = { + def page(order: :unset, page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ 'Order' => order, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, - } + }) response = @version.page( 'GET', @uri, params ) - return MessagePage.new(@version, response, @solution) + MessagePage.new(@version, response, @solution) end ## + # Retrieve a single page of MessageInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of MessageInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + MessagePage.new(@version, response, @solution) + end + + ## # Provide a user friendly representation def to_s '#<Twilio.IpMessaging.V1.MessageList>' end end @@ -171,11 +184,11 @@ ## # Build an instance of MessageInstance # @param [Hash] payload Payload response from the API # @return [MessageInstance] MessageInstance def get_instance(payload) - return MessageInstance.new( + MessageInstance.new( @version, payload, service_sid: @solution[:service_sid], channel_sid: @solution[:channel_sid], ) @@ -210,19 +223,19 @@ ## # Fetch a MessageInstance # @return [MessageInstance] Fetched MessageInstance def fetch - params = {} + params = Twilio::Values.of({}) payload = @version.fetch( 'GET', @uri, params, ) - return MessageInstance.new( + MessageInstance.new( @version, payload, service_sid: @solution[:service_sid], channel_sid: @solution[:channel_sid], sid: @solution[:sid], @@ -231,31 +244,31 @@ ## # Deletes the MessageInstance # @return [Boolean] true if delete succeeds, true otherwise def delete - return @version.delete('delete', @uri) + @version.delete('delete', @uri) end ## # Update the MessageInstance # @param [String] body The body # @param [String] attributes The attributes # @return [MessageInstance] Updated MessageInstance - def update(body: nil, attributes: nil) - data = { + def update(body: :unset, attributes: :unset) + data = Twilio::Values.of({ 'Body' => body, 'Attributes' => attributes, - } + }) payload = @version.update( 'POST', @uri, data: data, ) - return MessageInstance.new( + MessageInstance.new( @version, payload, service_sid: @solution[:service_sid], channel_sid: @solution[:channel_sid], sid: @solution[:sid], @@ -394,10 +407,10 @@ ## # Update the MessageInstance # @param [String] body The body # @param [String] attributes The attributes # @return [MessageInstance] Updated MessageInstance - def update(body: nil, attributes: nil) + def update(body: :unset, attributes: :unset) context.update( body: body, attributes: attributes, ) end \ No newline at end of file