merge_ticketing_client 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -6
  3. data/docs/Account.md +11 -10
  4. data/docs/AccountIntegration.md +1 -1
  5. data/docs/Attachment.md +15 -14
  6. data/docs/AttachmentRequest.md +11 -12
  7. data/docs/Collection.md +33 -0
  8. data/docs/CollectionTypeEnum.md +15 -0
  9. data/docs/CollectionsApi.md +193 -0
  10. data/docs/Comment.md +16 -15
  11. data/docs/CommentRequest.md +12 -13
  12. data/docs/ConditionSchema.md +30 -0
  13. data/docs/ConditionTypeEnum.md +15 -0
  14. data/docs/Contact.md +14 -13
  15. data/docs/DataPassthroughRequest.md +10 -11
  16. data/docs/EndUserDetailsRequest.md +2 -2
  17. data/docs/FieldFormatEnum.md +15 -0
  18. data/docs/FieldTypeEnum.md +15 -0
  19. data/docs/Issue.md +18 -17
  20. data/docs/LinkToken.md +1 -1
  21. data/docs/LinkedAccountCondition.md +27 -0
  22. data/docs/LinkedAccountConditionRequest.md +21 -0
  23. data/docs/LinkedAccountSelectiveSyncConfiguration.md +18 -0
  24. data/docs/LinkedAccountSelectiveSyncConfigurationListRequest.md +18 -0
  25. data/docs/LinkedAccountSelectiveSyncConfigurationRequest.md +18 -0
  26. data/docs/MetaResponse.md +6 -7
  27. data/docs/OperatorSchema.md +20 -0
  28. data/docs/PaginatedCollectionList.md +22 -0
  29. data/docs/PaginatedConditionSchemaList.md +22 -0
  30. data/docs/PaginatedRemoteFieldClassList.md +22 -0
  31. data/docs/PatchedTicketRequest.md +25 -22
  32. data/docs/Project.md +11 -10
  33. data/docs/ProjectsApi.md +10 -8
  34. data/docs/RemoteData.md +4 -5
  35. data/docs/RemoteField.md +19 -0
  36. data/docs/RemoteFieldClass.md +38 -0
  37. data/docs/RemoteFieldClassItemSchema.md +22 -0
  38. data/docs/RemoteResponse.md +9 -10
  39. data/docs/SelectiveSyncApi.md +233 -0
  40. data/docs/SelectiveSyncConfigurationsUsageEnum.md +15 -0
  41. data/docs/SyncStatus.md +5 -3
  42. data/docs/Tag.md +9 -8
  43. data/docs/Team.md +11 -10
  44. data/docs/Ticket.md +32 -25
  45. data/docs/TicketRequest.md +26 -25
  46. data/docs/TicketsApi.md +141 -13
  47. data/docs/User.md +14 -13
  48. data/docs/UsersApi.md +2 -0
  49. data/lib/merge_ticketing_client/api/collections_api.rb +234 -0
  50. data/lib/merge_ticketing_client/api/linked_accounts_api.rb +1 -1
  51. data/lib/merge_ticketing_client/api/projects_api.rb +14 -11
  52. data/lib/merge_ticketing_client/api/selective_sync_api.rb +225 -0
  53. data/lib/merge_ticketing_client/api/tickets_api.rb +177 -19
  54. data/lib/merge_ticketing_client/api/users_api.rb +3 -0
  55. data/lib/merge_ticketing_client/models/account.rb +16 -4
  56. data/lib/merge_ticketing_client/models/account_details_and_actions_status_enum.rb +1 -1
  57. data/lib/merge_ticketing_client/models/account_integration.rb +1 -1
  58. data/lib/merge_ticketing_client/models/attachment.rb +18 -4
  59. data/lib/merge_ticketing_client/models/attachment_request.rb +24 -20
  60. data/lib/merge_ticketing_client/models/categories_enum.rb +3 -2
  61. data/lib/merge_ticketing_client/models/category_enum.rb +3 -2
  62. data/lib/merge_ticketing_client/models/collection.rb +308 -0
  63. data/lib/merge_ticketing_client/models/collection_type_enum.rb +45 -0
  64. data/lib/merge_ticketing_client/models/comment.rb +19 -4
  65. data/lib/merge_ticketing_client/models/comment_request.rb +25 -20
  66. data/lib/merge_ticketing_client/models/condition_schema.rb +297 -0
  67. data/lib/merge_ticketing_client/models/condition_type_enum.rb +50 -0
  68. data/lib/merge_ticketing_client/models/contact.rb +16 -4
  69. data/lib/merge_ticketing_client/models/data_passthrough_request.rb +1 -0
  70. data/lib/merge_ticketing_client/models/encoding_enum.rb +1 -1
  71. data/lib/merge_ticketing_client/models/end_user_details_request.rb +2 -2
  72. data/lib/merge_ticketing_client/models/field_format_enum.rb +49 -0
  73. data/lib/merge_ticketing_client/models/field_type_enum.rb +49 -0
  74. data/lib/merge_ticketing_client/models/issue.rb +15 -4
  75. data/lib/merge_ticketing_client/models/link_token.rb +0 -5
  76. data/lib/merge_ticketing_client/models/linked_account_condition.rb +282 -0
  77. data/lib/merge_ticketing_client/models/linked_account_condition_request.rb +269 -0
  78. data/lib/merge_ticketing_client/models/linked_account_selective_sync_configuration.rb +221 -0
  79. data/lib/merge_ticketing_client/models/linked_account_selective_sync_configuration_list_request.rb +226 -0
  80. data/lib/merge_ticketing_client/models/linked_account_selective_sync_configuration_request.rb +226 -0
  81. data/lib/merge_ticketing_client/models/method_enum.rb +1 -1
  82. data/lib/merge_ticketing_client/models/operator_schema.rb +229 -0
  83. data/lib/merge_ticketing_client/models/paginated_collection_list.rb +240 -0
  84. data/lib/merge_ticketing_client/models/paginated_condition_schema_list.rb +240 -0
  85. data/lib/merge_ticketing_client/models/paginated_remote_field_class_list.rb +240 -0
  86. data/lib/merge_ticketing_client/models/patched_ticket_request.rb +57 -29
  87. data/lib/merge_ticketing_client/models/priority_enum.rb +1 -1
  88. data/lib/merge_ticketing_client/models/project.rb +16 -4
  89. data/lib/merge_ticketing_client/models/remote_data.rb +9 -7
  90. data/lib/merge_ticketing_client/models/remote_field.rb +231 -0
  91. data/lib/merge_ticketing_client/models/remote_field_class.rb +318 -0
  92. data/lib/merge_ticketing_client/models/remote_field_class_item_schema.rb +241 -0
  93. data/lib/merge_ticketing_client/models/request_format_enum.rb +1 -1
  94. data/lib/merge_ticketing_client/models/response_type_enum.rb +1 -1
  95. data/lib/merge_ticketing_client/models/selective_sync_configurations_usage_enum.rb +45 -0
  96. data/lib/merge_ticketing_client/models/sync_status.rb +13 -4
  97. data/lib/merge_ticketing_client/models/sync_status_status_enum.rb +1 -1
  98. data/lib/merge_ticketing_client/models/tag.rb +16 -4
  99. data/lib/merge_ticketing_client/models/team.rb +16 -4
  100. data/lib/merge_ticketing_client/models/ticket.rb +56 -7
  101. data/lib/merge_ticketing_client/models/ticket_request.rb +57 -40
  102. data/lib/merge_ticketing_client/models/ticket_status_enum.rb +1 -1
  103. data/lib/merge_ticketing_client/models/user.rb +16 -4
  104. data/lib/merge_ticketing_client/version.rb +1 -1
  105. data/lib/merge_ticketing_client.rb +21 -0
  106. data/spec/api/collections_api_spec.rb +76 -0
  107. data/spec/api/projects_api_spec.rb +3 -2
  108. data/spec/api/selective_sync_api_spec.rb +72 -0
  109. data/spec/api/tickets_api_spec.rb +24 -4
  110. data/spec/api/users_api_spec.rb +1 -0
  111. data/spec/models/account_spec.rb +6 -0
  112. data/spec/models/attachment_request_spec.rb +12 -0
  113. data/spec/models/attachment_spec.rb +6 -0
  114. data/spec/models/collection_spec.rb +82 -0
  115. data/spec/models/collection_type_enum_spec.rb +28 -0
  116. data/spec/models/comment_request_spec.rb +12 -0
  117. data/spec/models/comment_spec.rb +6 -0
  118. data/spec/models/condition_schema_spec.rb +70 -0
  119. data/spec/models/condition_type_enum_spec.rb +28 -0
  120. data/spec/models/contact_spec.rb +6 -0
  121. data/spec/models/issue_spec.rb +6 -0
  122. data/spec/models/linked_account_condition_request_spec.rb +46 -0
  123. data/spec/models/linked_account_condition_spec.rb +64 -0
  124. data/spec/models/linked_account_selective_sync_configuration_list_request_spec.rb +34 -0
  125. data/spec/models/linked_account_selective_sync_configuration_request_spec.rb +34 -0
  126. data/spec/models/linked_account_selective_sync_configuration_spec.rb +34 -0
  127. data/spec/models/operator_schema_spec.rb +40 -0
  128. data/spec/models/paginated_collection_list_spec.rb +46 -0
  129. data/spec/models/paginated_condition_schema_list_spec.rb +46 -0
  130. data/spec/models/patched_ticket_request_spec.rb +24 -0
  131. data/spec/models/project_spec.rb +6 -0
  132. data/spec/models/selective_sync_configurations_usage_enum_spec.rb +28 -0
  133. data/spec/models/sync_status_spec.rb +6 -0
  134. data/spec/models/tag_spec.rb +6 -0
  135. data/spec/models/team_spec.rb +6 -0
  136. data/spec/models/ticket_request_spec.rb +24 -0
  137. data/spec/models/ticket_spec.rb +18 -0
  138. data/spec/models/user_spec.rb +6 -0
  139. metadata +144 -72
@@ -0,0 +1,231 @@
1
+ =begin
2
+ #Merge Ticketing API
3
+
4
+ #The unified API for building rich integrations with multiple Ticketing platforms.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: hello@merge.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MergeTicketingClient
17
+ class RemoteField
18
+ attr_accessor :value
19
+
20
+ attr_accessor :remote_field_class
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'value' => :'value',
26
+ :'remote_field_class' => :'remote_field_class'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'value' => :'Hash<String, Object>',
39
+ :'remote_field_class' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ :'value',
47
+ :'remote_field_class'
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MergeTicketingClient::RemoteField` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MergeTicketingClient::RemoteField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'value')
67
+ if (value = attributes[:'value']).is_a?(Hash)
68
+ self.value = value
69
+ end
70
+ end
71
+
72
+ if attributes.key?(:'remote_field_class')
73
+ self.remote_field_class = attributes[:'remote_field_class']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ value == o.value &&
96
+ remote_field_class == o.remote_field_class
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [value, remote_field_class].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.openapi_types.each_pair do |key, type|
124
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
125
+ self.send("#{key}=", nil)
126
+ elsif type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :Time
147
+ Time.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ # models (e.g. Pet) or oneOf
178
+ klass = MergeTicketingClient.const_get(type)
179
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
180
+ end
181
+ end
182
+
183
+ # Returns the string representation of the object
184
+ # @return [String] String presentation of the object
185
+ def to_s
186
+ to_hash.to_s
187
+ end
188
+
189
+ # to_body is an alias to to_hash (backward compatibility)
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_body
192
+ to_hash
193
+ end
194
+
195
+ # Returns the object in the form of hash
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_hash
198
+ hash = {}
199
+ self.class.attribute_map.each_pair do |attr, param|
200
+ value = self.send(attr)
201
+ if value.nil?
202
+ is_nullable = self.class.openapi_nullable.include?(attr)
203
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
204
+ end
205
+
206
+ hash[param] = _to_hash(value)
207
+ end
208
+ hash
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value)
216
+ if value.is_a?(Array)
217
+ value.compact.map { |v| _to_hash(v) }
218
+ elsif value.is_a?(Hash)
219
+ {}.tap do |hash|
220
+ value.each { |k, v| hash[k] = _to_hash(v) }
221
+ end
222
+ elsif value.respond_to? :to_hash
223
+ value.to_hash
224
+ else
225
+ value
226
+ end
227
+ end
228
+
229
+ end
230
+
231
+ end
@@ -0,0 +1,318 @@
1
+ =begin
2
+ #Merge Ticketing API
3
+
4
+ #The unified API for building rich integrations with multiple Ticketing platforms.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: hello@merge.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MergeTicketingClient
17
+ class RemoteFieldClass
18
+ attr_accessor :display_name
19
+
20
+ attr_accessor :remote_key_name
21
+
22
+ attr_accessor :description
23
+
24
+ attr_accessor :is_required
25
+
26
+ attr_accessor :field_type
27
+
28
+ attr_accessor :field_format
29
+
30
+ attr_accessor :field_choices
31
+
32
+ attr_accessor :item_schema
33
+
34
+ attr_accessor :is_custom
35
+
36
+ attr_accessor :id
37
+
38
+ attr_accessor :remote_fields
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'display_name' => :'display_name',
44
+ :'remote_key_name' => :'remote_key_name',
45
+ :'description' => :'description',
46
+ :'is_required' => :'is_required',
47
+ :'field_type' => :'field_type',
48
+ :'field_format' => :'field_format',
49
+ :'field_choices' => :'field_choices',
50
+ :'item_schema' => :'item_schema',
51
+ :'is_custom' => :'is_custom',
52
+ :'id' => :'id',
53
+ :'remote_fields' => :'remote_fields'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'display_name' => :'String',
66
+ :'remote_key_name' => :'String',
67
+ :'description' => :'String',
68
+ :'is_required' => :'Boolean',
69
+ :'field_type' => :'FieldTypeEnum',
70
+ :'field_format' => :'FieldFormatEnum',
71
+ :'field_choices' => :'Array<String>',
72
+ :'item_schema' => :'RemoteFieldClassItemSchema',
73
+ :'is_custom' => :'Boolean',
74
+ :'id' => :'String',
75
+ :'remote_fields' => :'Array<RemoteField>'
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([
82
+ :'display_name',
83
+ :'remote_key_name',
84
+ :'description',
85
+ :'field_choices',
86
+ :'item_schema',
87
+ :'is_custom',
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MergeTicketingClient::RemoteFieldClass` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MergeTicketingClient::RemoteFieldClass`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'display_name')
107
+ self.display_name = attributes[:'display_name']
108
+ end
109
+
110
+ if attributes.key?(:'remote_key_name')
111
+ self.remote_key_name = attributes[:'remote_key_name']
112
+ end
113
+
114
+ if attributes.key?(:'description')
115
+ self.description = attributes[:'description']
116
+ end
117
+
118
+ if attributes.key?(:'is_required')
119
+ self.is_required = attributes[:'is_required']
120
+ end
121
+
122
+ if attributes.key?(:'field_type')
123
+ self.field_type = attributes[:'field_type']
124
+ end
125
+
126
+ if attributes.key?(:'field_format')
127
+ self.field_format = attributes[:'field_format']
128
+ end
129
+
130
+ if attributes.key?(:'field_choices')
131
+ if (value = attributes[:'field_choices']).is_a?(Array)
132
+ self.field_choices = value
133
+ end
134
+ end
135
+
136
+ if attributes.key?(:'item_schema')
137
+ self.item_schema = attributes[:'item_schema']
138
+ end
139
+
140
+ if attributes.key?(:'is_custom')
141
+ self.is_custom = attributes[:'is_custom']
142
+ end
143
+
144
+ if attributes.key?(:'id')
145
+ self.id = attributes[:'id']
146
+ end
147
+
148
+ if attributes.key?(:'remote_fields')
149
+ if (value = attributes[:'remote_fields']).is_a?(Array)
150
+ self.remote_fields = value
151
+ end
152
+ end
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properties with the reasons
157
+ def list_invalid_properties
158
+ invalid_properties = Array.new
159
+ invalid_properties
160
+ end
161
+
162
+ # Check to see if the all the properties in the model are valid
163
+ # @return true if the model is valid
164
+ def valid?
165
+ true
166
+ end
167
+
168
+ # Checks equality by comparing each attribute.
169
+ # @param [Object] Object to be compared
170
+ def ==(o)
171
+ return true if self.equal?(o)
172
+ self.class == o.class &&
173
+ display_name == o.display_name &&
174
+ remote_key_name == o.remote_key_name &&
175
+ description == o.description &&
176
+ is_required == o.is_required &&
177
+ field_type == o.field_type &&
178
+ field_format == o.field_format &&
179
+ field_choices == o.field_choices &&
180
+ item_schema == o.item_schema &&
181
+ is_custom == o.is_custom &&
182
+ id == o.id &&
183
+ remote_fields == o.remote_fields
184
+ end
185
+
186
+ # @see the `==` method
187
+ # @param [Object] Object to be compared
188
+ def eql?(o)
189
+ self == o
190
+ end
191
+
192
+ # Calculates hash code according to all attributes.
193
+ # @return [Integer] Hash code
194
+ def hash
195
+ [display_name, remote_key_name, description, is_required, field_type, field_format, field_choices, item_schema, is_custom, id, remote_fields].hash
196
+ end
197
+
198
+ # Builds the object from hash
199
+ # @param [Hash] attributes Model attributes in the form of hash
200
+ # @return [Object] Returns the model itself
201
+ def self.build_from_hash(attributes)
202
+ new.build_from_hash(attributes)
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ self.class.openapi_types.each_pair do |key, type|
211
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
212
+ self.send("#{key}=", nil)
213
+ elsif type =~ /\AArray<(.*)>/i
214
+ # check to ensure the input is an array given that the attribute
215
+ # is documented as an array but the input is not
216
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
217
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
218
+ end
219
+ elsif !attributes[self.class.attribute_map[key]].nil?
220
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
221
+ end
222
+ end
223
+
224
+ self
225
+ end
226
+
227
+ # Deserializes the data based on type
228
+ # @param string type Data type
229
+ # @param string value Value to be deserialized
230
+ # @return [Object] Deserialized data
231
+ def _deserialize(type, value)
232
+ case type.to_sym
233
+ when :Time
234
+ Time.parse(value)
235
+ when :Date
236
+ Date.parse(value)
237
+ when :String
238
+ value
239
+ when :Integer
240
+ value.to_i
241
+ when :Float
242
+ value.to_f
243
+ when :Boolean
244
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
245
+ true
246
+ else
247
+ false
248
+ end
249
+ when :Object
250
+ # generic object (usually a Hash), return directly
251
+ value
252
+ when /\AArray<(?<inner_type>.+)>\z/
253
+ inner_type = Regexp.last_match[:inner_type]
254
+ value.map { |v| _deserialize(inner_type, v) }
255
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
256
+ k_type = Regexp.last_match[:k_type]
257
+ v_type = Regexp.last_match[:v_type]
258
+ {}.tap do |hash|
259
+ value.each do |k, v|
260
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
261
+ end
262
+ end
263
+ else # model
264
+ # models (e.g. Pet) or oneOf
265
+ klass = MergeTicketingClient.const_get(type)
266
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
267
+ end
268
+ end
269
+
270
+ # Returns the string representation of the object
271
+ # @return [String] String presentation of the object
272
+ def to_s
273
+ to_hash.to_s
274
+ end
275
+
276
+ # to_body is an alias to to_hash (backward compatibility)
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_body
279
+ to_hash
280
+ end
281
+
282
+ # Returns the object in the form of hash
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_hash
285
+ hash = {}
286
+ self.class.attribute_map.each_pair do |attr, param|
287
+ value = self.send(attr)
288
+ if value.nil?
289
+ is_nullable = self.class.openapi_nullable.include?(attr)
290
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
291
+ end
292
+
293
+ hash[param] = _to_hash(value)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Outputs non-array value in the form of hash
299
+ # For object, use to_hash. Otherwise, just return the value
300
+ # @param [Object] value Any valid value
301
+ # @return [Hash] Returns the value in the form of hash
302
+ def _to_hash(value)
303
+ if value.is_a?(Array)
304
+ value.compact.map { |v| _to_hash(v) }
305
+ elsif value.is_a?(Hash)
306
+ {}.tap do |hash|
307
+ value.each { |k, v| hash[k] = _to_hash(v) }
308
+ end
309
+ elsif value.respond_to? :to_hash
310
+ value.to_hash
311
+ else
312
+ value
313
+ end
314
+ end
315
+
316
+ end
317
+
318
+ end