Class: Merge::Ticketing::AttachmentRequest

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

Overview

# The Attachment Object

### Description
The `Attachment` object is used to represent an attachment for 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(file_name: OMIT, ticket: OMIT, file_url: OMIT, content_type: OMIT, uploaded_by: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Ticketing::AttachmentRequest

Parameters:

  • file_name (String) (defaults to: OMIT)

    The attachment’s name. It is required to include the file extension in the attachment’s name.

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

    The ticket associated with the attachment.

  • file_url (String) (defaults to: OMIT)

    The attachment’s url. It is required to include the file extension in the file’s URL.

  • content_type (String) (defaults to: OMIT)

    The attachment’s file format.

  • uploaded_by (String) (defaults to: OMIT)

    The user who uploaded the attachment.

  • 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



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

def initialize(file_name: OMIT, ticket: OMIT, file_url: OMIT, content_type: OMIT, uploaded_by: OMIT,
               integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil)
  @file_name = file_name if file_name != OMIT
  @ticket = ticket if ticket != OMIT
  @file_url = file_url if file_url != OMIT
  @content_type = content_type if content_type != OMIT
  @uploaded_by = uploaded_by if uploaded_by != OMIT
  @integration_params = integration_params if integration_params != OMIT
  @linked_account_params =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "file_name": file_name,
    "ticket": ticket,
    "file_url": file_url,
    "content_type": content_type,
    "uploaded_by": uploaded_by,
    "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



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

def additional_properties
  @additional_properties
end

#content_typeString (readonly)

Returns The attachment’s file format.

Returns:

  • (String)

    The attachment’s file format.



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

def content_type
  @content_type
end

#file_nameString (readonly)

Returns The attachment’s name. It is required to include the file extension in the attachment’s name.

Returns:

  • (String)

    The attachment’s name. It is required to include the file extension in the attachment’s name.



17
18
19
# File 'lib/merge_ruby_client/ticketing/types/attachment_request.rb', line 17

def file_name
  @file_name
end

#file_urlString (readonly)

Returns The attachment’s url. It is required to include the file extension in the file’s URL.

Returns:

  • (String)

    The attachment’s url. It is required to include the file extension in the file’s URL.



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

def file_url
  @file_url
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


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

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


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

def 
  @linked_account_params
end

#ticketMerge::Ticketing::AttachmentRequestTicket (readonly)

Returns The ticket associated with the attachment.

Returns:



19
20
21
# File 'lib/merge_ruby_client/ticketing/types/attachment_request.rb', line 19

def ticket
  @ticket
end

#uploaded_byString (readonly)

Returns The user who uploaded the attachment.

Returns:

  • (String)

    The user who uploaded the attachment.



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

def uploaded_by
  @uploaded_by
end

Class Method Details

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

Deserialize a JSON object to an instance of AttachmentRequest

Parameters:

  • json_object (String)

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/merge_ruby_client/ticketing/types/attachment_request.rb', line 77

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  file_name = parsed_json["file_name"]
  if parsed_json["ticket"].nil?
    ticket = nil
  else
    ticket = parsed_json["ticket"].to_json
    ticket = Merge::Ticketing::AttachmentRequestTicket.from_json(json_object: ticket)
  end
  file_url = parsed_json["file_url"]
  content_type = parsed_json["content_type"]
  uploaded_by = parsed_json["uploaded_by"]
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  new(
    file_name: file_name,
    ticket: ticket,
    file_url: file_url,
    content_type: content_type,
    uploaded_by: uploaded_by,
    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)


117
118
119
120
121
122
123
124
125
# File 'lib/merge_ruby_client/ticketing/types/attachment_request.rb', line 117

def self.validate_raw(obj:)
  obj.file_name&.is_a?(String) != false || raise("Passed value for field obj.file_name is not the expected type, validation failed.")
  obj.ticket.nil? || Merge::Ticketing::AttachmentRequestTicket.validate_raw(obj: obj.ticket)
  obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.")
  obj.content_type&.is_a?(String) != false || raise("Passed value for field obj.content_type is not the expected type, validation failed.")
  obj.uploaded_by&.is_a?(String) != false || raise("Passed value for field obj.uploaded_by 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 AttachmentRequest to a JSON object

Returns:

  • (String)


107
108
109
# File 'lib/merge_ruby_client/ticketing/types/attachment_request.rb', line 107

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