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
@@ -7,6 +7,7 @@ module Ably::Models
7
7
  # @param attributes (see #initialize)
8
8
  #
9
9
  # @return [CipherParams]
10
+ #
10
11
  def self.CipherParams(attributes)
11
12
  case attributes
12
13
  when CipherParams
@@ -16,7 +17,7 @@ module Ably::Models
16
17
  end
17
18
  end
18
19
 
19
- # CipherParams is used to configure a channel for encryption
20
+ # Sets the properties to configure encryption for a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel} object.
20
21
  #
21
22
  class CipherParams
22
23
  include Ably::Modules::ModelCommon
@@ -57,49 +58,71 @@ module Ably::Models
57
58
  end
58
59
 
59
60
  # The Cipher algorithm string such as AES-128-CBC
61
+ #
60
62
  # @param [Hash] params Hash containing :algorithm, :key_length and :mode key values
61
63
  #
62
64
  # @return [String]
65
+ #
63
66
  def self.cipher_type(params)
64
67
  "#{params[:algorithm]}-#{params[:key_length]}-#{params[:mode]}".to_s.upcase
65
68
  end
66
69
 
67
- # @!attribute [r] algorithm
68
- # @return [String] The algorithm to use for encryption, currently only +AES+ is supported
70
+ # The algorithm to use for encryption. Only AES is supported and is the default value.
71
+ #
72
+ # @spec TZ2a
73
+ #
74
+ # @return [String]
75
+ #
69
76
  def algorithm
70
77
  attributes.fetch(:algorithm) do
71
78
  Ably::Util::Crypto::DEFAULTS.fetch(:algorithm)
72
79
  end.downcase
73
80
  end
74
81
 
75
- # @!attribute [r] key
76
- # @return [Binary] Private key used to encrypt and decrypt payloads
82
+ # The private key used to encrypt and decrypt payloads.
83
+ #
84
+ # @spec TZ2d
85
+ #
86
+ # @return [Binary]
87
+ #
77
88
  def key
78
89
  attributes[:key]
79
90
  end
80
91
 
81
- # @!attribute [r] key_length
82
- # @return [Integer] The length in bits of the +key+
92
+ # The length of the key in bits; for example 128 or 256.
93
+ #
94
+ # @spec TZ2b
95
+ #
96
+ # @return [Integer]
97
+ #
83
98
  def key_length
84
99
  key.unpack('b*').first.length
85
100
  end
86
101
 
87
- # @!attribute [r] mode
88
- # @return [String] The cipher mode, currently only +CBC+ is supported
102
+ # The cipher mode. Only CBC is supported and is the default value.
103
+ #
104
+ # @spec TZ2c
105
+ #
106
+ # @return [String]
107
+ #
89
108
  def mode
90
109
  attributes.fetch(:mode) do
91
110
  Ably::Util::Crypto::DEFAULTS.fetch(:mode)
92
111
  end.downcase
93
112
  end
94
113
 
95
- # @!attribute [r] cipher_type
96
- # @return [String] The complete Cipher algorithm string such as AES-128-CBC
114
+ # The complete Cipher algorithm string such as AES-128-CBC
115
+ #
116
+ # @return [String]
117
+ #
97
118
  def cipher_type
98
119
  self.class.cipher_type(algorithm: algorithm, key_length: key_length, mode: mode)
99
120
  end
100
121
 
101
- # @!attribute [r] attributes
102
- # @return [Hash] Access the token details Hash object ruby'fied to use symbolized keys
122
+ # Access the token details Hash object ruby'fied to use symbolized keys
123
+ #
124
+ # @return [Hash]
125
+ #
103
126
  def attributes
104
127
  @attributes
105
128
  end
@@ -4,6 +4,7 @@ module Ably::Models
4
4
  # @param attributes (see #initialize)
5
5
  #
6
6
  # @return [ConnectionDetails]
7
+ #
7
8
  def self.ConnectionDetails(attributes)
8
9
  case attributes
9
10
  when ConnectionDetails
@@ -13,10 +14,8 @@ module Ably::Models
13
14
  end
14
15
  end
15
16
 
16
- # ConnectionDetails are optionally passed to the client library in the +CONNECTED+ {Ably::Models::ProtocolMessage#connectionDetails} attribute
17
- # to inform the client about any constraints it should adhere to and provide additional metadata about the connection.
18
- # For example, if a request is made to publish a message that exceeds the +maxMessageSize+, the client library can reject
19
- # the message immediately, without communicating with the Ably service
17
+ # Contains any constraints a client should adhere to and provides additional metadata about a {Ably::Realtime::Connection},
18
+ # such as if a request to {Ably::Realtime::Client#publish} a message that exceeds the maximum message size should be rejected immediately without communicating with Ably.
20
19
  #
21
20
  class ConnectionDetails
22
21
  include Ably::Modules::ModelCommon
@@ -28,7 +27,7 @@ module Ably::Models
28
27
  MAX_FRAME_SIZE = 524288 # See spec TO3l9
29
28
 
30
29
  # @param attributes [Hash]
31
- # @option attributes [String] :client_id contains the client ID assigned to the connection
30
+ # @option attributes [String] :client_id Contains the client ID assigned to the token. If clientId is null or omitted, then the client is prohibited from assuming a clientId in any operations, however if clientId is a wildcard string *, then the client is permitted to assume any clientId. Any other string value for clientId implies that the clientId is both enforced and assumed for all operations from this client.
32
31
  # @option attributes [String] :connection_key the connection secret key string that is used to resume a connection and its state
33
32
  # @option attributes [Integer] :max_message_size maximum individual message size in bytes
34
33
  # @option attributes [Integer] :max_frame_size maximum size for a single frame of data sent to Ably. This restriction applies to a {Ably::Models::ProtocolMessage} sent over a realtime connection, or the total body size for a REST request
@@ -49,18 +48,100 @@ module Ably::Models
49
48
  self.attributes.freeze
50
49
  end
51
50
 
52
- %w(client_id connection_key max_message_size max_frame_size max_inbound_rate connection_state_ttl max_idle_interval server_id).each do |attribute|
53
- define_method attribute do
54
- attributes[attribute.to_sym]
55
- end
51
+ # Contains the client ID assigned to the token. If clientId is null or omitted, then the client is prohibited from
52
+ # assuming a clientId in any operations, however if clientId is a wildcard string *, then the client is permitted
53
+ # to assume any clientId. Any other string value for clientId implies that the clientId is both enforced and assumed
54
+ # for all operations from this client.
55
+ #
56
+ # @spec RSA12a, CD2a
57
+ #
58
+ # @return [String]
59
+ #
60
+ def client_id
61
+ attributes[:client_id]
62
+ end
63
+
64
+ # The connection secret key string that is used to resume a connection and its state.
65
+ #
66
+ # @spec RTN15e, CD2b
67
+ #
68
+ # @return [String]
69
+ #
70
+ def connection_key
71
+ attributes[:connection_key]
72
+ end
73
+
74
+ # The duration that Ably will persist the connection state for when a Realtime client is abruptly disconnected.
75
+ #
76
+ # @spec CD2f, RTN14e, DF1a
77
+ #
78
+ # @return [Integer]
79
+ #
80
+ def connection_state_ttl
81
+ attributes[:connection_state_ttl]
82
+ end
83
+
84
+ # Overrides the default maxFrameSize.
85
+ #
86
+ # @spec CD2d
87
+ #
88
+ # @return [Integer]
89
+ #
90
+ def max_frame_size
91
+ attributes[:max_frame_size]
92
+ end
93
+
94
+ # The maximum allowable number of requests per second from a client or Ably. In the case of a realtime connection,
95
+ # this restriction applies to the number of messages sent, whereas in the case of REST, it is the total number of REST requests per second.
96
+ #
97
+ # @spec CD2e
98
+ #
99
+ # @return [Integer]
100
+ #
101
+ def max_inbound_rate
102
+ attributes[:max_inbound_rate]
103
+ end
104
+
105
+ # The maximum message size is an attribute of an Ably account and enforced by Ably servers.
106
+ # maxMessageSize indicates the maximum message size allowed by the Ably account this connection is using.
107
+ # Overrides the default value of ClientOptions.maxMessageSize.
108
+ #
109
+ # @spec CD2c
110
+ #
111
+ # @return [Integer]
112
+ #
113
+ def max_message_size
114
+ attributes[:max_message_size]
115
+ end
116
+
117
+ # A unique identifier for the front-end server that the client has connected to. This server ID is only used for the purposes of debugging.
118
+ #
119
+ # @spec CD2g
120
+ #
121
+ # @return [String]
122
+ #
123
+ def server_id
124
+ attributes[:server_id]
125
+ end
126
+
127
+ # The maximum length of time in milliseconds that the server will allow no activity to occur in the server to client direction.
128
+ # After such a period of inactivity, the server will send a HEARTBEAT or transport-level ping to the client.
129
+ # If the value is 0, the server will allow arbitrarily-long levels of inactivity.
130
+ #
131
+ # @spec CD2h
132
+ #
133
+ # @return [Integer]
134
+ #
135
+ def max_idle_interval
136
+ attributes[:max_idle_interval]
56
137
  end
57
138
 
58
139
  def has_client_id?
59
140
  attributes.has_key?(:client_id)
60
141
  end
61
142
 
62
- # @!attribute [r] attributes
63
143
  # @return [Hash] Access the token details Hash object ruby'fied to use symbolized keys
144
+ #
64
145
  def attributes
65
146
  @hash_object
66
147
  end
@@ -1,15 +1,5 @@
1
1
  module Ably::Models
2
- # ConnectionStateChange is a class that is emitted by the {Ably::Realtime::Connection} object
3
- # when a state change occurs
4
- #
5
- # @!attribute [r] current
6
- # @return [Connection::STATE] Current connection state
7
- # @!attribute [r] previous
8
- # @return [Connection::STATE] Previous connection state
9
- # @!attribute [r] retry_in
10
- # @return [Integer] Time in seconds until the connection will reattempt to connect when in the +:disconnected+ or +:suspended+ state
11
- # @!attribute [r] reason
12
- # @return [Ably::Models::ErrorInfo] Object describing the reason for a state change when not initiated by the consumer of the client library
2
+ # Contains {Ably::Models::ConnectionState} change information emitted by the {Ably::Realtime::Connection} object.
13
3
  #
14
4
  class ConnectionStateChange
15
5
  include Ably::Modules::ModelCommon
@@ -31,10 +21,59 @@ module Ably::Models
31
21
  raise ArgumentError, e
32
22
  end
33
23
 
34
- %w(current previous event retry_in reason protocol_message).each do |attribute|
35
- define_method attribute do
36
- @hash_object[attribute.to_sym]
37
- end
24
+ # The new {Ably::Realtime::Connection::STATE}.
25
+ #
26
+ # @spec TA2
27
+ #
28
+ # @return [Ably::Realtime::Connection::STATE]
29
+ #
30
+ def current
31
+ @hash_object[:current]
32
+ end
33
+
34
+ # The event that triggered this {Ably::Realtime::Connection::EVENT} change.
35
+ #
36
+ # @spec TA5
37
+ #
38
+ # @return [Ably::Realtime::Connection::STATE]
39
+ #
40
+ def event
41
+ @hash_object[:event]
42
+ end
43
+
44
+ # The previous {Ably::Models::Connection::STATE}. For the {Ably::Models::Connection::EVENT} UPDATE event,
45
+ # this is equal to the current {Ably::Models::Connection::STATE}.
46
+ #
47
+ # @spec TA2
48
+ #
49
+ # @return [Ably::Realtime::Connection::STATE]
50
+ #
51
+ def previous
52
+ @hash_object[:previous]
53
+ end
54
+
55
+ # An {Ably::Models::ErrorInfo} object containing any information relating to the transition.
56
+ #
57
+ # @spec RTN4f, TA3
58
+ #
59
+ # @return [Ably::Models::ErrorInfo, nil]
60
+ #
61
+ def reason
62
+ @hash_object[:reason]
63
+ end
64
+
65
+ # Duration in milliseconds, after which the client retries a connection where applicable.
66
+ #
67
+ # @spec RTN14d, TA2
68
+ #
69
+ # @return [Integer]
70
+ #
71
+ def retry_in
72
+ @hash_object[:retry_in]
73
+ end
74
+
75
+ def protocol_message
76
+ @hash_object[:protocol_message]
38
77
  end
39
78
 
40
79
  def to_s
@@ -1,19 +1,18 @@
1
1
  module Ably::Models
2
- #
3
- # @!attribute [r] from
4
- # @return [String] The id of the message the delta was generated from
5
- # @!attribute [r] format
6
- # @return [String] The delta format. Only vcdiff is supported as at API version 1.2
2
+ # Contains any arbitrary key-value pairs, which may also contain other primitive JSON types, JSON-encodable objects,
3
+ # or JSON-encodable arrays from delta compression.
7
4
  #
8
5
  class DeltaExtras
9
6
  include Ably::Modules::ModelCommon
10
7
 
11
- # The id of the message the delta was generated from.
8
+ # The ID of the message the delta was generated from.
9
+ #
12
10
  # @return [String, nil]
13
11
  #
14
12
  attr_reader :from
15
13
 
16
- # The delta format.
14
+ # The delta compression format. Only vcdiff is supported.
15
+ #
17
16
  # @return [String, nil]
18
17
  #
19
18
  attr_reader :format
@@ -6,6 +6,7 @@ module Ably::Modules
6
6
  # @param device_details [Ably::Models::DeviceDetails,Hash,nil] A device details object
7
7
  #
8
8
  # @return [Ably::Models::DeviceDetails]
9
+ #
9
10
  def DeviceDetails(device_details)
10
11
  case device_details
11
12
  when Ably::Models::DeviceDetails
@@ -18,38 +19,63 @@ 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] id
24
- # @return [String] Unique device identifier assigned randomly by the device
25
- # @!attribute [r] platform
26
- # @return [String] Device platform such as android, ios or browser
27
- # @!attribute [r] form_factor
28
- # @return [String] Device form factor such as phone, tablet, watch
29
- # @!attribute [r] client_id
30
- # @return [String] The authenticated client identifier for this device. See {https://www.ably.com/docs/general/authentication#identified-clients auth documentation}.
31
- # @!attribute [r] metadata
32
- # @return [Hash] Arbitrary metadata that can be associated with a device
33
- # @!attribute [r] device_secret
34
- # @return [String] This secret is used internally by Ably client libraries to authenticate with Ably when push registration updates are required such as when the GCM token expires and needs renewing
35
- # @!attribute [r] push
36
- # @return [DevicePushDetails] The push notification specific properties for this device allowing push notifications to be delivered to the device
22
+ # Contains the properties of a device registered for push notifications.
37
23
  #
38
24
  class DeviceDetails < Ably::Exceptions::BaseAblyException
39
25
  include Ably::Modules::ModelCommon
40
26
 
41
27
  # @param hash_object [Hash,nil] Device detail attributes
42
- #a
28
+ #
43
29
  def initialize(hash_object = {})
44
30
  @raw_hash_object = hash_object || {}
45
31
  @hash_object = IdiomaticRubyWrapper(hash_object)
46
32
  end
47
33
 
48
- %w(id platform form_factor client_id device_secret).each do |attribute|
49
- define_method attribute do
50
- attributes[attribute.to_sym]
51
- end
34
+ # A unique ID generated by the device.
35
+ #
36
+ # @spec PCD2
37
+ #
38
+ def id
39
+ attributes[:id]
40
+ end
41
+
42
+ # The DevicePlatform associated with the device.
43
+ # Describes the platform the device uses, such as android or ios.
44
+ #
45
+ # @spec PCD6
46
+ #
47
+ # @return [String]
48
+ #
49
+ def platform
50
+ attributes[:platform]
51
+ end
52
+
53
+ # The client ID the device is connected to Ably with.
54
+ #
55
+ # @spec PCD3
56
+ #
57
+ # @return [String]
58
+ #
59
+ def client_id
60
+ attributes[:client_id]
61
+ end
62
+
63
+ # The DeviceFormFactor object associated with the device.
64
+ # Describes the type of the device, such as phone or tablet.
65
+ #
66
+ # @spec PCD4
67
+ #
68
+ # @return [String]
69
+ #
70
+ def form_factor
71
+ attributes[:form_factor]
72
+ end
73
+
74
+ def device_secret
75
+ attributes[:device_secret]
76
+ end
52
77
 
78
+ %w(id platform form_factor client_id device_secret).each do |attribute|
53
79
  define_method "#{attribute}=" do |val|
54
80
  unless val.nil? || val.kind_of?(String)
55
81
  raise ArgumentError, "#{attribute} must be nil or a string value"
@@ -58,6 +84,12 @@ module Ably::Models
58
84
  end
59
85
  end
60
86
 
87
+ # A JSON object of key-value pairs that contains metadata for the device.
88
+ #
89
+ # @spec PCD5
90
+ #
91
+ # @return [Hash, nil]
92
+ #
61
93
  def metadata
62
94
  attributes[:metadata] || {}
63
95
  end
@@ -69,6 +101,13 @@ module Ably::Models
69
101
  attributes[:metadata] = val
70
102
  end
71
103
 
104
+ # The {Ably::Models::DevicePushDetails} object associated with the device.
105
+ # Describes the details of the push registration of the device.
106
+ #
107
+ # @spec PCD7
108
+ #
109
+ # @return [Ably::Models::DevicePushDetails]
110
+ #
72
111
  def push
73
112
  DevicePushDetails(attributes[:push] || {})
74
113
  end
@@ -6,6 +6,7 @@ module Ably::Modules
6
6
  # @param device_push_details [Ably::Models::DevicePushDetails,Hash,nil] A device push notification details object
7
7
  #
8
8
  # @return [Ably::Models::DevicePushDetails]
9
+ #
9
10
  def DevicePushDetails(device_push_details)
10
11
  case device_push_details
11
12
  when Ably::Models::DevicePushDetails
@@ -20,38 +21,39 @@ end
20
21
  module Ably::Models
21
22
  # An object with the push notification details for {DeviceDetails} object
22
23
  #
23
- # @!attribute [r] transport_type
24
- # @return [String] Transport type for push notifications such as gcm, apns, web
25
- # @!attribute [r] state
26
- # @return [String] The current state of this push target such as Active, Failing or Failed
27
- # @!attribute [r] error_reason
28
- # @return [ErrorInfo] If the state is Failing of Failed, this field may optionally contain a reason
29
- # @!attribute [r] metadata
30
- # @return [Hash] Arbitrary metadata that can be associated with this object
31
- #
32
24
  class DevicePushDetails < Ably::Exceptions::BaseAblyException
33
25
  include Ably::Modules::ModelCommon
34
26
 
35
27
  # @param hash_object [Hash,nil] Device push detail attributes
36
- #a
28
+ #
37
29
  def initialize(hash_object = {})
38
30
  @raw_hash_object = hash_object || {}
39
31
  @hash_object = IdiomaticRubyWrapper(@raw_hash_object)
40
32
  end
41
33
 
42
- %w(state).each do |attribute|
43
- define_method attribute do
44
- attributes[attribute.to_sym]
45
- end
34
+ # The current state of the push registration.
35
+ #
36
+ # @spec PCP4
37
+ #
38
+ # @return [Symbol]
39
+ #
40
+ def state
41
+ attributes[:state]
42
+ end
46
43
 
47
- define_method "#{attribute}=" do |val|
48
- unless val.nil? || val.kind_of?(String)
49
- raise ArgumentError, "#{attribute} must be nil or a string value"
50
- end
51
- attributes[attribute.to_sym] = val
44
+ def state=(val)
45
+ unless val.nil? || val.kind_of?(String)
46
+ raise ArgumentError, "state must be nil or a string value"
52
47
  end
48
+ attributes[:state] = val
53
49
  end
54
50
 
51
+ # A JSON object of key-value pairs that contains of the push transport and address.
52
+ #
53
+ # @spec PCP3
54
+ #
55
+ # @return [Hash, nil]
56
+ #
55
57
  def recipient
56
58
  attributes[:recipient] || {}
57
59
  end
@@ -63,6 +65,12 @@ module Ably::Models
63
65
  attributes[:recipient] = val
64
66
  end
65
67
 
68
+ # An {Ably::Models::ErrorInfo} object describing the most recent error when the state is Failing or Failed.
69
+ #
70
+ # @spec PCP2
71
+ #
72
+ # @return [Ably::Models::ErrorInfo]
73
+ #
66
74
  def error_reason
67
75
  attributes[:error_reason]
68
76
  end
@@ -6,6 +6,7 @@ module Ably::Modules
6
6
  # @param error_details [ErrorInfo,Hash] Error info attributes
7
7
  #
8
8
  # @return [ErrorInfo]
9
+ #
9
10
  def ErrorInfo(error_details)
10
11
  case error_details
11
12
  when Ably::Models::ErrorInfo
@@ -21,19 +22,6 @@ module Ably::Models
21
22
  # An exception type encapsulating error information containing
22
23
  # an Ably-specific error code and generic status code.
23
24
  #
24
- # @!attribute [r] message
25
- # @return [String] Additional reason information, where available
26
- # @!attribute [r] code
27
- # @return [Integer] Ably error code (see ably-common/protocol/errors.json)
28
- # @!attribute [r] status
29
- # @return [Integer] HTTP Status Code corresponding to this error, where applicable
30
- # @!attribute [r] request_id
31
- # @return [Integer] HTTP RequestId corresponding to this error, where applicable (#RSC7c)
32
- # @!attribute [r] cause
33
- # @return [Integer] HTTP Status Code corresponding to this error, where applicable (#TI1)
34
- # @!attribute [r] attributes
35
- # @return [Hash] Access the protocol message Hash object ruby'fied to use symbolized keys
36
- #
37
25
  class ErrorInfo < Ably::Exceptions::BaseAblyException
38
26
  include Ably::Modules::ModelCommon
39
27
 
@@ -42,10 +30,64 @@ module Ably::Models
42
30
  @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze)
43
31
  end
44
32
 
45
- %w(message code href status_code request_id cause).each do |attribute|
46
- define_method attribute do
47
- attributes[attribute.to_sym]
48
- end
33
+ # Ably error code.
34
+ #
35
+ # @spec TI1
36
+ #
37
+ # @return [Integer]
38
+ #
39
+ def code
40
+ attributes[:code]
41
+ end
42
+
43
+ # This is included for REST responses to provide a URL for additional help on the error code.
44
+ #
45
+ # @spec TI4
46
+ #
47
+ # @return [String]
48
+ #
49
+ def href
50
+ attributes[:href]
51
+ end
52
+
53
+ # Additional message information, where available.
54
+ #
55
+ # @spec TI1
56
+ #
57
+ # @return [String]
58
+ #
59
+ def message
60
+ attributes[:message]
61
+ end
62
+
63
+ # Information pertaining to what caused the error where available.
64
+ #
65
+ # @spec TI1
66
+ #
67
+ # @return [Ably::Models::ErrorInfo]
68
+ #
69
+ def cause
70
+ attributes[:cause]
71
+ end
72
+
73
+ # HTTP Status Code corresponding to this error, where applicable.
74
+ #
75
+ # @spec TI1
76
+ #
77
+ # @return [Integer]
78
+ #
79
+ def status_code
80
+ attributes[:status_code]
81
+ end
82
+
83
+ # If a request fails, the request ID must be included in the ErrorInfo returned to the user.
84
+ #
85
+ # @spec RSC7c
86
+ #
87
+ # @return [String]
88
+ #
89
+ def request_id
90
+ attributes[:request_id]
49
91
  end
50
92
  alias_method :status, :status_code
51
93