Class: CalendarApi::Channel
- Defined in:
- lib/calendar_api/models/channel.rb
Overview
A notification channel used to watch for resource changes.
Instance Attribute Summary collapse
-
#expiration ⇒ Integer
Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds.
-
#id ⇒ String
A UUID or similar unique string that identifies this channel.
-
#kind ⇒ String
Identifies this as a notification channel used to watch for changes to a resource.
-
#resource_id ⇒ String
An opaque value that identifies the resource being watched on this channel.
-
#resource_uri ⇒ String
A version-specific identifier for the watched resource.
-
#token ⇒ String
An arbitrary string delivered to the target address with each notification.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(kind: 'api#channel', id: SKIP, resource_id: SKIP, resource_uri: SKIP, token: SKIP, expiration: SKIP, additional_properties: nil) ⇒ Channel
constructor
A new instance of Channel.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(kind: 'api#channel', id: SKIP, resource_id: SKIP, resource_uri: SKIP, token: SKIP, expiration: SKIP, additional_properties: nil) ⇒ Channel
Returns a new instance of Channel.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/calendar_api/models/channel.rb', line 69 def initialize(kind: 'api#channel', id: SKIP, resource_id: SKIP, resource_uri: SKIP, token: SKIP, expiration: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @kind = kind unless kind == SKIP @id = id unless id == SKIP @resource_id = resource_id unless resource_id == SKIP @resource_uri = resource_uri unless resource_uri == SKIP @token = token unless token == SKIP @expiration = expiration unless expiration == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#expiration ⇒ Integer
Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds.
38 39 40 |
# File 'lib/calendar_api/models/channel.rb', line 38 def expiration @expiration end |
#id ⇒ String
A UUID or similar unique string that identifies this channel.
19 20 21 |
# File 'lib/calendar_api/models/channel.rb', line 19 def id @id end |
#kind ⇒ String
Identifies this as a notification channel used to watch for changes to a resource.
15 16 17 |
# File 'lib/calendar_api/models/channel.rb', line 15 def kind @kind end |
#resource_id ⇒ String
An opaque value that identifies the resource being watched on this channel.
24 25 26 |
# File 'lib/calendar_api/models/channel.rb', line 24 def resource_id @resource_id end |
#resource_uri ⇒ String
A version-specific identifier for the watched resource.
28 29 30 |
# File 'lib/calendar_api/models/channel.rb', line 28 def resource_uri @resource_uri end |
#token ⇒ String
An arbitrary string delivered to the target address with each notification.
33 34 35 |
# File 'lib/calendar_api/models/channel.rb', line 33 def token @token end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/calendar_api/models/channel.rb', line 85 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. kind = hash['kind'] ||= 'api#channel' id = hash.key?('id') ? hash['id'] : SKIP resource_id = hash.key?('resourceId') ? hash['resourceId'] : SKIP resource_uri = hash.key?('resourceUri') ? hash['resourceUri'] : SKIP token = hash.key?('token') ? hash['token'] : SKIP expiration = hash.key?('expiration') ? hash['expiration'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Channel.new(kind: kind, id: id, resource_id: resource_id, resource_uri: resource_uri, token: token, expiration: expiration, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/calendar_api/models/channel.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['kind'] = 'kind' @_hash['id'] = 'id' @_hash['resource_id'] = 'resourceId' @_hash['resource_uri'] = 'resourceUri' @_hash['token'] = 'token' @_hash['expiration'] = 'expiration' @_hash end |
.nullables ⇒ Object
An array for nullable fields
65 66 67 |
# File 'lib/calendar_api/models/channel.rb', line 65 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/calendar_api/models/channel.rb', line 53 def self.optionals %w[ kind id resource_id resource_uri token expiration ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
122 123 124 125 126 127 |
# File 'lib/calendar_api/models/channel.rb', line 122 def inspect class_name = self.class.name.split('::').last "<#{class_name} kind: #{@kind.inspect}, id: #{@id.inspect}, resource_id:"\ " #{@resource_id.inspect}, resource_uri: #{@resource_uri.inspect}, token: #{@token.inspect},"\ " expiration: #{@expiration.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
114 115 116 117 118 119 |
# File 'lib/calendar_api/models/channel.rb', line 114 def to_s class_name = self.class.name.split('::').last "<#{class_name} kind: #{@kind}, id: #{@id}, resource_id: #{@resource_id}, resource_uri:"\ " #{@resource_uri}, token: #{@token}, expiration: #{@expiration}, additional_properties:"\ " #{@additional_properties}>" end |