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
@@ -26,6 +26,35 @@ module Phrase
26
26
 
27
27
  attr_accessor :last_export_at
28
28
 
29
+ attr_accessor :owner
30
+
31
+ # Events that trigger an automatic export. Only present when the automatic export feature is enabled for the account. Possible values: `schedule` (runs on the configured schedule), `branch_merged` (runs when a branch is merged in the connected repository), `job_completed` (runs when a translation job completes in the project).
32
+ attr_accessor :export_triggers
33
+
34
+ attr_accessor :export_schedule
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
29
58
  # Attribute mapping from ruby-style variable name to JSON key.
30
59
  def self.attribute_map
31
60
  {
@@ -39,7 +68,10 @@ module Phrase
39
68
  :'pr_branch' => :'pr_branch',
40
69
  :'created_at' => :'created_at',
41
70
  :'last_import_at' => :'last_import_at',
42
- :'last_export_at' => :'last_export_at'
71
+ :'last_export_at' => :'last_export_at',
72
+ :'owner' => :'owner',
73
+ :'export_triggers' => :'export_triggers',
74
+ :'export_schedule' => :'export_schedule'
43
75
  }
44
76
  end
45
77
 
@@ -56,7 +88,10 @@ module Phrase
56
88
  :'pr_branch' => :'String',
57
89
  :'created_at' => :'DateTime',
58
90
  :'last_import_at' => :'DateTime',
59
- :'last_export_at' => :'DateTime'
91
+ :'last_export_at' => :'DateTime',
92
+ :'owner' => :'UserShort',
93
+ :'export_triggers' => :'Array<String>',
94
+ :'export_schedule' => :'RepoSyncExportSchedule'
60
95
  }
61
96
  end
62
97
 
@@ -66,7 +101,8 @@ module Phrase
66
101
  :'name',
67
102
  :'pr_branch',
68
103
  :'last_import_at',
69
- :'last_export_at'
104
+ :'last_export_at',
105
+ :'export_schedule'
70
106
  ])
71
107
  end
72
108
 
@@ -128,6 +164,20 @@ module Phrase
128
164
  if attributes.key?(:'last_export_at')
129
165
  self.last_export_at = attributes[:'last_export_at']
130
166
  end
167
+
168
+ if attributes.key?(:'owner')
169
+ self.owner = attributes[:'owner']
170
+ end
171
+
172
+ if attributes.key?(:'export_triggers')
173
+ if (value = attributes[:'export_triggers']).is_a?(Array)
174
+ self.export_triggers = value
175
+ end
176
+ end
177
+
178
+ if attributes.key?(:'export_schedule')
179
+ self.export_schedule = attributes[:'export_schedule']
180
+ end
131
181
  end
132
182
 
133
183
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -173,7 +223,10 @@ module Phrase
173
223
  pr_branch == o.pr_branch &&
174
224
  created_at == o.created_at &&
175
225
  last_import_at == o.last_import_at &&
176
- last_export_at == o.last_export_at
226
+ last_export_at == o.last_export_at &&
227
+ owner == o.owner &&
228
+ export_triggers == o.export_triggers &&
229
+ export_schedule == o.export_schedule
177
230
  end
178
231
 
179
232
  # @see the `==` method
@@ -185,7 +238,7 @@ module Phrase
185
238
  # Calculates hash code according to all attributes.
186
239
  # @return [Integer] Hash code
187
240
  def hash
188
- [id, name, project, provider, enabled, auto_import, repo_name, pr_branch, created_at, last_import_at, last_export_at].hash
241
+ [id, name, project, provider, enabled, auto_import, repo_name, pr_branch, created_at, last_import_at, last_export_at, owner, export_triggers, export_schedule].hash
189
242
  end
190
243
 
191
244
  # Builds the object from hash
@@ -32,6 +32,14 @@ module Phrase
32
32
  # Custom API endpoint URL for self-hosted Git instances. Required when `connection_type` is `self_hosted`.
33
33
  attr_accessor :custom_api_endpoint
34
34
 
35
+ # Code of the user who will own this repo sync. Automated actions run as this user. Defaults to the account owner when not set.
36
+ attr_accessor :owner_id
37
+
38
+ # Events that should trigger an automatic export. Requires the automatic export feature to be enabled for the account; returns `422` otherwise. Accepted values: `schedule`, `branch_merged`, `job_completed`.
39
+ attr_accessor :export_triggers
40
+
41
+ attr_accessor :export_schedule
42
+
35
43
  class EnumAttributeValidator
36
44
  attr_reader :datatype
37
45
  attr_reader :allowable_values
@@ -66,7 +74,10 @@ module Phrase
66
74
  :'pr_branch' => :'pr_branch',
67
75
  :'auto_import' => :'auto_import',
68
76
  :'access_token' => :'access_token',
69
- :'custom_api_endpoint' => :'custom_api_endpoint'
77
+ :'custom_api_endpoint' => :'custom_api_endpoint',
78
+ :'owner_id' => :'owner_id',
79
+ :'export_triggers' => :'export_triggers',
80
+ :'export_schedule' => :'export_schedule'
70
81
  }
71
82
  end
72
83
 
@@ -82,7 +93,10 @@ module Phrase
82
93
  :'pr_branch' => :'String',
83
94
  :'auto_import' => :'Boolean',
84
95
  :'access_token' => :'String',
85
- :'custom_api_endpoint' => :'String'
96
+ :'custom_api_endpoint' => :'String',
97
+ :'owner_id' => :'String',
98
+ :'export_triggers' => :'Array<String>',
99
+ :'export_schedule' => :'RepoSyncCreateParametersExportSchedule'
86
100
  }
87
101
  end
88
102
 
@@ -149,6 +163,20 @@ module Phrase
149
163
  if attributes.key?(:'custom_api_endpoint')
150
164
  self.custom_api_endpoint = attributes[:'custom_api_endpoint']
151
165
  end
166
+
167
+ if attributes.key?(:'owner_id')
168
+ self.owner_id = attributes[:'owner_id']
169
+ end
170
+
171
+ if attributes.key?(:'export_triggers')
172
+ if (value = attributes[:'export_triggers']).is_a?(Array)
173
+ self.export_triggers = value
174
+ end
175
+ end
176
+
177
+ if attributes.key?(:'export_schedule')
178
+ self.export_schedule = attributes[:'export_schedule']
179
+ end
152
180
  end
153
181
 
154
182
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -232,7 +260,10 @@ module Phrase
232
260
  pr_branch == o.pr_branch &&
233
261
  auto_import == o.auto_import &&
234
262
  access_token == o.access_token &&
235
- custom_api_endpoint == o.custom_api_endpoint
263
+ custom_api_endpoint == o.custom_api_endpoint &&
264
+ owner_id == o.owner_id &&
265
+ export_triggers == o.export_triggers &&
266
+ export_schedule == o.export_schedule
236
267
  end
237
268
 
238
269
  # @see the `==` method
@@ -244,7 +275,7 @@ module Phrase
244
275
  # Calculates hash code according to all attributes.
245
276
  # @return [Integer] Hash code
246
277
  def hash
247
- [project_id, name, git_provider, connection_type, repo_name, base_branch, pr_branch, auto_import, access_token, custom_api_endpoint].hash
278
+ [project_id, name, git_provider, connection_type, repo_name, base_branch, pr_branch, auto_import, access_token, custom_api_endpoint, owner_id, export_triggers, export_schedule].hash
248
279
  end
249
280
 
250
281
  # Builds the object from hash
@@ -0,0 +1,281 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # Schedule settings for automatic exports. Required when `export_triggers` includes `schedule`. Requires the automatic export feature to be enabled.
5
+ class RepoSyncCreateParametersExportSchedule
6
+ attr_accessor :frequency
7
+
8
+ # Time of day for the export (HH:MM format). Used with `day`, `week`, and `month` frequencies.
9
+ attr_accessor :time
10
+
11
+ # IANA time zone name.
12
+ attr_accessor :time_zone
13
+
14
+ # Comma-separated day numbers (0=Sunday … 6=Saturday). Used with `week` frequency.
15
+ attr_accessor :days_of_week
16
+
17
+ # Day of the month (1–31). Used with `month` frequency.
18
+ attr_accessor :day_of_month
19
+
20
+ # Raw cron expression. Used when `frequency` is `cron`.
21
+ attr_accessor :cron_schedule
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'frequency' => :'frequency',
49
+ :'time' => :'time',
50
+ :'time_zone' => :'time_zone',
51
+ :'days_of_week' => :'days_of_week',
52
+ :'day_of_month' => :'day_of_month',
53
+ :'cron_schedule' => :'cron_schedule'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'frequency' => :'String',
61
+ :'time' => :'String',
62
+ :'time_zone' => :'String',
63
+ :'days_of_week' => :'String',
64
+ :'day_of_month' => :'Integer',
65
+ :'cron_schedule' => :'String'
66
+ }
67
+ end
68
+
69
+ # List of attributes with nullable: true
70
+ def self.openapi_nullable
71
+ Set.new([
72
+ ])
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ if (!attributes.is_a?(Hash))
79
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::RepoSyncCreateParametersExportSchedule` initialize method"
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) { |(k, v), h|
84
+ if (!self.class.attribute_map.key?(k.to_sym))
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::RepoSyncCreateParametersExportSchedule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
+ end
87
+ h[k.to_sym] = v
88
+ }
89
+
90
+ if attributes.key?(:'frequency')
91
+ self.frequency = attributes[:'frequency']
92
+ end
93
+
94
+ if attributes.key?(:'time')
95
+ self.time = attributes[:'time']
96
+ end
97
+
98
+ if attributes.key?(:'time_zone')
99
+ self.time_zone = attributes[:'time_zone']
100
+ end
101
+
102
+ if attributes.key?(:'days_of_week')
103
+ self.days_of_week = attributes[:'days_of_week']
104
+ end
105
+
106
+ if attributes.key?(:'day_of_month')
107
+ self.day_of_month = attributes[:'day_of_month']
108
+ end
109
+
110
+ if attributes.key?(:'cron_schedule')
111
+ self.cron_schedule = attributes[:'cron_schedule']
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ frequency_validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "cron"])
126
+ return false unless frequency_validator.valid?(@frequency)
127
+ true
128
+ end
129
+
130
+ # Custom attribute writer method checking allowed values (enum).
131
+ # @param [Object] frequency Object to be assigned
132
+ def frequency=(frequency)
133
+ validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "cron"])
134
+ unless validator.valid?(frequency)
135
+ fail ArgumentError, "invalid value for \"frequency\", must be one of #{validator.allowable_values}."
136
+ end
137
+ @frequency = frequency
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ frequency == o.frequency &&
146
+ time == o.time &&
147
+ time_zone == o.time_zone &&
148
+ days_of_week == o.days_of_week &&
149
+ day_of_month == o.day_of_month &&
150
+ cron_schedule == o.cron_schedule
151
+ end
152
+
153
+ # @see the `==` method
154
+ # @param [Object] Object to be compared
155
+ def eql?(o)
156
+ self == o
157
+ end
158
+
159
+ # Calculates hash code according to all attributes.
160
+ # @return [Integer] Hash code
161
+ def hash
162
+ [frequency, time, time_zone, days_of_week, day_of_month, cron_schedule].hash
163
+ end
164
+
165
+ # Builds the object from hash
166
+ # @param [Hash] attributes Model attributes in the form of hash
167
+ # @return [Object] Returns the model itself
168
+ def self.build_from_hash(attributes)
169
+ new.build_from_hash(attributes)
170
+ end
171
+
172
+ # Builds the object from hash
173
+ # @param [Hash] attributes Model attributes in the form of hash
174
+ # @return [Object] Returns the model itself
175
+ def build_from_hash(attributes)
176
+ return nil unless attributes.is_a?(Hash)
177
+ self.class.openapi_types.each_pair do |key, type|
178
+ if type =~ /\AArray<(.*)>/i
179
+ # check to ensure the input is an array given that the attribute
180
+ # is documented as an array but the input is not
181
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
182
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
183
+ end
184
+ elsif !attributes[self.class.attribute_map[key]].nil?
185
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
186
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
187
+ end
188
+
189
+ self
190
+ end
191
+
192
+ # Deserializes the data based on type
193
+ # @param string type Data type
194
+ # @param string value Value to be deserialized
195
+ # @return [Object] Deserialized data
196
+ def _deserialize(type, value)
197
+ case type.to_sym
198
+ when :DateTime
199
+ DateTime.parse(value)
200
+ when :Date
201
+ Date.parse(value)
202
+ when :Time
203
+ Time.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :Boolean
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ Phrase.const_get(type).build_from_hash(value)
232
+ end
233
+ end
234
+
235
+ # Returns the string representation of the object
236
+ # @return [String] String presentation of the object
237
+ def to_s
238
+ to_hash.to_s
239
+ end
240
+
241
+ # to_body is an alias to to_hash (backward compatibility)
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_body
244
+ to_hash
245
+ end
246
+
247
+ # Returns the object in the form of hash
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_hash
250
+ hash = {}
251
+ self.class.attribute_map.each_pair do |attr, param|
252
+ value = self.send(attr)
253
+ if value.nil?
254
+ is_nullable = self.class.openapi_nullable.include?(attr)
255
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
+ end
257
+
258
+ hash[param] = _to_hash(value)
259
+ end
260
+ hash
261
+ end
262
+
263
+ # Outputs non-array value in the form of hash
264
+ # For object, use to_hash. Otherwise, just return the value
265
+ # @param [Object] value Any valid value
266
+ # @return [Hash] Returns the value in the form of hash
267
+ def _to_hash(value)
268
+ if value.is_a?(Array)
269
+ value.compact.map { |v| _to_hash(v) }
270
+ elsif value.is_a?(Hash)
271
+ {}.tap do |hash|
272
+ value.each { |k, v| hash[k] = _to_hash(v) }
273
+ end
274
+ elsif value.respond_to? :to_hash
275
+ value.to_hash
276
+ else
277
+ value
278
+ end
279
+ end
280
+ end
281
+ end