phrase 4.33.0 → 4.35.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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/README.md +11 -3
  4. data/docs/KeysApi.md +6 -2
  5. data/docs/RepoSync.md +7 -1
  6. data/docs/RepoSyncCreateParameters.md +7 -1
  7. data/docs/RepoSyncCreateParametersExportSchedule.md +27 -0
  8. data/docs/RepoSyncExportSchedule.md +23 -0
  9. data/docs/RepoSyncUpdateParameters.md +23 -0
  10. data/docs/RepoSyncUpdateParametersExportSchedule.md +27 -0
  11. data/docs/RepoSyncsApi.md +66 -0
  12. data/docs/TranslationKey.md +3 -1
  13. data/docs/TranslationKeyDetails.md +2 -0
  14. data/docs/TranslationKeyLinkedKey.md +21 -0
  15. data/docs/TranslationKeyLinkedKeyParent.md +19 -0
  16. data/docs/UserShort.md +23 -0
  17. data/lib/phrase/api/keys_api.rb +6 -0
  18. data/lib/phrase/api/repo_syncs_api.rb +80 -0
  19. data/lib/phrase/models/repo_sync.rb +58 -5
  20. data/lib/phrase/models/repo_sync_create_parameters.rb +35 -4
  21. data/lib/phrase/models/repo_sync_create_parameters_export_schedule.rb +281 -0
  22. data/lib/phrase/models/repo_sync_export_schedule.rb +263 -0
  23. data/lib/phrase/models/repo_sync_update_parameters.rb +250 -0
  24. data/lib/phrase/models/repo_sync_update_parameters_export_schedule.rb +276 -0
  25. data/lib/phrase/models/translation_key.rb +14 -4
  26. data/lib/phrase/models/translation_key_details.rb +11 -1
  27. data/lib/phrase/models/translation_key_linked_key.rb +253 -0
  28. data/lib/phrase/models/translation_key_linked_key_parent.rb +208 -0
  29. data/lib/phrase/models/user_short.rb +223 -0
  30. data/lib/phrase/version.rb +1 -1
  31. data/lib/phrase.rb +7 -0
  32. data/spec/api/keys_api_spec.rb +2 -0
  33. data/spec/api/repo_syncs_api_spec.rb +15 -0
  34. data/spec/models/repo_sync_create_parameters_export_schedule_spec.rb +63 -0
  35. data/spec/models/repo_sync_create_parameters_spec.rb +22 -0
  36. data/spec/models/repo_sync_export_schedule_spec.rb +51 -0
  37. data/spec/models/repo_sync_spec.rb +22 -0
  38. data/spec/models/repo_sync_update_parameters_export_schedule_spec.rb +63 -0
  39. data/spec/models/repo_sync_update_parameters_spec.rb +51 -0
  40. data/spec/models/translation_key_details_spec.rb +6 -0
  41. data/spec/models/translation_key_linked_key_parent_spec.rb +35 -0
  42. data/spec/models/translation_key_linked_key_spec.rb +45 -0
  43. data/spec/models/translation_key_spec.rb +6 -0
  44. data/spec/models/user_short_spec.rb +47 -0
  45. metadata +295 -267
@@ -0,0 +1,263 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # Schedule configuration for automatic exports. Only present when the automatic export feature is enabled for the account. `null` when the `schedule` trigger is not active.
5
+ class RepoSyncExportSchedule
6
+ # How often the export runs. `cron` means a fully custom cron expression is used (`cron_schedule` holds the raw expression).
7
+ attr_accessor :frequency
8
+
9
+ # The underlying cron expression. Derived automatically from `frequency`, `time`, and day fields when using a named frequency; provided verbatim when `frequency` is `cron`.
10
+ attr_accessor :cron_schedule
11
+
12
+ # IANA time zone name used to interpret the schedule.
13
+ attr_accessor :time_zone
14
+
15
+ # When the next scheduled export will run, in UTC.
16
+ attr_accessor :next_run_at
17
+
18
+ class EnumAttributeValidator
19
+ attr_reader :datatype
20
+ attr_reader :allowable_values
21
+
22
+ def initialize(datatype, allowable_values)
23
+ @allowable_values = allowable_values.map do |value|
24
+ case datatype.to_s
25
+ when /Integer/i
26
+ value.to_i
27
+ when /Float/i
28
+ value.to_f
29
+ else
30
+ value
31
+ end
32
+ end
33
+ end
34
+
35
+ def valid?(value)
36
+ !value || allowable_values.include?(value)
37
+ end
38
+ end
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'frequency' => :'frequency',
44
+ :'cron_schedule' => :'cron_schedule',
45
+ :'time_zone' => :'time_zone',
46
+ :'next_run_at' => :'next_run_at'
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'frequency' => :'String',
54
+ :'cron_schedule' => :'String',
55
+ :'time_zone' => :'String',
56
+ :'next_run_at' => :'DateTime'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ :'next_run_at'
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::RepoSyncExportSchedule` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::RepoSyncExportSchedule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'frequency')
83
+ self.frequency = attributes[:'frequency']
84
+ end
85
+
86
+ if attributes.key?(:'cron_schedule')
87
+ self.cron_schedule = attributes[:'cron_schedule']
88
+ end
89
+
90
+ if attributes.key?(:'time_zone')
91
+ self.time_zone = attributes[:'time_zone']
92
+ end
93
+
94
+ if attributes.key?(:'next_run_at')
95
+ self.next_run_at = attributes[:'next_run_at']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ invalid_properties
104
+ end
105
+
106
+ # Check to see if the all the properties in the model are valid
107
+ # @return true if the model is valid
108
+ def valid?
109
+ frequency_validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "cron"])
110
+ return false unless frequency_validator.valid?(@frequency)
111
+ true
112
+ end
113
+
114
+ # Custom attribute writer method checking allowed values (enum).
115
+ # @param [Object] frequency Object to be assigned
116
+ def frequency=(frequency)
117
+ validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "cron"])
118
+ unless validator.valid?(frequency)
119
+ fail ArgumentError, "invalid value for \"frequency\", must be one of #{validator.allowable_values}."
120
+ end
121
+ @frequency = frequency
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ frequency == o.frequency &&
130
+ cron_schedule == o.cron_schedule &&
131
+ time_zone == o.time_zone &&
132
+ next_run_at == o.next_run_at
133
+ end
134
+
135
+ # @see the `==` method
136
+ # @param [Object] Object to be compared
137
+ def eql?(o)
138
+ self == o
139
+ end
140
+
141
+ # Calculates hash code according to all attributes.
142
+ # @return [Integer] Hash code
143
+ def hash
144
+ [frequency, cron_schedule, time_zone, next_run_at].hash
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def self.build_from_hash(attributes)
151
+ new.build_from_hash(attributes)
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def build_from_hash(attributes)
158
+ return nil unless attributes.is_a?(Hash)
159
+ self.class.openapi_types.each_pair do |key, type|
160
+ if type =~ /\AArray<(.*)>/i
161
+ # check to ensure the input is an array given that the attribute
162
+ # is documented as an array but the input is not
163
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
164
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
165
+ end
166
+ elsif !attributes[self.class.attribute_map[key]].nil?
167
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
168
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
169
+ end
170
+
171
+ self
172
+ end
173
+
174
+ # Deserializes the data based on type
175
+ # @param string type Data type
176
+ # @param string value Value to be deserialized
177
+ # @return [Object] Deserialized data
178
+ def _deserialize(type, value)
179
+ case type.to_sym
180
+ when :DateTime
181
+ DateTime.parse(value)
182
+ when :Date
183
+ Date.parse(value)
184
+ when :Time
185
+ Time.parse(value)
186
+ when :String
187
+ value.to_s
188
+ when :Integer
189
+ value.to_i
190
+ when :Float
191
+ value.to_f
192
+ when :Boolean
193
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
194
+ true
195
+ else
196
+ false
197
+ end
198
+ when :Object
199
+ # generic object (usually a Hash), return directly
200
+ value
201
+ when /\AArray<(?<inner_type>.+)>\z/
202
+ inner_type = Regexp.last_match[:inner_type]
203
+ value.map { |v| _deserialize(inner_type, v) }
204
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
205
+ k_type = Regexp.last_match[:k_type]
206
+ v_type = Regexp.last_match[:v_type]
207
+ {}.tap do |hash|
208
+ value.each do |k, v|
209
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
210
+ end
211
+ end
212
+ else # model
213
+ Phrase.const_get(type).build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ if value.nil?
236
+ is_nullable = self.class.openapi_nullable.include?(attr)
237
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
238
+ end
239
+
240
+ hash[param] = _to_hash(value)
241
+ end
242
+ hash
243
+ end
244
+
245
+ # Outputs non-array value in the form of hash
246
+ # For object, use to_hash. Otherwise, just return the value
247
+ # @param [Object] value Any valid value
248
+ # @return [Hash] Returns the value in the form of hash
249
+ def _to_hash(value)
250
+ if value.is_a?(Array)
251
+ value.compact.map { |v| _to_hash(v) }
252
+ elsif value.is_a?(Hash)
253
+ {}.tap do |hash|
254
+ value.each { |k, v| hash[k] = _to_hash(v) }
255
+ end
256
+ elsif value.respond_to? :to_hash
257
+ value.to_hash
258
+ else
259
+ value
260
+ end
261
+ end
262
+ end
263
+ end
@@ -0,0 +1,250 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class RepoSyncUpdateParameters
5
+ # Display name for the repo sync.
6
+ attr_accessor :name
7
+
8
+ # Code of the user to assign as owner. Requires `manage_github_sync?` permission on the project; returns `403` if not satisfied.
9
+ attr_accessor :owner_id
10
+
11
+ # Replaces the current set of automatic export triggers. Requires `manage_github_sync?` permission on the project and the automatic export feature to be enabled for the account. Accepted values: `schedule`, `branch_merged`, `job_completed`.
12
+ attr_accessor :export_triggers
13
+
14
+ attr_accessor :export_schedule
15
+
16
+ class EnumAttributeValidator
17
+ attr_reader :datatype
18
+ attr_reader :allowable_values
19
+
20
+ def initialize(datatype, allowable_values)
21
+ @allowable_values = allowable_values.map do |value|
22
+ case datatype.to_s
23
+ when /Integer/i
24
+ value.to_i
25
+ when /Float/i
26
+ value.to_f
27
+ else
28
+ value
29
+ end
30
+ end
31
+ end
32
+
33
+ def valid?(value)
34
+ !value || allowable_values.include?(value)
35
+ end
36
+ end
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'name' => :'name',
42
+ :'owner_id' => :'owner_id',
43
+ :'export_triggers' => :'export_triggers',
44
+ :'export_schedule' => :'export_schedule'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'name' => :'String',
52
+ :'owner_id' => :'String',
53
+ :'export_triggers' => :'Array<String>',
54
+ :'export_schedule' => :'RepoSyncUpdateParametersExportSchedule'
55
+ }
56
+ end
57
+
58
+ # List of attributes with nullable: true
59
+ def self.openapi_nullable
60
+ Set.new([
61
+ ])
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ if (!attributes.is_a?(Hash))
68
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::RepoSyncUpdateParameters` initialize method"
69
+ end
70
+
71
+ # check to see if the attribute exists and convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}) { |(k, v), h|
73
+ if (!self.class.attribute_map.key?(k.to_sym))
74
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::RepoSyncUpdateParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
75
+ end
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:'name')
80
+ self.name = attributes[:'name']
81
+ end
82
+
83
+ if attributes.key?(:'owner_id')
84
+ self.owner_id = attributes[:'owner_id']
85
+ end
86
+
87
+ if attributes.key?(:'export_triggers')
88
+ if (value = attributes[:'export_triggers']).is_a?(Array)
89
+ self.export_triggers = value
90
+ end
91
+ end
92
+
93
+ if attributes.key?(:'export_schedule')
94
+ self.export_schedule = attributes[:'export_schedule']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ name == o.name &&
117
+ owner_id == o.owner_id &&
118
+ export_triggers == o.export_triggers &&
119
+ export_schedule == o.export_schedule
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [name, owner_id, export_triggers, export_schedule].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.openapi_types.each_pair do |key, type|
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :DateTime
168
+ DateTime.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :Time
172
+ Time.parse(value)
173
+ when :String
174
+ value.to_s
175
+ when :Integer
176
+ value.to_i
177
+ when :Float
178
+ value.to_f
179
+ when :Boolean
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
+ true
182
+ else
183
+ false
184
+ end
185
+ when :Object
186
+ # generic object (usually a Hash), return directly
187
+ value
188
+ when /\AArray<(?<inner_type>.+)>\z/
189
+ inner_type = Regexp.last_match[:inner_type]
190
+ value.map { |v| _deserialize(inner_type, v) }
191
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
+ k_type = Regexp.last_match[:k_type]
193
+ v_type = Regexp.last_match[:v_type]
194
+ {}.tap do |hash|
195
+ value.each do |k, v|
196
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
+ end
198
+ end
199
+ else # model
200
+ Phrase.const_get(type).build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ if value.nil?
223
+ is_nullable = self.class.openapi_nullable.include?(attr)
224
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
225
+ end
226
+
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+ end
250
+ end