lib/submodules/ably-ruby/lib/ably/rest/channel.rb in ably-rest-0.7.5 vs lib/submodules/ably-ruby/lib/ably/rest/channel.rb in ably-rest-0.8.1
- old
+ new
@@ -18,11 +18,11 @@
#
# @param client [Ably::Rest::Client]
# @param name [String] The name of the channel
# @param channel_options [Hash] Channel options, currently reserved for Encryption options
# @option channel_options [Boolean] :encrypted setting this to true for this channel will encrypt & decrypt all messages automatically
- # @option channel_options [Hash] :cipher_params A hash of options to configure the encryption. *:key* is required, all other options are optional. See {Ably::Util::Crypto#initialize} for a list of `cipher_params` options
+ # @option channel_options [Hash] :cipher_params A hash of options to configure the encryption. *:key* is required, all other options are optional. See {Ably::Util::Crypto#initialize} for a list of +cipher_params+ options
#
def initialize(client, name, channel_options = {})
ensure_utf_8 :name, name
@client = client
@@ -50,22 +50,25 @@
response = client.post("#{base_path}/publish", message)
[201, 204].include?(response.status)
end
- # Return the message history of the channel
+ # Return the message of the channel
#
- # @param [Hash] options the options for the message history request
- # @option options [Integer,Time] :start Time or millisecond since epoch
- # @option options [Integer,Time] :end Time or millisecond since epoch
- # @option options [Symbol] :direction `:forwards` or `:backwards`
- # @option options [Integer] :limit Maximum number of messages to retrieve up to 10,000
- # @option options [Symbol] :by `:message`, `:bundle` or `:hour`. Defaults to `:message`
+ # @param [Hash] options the options for the message history request
+ # @option options [Integer,Time] :start Ensure earliest time or millisecond since epoch for any messages retrieved is +:start+
+ # @option options [Integer,Time] :end Ensure latest time or millisecond since epoch for any messages retrieved is +:end+
+ # @option options [Symbol] :direction +:forwards+ or +:backwards+, defaults to +:backwards+
+ # @option options [Integer] :limit Maximum number of messages to retrieve up to 1,000, defaults to 100
#
- # @return [Ably::Models::PaginatedResource<Ably::Models::Message>] An Array of {Ably::Models::Message} objects that supports paging (#next_page, #first_page)
+ # @return [Ably::Models::PaginatedResource<Ably::Models::Message>] First {Ably::Models::PaginatedResource page} of {Ably::Models::Message} objects accessible with {Ably::Models::PaginatedResource#items #items}.
+ #
def history(options = {})
url = "#{base_path}/messages"
- options = options.dup
+ options = {
+ :direction => :backwards,
+ :limit => 100
+ }.merge(options)
[:start, :end].each { |option| options[option] = as_since_epoch(options[option]) if options.has_key?(option) }
paginated_options = {
coerce_into: 'Ably::Models::Message',