lib/ably/models/device_details.rb in ably-1.2.2 vs lib/ably/models/device_details.rb in ably-1.2.3

- old
+ new

@@ -4,10 +4,11 @@ # Convert device_details argument to a {Ably::Models::DeviceDetails} object # # @param device_details [Ably::Models::DeviceDetails,Hash,nil] A device details object # # @return [Ably::Models::DeviceDetails] + # def DeviceDetails(device_details) case device_details when Ably::Models::DeviceDetails device_details else @@ -16,50 +17,81 @@ end end end module Ably::Models - # An object representing a devices details, used currently for push notifications + # Contains the properties of a device registered for push notifications. # - # @!attribute [r] id - # @return [String] Unique device identifier assigned randomly by the device - # @!attribute [r] platform - # @return [String] Device platform such as android, ios or browser - # @!attribute [r] form_factor - # @return [String] Device form factor such as phone, tablet, watch - # @!attribute [r] client_id - # @return [String] The authenticated client identifier for this device. See {https://www.ably.com/docs/general/authentication#identified-clients auth documentation}. - # @!attribute [r] metadata - # @return [Hash] Arbitrary metadata that can be associated with a device - # @!attribute [r] device_secret - # @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 - # @!attribute [r] push - # @return [DevicePushDetails] The push notification specific properties for this device allowing push notifications to be delivered to the device - # class DeviceDetails < Ably::Exceptions::BaseAblyException include Ably::Modules::ModelCommon # @param hash_object [Hash,nil] Device detail attributes - #a + # def initialize(hash_object = {}) @raw_hash_object = hash_object || {} @hash_object = IdiomaticRubyWrapper(hash_object) end - %w(id platform form_factor client_id device_secret).each do |attribute| - define_method attribute do - attributes[attribute.to_sym] - end + # A unique ID generated by the device. + # + # @spec PCD2 + # + def id + attributes[:id] + end + # The DevicePlatform associated with the device. + # Describes the platform the device uses, such as android or ios. + # + # @spec PCD6 + # + # @return [String] + # + def platform + attributes[:platform] + end + + # The client ID the device is connected to Ably with. + # + # @spec PCD3 + # + # @return [String] + # + def client_id + attributes[:client_id] + end + + # The DeviceFormFactor object associated with the device. + # Describes the type of the device, such as phone or tablet. + # + # @spec PCD4 + # + # @return [String] + # + def form_factor + attributes[:form_factor] + end + + def device_secret + attributes[:device_secret] + end + + %w(id platform form_factor client_id device_secret).each do |attribute| define_method "#{attribute}=" do |val| unless val.nil? || val.kind_of?(String) raise ArgumentError, "#{attribute} must be nil or a string value" end attributes[attribute.to_sym] = val end end + # A JSON object of key-value pairs that contains metadata for the device. + # + # @spec PCD5 + # + # @return [Hash, nil] + # def metadata attributes[:metadata] || {} end def metadata=(val) @@ -67,9 +99,16 @@ raise ArgumentError, "metadata must be nil or a Hash value" end attributes[:metadata] = val end + # The {Ably::Models::DevicePushDetails} object associated with the device. + # Describes the details of the push registration of the device. + # + # @spec PCD7 + # + # @return [Ably::Models::DevicePushDetails] + # def push DevicePushDetails(attributes[:push] || {}) end def push=(val)