ably 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/.rspec_parallel +3 -0
  3. data/.github/workflows/check.yml +13 -2
  4. data/.github/workflows/docs.yml +36 -0
  5. data/CHANGELOG.md +18 -0
  6. data/INTRO.md +14 -0
  7. data/lib/ably/auth.rb +26 -23
  8. data/lib/ably/models/auth_details.rb +9 -6
  9. data/lib/ably/models/channel_details.rb +15 -5
  10. data/lib/ably/models/channel_metrics.rb +31 -8
  11. data/lib/ably/models/channel_occupancy.rb +10 -3
  12. data/lib/ably/models/channel_options.rb +26 -3
  13. data/lib/ably/models/channel_state_change.rb +45 -15
  14. data/lib/ably/models/channel_status.rb +14 -4
  15. data/lib/ably/models/cipher_params.rb +36 -13
  16. data/lib/ably/models/connection_details.rb +91 -10
  17. data/lib/ably/models/connection_state_change.rb +54 -15
  18. data/lib/ably/models/delta_extras.rb +6 -7
  19. data/lib/ably/models/device_details.rb +60 -21
  20. data/lib/ably/models/device_push_details.rb +27 -19
  21. data/lib/ably/models/error_info.rb +59 -17
  22. data/lib/ably/models/http_paginated_response.rb +27 -5
  23. data/lib/ably/models/idiomatic_ruby_wrapper.rb +3 -2
  24. data/lib/ably/models/message.rb +64 -24
  25. data/lib/ably/models/message_encoders/base.rb +6 -0
  26. data/lib/ably/models/paginated_result.rb +29 -14
  27. data/lib/ably/models/presence_message.rb +72 -22
  28. data/lib/ably/models/protocol_message.rb +0 -4
  29. data/lib/ably/models/push_channel_subscription.rb +40 -15
  30. data/lib/ably/models/stats.rb +76 -40
  31. data/lib/ably/models/stats_types.rb +16 -40
  32. data/lib/ably/models/token_details.rb +34 -12
  33. data/lib/ably/models/token_request.rb +63 -2
  34. data/lib/ably/modules/async_wrapper.rb +1 -0
  35. data/lib/ably/modules/enum.rb +2 -0
  36. data/lib/ably/modules/event_emitter.rb +14 -1
  37. data/lib/ably/modules/model_common.rb +5 -0
  38. data/lib/ably/modules/state_emitter.rb +2 -0
  39. data/lib/ably/modules/state_machine.rb +4 -0
  40. data/lib/ably/realtime/channel/channel_properties.rb +9 -2
  41. data/lib/ably/realtime/channel/publisher.rb +2 -0
  42. data/lib/ably/realtime/channel/push_channel.rb +17 -10
  43. data/lib/ably/realtime/channel.rb +79 -42
  44. data/lib/ably/realtime/channels.rb +4 -3
  45. data/lib/ably/realtime/client/incoming_message_dispatcher.rb +6 -14
  46. data/lib/ably/realtime/client.rb +53 -32
  47. data/lib/ably/realtime/connection/connection_manager.rb +4 -0
  48. data/lib/ably/realtime/connection/websocket_transport.rb +4 -2
  49. data/lib/ably/realtime/connection.rb +94 -55
  50. data/lib/ably/realtime/presence.rb +61 -36
  51. data/lib/ably/realtime/push/admin.rb +16 -2
  52. data/lib/ably/realtime/push.rb +15 -3
  53. data/lib/ably/rest/channel/push_channel.rb +0 -3
  54. data/lib/ably/rest/channel.rb +29 -21
  55. data/lib/ably/rest/channels.rb +6 -3
  56. data/lib/ably/rest/client.rb +41 -35
  57. data/lib/ably/rest/presence.rb +27 -12
  58. data/lib/ably/rest/push/admin.rb +4 -0
  59. data/lib/ably/rest/push/device_registrations.rb +13 -2
  60. data/lib/ably/rest/push.rb +2 -0
  61. data/lib/ably/util/crypto.rb +14 -10
  62. data/lib/ably/version.rb +1 -1
  63. data/spec/acceptance/realtime/connection_spec.rb +0 -15
  64. data/spec/acceptance/realtime/message_spec.rb +3 -3
  65. data/spec/unit/models/protocol_message_spec.rb +0 -26
  66. data/spec/unit/realtime/incoming_message_dispatcher_spec.rb +0 -38
  67. metadata +6 -3
@@ -11,6 +11,7 @@ module Ably::Models
11
11
  # and allows an optional success callback block to be provided.
12
12
  #
13
13
  # @return [HttpPaginatedResponse,Ably::Util::SafeDeferrable]
14
+ #
14
15
  def first(&success_callback)
15
16
  async_wrap_if_realtime(success_callback) do
16
17
  return nil unless supports_pagination?
@@ -23,6 +24,7 @@ module Ably::Models
23
24
  # and allows an optional success callback block to be provided.
24
25
  #
25
26
  # @return [HttpPaginatedResponse,Ably::Util::SafeDeferrable]
27
+ #
26
28
  def next(&success_callback)
27
29
  async_wrap_if_realtime(success_callback) do
28
30
  return nil unless has_next?
@@ -30,34 +32,54 @@ module Ably::Models
30
32
  end
31
33
  end
32
34
 
33
- # HTTP status code for response
35
+ # The HTTP status code of the response.
36
+ #
37
+ # @spec HP4
38
+ #
34
39
  # @return [Integer]
40
+ #
35
41
  def status_code
36
42
  http_response.status.to_i
37
43
  end
38
44
 
39
- # True if the response is considered successful due to the HTTP status code
45
+ # Whether statusCode indicates success. This is equivalent to 200 <= statusCode < 300.
46
+ #
47
+ # @spec HP5
48
+ #
40
49
  # @return [Boolean]
50
+ #
41
51
  def success?
42
52
  (200..299).include?(http_response.status.to_i)
43
53
  end
44
54
 
45
- # Ably error code from +X-Ably-Errorcode+ header if available from response
55
+ # The error code if the X-Ably-Errorcode HTTP header is sent in the response.
56
+ #
57
+ # @spec HP6
58
+ #
46
59
  # @return [Integer]
60
+ #
47
61
  def error_code
48
62
  if http_response.headers['X-Ably-Errorcode']
49
63
  http_response.headers['X-Ably-Errorcode'].to_i
50
64
  end
51
65
  end
52
66
 
53
- # Error message from +X-Ably-Errormessage+ header if available from response
67
+ # The error message if the X-Ably-Errormessage HTTP header is sent in the response.
68
+ #
69
+ # @spec HP7
70
+ #
54
71
  # @return [String]
72
+ #
55
73
  def error_message
56
74
  http_response.headers['X-Ably-Errormessage']
57
75
  end
58
76
 
59
- # Headers for the HTTP response
77
+ # The headers of the response.
78
+ #
79
+ # @spec HP8
80
+ #
60
81
  # @return [Hash<String, String>]
82
+ #
61
83
  def headers
62
84
  http_response.headers || {}
63
85
  end
@@ -5,7 +5,8 @@ module Ably::Modules
5
5
  private
6
6
  # Creates or returns an {IdiomaticRubyWrapper} ensuring it never wraps itself
7
7
  #
8
- # @return {IdiomaticRubyWrapper}
8
+ # @return [IdiomaticRubyWrapper]
9
+ #
9
10
  def IdiomaticRubyWrapper(object, options = {})
10
11
  case object
11
12
  when Ably::Models::IdiomaticRubyWrapper
@@ -143,7 +144,7 @@ module Ably::Models
143
144
  end
144
145
 
145
146
  # @!attribute [r] Hash
146
- # @return [Hash] Access to the raw Hash object provided to the constructer of this wrapper
147
+ # @return [Hash] Access to the raw Hash object provided to the constructor of this wrapper
147
148
  def attributes
148
149
  @attributes
149
150
  end
@@ -7,6 +7,7 @@ module Ably::Models
7
7
  # @param [Hash] options (see Message#initialize)
8
8
  #
9
9
  # @return [Message]
10
+ #
10
11
  def self.Message(message, options = {})
11
12
  case message
12
13
  when Message
@@ -18,26 +19,7 @@ module Ably::Models
18
19
  end
19
20
  end
20
21
 
21
- # A class representing an individual message to be sent or received
22
- # via the Ably Realtime service.
23
- #
24
- # @!attribute [r] name
25
- # @return [String] The event name, if available
26
- # @!attribute [r] client_id
27
- # @return [String] The id of the publisher of this message
28
- # @!attribute [r] data
29
- # @return [Object] The message payload. See the documentation for supported datatypes.
30
- # @!attribute [r] encoding
31
- # @return [Object] The encoding for the message data. Encoding and decoding of messages is handled automatically by the client library.
32
- # Therefore, the `encoding` attribute should always be nil unless an Ably library decoding error has occurred.
33
- # @!attribute [r] timestamp
34
- # @return [Time] Timestamp when the message was received by the Ably the realtime service
35
- # @!attribute [r] id
36
- # @return [String] A globally unique message ID
37
- # @!attribute [r] connection_id
38
- # @return [String] The connection_id of the publisher of the message
39
- # @!attribute [r] attributes
40
- # @return [Hash] Access the protocol message Hash object ruby'fied to use symbolized keys
22
+ # Contains an individual message that is sent to, or received from, Ably.
41
23
  #
42
24
  class Message
43
25
  include Ably::Modules::Conversions
@@ -50,6 +32,8 @@ module Ably::Models
50
32
 
51
33
  # {Message} initializer
52
34
  #
35
+ # @spec TM2, TM3
36
+ #
53
37
  # @param attributes [Hash] object with the underlying message detail key value attributes
54
38
  # @param [Hash] options an options Hash for this initializer
55
39
  # @option options [ProtocolMessage] :protocol_message An optional protocol message to assocate the presence message with
@@ -69,24 +53,74 @@ module Ably::Models
69
53
  self.attributes.freeze
70
54
  end
71
55
 
72
- %w( name client_id encoding ).each do |attribute|
73
- define_method attribute do
74
- attributes[attribute.to_sym]
75
- end
56
+ # The client ID of the publisher of this message.
57
+ #
58
+ # @spec RSL1g1, TM2b
59
+ #
60
+ # @return [String]
61
+ #
62
+ def client_id
63
+ attributes[:client_id]
64
+ end
65
+
66
+ # This is typically empty, as all messages received from Ably are automatically decoded client-side using this value.
67
+ # However, if the message encoding cannot be processed, this attribute contains the remaining transformations
68
+ # not applied to the data payload.
69
+ #
70
+ # @spec TM2e
71
+ #
72
+ # @return [String]
73
+ #
74
+ def encoding
75
+ attributes[:encoding]
76
76
  end
77
77
 
78
+ # The event name.
79
+ #
80
+ # @spec TM2g
81
+ #
82
+ # @return [String]
83
+ #
84
+ def name
85
+ attributes[:name]
86
+ end
87
+
88
+ # The message payload, if provided.
89
+ #
90
+ # @spec TM2d
91
+ #
92
+ # @return [Hash, nil]
93
+ #
78
94
  def data
79
95
  @data ||= attributes[:data].freeze
80
96
  end
81
97
 
98
+ # A Unique ID assigned by Ably to this message.
99
+ #
100
+ # @spec TM2a
101
+ #
102
+ # @return [String]
103
+ #
82
104
  def id
83
105
  attributes.fetch(:id) { "#{protocol_message.id!}:#{protocol_message_index}" }
84
106
  end
85
107
 
108
+ # The connection ID of the publisher of this message.
109
+ #
110
+ # @spec TM2c
111
+ #
112
+ # @return [String]
113
+ #
86
114
  def connection_id
87
115
  attributes.fetch(:connection_id) { protocol_message.connection_id if assigned_to_protocol_message? }
88
116
  end
89
117
 
118
+ # Timestamp of when the message was received by Ably, as milliseconds since the Unix epoch.
119
+ #
120
+ # @spec TM2f
121
+ #
122
+ # @return [Integer]
123
+ #
90
124
  def timestamp
91
125
  if attributes[:timestamp]
92
126
  as_time_from_epoch(attributes[:timestamp])
@@ -126,14 +160,18 @@ module Ably::Models
126
160
  end
127
161
 
128
162
  # True if this message is assigned to a ProtocolMessage for delivery to Ably, or received from Ably
163
+ #
129
164
  # @return [Boolean]
165
+ #
130
166
  # @api private
131
167
  def assigned_to_protocol_message?
132
168
  !!@protocol_message
133
169
  end
134
170
 
135
171
  # The optional ProtocolMessage this message is assigned to. If ProtocolMessage is nil, an error will be raised.
172
+ #
136
173
  # @return [Ably::Models::ProtocolMessage]
174
+ #
137
175
  # @api private
138
176
  def protocol_message
139
177
  raise RuntimeError, 'Message is not yet published with a ProtocolMessage. ProtocolMessage is nil' if @protocol_message.nil?
@@ -155,7 +193,9 @@ module Ably::Models
155
193
  end
156
194
 
157
195
  # Delta extras extension (TM2i)
196
+ #
158
197
  # @return [DeltaExtras, nil]
198
+ #
159
199
  # @api private
160
200
  def delta_extras
161
201
  return nil if attributes[:extras][:delta].nil?
@@ -32,6 +32,7 @@ module Ably
32
32
  # @param [Hash] channel_options the options used to initialize the channel that this message was received on
33
33
  #
34
34
  # @return [void]
35
+ #
35
36
  def encode(message, channel_options)
36
37
  raise "Not yet implemented"
37
38
  end
@@ -48,6 +49,7 @@ module Ably
48
49
  # @param [Hash] channel_options the options used to initialize the channel that this message was received on
49
50
  #
50
51
  # @return [void]
52
+ #
51
53
  def decode(message, channel_options)
52
54
  raise "Not yet implemented"
53
55
  end
@@ -59,6 +61,7 @@ module Ably
59
61
  # @param [String] encoding encoding to add to the current encoding
60
62
  #
61
63
  # @return [void]
64
+ #
62
65
  def add_encoding_to_message(encoding, message)
63
66
  message[:encoding] = [message[:encoding], encoding].compact.join('/')
64
67
  end
@@ -67,6 +70,7 @@ module Ably
67
70
  # i.e. current_encoding_part('utf-8/cipher+aes-128-cbc/base64') => 'base64'
68
71
  #
69
72
  # @return [String,nil]
73
+ #
70
74
  def current_encoding_part(message)
71
75
  if message[:encoding]
72
76
  message[:encoding].split('/')[-1]
@@ -81,6 +85,7 @@ module Ably
81
85
  # @param [Hash] message the message as a Hash object received directly from Ably.
82
86
  #
83
87
  # @return [void]
88
+ #
84
89
  def strip_current_encoding_part(message)
85
90
  raise "Cannot strip encoding when there is no encoding for this message" unless message[:encoding]
86
91
  message[:encoding] = message[:encoding].split('/')[0...-1].join('/')
@@ -92,6 +97,7 @@ module Ably
92
97
  # @param [Hash] message the message as a Hash object received directly from Ably.
93
98
  #
94
99
  # @return [Boolean]
100
+ #
95
101
  def is_empty?(message)
96
102
  message[:data].nil? || message[:data] == ''
97
103
  end
@@ -1,16 +1,18 @@
1
1
  module Ably::Models
2
- # Wraps any Ably HTTP response that supports paging and provides methods to iterate through
3
- # the pages using {#first}, {#next}, {#has_next?} and {#last?}
4
- #
5
- # All items in the HTTP response are available in the Array returned from {#items}
6
- #
7
- # Paging information is provided by Ably in the LINK HTTP headers
2
+ # Contains a page of results for message or presence history, stats, or REST presence requests.
3
+ # A PaginatedResult response from a REST API paginated query is also accompanied by metadata
4
+ # that indicates the relative queries available to the PaginatedResult object.
8
5
  #
9
6
  class PaginatedResult
10
7
  include Ably::Modules::AsyncWrapper if defined?(Ably::Realtime)
11
8
 
12
- # The items contained within this {PaginatedResult}
9
+ # Contains the current page of results; for example, an array of {Ably::Models::Message} or {Ably::Models::PresenceMessage} objects
10
+ # for a channel history request.
11
+ #
12
+ # @spec TG3
13
+ #
13
14
  # @return [Array]
15
+ #
14
16
  attr_reader :items
15
17
 
16
18
  # @param [Faraday::Response] http_response Initial HTTP response from an Ably request to a paged resource
@@ -22,6 +24,7 @@ module Ably::Models
22
24
  # @yield [Object] block will be called for each resource object for the current page. This is a useful way to apply a transformation to any page resources after they are retrieved
23
25
  #
24
26
  # @return [PaginatedResult]
27
+ #
25
28
  def initialize(http_response, base_url, client, options = {}, &each_block)
26
29
  @http_response = http_response
27
30
  @client = client
@@ -41,11 +44,12 @@ module Ably::Models
41
44
  @items = items.map { |item| yield item } if block_given?
42
45
  end
43
46
 
44
- # Retrieve the first page of results.
45
- # When used as part of the {Ably::Realtime} library, it will return a {Ably::Util::SafeDeferrable} object,
46
- # and allows an optional success callback block to be provided.
47
+ # Returns a new PaginatedResult for the first page of results.
48
+ #
49
+ # @spec TG5
50
+ #
51
+ # @return [PaginatedResult, Ably::Util::SafeDeferrable]
47
52
  #
48
- # @return [PaginatedResult,Ably::Util::SafeDeferrable]
49
53
  def first(&success_callback)
50
54
  async_wrap_if_realtime(success_callback) do
51
55
  return nil unless supports_pagination?
@@ -54,10 +58,14 @@ module Ably::Models
54
58
  end
55
59
 
56
60
  # Retrieve the next page of results.
61
+ #
57
62
  # When used as part of the {Ably::Realtime} library, it will return a {Ably::Util::SafeDeferrable} object,
58
- # and allows an optional success callback block to be provided.
63
+ # and allows an optional success callback block to be provided.
64
+ #
65
+ # @spec TG4
59
66
  #
60
67
  # @return [PaginatedResult,Ably::Util::SafeDeferrable]
68
+ #
61
69
  def next(&success_callback)
62
70
  async_wrap_if_realtime(success_callback) do
63
71
  return nil unless has_next?
@@ -65,17 +73,23 @@ module Ably::Models
65
73
  end
66
74
  end
67
75
 
68
- # True if this is the last page in the paged resource set
76
+ # Returns true if this page is the last page and returns false if there are more pages available by calling next available.
77
+ #
78
+ # @spec TG7
69
79
  #
70
80
  # @return [Boolean]
81
+ #
71
82
  def last?
72
83
  !supports_pagination? ||
73
84
  pagination_header('next').nil?
74
85
  end
75
86
 
76
- # True if there is a subsequent page in this paginated set available with {#next}
87
+ # Returns true if there are more pages available by calling next and returns false if this page is the last page available.
88
+ #
89
+ # @spec TG6
77
90
  #
78
91
  # @return [Boolean]
92
+ #
79
93
  def has_next?
80
94
  supports_pagination? && !last?
81
95
  end
@@ -83,6 +97,7 @@ module Ably::Models
83
97
  # True if the HTTP response supports paging with the expected LINK HTTP headers
84
98
  #
85
99
  # @return [Boolean]
100
+ #
86
101
  def supports_pagination?
87
102
  !pagination_headers.empty?
88
103
  end
@@ -5,6 +5,7 @@ module Ably::Models
5
5
  # @param [Hash] options (see PresenceMessage#initialize)
6
6
  #
7
7
  # @return [PresenceMessage]
8
+ #
8
9
  def self.PresenceMessage(presence_message, options = {})
9
10
  case presence_message
10
11
  when PresenceMessage
@@ -19,24 +20,6 @@ module Ably::Models
19
20
  # A class representing an individual presence message to be sent or received
20
21
  # via the Ably Realtime service.
21
22
  #
22
- # @!attribute [r] action
23
- # @return [ACTION] the state change event signified by a PresenceMessage
24
- # @!attribute [r] client_id
25
- # @return [String] The client_id associated with this presence state
26
- # @!attribute [r] connection_id
27
- # @return [String] A unique member identifier, disambiguating situations where a given client_id is present on multiple connections simultaneously
28
- # @!attribute [r] member_key
29
- # @return [String] A unique connection and client_id identifier ensuring multiple connected clients with the same client_id are unique
30
- # @!attribute [r] data
31
- # @return [Object] Optional client-defined status or other event payload associated with this state
32
- # @!attribute [r] encoding
33
- # @return [String] The encoding for the message data. Encoding and decoding of messages is handled automatically by the client library.
34
- # Therefore, the `encoding` attribute should always be nil unless an Ably library decoding error has occurred.
35
- # @!attribute [r] timestamp
36
- # @return [Time] Timestamp when the message was received by the Ably the realtime service
37
- # @!attribute [r] attributes
38
- # @return [Hash] Access the protocol message Hash object ruby'fied to use symbolized keys
39
- #
40
23
  class PresenceMessage
41
24
  include Ably::Modules::Conversions
42
25
  include Ably::Modules::Encodeable
@@ -44,6 +27,16 @@ module Ably::Models
44
27
  include Ably::Modules::SafeDeferrable if defined?(Ably::Realtime)
45
28
  extend Ably::Modules::Enum
46
29
 
30
+ # Describes the possible actions members in the presence set can emit.
31
+ #
32
+ # ABSENT TP2 A member is not present in the channel.
33
+ # PRESENT TP2 When subscribing to presence events on a channel that already has members present, this event is emitted for every member already present on the channel before the subscribe listener was registered.
34
+ # ENTER TP2 A new member has entered the channel.
35
+ # LEAVE TP2 A member who was present has now left the channel. This may be a result of an explicit request to leave or implicitly when detaching from the channel. Alternatively, if a member's connection is abruptly disconnected and they do not resume their connection within a minute, Ably treats this as a leave event as the client is no longer present.
36
+ # UPDATE TP2 An already present member has updated their member data. Being notified of member data updates can be very useful, for example, it can be used to update the status of a user when they are typing a message.
37
+ #
38
+ # @spec TP2
39
+ #
47
40
  ACTION = ruby_enum('ACTION',
48
41
  :absent,
49
42
  :present,
@@ -76,24 +69,75 @@ module Ably::Models
76
69
  self.attributes.freeze
77
70
  end
78
71
 
79
- %w( client_id data encoding ).each do |attribute|
80
- define_method attribute do
81
- attributes[attribute.to_sym]
82
- end
72
+ # The ID of the client that published the PresenceMessage.
73
+ #
74
+ # @spec TP3c
75
+ #
76
+ # @return [String]
77
+ #
78
+ def client_id
79
+ attributes[:client_id]
80
+ end
81
+
82
+ # The payload of the {Ably::Models::PresenceMessage}.
83
+ #
84
+ # @spec TP3e
85
+ #
86
+ # @return [Hash, nil]
87
+ #
88
+ def data
89
+ attributes[:data]
90
+ end
91
+
92
+ # This will typically be empty as all presence messages received from Ably are automatically decoded client-side
93
+ # using this value. However, if the message encoding cannot be processed, this attribute will contain the remaining
94
+ # transformations not applied to the data payload.
95
+ #
96
+ # @spec TP3f
97
+ #
98
+ # @return [String]
99
+ #
100
+ def encoding
101
+ attributes[:encoding]
83
102
  end
84
103
 
104
+ # A unique ID assigned to each {Ably::Models::PresenceMessage} by Ably.
105
+ #
106
+ # @spec TP3a
107
+ #
108
+ # @return [String]
109
+ #
85
110
  def id
86
111
  attributes.fetch(:id) { "#{protocol_message.id!}:#{protocol_message_index}" }
87
112
  end
88
113
 
114
+ # The ID of the connection associated with the client that published the {Ably::Models::PresenceMessage}.
115
+ #
116
+ # @spec TP3d
117
+ #
118
+ # @return [String]
119
+ #
89
120
  def connection_id
90
121
  attributes.fetch(:connection_id) { protocol_message.connection_id if assigned_to_protocol_message? }
91
122
  end
92
123
 
124
+ # Combines clientId and connectionId to ensure that multiple connected clients with an identical clientId are uniquely
125
+ # identifiable. A string function that returns the combined clientId and connectionId.
126
+ #
127
+ # @spec TP3h
128
+ #
129
+ # @return [String]
130
+ #
93
131
  def member_key
94
132
  "#{connection_id}:#{client_id}"
95
133
  end
96
134
 
135
+ # The time the {Ably::Models::PresenceMessage} was received by Ably, as milliseconds since the Unix epoch.
136
+ #
137
+ # @spec TP3g
138
+ #
139
+ # @return [Integer]
140
+ #
97
141
  def timestamp
98
142
  if attributes[:timestamp]
99
143
  as_time_from_epoch(attributes[:timestamp])
@@ -102,6 +146,12 @@ module Ably::Models
102
146
  end
103
147
  end
104
148
 
149
+ # The type of {Ably::Models::PresenceMessage::ACTION} the PresenceMessage is for.
150
+ #
151
+ # @spec TP3b
152
+ #
153
+ # @return [Ably::Models::PresenceMessage::ACTION]
154
+ #
105
155
  def action
106
156
  ACTION(attributes[:action])
107
157
  end
@@ -189,10 +189,6 @@ module Ably::Models
189
189
  presence.map(&:size).sum + messages.map(&:size).sum
190
190
  end
191
191
 
192
- def has_correct_message_size?
193
- message_size <= connection_details.max_message_size
194
- end
195
-
196
192
  def params
197
193
  @params ||= attributes[:params].to_h
198
194
  end
@@ -6,6 +6,7 @@ module Ably::Modules
6
6
  # @param push_channel_subscription [Ably::Models::PushChannelSubscription,Hash,nil] A device details object
7
7
  #
8
8
  # @return [Ably::Models::PushChannelSubscription]
9
+ #
9
10
  def PushChannelSubscription(push_channel_subscription)
10
11
  case push_channel_subscription
11
12
  when Ably::Models::PushChannelSubscription
@@ -18,20 +19,14 @@ module Ably::Modules
18
19
  end
19
20
 
20
21
  module Ably::Models
21
- # An object representing a devices details, used currently for push notifications
22
- #
23
- # @!attribute [r] channel
24
- # @return [String] The realtime pub/sub channel this subscription is registered to
25
- # @!attribute [r] client_id
26
- # @return [String] Client ID that is assigned to one or more registered push devices
27
- # @!attribute [r] device_id
28
- # @return [String] Unique device identifier assigned to the push device
22
+ # Contains the subscriptions of a device, or a group of devices sharing the same clientId,
23
+ # has to a channel in order to receive push notifications.
29
24
  #
30
25
  class PushChannelSubscription < Ably::Exceptions::BaseAblyException
31
26
  include Ably::Modules::ModelCommon
32
27
 
33
28
  # @param hash_object [Hash,nil] Device detail attributes
34
- #a
29
+ #
35
30
  def initialize(hash_object = {})
36
31
  @raw_hash_object = hash_object || {}
37
32
  @hash_object = IdiomaticRubyWrapper(hash_object)
@@ -47,7 +42,9 @@ module Ably::Models
47
42
  end
48
43
  end
49
44
 
50
- # Constructor for channel subscription by device ID
45
+ # A static factory method to create a PushChannelSubscription object for a channel and single device.
46
+ #
47
+ # @spec PSC5
51
48
  #
52
49
  # @param channel [String] the realtime pub/sub channel this subscription is registered to
53
50
  # @param device_id [String] Unique device identifier assigned to the push device
@@ -58,7 +55,9 @@ module Ably::Models
58
55
  PushChannelSubscription.new(channel: channel, device_id: device_id)
59
56
  end
60
57
 
61
- # Constructor for channel subscription by client ID
58
+ # A static factory method to create a PushChannelSubscription object for a channel and group of devices sharing the same clientId.
59
+ #
60
+ # @spec PSC5
62
61
  #
63
62
  # @param channel [String] the realtime pub/sub channel this subscription is registered to
64
63
  # @param client_id [String] Client ID that is assigned to one or more registered push devices
@@ -69,11 +68,37 @@ module Ably::Models
69
68
  PushChannelSubscription.new(channel: channel, client_id: client_id)
70
69
  end
71
70
 
72
- %w(channel client_id device_id).each do |attribute|
73
- define_method attribute do
74
- attributes[attribute.to_sym]
75
- end
71
+ # The channel the push notification subscription is for.
72
+ #
73
+ # @spec PCS4
74
+ #
75
+ # @return [String]
76
+ #
77
+ def channel
78
+ attributes[:channel]
79
+ end
76
80
 
81
+ # The ID of the client the device, or devices are associated to.
82
+ #
83
+ # @spec PCS3, PCS6
84
+ #
85
+ # @return [String]
86
+ #
87
+ def client_id
88
+ attributes[:client_id]
89
+ end
90
+
91
+ # The unique ID of the device.
92
+ #
93
+ # @spec PCS2, PCS5, PCS6
94
+ #
95
+ # @return [String]
96
+ #
97
+ def device_id
98
+ attributes[:device_id]
99
+ end
100
+
101
+ %w(channel client_id device_id).each do |attribute|
77
102
  define_method "#{attribute}=" do |val|
78
103
  unless val.nil? || val.kind_of?(String)
79
104
  raise ArgumentError, "#{attribute} must be nil or a string value"