ably 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ably/capabilities.yaml +112 -0
- data/.github/workflows/check.yml +13 -3
- data/.github/workflows/docs.yml +36 -0
- data/.github/workflows/features.yml +14 -0
- data/.rspec_parallel +3 -0
- data/CHANGELOG.md +26 -0
- data/INTRO.md +14 -0
- data/README.md +2 -0
- data/lib/ably/auth.rb +26 -23
- data/lib/ably/models/auth_details.rb +9 -6
- data/lib/ably/models/channel_details.rb +15 -5
- data/lib/ably/models/channel_metrics.rb +31 -8
- data/lib/ably/models/channel_occupancy.rb +10 -3
- data/lib/ably/models/channel_options.rb +26 -3
- data/lib/ably/models/channel_state_change.rb +45 -15
- data/lib/ably/models/channel_status.rb +14 -4
- data/lib/ably/models/cipher_params.rb +36 -13
- data/lib/ably/models/connection_details.rb +91 -10
- data/lib/ably/models/connection_state_change.rb +54 -15
- data/lib/ably/models/delta_extras.rb +6 -7
- data/lib/ably/models/device_details.rb +60 -21
- data/lib/ably/models/device_push_details.rb +27 -19
- data/lib/ably/models/error_info.rb +59 -17
- data/lib/ably/models/http_paginated_response.rb +27 -5
- data/lib/ably/models/idiomatic_ruby_wrapper.rb +3 -2
- data/lib/ably/models/message.rb +64 -24
- data/lib/ably/models/message_encoders/base.rb +6 -0
- data/lib/ably/models/paginated_result.rb +29 -14
- data/lib/ably/models/presence_message.rb +72 -22
- data/lib/ably/models/protocol_message.rb +0 -4
- data/lib/ably/models/push_channel_subscription.rb +40 -15
- data/lib/ably/models/stats.rb +76 -40
- data/lib/ably/models/stats_types.rb +16 -40
- data/lib/ably/models/token_details.rb +34 -12
- data/lib/ably/models/token_request.rb +63 -2
- data/lib/ably/modules/async_wrapper.rb +1 -0
- data/lib/ably/modules/enum.rb +2 -0
- data/lib/ably/modules/event_emitter.rb +14 -1
- data/lib/ably/modules/model_common.rb +5 -0
- data/lib/ably/modules/state_emitter.rb +2 -0
- data/lib/ably/modules/state_machine.rb +4 -0
- data/lib/ably/realtime/channel/channel_properties.rb +9 -2
- data/lib/ably/realtime/channel/publisher.rb +2 -0
- data/lib/ably/realtime/channel/push_channel.rb +17 -10
- data/lib/ably/realtime/channel.rb +79 -42
- data/lib/ably/realtime/channels.rb +4 -3
- data/lib/ably/realtime/client/incoming_message_dispatcher.rb +6 -14
- data/lib/ably/realtime/client.rb +53 -32
- data/lib/ably/realtime/connection/connection_manager.rb +4 -0
- data/lib/ably/realtime/connection/websocket_transport.rb +4 -2
- data/lib/ably/realtime/connection.rb +94 -55
- data/lib/ably/realtime/presence.rb +61 -36
- data/lib/ably/realtime/push/admin.rb +16 -2
- data/lib/ably/realtime/push.rb +15 -3
- data/lib/ably/rest/channel/push_channel.rb +0 -3
- data/lib/ably/rest/channel.rb +29 -21
- data/lib/ably/rest/channels.rb +6 -3
- data/lib/ably/rest/client.rb +41 -35
- data/lib/ably/rest/presence.rb +27 -12
- data/lib/ably/rest/push/admin.rb +4 -0
- data/lib/ably/rest/push/device_registrations.rb +13 -2
- data/lib/ably/rest/push.rb +2 -0
- data/lib/ably/util/crypto.rb +14 -10
- data/lib/ably/version.rb +1 -1
- data/spec/acceptance/realtime/connection_spec.rb +0 -15
- data/spec/acceptance/realtime/message_spec.rb +3 -3
- data/spec/unit/models/protocol_message_spec.rb +0 -26
- data/spec/unit/realtime/incoming_message_dispatcher_spec.rb +0 -38
- metadata +8 -17
@@ -1,15 +1,5 @@
|
|
1
1
|
module Ably::Models
|
2
|
-
#
|
3
|
-
# when a state change occurs
|
4
|
-
#
|
5
|
-
# @!attribute [r] current
|
6
|
-
# @return [Connection::STATE] Current channel state
|
7
|
-
# @!attribute [r] previous
|
8
|
-
# @return [Connection::STATE] Previous channel state
|
9
|
-
# @!attribute [r] reason
|
10
|
-
# @return [Ably::Models::ErrorInfo] Object describing the reason for a state change when not initiated by the consumer of the client library
|
11
|
-
# @!attribute [r] resumed
|
12
|
-
# @return [Boolean] True when a channel is resumed, false when continuity on the channel is no longer provided indicating that the developer is now responsible for recovering lost messages on this channel through other means, such as using the hisory API
|
2
|
+
# Contains state change information emitted by {Ably::Rest::Channel} and {Ably::Realtime::Channel} objects.
|
13
3
|
#
|
14
4
|
class ChannelStateChange
|
15
5
|
include Ably::Modules::ModelCommon
|
@@ -31,12 +21,52 @@ module Ably::Models
|
|
31
21
|
raise ArgumentError, e
|
32
22
|
end
|
33
23
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
# The new current {Ably::Realtime::Channel::STATE}.
|
25
|
+
#
|
26
|
+
# @spec RTL2a, RTL2b
|
27
|
+
#
|
28
|
+
# @return [Ably::Realtime::Channel::STATE]
|
29
|
+
#
|
30
|
+
def current
|
31
|
+
@hash_object[:current]
|
32
|
+
end
|
33
|
+
|
34
|
+
# The previous state. For the {Ably::Realtime::Channel::EVENT}(:update) event, this is equal to the current {Ably::Realtime::Channel::STATE}.
|
35
|
+
#
|
36
|
+
# @spec RTL2a, RTL2b
|
37
|
+
#
|
38
|
+
# @return [Ably::Realtime::Channel::EVENT]
|
39
|
+
#
|
40
|
+
def previous
|
41
|
+
@hash_object[:previous]
|
42
|
+
end
|
43
|
+
|
44
|
+
# The event that triggered this {Ably::Realtime::Channel::STATE} change.
|
45
|
+
#
|
46
|
+
# @spec TH5
|
47
|
+
#
|
48
|
+
# @return [Ably::Realtime::Channel::STATE]
|
49
|
+
#
|
50
|
+
def event
|
51
|
+
@hash_object[:event]
|
52
|
+
end
|
53
|
+
|
54
|
+
# An {Ably::Models::ErrorInfo} object containing any information relating to the transition.
|
55
|
+
#
|
56
|
+
# @spec RTL2e, TH3
|
57
|
+
#
|
58
|
+
# @return [Ably::Models::ErrorInfo, nil]
|
59
|
+
#
|
60
|
+
def reason
|
61
|
+
@hash_object[:reason]
|
38
62
|
end
|
39
63
|
|
64
|
+
# Indicates whether message continuity on this channel is preserved, see Nonfatal channel errors for more info.
|
65
|
+
#
|
66
|
+
# @spec RTL2f, TH4
|
67
|
+
#
|
68
|
+
# @return [Boolean]
|
69
|
+
#
|
40
70
|
def resumed
|
41
71
|
!!@hash_object[:resumed]
|
42
72
|
end
|
@@ -4,6 +4,7 @@ module Ably::Models
|
|
4
4
|
# @param attributes (see #initialize)
|
5
5
|
#
|
6
6
|
# @return [ChannelStatus]
|
7
|
+
#
|
7
8
|
def self.ChannelStatus(attributes)
|
8
9
|
case attributes
|
9
10
|
when ChannelStatus
|
@@ -13,14 +14,19 @@ module Ably::Models
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
#
|
17
|
+
# Contains the status of a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel} object
|
18
|
+
# such as whether it is active and its {Ably::Models::ChannelOccupancy}.
|
19
|
+
#
|
20
|
+
# @spec CHS1
|
17
21
|
#
|
18
22
|
class ChannelStatus
|
19
23
|
extend Ably::Modules::Enum
|
20
24
|
extend Forwardable
|
21
25
|
include Ably::Modules::ModelCommon
|
22
26
|
|
23
|
-
# The attributes of ChannelStatus
|
27
|
+
# The attributes of ChannelStatus
|
28
|
+
#
|
29
|
+
# @spec CHS2
|
24
30
|
#
|
25
31
|
attr_reader :attributes
|
26
32
|
|
@@ -32,7 +38,9 @@ module Ably::Models
|
|
32
38
|
@attributes = IdiomaticRubyWrapper(attrs.clone)
|
33
39
|
end
|
34
40
|
|
35
|
-
#
|
41
|
+
# If true, the channel is active, otherwise false.
|
42
|
+
#
|
43
|
+
# @spec CHS2a
|
36
44
|
#
|
37
45
|
# @return [Boolean]
|
38
46
|
#
|
@@ -42,7 +50,9 @@ module Ably::Models
|
|
42
50
|
alias_method :active?, :is_active
|
43
51
|
alias_method :is_active?, :is_active
|
44
52
|
|
45
|
-
#
|
53
|
+
# A {Ably::Models::ChannelOccupancy} object.
|
54
|
+
#
|
55
|
+
# @spec CHS2b
|
46
56
|
#
|
47
57
|
# @return [Ably::Models::ChannelOccupancy, nil]
|
48
58
|
#
|
@@ -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
|
-
#
|
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
|
-
#
|
68
|
-
#
|
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
|
-
#
|
76
|
-
#
|
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
|
-
#
|
82
|
-
#
|
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
|
-
#
|
88
|
-
#
|
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
|
-
#
|
96
|
-
#
|
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
|
-
#
|
102
|
-
#
|
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
|
-
#
|
17
|
-
# to
|
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
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
#
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
#
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
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
|