Class: Merge::Ticketing::CommentRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/ticketing/types/comment_request.rb

Overview

# The Comment Object

### Description
The `Comment` object is used to represent a comment on a ticket.
### Usage Example
TODO

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user: OMIT, contact: OMIT, body: OMIT, html_body: OMIT, ticket: OMIT, is_private: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Ticketing::CommentRequest

Parameters:

  • user (Merge::Ticketing::CommentRequestUser) (defaults to: OMIT)

    The author of the Comment, if the author is a User.

  • contact (Merge::Ticketing::CommentRequestContact) (defaults to: OMIT)

    The author of the Comment, if the author is a Contact.

  • body (String) (defaults to: OMIT)

    The comment’s text body.

  • html_body (String) (defaults to: OMIT)

    The comment’s text body formatted as html.

  • ticket (Merge::Ticketing::CommentRequestTicket) (defaults to: OMIT)

    The ticket associated with the comment.

  • is_private (Boolean) (defaults to: OMIT)

    Whether or not the comment is internal.

  • integration_params (Hash{String => Object}) (defaults to: OMIT)
  • linked_account_params (Hash{String => Object}) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 51

def initialize(user: OMIT, contact: OMIT, body: OMIT, html_body: OMIT, ticket: OMIT, is_private: OMIT,
               integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil)
  @user = user if user != OMIT
  @contact = contact if contact != OMIT
  @body = body if body != OMIT
  @html_body = html_body if html_body != OMIT
  @ticket = ticket if ticket != OMIT
  @is_private = is_private if is_private != OMIT
  @integration_params = integration_params if integration_params != OMIT
  @linked_account_params =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "user": user,
    "contact": contact,
    "body": body,
    "html_body": html_body,
    "ticket": ticket,
    "is_private": is_private,
    "integration_params": integration_params,
    "linked_account_params": 
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



34
35
36
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 34

def additional_properties
  @additional_properties
end

#bodyString (readonly)

Returns The comment’s text body.

Returns:

  • (String)

    The comment’s text body.



22
23
24
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 22

def body
  @body
end

#contactMerge::Ticketing::CommentRequestContact (readonly)

Returns The author of the Comment, if the author is a Contact.

Returns:



20
21
22
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 20

def contact
  @contact
end

#html_bodyString (readonly)

Returns The comment’s text body formatted as html.

Returns:

  • (String)

    The comment’s text body formatted as html.



24
25
26
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 24

def html_body
  @html_body
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


30
31
32
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 30

def integration_params
  @integration_params
end

#is_privateBoolean (readonly)

Returns Whether or not the comment is internal.

Returns:

  • (Boolean)

    Whether or not the comment is internal.



28
29
30
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 28

def is_private
  @is_private
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


32
33
34
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 32

def 
  @linked_account_params
end

#ticketMerge::Ticketing::CommentRequestTicket (readonly)

Returns The ticket associated with the comment.

Returns:



26
27
28
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 26

def ticket
  @ticket
end

#userMerge::Ticketing::CommentRequestUser (readonly)

Returns The author of the Comment, if the author is a User.

Returns:



18
19
20
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 18

def user
  @user
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Ticketing::CommentRequest

Deserialize a JSON object to an instance of CommentRequest

Parameters:

  • json_object (String)

Returns:



80
81
82
83
84
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
112
113
114
115
116
117
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 80

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["user"].nil?
    user = nil
  else
    user = parsed_json["user"].to_json
    user = Merge::Ticketing::CommentRequestUser.from_json(json_object: user)
  end
  if parsed_json["contact"].nil?
    contact = nil
  else
    contact = parsed_json["contact"].to_json
    contact = Merge::Ticketing::CommentRequestContact.from_json(json_object: contact)
  end
  body = parsed_json["body"]
  html_body = parsed_json["html_body"]
  if parsed_json["ticket"].nil?
    ticket = nil
  else
    ticket = parsed_json["ticket"].to_json
    ticket = Merge::Ticketing::CommentRequestTicket.from_json(json_object: ticket)
  end
  is_private = parsed_json["is_private"]
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  new(
    user: user,
    contact: contact,
    body: body,
    html_body: html_body,
    ticket: ticket,
    is_private: is_private,
    integration_params: integration_params,
    linked_account_params: ,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


132
133
134
135
136
137
138
139
140
141
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 132

def self.validate_raw(obj:)
  obj.user.nil? || Merge::Ticketing::CommentRequestUser.validate_raw(obj: obj.user)
  obj.contact.nil? || Merge::Ticketing::CommentRequestContact.validate_raw(obj: obj.contact)
  obj.body&.is_a?(String) != false || raise("Passed value for field obj.body is not the expected type, validation failed.")
  obj.html_body&.is_a?(String) != false || raise("Passed value for field obj.html_body is not the expected type, validation failed.")
  obj.ticket.nil? || Merge::Ticketing::CommentRequestTicket.validate_raw(obj: obj.ticket)
  obj.is_private&.is_a?(Boolean) != false || raise("Passed value for field obj.is_private is not the expected type, validation failed.")
  obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CommentRequest to a JSON object

Returns:

  • (String)


122
123
124
# File 'lib/merge_ruby_client/ticketing/types/comment_request.rb', line 122

def to_json(*_args)
  @_field_set&.to_json
end