Class: Merge::Ticketing::Viewer
- Inherits:
-
Object
- Object
- Merge::Ticketing::Viewer
- Defined in:
- lib/merge_ruby_client/ticketing/types/viewer.rb
Overview
# The Viewer Object
### Description
The `Viewer` object is used to represent a User or Team within a company.
### Usage Example
TODO
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
- #id ⇒ String readonly
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
-
#team ⇒ Merge::Ticketing::ViewerTeam
readonly
The Team this Viewer belongs to.
-
#user ⇒ Merge::Ticketing::ViewerUser
readonly
The User this Viewer belongs to.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Ticketing::Viewer
Deserialize a JSON object to an instance of Viewer.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, team: OMIT, user: OMIT, additional_properties: nil) ⇒ Merge::Ticketing::Viewer constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Viewer to a JSON object.
Constructor Details
#initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, team: OMIT, user: OMIT, additional_properties: nil) ⇒ Merge::Ticketing::Viewer
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 45 def initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, team: OMIT, user: OMIT, additional_properties: nil) @id = id if id != OMIT @remote_id = remote_id if remote_id != OMIT @created_at = created_at if created_at != OMIT @modified_at = modified_at if modified_at != OMIT @team = team if team != OMIT @user = user if user != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "remote_id": remote_id, "created_at": created_at, "modified_at": modified_at, "team": team, "user": user }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
30 31 32 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 30 def additional_properties @additional_properties end |
#created_at ⇒ DateTime (readonly)
Returns The datetime that this object was created by Merge.
22 23 24 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 22 def created_at @created_at end |
#id ⇒ String (readonly)
18 19 20 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 18 def id @id end |
#modified_at ⇒ DateTime (readonly)
Returns The datetime that this object was modified by Merge.
24 25 26 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 24 def modified_at @modified_at end |
#remote_id ⇒ String (readonly)
Returns The third-party API ID of the matching object.
20 21 22 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 20 def remote_id @remote_id end |
#team ⇒ Merge::Ticketing::ViewerTeam (readonly)
Returns The Team this Viewer belongs to.
26 27 28 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 26 def team @team end |
#user ⇒ Merge::Ticketing::ViewerUser (readonly)
Returns The User this Viewer belongs to.
28 29 30 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 28 def user @user end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Ticketing::Viewer
Deserialize a JSON object to an instance of Viewer
70 71 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 97 98 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 70 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] remote_id = parsed_json["remote_id"] created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?) modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?) if parsed_json["team"].nil? team = nil else team = parsed_json["team"].to_json team = Merge::Ticketing::ViewerTeam.from_json(json_object: team) end if parsed_json["user"].nil? user = nil else user = parsed_json["user"].to_json user = Merge::Ticketing::ViewerUser.from_json(json_object: user) end new( id: id, remote_id: remote_id, created_at: created_at, modified_at: modified_at, team: team, user: user, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
113 114 115 116 117 118 119 120 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 113 def self.validate_raw(obj:) obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.") obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.") obj.team.nil? || Merge::Ticketing::ViewerTeam.validate_raw(obj: obj.team) obj.user.nil? || Merge::Ticketing::ViewerUser.validate_raw(obj: obj.user) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Viewer to a JSON object
103 104 105 |
# File 'lib/merge_ruby_client/ticketing/types/viewer.rb', line 103 def to_json(*_args) @_field_set&.to_json end |