phrase 4.24.0 → 4.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/README.md +19 -4
  4. data/docs/AutomationEvent.md +33 -0
  5. data/docs/AutomationEventProject.md +19 -0
  6. data/docs/AutomationEventsApi.md +168 -0
  7. data/docs/AutomationsCreateParameters.md +1 -1
  8. data/docs/AutomationsCreateParameters1.md +1 -1
  9. data/docs/BranchComparison.md +23 -0
  10. data/docs/BranchComparisonChange.md +19 -0
  11. data/docs/BranchComparisonDiff.md +21 -0
  12. data/docs/BranchComparisonDiffConflictsValue.md +19 -0
  13. data/docs/BranchesApi.md +5 -4
  14. data/docs/DocumentsApi.md +4 -4
  15. data/docs/Format.md +20 -20
  16. data/docs/FormatsApi.md +1 -1
  17. data/docs/ICUApi.md +1 -1
  18. data/docs/IcuSkeletonError.md +17 -0
  19. data/docs/IcuSkeletonParameters.md +11 -11
  20. data/docs/Job.md +3 -1
  21. data/docs/JobDetails.md +2 -0
  22. data/docs/JobsApi.md +2 -2
  23. data/docs/KeyCreateParameters.md +1 -1
  24. data/docs/KeyFormatAnnotationsApi.md +74 -0
  25. data/docs/KeyFormatAnnotationsList200ResponseInner.md +19 -0
  26. data/docs/KeyLinksBatchDestroyParameters.md +6 -4
  27. data/docs/KeyLinksCreateParameters.md +2 -2
  28. data/docs/KeyUpdateParameters.md +1 -1
  29. data/docs/LinkedKeysApi.md +14 -13
  30. data/docs/Locale.md +2 -0
  31. data/docs/LocaleCreateParameters.md +3 -1
  32. data/docs/LocaleDetails.md +2 -0
  33. data/docs/LocaleDownloadCreateParameters.md +4 -0
  34. data/docs/LocaleUpdateParameters.md +3 -1
  35. data/docs/LocalesApi.md +2 -2
  36. data/docs/PreTranslation.md +29 -0
  37. data/docs/PreTranslationCreateParameters.md +19 -0
  38. data/docs/PreTranslationsApi.md +210 -0
  39. data/docs/ProjectCreateParameters.md +1 -1
  40. data/docs/ProjectUpdateParameters.md +1 -1
  41. data/docs/RepoSync.md +2 -0
  42. data/docs/RepoSyncCreateParameters.md +2 -0
  43. data/docs/ScreenshotUpdateParameters.md +1 -1
  44. data/docs/ScreenshotsApi.md +11 -11
  45. data/lib/phrase/api/automation_events_api.rb +215 -0
  46. data/lib/phrase/api/branches_api.rb +5 -3
  47. data/lib/phrase/api/documents_api.rb +6 -6
  48. data/lib/phrase/api/formats_api.rb +2 -2
  49. data/lib/phrase/api/icu_api.rb +2 -6
  50. data/lib/phrase/api/key_format_annotations_api.rb +85 -0
  51. data/lib/phrase/api/linked_keys_api.rb +19 -23
  52. data/lib/phrase/api/locales_api.rb +2 -2
  53. data/lib/phrase/api/pre_translations_api.rb +240 -0
  54. data/lib/phrase/api/screenshots_api.rb +20 -16
  55. data/lib/phrase/models/automation_event.rb +325 -0
  56. data/lib/phrase/models/automation_event_project.rb +208 -0
  57. data/lib/phrase/models/automations_create_parameters.rb +1 -1
  58. data/lib/phrase/models/automations_create_parameters1.rb +1 -1
  59. data/lib/phrase/models/branch_comparison.rb +224 -0
  60. data/lib/phrase/models/branch_comparison_change.rb +212 -0
  61. data/lib/phrase/models/branch_comparison_diff.rb +223 -0
  62. data/lib/phrase/models/branch_comparison_diff_conflicts_value.rb +209 -0
  63. data/lib/phrase/models/format.rb +60 -0
  64. data/lib/phrase/models/{key_links_index400_response.rb → icu_skeleton_error.rb} +11 -10
  65. data/lib/phrase/models/icu_skeleton_parameters.rb +6 -6
  66. data/lib/phrase/models/job.rb +16 -5
  67. data/lib/phrase/models/job_details.rb +12 -1
  68. data/lib/phrase/models/key_format_annotations_list200_response_inner.rb +207 -0
  69. data/lib/phrase/models/key_links_batch_destroy_parameters.rb +52 -6
  70. data/lib/phrase/models/key_links_create_parameters.rb +1 -1
  71. data/lib/phrase/models/locale.rb +10 -1
  72. data/lib/phrase/models/locale_create_parameters.rb +14 -4
  73. data/lib/phrase/models/locale_details.rb +10 -1
  74. data/lib/phrase/models/locale_download_create_parameters.rb +21 -1
  75. data/lib/phrase/models/locale_update_parameters.rb +14 -4
  76. data/lib/phrase/models/pre_translation.rb +301 -0
  77. data/lib/phrase/models/pre_translation_create_parameters.rb +241 -0
  78. data/lib/phrase/models/repo_sync.rb +29 -1
  79. data/lib/phrase/models/repo_sync_create_parameters.rb +27 -1
  80. data/lib/phrase/response.rb +2 -2
  81. data/lib/phrase/version.rb +1 -1
  82. data/lib/phrase.rb +13 -1
  83. data/phrase.gemspec +1 -1
  84. data/spec/api/automation_events_api_spec.rb +67 -0
  85. data/spec/api/branches_api_spec.rb +1 -1
  86. data/spec/api/documents_api_spec.rb +3 -3
  87. data/spec/api/formats_api_spec.rb +1 -1
  88. data/spec/api/icu_api_spec.rb +1 -1
  89. data/spec/api/key_format_annotations_api_spec.rb +38 -0
  90. data/spec/api/linked_keys_api_spec.rb +7 -7
  91. data/spec/api/pre_translations_api_spec.rb +70 -0
  92. data/spec/api/screenshots_api_spec.rb +6 -6
  93. data/spec/models/automation_event_project_spec.rb +35 -0
  94. data/spec/models/automation_event_spec.rb +85 -0
  95. data/spec/models/branch_comparison_change_spec.rb +35 -0
  96. data/spec/models/branch_comparison_diff_conflicts_value_spec.rb +35 -0
  97. data/spec/models/branch_comparison_diff_spec.rb +41 -0
  98. data/spec/models/branch_comparison_spec.rb +47 -0
  99. data/spec/models/{key_links_index400_response_spec.rb → icu_skeleton_error_spec.rb} +7 -7
  100. data/spec/models/job_details_spec.rb +6 -0
  101. data/spec/models/job_spec.rb +6 -0
  102. data/spec/models/key_format_annotations_list200_response_inner_spec.rb +35 -0
  103. data/spec/models/key_links_batch_destroy_parameters_spec.rb +10 -0
  104. data/spec/models/locale_create_parameters_spec.rb +6 -0
  105. data/spec/models/locale_details_spec.rb +6 -0
  106. data/spec/models/locale_download_create_parameters_spec.rb +12 -0
  107. data/spec/models/locale_spec.rb +6 -0
  108. data/spec/models/locale_update_parameters_spec.rb +6 -0
  109. data/spec/models/pre_translation_create_parameters_spec.rb +39 -0
  110. data/spec/models/pre_translation_spec.rb +73 -0
  111. data/spec/models/repo_sync_create_parameters_spec.rb +6 -0
  112. data/spec/models/repo_sync_spec.rb +6 -0
  113. data/spec/response_spec.rb +53 -0
  114. metadata +304 -254
  115. data/docs/KeyLinksIndex400Response.md +0 -17
@@ -0,0 +1,224 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # Comparison result of a branch against its base branch. Top-level properties correspond to resource types. Each resource type lists changes made in the base branch (`base_changes`), changes made in the feature branch (`head_changes`), and conflicting entries (`conflicts`).
5
+ class BranchComparison
6
+ attr_accessor :translation_keys
7
+
8
+ attr_accessor :translations
9
+
10
+ attr_accessor :locales
11
+
12
+ attr_accessor :tags
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :'translation_keys' => :'translation_keys',
18
+ :'translations' => :'translations',
19
+ :'locales' => :'locales',
20
+ :'tags' => :'tags'
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.openapi_types
26
+ {
27
+ :'translation_keys' => :'BranchComparisonDiff',
28
+ :'translations' => :'BranchComparisonDiff',
29
+ :'locales' => :'BranchComparisonDiff',
30
+ :'tags' => :'BranchComparisonDiff'
31
+ }
32
+ end
33
+
34
+ # List of attributes with nullable: true
35
+ def self.openapi_nullable
36
+ Set.new([
37
+ ])
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::BranchComparison` initialize method"
45
+ end
46
+
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h|
49
+ if (!self.class.attribute_map.key?(k.to_sym))
50
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::BranchComparison`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'translation_keys')
56
+ self.translation_keys = attributes[:'translation_keys']
57
+ end
58
+
59
+ if attributes.key?(:'translations')
60
+ self.translations = attributes[:'translations']
61
+ end
62
+
63
+ if attributes.key?(:'locales')
64
+ self.locales = attributes[:'locales']
65
+ end
66
+
67
+ if attributes.key?(:'tags')
68
+ self.tags = attributes[:'tags']
69
+ end
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properties with the reasons
74
+ def list_invalid_properties
75
+ invalid_properties = Array.new
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ true
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(o)
88
+ return true if self.equal?(o)
89
+ self.class == o.class &&
90
+ translation_keys == o.translation_keys &&
91
+ translations == o.translations &&
92
+ locales == o.locales &&
93
+ tags == o.tags
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [translation_keys, translations, locales, tags].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ new.build_from_hash(attributes)
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ self.class.openapi_types.each_pair do |key, type|
121
+ if type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
125
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
126
+ end
127
+ elsif !attributes[self.class.attribute_map[key]].nil?
128
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
129
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
130
+ end
131
+
132
+ self
133
+ end
134
+
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
139
+ def _deserialize(type, value)
140
+ case type.to_sym
141
+ when :DateTime
142
+ DateTime.parse(value)
143
+ when :Date
144
+ Date.parse(value)
145
+ when :Time
146
+ Time.parse(value)
147
+ when :String
148
+ value.to_s
149
+ when :Integer
150
+ value.to_i
151
+ when :Float
152
+ value.to_f
153
+ when :Boolean
154
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
155
+ true
156
+ else
157
+ false
158
+ end
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ Phrase.const_get(type).build_from_hash(value)
175
+ end
176
+ end
177
+
178
+ # Returns the string representation of the object
179
+ # @return [String] String presentation of the object
180
+ def to_s
181
+ to_hash.to_s
182
+ end
183
+
184
+ # to_body is an alias to to_hash (backward compatibility)
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_body
187
+ to_hash
188
+ end
189
+
190
+ # Returns the object in the form of hash
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_hash
193
+ hash = {}
194
+ self.class.attribute_map.each_pair do |attr, param|
195
+ value = self.send(attr)
196
+ if value.nil?
197
+ is_nullable = self.class.openapi_nullable.include?(attr)
198
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
199
+ end
200
+
201
+ hash[param] = _to_hash(value)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map { |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,212 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # A single resource change. `from` holds the state before the change (null when the resource was added). `to` holds the state after (null when the resource was deleted). Fields depend on the resource type.
5
+ class BranchComparisonChange
6
+ attr_accessor :from
7
+
8
+ attr_accessor :to
9
+
10
+ # Attribute mapping from ruby-style variable name to JSON key.
11
+ def self.attribute_map
12
+ {
13
+ :'from' => :'from',
14
+ :'to' => :'to'
15
+ }
16
+ end
17
+
18
+ # Attribute type mapping.
19
+ def self.openapi_types
20
+ {
21
+ :'from' => :'Hash<String, Object>',
22
+ :'to' => :'Hash<String, Object>'
23
+ }
24
+ end
25
+
26
+ # List of attributes with nullable: true
27
+ def self.openapi_nullable
28
+ Set.new([
29
+ :'from',
30
+ :'to'
31
+ ])
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::BranchComparisonChange` initialize method"
39
+ end
40
+
41
+ # check to see if the attribute exists and convert string to symbol for hash key
42
+ attributes = attributes.each_with_object({}) { |(k, v), h|
43
+ if (!self.class.attribute_map.key?(k.to_sym))
44
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::BranchComparisonChange`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
+ end
46
+ h[k.to_sym] = v
47
+ }
48
+
49
+ if attributes.key?(:'from')
50
+ if (value = attributes[:'from']).is_a?(Hash)
51
+ self.from = value
52
+ end
53
+ end
54
+
55
+ if attributes.key?(:'to')
56
+ if (value = attributes[:'to']).is_a?(Hash)
57
+ self.to = value
58
+ end
59
+ end
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properties with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ true
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(o)
78
+ return true if self.equal?(o)
79
+ self.class == o.class &&
80
+ from == o.from &&
81
+ to == o.to
82
+ end
83
+
84
+ # @see the `==` method
85
+ # @param [Object] Object to be compared
86
+ def eql?(o)
87
+ self == o
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Integer] Hash code
92
+ def hash
93
+ [from, to].hash
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def self.build_from_hash(attributes)
100
+ new.build_from_hash(attributes)
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ self.class.openapi_types.each_pair do |key, type|
109
+ if type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
113
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
114
+ end
115
+ elsif !attributes[self.class.attribute_map[key]].nil?
116
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
117
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
118
+ end
119
+
120
+ self
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def _deserialize(type, value)
128
+ case type.to_sym
129
+ when :DateTime
130
+ DateTime.parse(value)
131
+ when :Date
132
+ Date.parse(value)
133
+ when :Time
134
+ Time.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :Boolean
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ Phrase.const_get(type).build_from_hash(value)
163
+ end
164
+ end
165
+
166
+ # Returns the string representation of the object
167
+ # @return [String] String presentation of the object
168
+ def to_s
169
+ to_hash.to_s
170
+ end
171
+
172
+ # to_body is an alias to to_hash (backward compatibility)
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_body
175
+ to_hash
176
+ end
177
+
178
+ # Returns the object in the form of hash
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_hash
181
+ hash = {}
182
+ self.class.attribute_map.each_pair do |attr, param|
183
+ value = self.send(attr)
184
+ if value.nil?
185
+ is_nullable = self.class.openapi_nullable.include?(attr)
186
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
187
+ end
188
+
189
+ hash[param] = _to_hash(value)
190
+ end
191
+ hash
192
+ end
193
+
194
+ # Outputs non-array value in the form of hash
195
+ # For object, use to_hash. Otherwise, just return the value
196
+ # @param [Object] value Any valid value
197
+ # @return [Hash] Returns the value in the form of hash
198
+ def _to_hash(value)
199
+ if value.is_a?(Array)
200
+ value.compact.map { |v| _to_hash(v) }
201
+ elsif value.is_a?(Hash)
202
+ {}.tap do |hash|
203
+ value.each { |k, v| hash[k] = _to_hash(v) }
204
+ end
205
+ elsif value.respond_to? :to_hash
206
+ value.to_hash
207
+ else
208
+ value
209
+ end
210
+ end
211
+ end
212
+ end
@@ -0,0 +1,223 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class BranchComparisonDiff
5
+ # Changes made to this resource type in the base branch since the branch was created.
6
+ attr_accessor :base_changes
7
+
8
+ # Changes made to this resource type in the feature branch.
9
+ attr_accessor :head_changes
10
+
11
+ # Conflicting changes present in both branches, keyed by conflict type. Possible conflict type keys: `changed_in_head_changed_in_base`, `added_in_head_added_in_base`, `changed_in_head_deleted_in_base`, `deleted_in_head_changed_in_base`. Each value contains `base` and `head` arrays of changed attribute objects.
12
+ attr_accessor :conflicts
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :'base_changes' => :'base_changes',
18
+ :'head_changes' => :'head_changes',
19
+ :'conflicts' => :'conflicts'
20
+ }
21
+ end
22
+
23
+ # Attribute type mapping.
24
+ def self.openapi_types
25
+ {
26
+ :'base_changes' => :'Array<BranchComparisonChange>',
27
+ :'head_changes' => :'Array<BranchComparisonChange>',
28
+ :'conflicts' => :'Hash<String, BranchComparisonDiffConflictsValue>'
29
+ }
30
+ end
31
+
32
+ # List of attributes with nullable: true
33
+ def self.openapi_nullable
34
+ Set.new([
35
+ ])
36
+ end
37
+
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
40
+ def initialize(attributes = {})
41
+ if (!attributes.is_a?(Hash))
42
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::BranchComparisonDiff` initialize method"
43
+ end
44
+
45
+ # check to see if the attribute exists and convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h|
47
+ if (!self.class.attribute_map.key?(k.to_sym))
48
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::BranchComparisonDiff`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
49
+ end
50
+ h[k.to_sym] = v
51
+ }
52
+
53
+ if attributes.key?(:'base_changes')
54
+ if (value = attributes[:'base_changes']).is_a?(Array)
55
+ self.base_changes = value
56
+ end
57
+ end
58
+
59
+ if attributes.key?(:'head_changes')
60
+ if (value = attributes[:'head_changes']).is_a?(Array)
61
+ self.head_changes = value
62
+ end
63
+ end
64
+
65
+ if attributes.key?(:'conflicts')
66
+ if (value = attributes[:'conflicts']).is_a?(Hash)
67
+ self.conflicts = value
68
+ end
69
+ end
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properties with the reasons
74
+ def list_invalid_properties
75
+ invalid_properties = Array.new
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ true
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(o)
88
+ return true if self.equal?(o)
89
+ self.class == o.class &&
90
+ base_changes == o.base_changes &&
91
+ head_changes == o.head_changes &&
92
+ conflicts == o.conflicts
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [base_changes, head_changes, conflicts].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ new.build_from_hash(attributes)
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ self.class.openapi_types.each_pair do |key, type|
120
+ if type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :DateTime
141
+ DateTime.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :Time
145
+ Time.parse(value)
146
+ when :String
147
+ value.to_s
148
+ when :Integer
149
+ value.to_i
150
+ when :Float
151
+ value.to_f
152
+ when :Boolean
153
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154
+ true
155
+ else
156
+ false
157
+ end
158
+ when :Object
159
+ # generic object (usually a Hash), return directly
160
+ value
161
+ when /\AArray<(?<inner_type>.+)>\z/
162
+ inner_type = Regexp.last_match[:inner_type]
163
+ value.map { |v| _deserialize(inner_type, v) }
164
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
165
+ k_type = Regexp.last_match[:k_type]
166
+ v_type = Regexp.last_match[:v_type]
167
+ {}.tap do |hash|
168
+ value.each do |k, v|
169
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
170
+ end
171
+ end
172
+ else # model
173
+ Phrase.const_get(type).build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+ end
223
+ end