Class: CalendarApi::WatchRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/calendar_api/models/watch_request.rb

Overview

Request body to set up a push notification channel.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, type:, address:, token: SKIP, params: SKIP, additional_properties: nil) ⇒ WatchRequest

Returns a new instance of WatchRequest.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/calendar_api/models/watch_request.rb', line 58

def initialize(id:, type:, address:, token: SKIP, params: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @token = token unless token == SKIP
  @type = type
  @address = address
  @params = params unless params == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressString

The address where notifications are delivered for this channel. Must be HTTPS.

Returns:

  • (String)


28
29
30
# File 'lib/calendar_api/models/watch_request.rb', line 28

def address
  @address
end

#idString

A UUID or similar unique string that identifies this channel.

Returns:

  • (String)


14
15
16
# File 'lib/calendar_api/models/watch_request.rb', line 14

def id
  @id
end

#paramsChannelParams

Additional parameters controlling delivery channel behavior.

Returns:



32
33
34
# File 'lib/calendar_api/models/watch_request.rb', line 32

def params
  @params
end

#tokenString

An arbitrary string delivered to the target address with each notification. Optional.

Returns:

  • (String)


19
20
21
# File 'lib/calendar_api/models/watch_request.rb', line 19

def token
  @token
end

#typeChannelType

The type of delivery mechanism used for the notification channel.

Returns:



23
24
25
# File 'lib/calendar_api/models/watch_request.rb', line 23

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/calendar_api/models/watch_request.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  address = hash.key?('address') ? hash['address'] : nil
  token = hash.key?('token') ? hash['token'] : SKIP
  params = ChannelParams.from_hash(hash['params']) if hash['params']

  # 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.
  WatchRequest.new(id: id,
                   type: type,
                   address: address,
                   token: token,
                   params: params,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/calendar_api/models/watch_request.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['token'] = 'token'
  @_hash['type'] = 'type'
  @_hash['address'] = 'address'
  @_hash['params'] = 'params'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/calendar_api/models/watch_request.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
# File 'lib/calendar_api/models/watch_request.rb', line 46

def self.optionals
  %w[
    token
    params
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



106
107
108
109
110
111
# File 'lib/calendar_api/models/watch_request.rb', line 106

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, token: #{@token.inspect}, type: #{@type.inspect},"\
  " address: #{@address.inspect}, params: #{@params.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
# File 'lib/calendar_api/models/watch_request.rb', line 99

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, token: #{@token}, type: #{@type}, address: #{@address}, params:"\
  " #{@params}, additional_properties: #{@additional_properties}>"
end