phrase 4.25.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +15 -4
- data/docs/AutomationEvent.md +33 -0
- data/docs/AutomationEventProject.md +19 -0
- data/docs/AutomationEventsApi.md +168 -0
- data/docs/AutomationsCreateParameters.md +1 -1
- data/docs/AutomationsCreateParameters1.md +1 -1
- data/docs/DocumentsApi.md +4 -4
- data/docs/ICUApi.md +1 -1
- data/docs/IcuSkeletonError.md +17 -0
- data/docs/IcuSkeletonParameters.md +11 -11
- data/docs/JobsApi.md +2 -2
- data/docs/KeyCreateParameters.md +1 -1
- data/docs/KeyFormatAnnotationsApi.md +74 -0
- data/docs/KeyFormatAnnotationsList200ResponseInner.md +19 -0
- data/docs/KeyLinksBatchDestroyParameters.md +6 -4
- data/docs/KeyLinksCreateParameters.md +2 -2
- data/docs/KeyUpdateParameters.md +1 -1
- data/docs/LinkedKeysApi.md +14 -13
- data/docs/PreTranslation.md +29 -0
- data/docs/PreTranslationCreateParameters.md +19 -0
- data/docs/PreTranslationsApi.md +210 -0
- data/docs/ProjectCreateParameters.md +1 -1
- data/docs/ProjectUpdateParameters.md +1 -1
- data/docs/ScreenshotUpdateParameters.md +1 -1
- data/docs/ScreenshotsApi.md +2 -2
- data/lib/phrase/api/automation_events_api.rb +215 -0
- data/lib/phrase/api/documents_api.rb +6 -6
- data/lib/phrase/api/icu_api.rb +2 -6
- data/lib/phrase/api/key_format_annotations_api.rb +85 -0
- data/lib/phrase/api/linked_keys_api.rb +19 -23
- data/lib/phrase/api/pre_translations_api.rb +240 -0
- data/lib/phrase/api/screenshots_api.rb +4 -4
- data/lib/phrase/models/automation_event.rb +325 -0
- data/lib/phrase/models/automation_event_project.rb +208 -0
- data/lib/phrase/models/automations_create_parameters.rb +1 -1
- data/lib/phrase/models/automations_create_parameters1.rb +1 -1
- data/lib/phrase/models/{key_links_index400_response.rb → icu_skeleton_error.rb} +11 -10
- data/lib/phrase/models/icu_skeleton_parameters.rb +6 -6
- data/lib/phrase/models/key_format_annotations_list200_response_inner.rb +207 -0
- data/lib/phrase/models/key_links_batch_destroy_parameters.rb +52 -6
- data/lib/phrase/models/key_links_create_parameters.rb +1 -1
- data/lib/phrase/models/pre_translation.rb +301 -0
- data/lib/phrase/models/pre_translation_create_parameters.rb +241 -0
- data/lib/phrase/response.rb +2 -2
- data/lib/phrase/version.rb +1 -1
- data/lib/phrase.rb +9 -1
- data/phrase.gemspec +1 -1
- data/spec/api/automation_events_api_spec.rb +67 -0
- data/spec/api/documents_api_spec.rb +3 -3
- data/spec/api/icu_api_spec.rb +1 -1
- data/spec/api/key_format_annotations_api_spec.rb +38 -0
- data/spec/api/linked_keys_api_spec.rb +7 -7
- data/spec/api/pre_translations_api_spec.rb +70 -0
- data/spec/api/screenshots_api_spec.rb +2 -2
- data/spec/models/automation_event_project_spec.rb +35 -0
- data/spec/models/automation_event_spec.rb +85 -0
- data/spec/models/{key_links_index400_response_spec.rb → icu_skeleton_error_spec.rb} +7 -7
- data/spec/models/key_format_annotations_list200_response_inner_spec.rb +35 -0
- data/spec/models/key_links_batch_destroy_parameters_spec.rb +10 -0
- data/spec/models/pre_translation_create_parameters_spec.rb +39 -0
- data/spec/models/pre_translation_spec.rb +73 -0
- data/spec/response_spec.rb +53 -0
- metadata +291 -257
- data/docs/KeyLinksIndex400Response.md +0 -17
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
|
|
3
|
+
module Phrase
|
|
4
|
+
class KeyFormatAnnotationsList200ResponseInner
|
|
5
|
+
# The file format that produced this annotation.
|
|
6
|
+
attr_accessor :file_format
|
|
7
|
+
|
|
8
|
+
# The original file-format snippet captured when the key was imported. Returned as-is, may contain multi-line content.
|
|
9
|
+
attr_accessor :original_representation
|
|
10
|
+
|
|
11
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
12
|
+
def self.attribute_map
|
|
13
|
+
{
|
|
14
|
+
:'file_format' => :'file_format',
|
|
15
|
+
:'original_representation' => :'original_representation'
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Attribute type mapping.
|
|
20
|
+
def self.openapi_types
|
|
21
|
+
{
|
|
22
|
+
:'file_format' => :'String',
|
|
23
|
+
:'original_representation' => :'String'
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# List of attributes with nullable: true
|
|
28
|
+
def self.openapi_nullable
|
|
29
|
+
Set.new([
|
|
30
|
+
])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Initializes the object
|
|
34
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
35
|
+
def initialize(attributes = {})
|
|
36
|
+
if (!attributes.is_a?(Hash))
|
|
37
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeyFormatAnnotationsList200ResponseInner` initialize method"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
41
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
42
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
43
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeyFormatAnnotationsList200ResponseInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
44
|
+
end
|
|
45
|
+
h[k.to_sym] = v
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if attributes.key?(:'file_format')
|
|
49
|
+
self.file_format = attributes[:'file_format']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
if attributes.key?(:'original_representation')
|
|
53
|
+
self.original_representation = attributes[:'original_representation']
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
58
|
+
# @return Array for valid properties with the reasons
|
|
59
|
+
def list_invalid_properties
|
|
60
|
+
invalid_properties = Array.new
|
|
61
|
+
invalid_properties
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Check to see if the all the properties in the model are valid
|
|
65
|
+
# @return true if the model is valid
|
|
66
|
+
def valid?
|
|
67
|
+
true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Checks equality by comparing each attribute.
|
|
71
|
+
# @param [Object] Object to be compared
|
|
72
|
+
def ==(o)
|
|
73
|
+
return true if self.equal?(o)
|
|
74
|
+
self.class == o.class &&
|
|
75
|
+
file_format == o.file_format &&
|
|
76
|
+
original_representation == o.original_representation
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @see the `==` method
|
|
80
|
+
# @param [Object] Object to be compared
|
|
81
|
+
def eql?(o)
|
|
82
|
+
self == o
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Calculates hash code according to all attributes.
|
|
86
|
+
# @return [Integer] Hash code
|
|
87
|
+
def hash
|
|
88
|
+
[file_format, original_representation].hash
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Builds the object from hash
|
|
92
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
93
|
+
# @return [Object] Returns the model itself
|
|
94
|
+
def self.build_from_hash(attributes)
|
|
95
|
+
new.build_from_hash(attributes)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Builds the object from hash
|
|
99
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
100
|
+
# @return [Object] Returns the model itself
|
|
101
|
+
def build_from_hash(attributes)
|
|
102
|
+
return nil unless attributes.is_a?(Hash)
|
|
103
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
104
|
+
if type =~ /\AArray<(.*)>/i
|
|
105
|
+
# check to ensure the input is an array given that the attribute
|
|
106
|
+
# is documented as an array but the input is not
|
|
107
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
108
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
109
|
+
end
|
|
110
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
111
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
112
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
self
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Deserializes the data based on type
|
|
119
|
+
# @param string type Data type
|
|
120
|
+
# @param string value Value to be deserialized
|
|
121
|
+
# @return [Object] Deserialized data
|
|
122
|
+
def _deserialize(type, value)
|
|
123
|
+
case type.to_sym
|
|
124
|
+
when :DateTime
|
|
125
|
+
DateTime.parse(value)
|
|
126
|
+
when :Date
|
|
127
|
+
Date.parse(value)
|
|
128
|
+
when :Time
|
|
129
|
+
Time.parse(value)
|
|
130
|
+
when :String
|
|
131
|
+
value.to_s
|
|
132
|
+
when :Integer
|
|
133
|
+
value.to_i
|
|
134
|
+
when :Float
|
|
135
|
+
value.to_f
|
|
136
|
+
when :Boolean
|
|
137
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
138
|
+
true
|
|
139
|
+
else
|
|
140
|
+
false
|
|
141
|
+
end
|
|
142
|
+
when :Object
|
|
143
|
+
# generic object (usually a Hash), return directly
|
|
144
|
+
value
|
|
145
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
146
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
147
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
148
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
149
|
+
k_type = Regexp.last_match[:k_type]
|
|
150
|
+
v_type = Regexp.last_match[:v_type]
|
|
151
|
+
{}.tap do |hash|
|
|
152
|
+
value.each do |k, v|
|
|
153
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
else # model
|
|
157
|
+
Phrase.const_get(type).build_from_hash(value)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Returns the string representation of the object
|
|
162
|
+
# @return [String] String presentation of the object
|
|
163
|
+
def to_s
|
|
164
|
+
to_hash.to_s
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
168
|
+
# @return [Hash] Returns the object in the form of hash
|
|
169
|
+
def to_body
|
|
170
|
+
to_hash
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Returns the object in the form of hash
|
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
|
175
|
+
def to_hash
|
|
176
|
+
hash = {}
|
|
177
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
178
|
+
value = self.send(attr)
|
|
179
|
+
if value.nil?
|
|
180
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
181
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
hash[param] = _to_hash(value)
|
|
185
|
+
end
|
|
186
|
+
hash
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Outputs non-array value in the form of hash
|
|
190
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
191
|
+
# @param [Object] value Any valid value
|
|
192
|
+
# @return [Hash] Returns the value in the form of hash
|
|
193
|
+
def _to_hash(value)
|
|
194
|
+
if value.is_a?(Array)
|
|
195
|
+
value.compact.map { |v| _to_hash(v) }
|
|
196
|
+
elsif value.is_a?(Hash)
|
|
197
|
+
{}.tap do |hash|
|
|
198
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
199
|
+
end
|
|
200
|
+
elsif value.respond_to? :to_hash
|
|
201
|
+
value.to_hash
|
|
202
|
+
else
|
|
203
|
+
value
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
@@ -2,17 +2,43 @@ require 'date'
|
|
|
2
2
|
|
|
3
3
|
module Phrase
|
|
4
4
|
class KeyLinksBatchDestroyParameters
|
|
5
|
-
#
|
|
5
|
+
# Codes of the child keys to unlink. Required when unlink_parent is false or omitted. Ignored when unlink_parent is true.
|
|
6
6
|
attr_accessor :child_key_ids
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# When true, dissolves the entire linked-key group by unlinking all children and removing the group. The child_key_ids field is ignored when this is set to true.
|
|
9
9
|
attr_accessor :unlink_parent
|
|
10
10
|
|
|
11
|
+
# Controls what happens to child key translation content after unlinking. keep_content (default) copies the parent translation into each child; remove_content clears each child translation.
|
|
12
|
+
attr_accessor :strategy
|
|
13
|
+
|
|
14
|
+
class EnumAttributeValidator
|
|
15
|
+
attr_reader :datatype
|
|
16
|
+
attr_reader :allowable_values
|
|
17
|
+
|
|
18
|
+
def initialize(datatype, allowable_values)
|
|
19
|
+
@allowable_values = allowable_values.map do |value|
|
|
20
|
+
case datatype.to_s
|
|
21
|
+
when /Integer/i
|
|
22
|
+
value.to_i
|
|
23
|
+
when /Float/i
|
|
24
|
+
value.to_f
|
|
25
|
+
else
|
|
26
|
+
value
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def valid?(value)
|
|
32
|
+
!value || allowable_values.include?(value)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
11
36
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
12
37
|
def self.attribute_map
|
|
13
38
|
{
|
|
14
39
|
:'child_key_ids' => :'child_key_ids',
|
|
15
|
-
:'unlink_parent' => :'unlink_parent'
|
|
40
|
+
:'unlink_parent' => :'unlink_parent',
|
|
41
|
+
:'strategy' => :'strategy'
|
|
16
42
|
}
|
|
17
43
|
end
|
|
18
44
|
|
|
@@ -20,7 +46,8 @@ module Phrase
|
|
|
20
46
|
def self.openapi_types
|
|
21
47
|
{
|
|
22
48
|
:'child_key_ids' => :'Array<String>',
|
|
23
|
-
:'unlink_parent' => :'Boolean'
|
|
49
|
+
:'unlink_parent' => :'Boolean',
|
|
50
|
+
:'strategy' => :'String'
|
|
24
51
|
}
|
|
25
52
|
end
|
|
26
53
|
|
|
@@ -56,6 +83,12 @@ module Phrase
|
|
|
56
83
|
else
|
|
57
84
|
self.unlink_parent = false
|
|
58
85
|
end
|
|
86
|
+
|
|
87
|
+
if attributes.key?(:'strategy')
|
|
88
|
+
self.strategy = attributes[:'strategy']
|
|
89
|
+
else
|
|
90
|
+
self.strategy = 'keep_content'
|
|
91
|
+
end
|
|
59
92
|
end
|
|
60
93
|
|
|
61
94
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -73,16 +106,29 @@ module Phrase
|
|
|
73
106
|
# @return true if the model is valid
|
|
74
107
|
def valid?
|
|
75
108
|
return false if @child_key_ids.nil?
|
|
109
|
+
strategy_validator = EnumAttributeValidator.new('String', ["keep_content", "remove_content"])
|
|
110
|
+
return false unless strategy_validator.valid?(@strategy)
|
|
76
111
|
true
|
|
77
112
|
end
|
|
78
113
|
|
|
114
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
115
|
+
# @param [Object] strategy Object to be assigned
|
|
116
|
+
def strategy=(strategy)
|
|
117
|
+
validator = EnumAttributeValidator.new('String', ["keep_content", "remove_content"])
|
|
118
|
+
unless validator.valid?(strategy)
|
|
119
|
+
fail ArgumentError, "invalid value for \"strategy\", must be one of #{validator.allowable_values}."
|
|
120
|
+
end
|
|
121
|
+
@strategy = strategy
|
|
122
|
+
end
|
|
123
|
+
|
|
79
124
|
# Checks equality by comparing each attribute.
|
|
80
125
|
# @param [Object] Object to be compared
|
|
81
126
|
def ==(o)
|
|
82
127
|
return true if self.equal?(o)
|
|
83
128
|
self.class == o.class &&
|
|
84
129
|
child_key_ids == o.child_key_ids &&
|
|
85
|
-
unlink_parent == o.unlink_parent
|
|
130
|
+
unlink_parent == o.unlink_parent &&
|
|
131
|
+
strategy == o.strategy
|
|
86
132
|
end
|
|
87
133
|
|
|
88
134
|
# @see the `==` method
|
|
@@ -94,7 +140,7 @@ module Phrase
|
|
|
94
140
|
# Calculates hash code according to all attributes.
|
|
95
141
|
# @return [Integer] Hash code
|
|
96
142
|
def hash
|
|
97
|
-
[child_key_ids, unlink_parent].hash
|
|
143
|
+
[child_key_ids, unlink_parent, strategy].hash
|
|
98
144
|
end
|
|
99
145
|
|
|
100
146
|
# Builds the object from hash
|
|
@@ -2,7 +2,7 @@ require 'date'
|
|
|
2
2
|
|
|
3
3
|
module Phrase
|
|
4
4
|
class KeyLinksCreateParameters
|
|
5
|
-
#
|
|
5
|
+
# Codes of the keys to link as children. Pass an empty array to mark the parent key without linking any children.
|
|
6
6
|
attr_accessor :child_key_ids
|
|
7
7
|
|
|
8
8
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
|
|
3
|
+
module Phrase
|
|
4
|
+
class PreTranslation
|
|
5
|
+
attr_accessor :id
|
|
6
|
+
|
|
7
|
+
# Current execution state of the pre-translation job. Jobs start as `pending` while queued, transition to `running` while executing, and settle to `success` or `error`.
|
|
8
|
+
attr_accessor :status
|
|
9
|
+
|
|
10
|
+
# Resource type that was pre-translated.
|
|
11
|
+
attr_accessor :translatable_type
|
|
12
|
+
|
|
13
|
+
# ID of the targeted resource (locale ID, job ID, key ID, or upload ID).
|
|
14
|
+
attr_accessor :translatable_id
|
|
15
|
+
|
|
16
|
+
# Error message. `null` unless the job's status is `error`.
|
|
17
|
+
attr_accessor :error
|
|
18
|
+
|
|
19
|
+
attr_accessor :created_at
|
|
20
|
+
|
|
21
|
+
attr_accessor :updated_at
|
|
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
|
+
:'id' => :'id',
|
|
49
|
+
:'status' => :'status',
|
|
50
|
+
:'translatable_type' => :'translatable_type',
|
|
51
|
+
:'translatable_id' => :'translatable_id',
|
|
52
|
+
:'error' => :'error',
|
|
53
|
+
:'created_at' => :'created_at',
|
|
54
|
+
:'updated_at' => :'updated_at'
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Attribute type mapping.
|
|
59
|
+
def self.openapi_types
|
|
60
|
+
{
|
|
61
|
+
:'id' => :'String',
|
|
62
|
+
:'status' => :'String',
|
|
63
|
+
:'translatable_type' => :'String',
|
|
64
|
+
:'translatable_id' => :'String',
|
|
65
|
+
:'error' => :'String',
|
|
66
|
+
:'created_at' => :'DateTime',
|
|
67
|
+
:'updated_at' => :'DateTime'
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# List of attributes with nullable: true
|
|
72
|
+
def self.openapi_nullable
|
|
73
|
+
Set.new([
|
|
74
|
+
:'error',
|
|
75
|
+
])
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Initializes the object
|
|
79
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
80
|
+
def initialize(attributes = {})
|
|
81
|
+
if (!attributes.is_a?(Hash))
|
|
82
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::PreTranslation` initialize method"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
86
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
87
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
88
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::PreTranslation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
89
|
+
end
|
|
90
|
+
h[k.to_sym] = v
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if attributes.key?(:'id')
|
|
94
|
+
self.id = attributes[:'id']
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'status')
|
|
98
|
+
self.status = attributes[:'status']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'translatable_type')
|
|
102
|
+
self.translatable_type = attributes[:'translatable_type']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'translatable_id')
|
|
106
|
+
self.translatable_id = attributes[:'translatable_id']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'error')
|
|
110
|
+
self.error = attributes[:'error']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'created_at')
|
|
114
|
+
self.created_at = attributes[:'created_at']
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if attributes.key?(:'updated_at')
|
|
118
|
+
self.updated_at = attributes[:'updated_at']
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
123
|
+
# @return Array for valid properties with the reasons
|
|
124
|
+
def list_invalid_properties
|
|
125
|
+
invalid_properties = Array.new
|
|
126
|
+
invalid_properties
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Check to see if the all the properties in the model are valid
|
|
130
|
+
# @return true if the model is valid
|
|
131
|
+
def valid?
|
|
132
|
+
status_validator = EnumAttributeValidator.new('String', ["pending", "running", "success", "error"])
|
|
133
|
+
return false unless status_validator.valid?(@status)
|
|
134
|
+
translatable_type_validator = EnumAttributeValidator.new('String', ["locale", "job", "translation_key", "upload"])
|
|
135
|
+
return false unless translatable_type_validator.valid?(@translatable_type)
|
|
136
|
+
true
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
140
|
+
# @param [Object] status Object to be assigned
|
|
141
|
+
def status=(status)
|
|
142
|
+
validator = EnumAttributeValidator.new('String', ["pending", "running", "success", "error"])
|
|
143
|
+
unless validator.valid?(status)
|
|
144
|
+
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
|
145
|
+
end
|
|
146
|
+
@status = status
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
150
|
+
# @param [Object] translatable_type Object to be assigned
|
|
151
|
+
def translatable_type=(translatable_type)
|
|
152
|
+
validator = EnumAttributeValidator.new('String', ["locale", "job", "translation_key", "upload"])
|
|
153
|
+
unless validator.valid?(translatable_type)
|
|
154
|
+
fail ArgumentError, "invalid value for \"translatable_type\", must be one of #{validator.allowable_values}."
|
|
155
|
+
end
|
|
156
|
+
@translatable_type = translatable_type
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Checks equality by comparing each attribute.
|
|
160
|
+
# @param [Object] Object to be compared
|
|
161
|
+
def ==(o)
|
|
162
|
+
return true if self.equal?(o)
|
|
163
|
+
self.class == o.class &&
|
|
164
|
+
id == o.id &&
|
|
165
|
+
status == o.status &&
|
|
166
|
+
translatable_type == o.translatable_type &&
|
|
167
|
+
translatable_id == o.translatable_id &&
|
|
168
|
+
error == o.error &&
|
|
169
|
+
created_at == o.created_at &&
|
|
170
|
+
updated_at == o.updated_at
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# @see the `==` method
|
|
174
|
+
# @param [Object] Object to be compared
|
|
175
|
+
def eql?(o)
|
|
176
|
+
self == o
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Calculates hash code according to all attributes.
|
|
180
|
+
# @return [Integer] Hash code
|
|
181
|
+
def hash
|
|
182
|
+
[id, status, translatable_type, translatable_id, error, created_at, updated_at].hash
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Builds the object from hash
|
|
186
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
187
|
+
# @return [Object] Returns the model itself
|
|
188
|
+
def self.build_from_hash(attributes)
|
|
189
|
+
new.build_from_hash(attributes)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Builds the object from hash
|
|
193
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
194
|
+
# @return [Object] Returns the model itself
|
|
195
|
+
def build_from_hash(attributes)
|
|
196
|
+
return nil unless attributes.is_a?(Hash)
|
|
197
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
198
|
+
if type =~ /\AArray<(.*)>/i
|
|
199
|
+
# check to ensure the input is an array given that the attribute
|
|
200
|
+
# is documented as an array but the input is not
|
|
201
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
202
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
203
|
+
end
|
|
204
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
205
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
206
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
self
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Deserializes the data based on type
|
|
213
|
+
# @param string type Data type
|
|
214
|
+
# @param string value Value to be deserialized
|
|
215
|
+
# @return [Object] Deserialized data
|
|
216
|
+
def _deserialize(type, value)
|
|
217
|
+
case type.to_sym
|
|
218
|
+
when :DateTime
|
|
219
|
+
DateTime.parse(value)
|
|
220
|
+
when :Date
|
|
221
|
+
Date.parse(value)
|
|
222
|
+
when :Time
|
|
223
|
+
Time.parse(value)
|
|
224
|
+
when :String
|
|
225
|
+
value.to_s
|
|
226
|
+
when :Integer
|
|
227
|
+
value.to_i
|
|
228
|
+
when :Float
|
|
229
|
+
value.to_f
|
|
230
|
+
when :Boolean
|
|
231
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
232
|
+
true
|
|
233
|
+
else
|
|
234
|
+
false
|
|
235
|
+
end
|
|
236
|
+
when :Object
|
|
237
|
+
# generic object (usually a Hash), return directly
|
|
238
|
+
value
|
|
239
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
240
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
241
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
242
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
243
|
+
k_type = Regexp.last_match[:k_type]
|
|
244
|
+
v_type = Regexp.last_match[:v_type]
|
|
245
|
+
{}.tap do |hash|
|
|
246
|
+
value.each do |k, v|
|
|
247
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
else # model
|
|
251
|
+
Phrase.const_get(type).build_from_hash(value)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Returns the string representation of the object
|
|
256
|
+
# @return [String] String presentation of the object
|
|
257
|
+
def to_s
|
|
258
|
+
to_hash.to_s
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
262
|
+
# @return [Hash] Returns the object in the form of hash
|
|
263
|
+
def to_body
|
|
264
|
+
to_hash
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Returns the object in the form of hash
|
|
268
|
+
# @return [Hash] Returns the object in the form of hash
|
|
269
|
+
def to_hash
|
|
270
|
+
hash = {}
|
|
271
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
272
|
+
value = self.send(attr)
|
|
273
|
+
if value.nil?
|
|
274
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
275
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
hash[param] = _to_hash(value)
|
|
279
|
+
end
|
|
280
|
+
hash
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Outputs non-array value in the form of hash
|
|
284
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
285
|
+
# @param [Object] value Any valid value
|
|
286
|
+
# @return [Hash] Returns the value in the form of hash
|
|
287
|
+
def _to_hash(value)
|
|
288
|
+
if value.is_a?(Array)
|
|
289
|
+
value.compact.map { |v| _to_hash(v) }
|
|
290
|
+
elsif value.is_a?(Hash)
|
|
291
|
+
{}.tap do |hash|
|
|
292
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
293
|
+
end
|
|
294
|
+
elsif value.respond_to? :to_hash
|
|
295
|
+
value.to_hash
|
|
296
|
+
else
|
|
297
|
+
value
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|