phrase 4.23.0 → 4.25.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 +23 -0
- data/README.md +7 -3
- data/docs/BranchComparison.md +23 -0
- data/docs/BranchComparisonChange.md +19 -0
- data/docs/BranchComparisonDiff.md +21 -0
- data/docs/BranchComparisonDiffConflictsValue.md +19 -0
- data/docs/BranchesApi.md +5 -4
- data/docs/Format.md +20 -20
- data/docs/FormatsApi.md +1 -1
- data/docs/Job.md +3 -1
- data/docs/JobDetails.md +2 -0
- data/docs/KeyCreateParameters.md +1 -1
- data/docs/KeyUpdateParameters.md +1 -1
- data/docs/Locale.md +2 -0
- data/docs/LocaleCreateParameters.md +3 -1
- data/docs/LocaleDetails.md +2 -0
- data/docs/LocaleDownloadCreateParameters.md +8 -2
- data/docs/LocaleUpdateParameters.md +3 -1
- data/docs/LocalesApi.md +8 -6
- data/docs/ProjectCreateParameters.md +1 -1
- data/docs/ProjectUpdateParameters.md +1 -1
- data/docs/RepoSync.md +2 -0
- data/docs/RepoSyncCreateParameters.md +2 -0
- data/docs/ScreenshotUpdateParameters.md +1 -1
- data/docs/ScreenshotsApi.md +9 -9
- data/docs/UploadSummary.md +1 -1
- data/lib/phrase/api/branches_api.rb +5 -3
- data/lib/phrase/api/formats_api.rb +2 -2
- data/lib/phrase/api/locales_api.rb +9 -6
- data/lib/phrase/api/screenshots_api.rb +16 -12
- data/lib/phrase/models/branch_comparison.rb +224 -0
- data/lib/phrase/models/branch_comparison_change.rb +212 -0
- data/lib/phrase/models/branch_comparison_diff.rb +223 -0
- data/lib/phrase/models/branch_comparison_diff_conflicts_value.rb +209 -0
- data/lib/phrase/models/format.rb +60 -0
- data/lib/phrase/models/job.rb +16 -5
- data/lib/phrase/models/job_details.rb +12 -1
- data/lib/phrase/models/locale.rb +10 -1
- data/lib/phrase/models/locale_create_parameters.rb +14 -4
- data/lib/phrase/models/locale_details.rb +10 -1
- data/lib/phrase/models/locale_download_create_parameters.rb +33 -3
- data/lib/phrase/models/locale_update_parameters.rb +14 -4
- data/lib/phrase/models/repo_sync.rb +29 -1
- data/lib/phrase/models/repo_sync_create_parameters.rb +27 -1
- data/lib/phrase/models/upload_summary.rb +1 -1
- data/lib/phrase/version.rb +1 -1
- data/lib/phrase.rb +4 -0
- data/spec/api/branches_api_spec.rb +1 -1
- data/spec/api/formats_api_spec.rb +1 -1
- data/spec/api/screenshots_api_spec.rb +4 -4
- data/spec/models/branch_comparison_change_spec.rb +35 -0
- data/spec/models/branch_comparison_diff_conflicts_value_spec.rb +35 -0
- data/spec/models/branch_comparison_diff_spec.rb +41 -0
- data/spec/models/branch_comparison_spec.rb +47 -0
- data/spec/models/job_details_spec.rb +6 -0
- data/spec/models/job_spec.rb +6 -0
- data/spec/models/locale_create_parameters_spec.rb +6 -0
- data/spec/models/locale_details_spec.rb +6 -0
- data/spec/models/locale_download_create_parameters_spec.rb +18 -0
- data/spec/models/locale_spec.rb +6 -0
- data/spec/models/locale_update_parameters_spec.rb +6 -0
- data/spec/models/repo_sync_create_parameters_spec.rb +6 -0
- data/spec/models/repo_sync_spec.rb +6 -0
- metadata +262 -246
|
@@ -13,7 +13,7 @@ module Phrase
|
|
|
13
13
|
# @param name [String] name
|
|
14
14
|
# @param [Hash] opts the optional parameters
|
|
15
15
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
|
16
|
-
# @return [
|
|
16
|
+
# @return [BranchComparison]
|
|
17
17
|
def branch_compare(project_id, name, opts = {})
|
|
18
18
|
data, _status_code, _headers = branch_compare_with_http_info(project_id, name, opts)
|
|
19
19
|
data
|
|
@@ -25,7 +25,7 @@ module Phrase
|
|
|
25
25
|
# @param name [String] name
|
|
26
26
|
# @param [Hash] opts the optional parameters
|
|
27
27
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
|
28
|
-
# @return [Array<(Response
|
|
28
|
+
# @return [Array<(Response<(BranchComparison)>, Integer, Hash)>] Response<(BranchComparison)> data, response status code and response headers
|
|
29
29
|
def branch_compare_with_http_info(project_id, name, opts = {})
|
|
30
30
|
if @api_client.config.debugging
|
|
31
31
|
@api_client.config.logger.debug 'Calling API: BranchesApi.branch_compare ...'
|
|
@@ -46,6 +46,8 @@ module Phrase
|
|
|
46
46
|
|
|
47
47
|
# header parameters
|
|
48
48
|
header_params = opts[:header_params] || {}
|
|
49
|
+
# HTTP header 'Accept' (if needed)
|
|
50
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
49
51
|
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
|
|
50
52
|
|
|
51
53
|
# form parameters
|
|
@@ -55,7 +57,7 @@ module Phrase
|
|
|
55
57
|
post_body = opts[:body]
|
|
56
58
|
|
|
57
59
|
# return_type
|
|
58
|
-
return_type = opts[:return_type]
|
|
60
|
+
return_type = opts[:return_type] || 'BranchComparison'
|
|
59
61
|
|
|
60
62
|
# auth_names
|
|
61
63
|
auth_names = opts[:auth_names] || ['Basic', 'Token']
|
|
@@ -8,7 +8,7 @@ module Phrase
|
|
|
8
8
|
@api_client = api_client
|
|
9
9
|
end
|
|
10
10
|
# List formats
|
|
11
|
-
#
|
|
11
|
+
# Returns all file formats that Phrase Strings supports. Use the api_name value from each format as the file_format parameter when uploading or downloading locale files. Not every format supports both directions: check the importable and exportable fields before using a format in a workflow. This endpoint does not require authentication and is not subject to rate limiting.
|
|
12
12
|
# @param [Hash] opts the optional parameters
|
|
13
13
|
# @return [Array<Format>]
|
|
14
14
|
def formats_list(opts = {})
|
|
@@ -17,7 +17,7 @@ module Phrase
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# List formats
|
|
20
|
-
#
|
|
20
|
+
# Returns all file formats that Phrase Strings supports. Use the api_name value from each format as the file_format parameter when uploading or downloading locale files. Not every format supports both directions: check the importable and exportable fields before using a format in a workflow. This endpoint does not require authentication and is not subject to rate limiting.
|
|
21
21
|
# @param [Hash] opts the optional parameters
|
|
22
22
|
# @return [Array<(Response<(Array<Format>)>, Integer, Hash)>] Response<(Array<Format>)> data, response status code and response headers
|
|
23
23
|
def formats_list_with_http_info(opts = {})
|
|
@@ -250,11 +250,12 @@ module Phrase
|
|
|
250
250
|
# @option opts [Boolean] :skip_unverified_translations Indicates whether the locale file should skip all unverified translations. This parameter is deprecated and should be replaced with `include_unverified_translations`.
|
|
251
251
|
# @option opts [Boolean] :include_unverified_translations if set to false unverified translations are excluded
|
|
252
252
|
# @option opts [Boolean] :use_last_reviewed_version If set to true the last reviewed version of a translation is used. This is only available if the review workflow is enabled for the project.
|
|
253
|
-
# @option opts [String] :fallback_locale_id If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Provide the ID of the locale that should be used as the fallback. Requires `include_empty_translations` to be set to `true`. Mutually exclusive with `use_locale_fallback`.
|
|
254
|
-
# @option opts [Boolean] :use_locale_fallback If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Fallback locale is defined in [locale's settings](/en/api/strings/locales/update-a-locale#body-fallback-locale-id). Requires `include_empty_translations` to be set to `true`. Mutually exclusive with `fallback_locale_id`.
|
|
253
|
+
# @option opts [String] :fallback_locale_id If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Provide the ID of the locale that should be used as the fallback. Requires `include_empty_translations` to be set to `true` unless `fallback_for_unverified_translations` is also set to `true`. Mutually exclusive with `use_locale_fallback`.
|
|
254
|
+
# @option opts [Boolean] :use_locale_fallback If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Fallback locale is defined in [locale's settings](/en/api/strings/locales/update-a-locale#body-fallback-locale-id). Requires `include_empty_translations` to be set to `true` unless `fallback_for_unverified_translations` is also set to `true`. Mutually exclusive with `fallback_locale_id`.
|
|
255
|
+
# @option opts [Boolean] :fallback_for_unverified_translations If set to `true`, translations in a non-final state are replaced by the fallback locale's translation at export time. In the simple workflow, \"non-final\" means `unverified`. In the review workflow, it additionally includes `translated` (awaiting review). No stored translations are modified. Requires `fallback_locale_id` or `use_locale_fallback` to be set; a `422` validation error is returned otherwise.
|
|
255
256
|
# @option opts [String] :source_locale_id Provides the source language of a corresponding job as the source language of the generated locale file. This parameter will be ignored unless used in combination with a `tag` parameter indicating a specific job.
|
|
256
257
|
# @option opts [String] :translation_key_prefix Download all translation keys, and remove the specified prefix where possible. Warning: this may create duplicate key names if other keys share the same name after the prefix is removed.
|
|
257
|
-
# @option opts [Boolean] :filter_by_prefix Only download translation keys containing the specified
|
|
258
|
+
# @option opts [Boolean] :filter_by_prefix Only download translation keys containing the prefix specified by `translation_key_prefix`, and remove that prefix from the generated file. Requires `translation_key_prefix` to be set.
|
|
258
259
|
# @option opts [Object] :custom_metadata_filters Custom metadata filters. Provide the name of the metadata field and the value to filter by. Only keys with matching metadata will be included in the download.
|
|
259
260
|
# @option opts [Array<String>] :locale_ids Locale IDs or locale names
|
|
260
261
|
# @option opts [String] :updated_since Only include translations and keys that have been updated since the given date. The date must be in ISO 8601 format (e.g., `2023-01-01T00:00:00Z`).
|
|
@@ -286,11 +287,12 @@ module Phrase
|
|
|
286
287
|
# @option opts [Boolean] :skip_unverified_translations Indicates whether the locale file should skip all unverified translations. This parameter is deprecated and should be replaced with `include_unverified_translations`.
|
|
287
288
|
# @option opts [Boolean] :include_unverified_translations if set to false unverified translations are excluded
|
|
288
289
|
# @option opts [Boolean] :use_last_reviewed_version If set to true the last reviewed version of a translation is used. This is only available if the review workflow is enabled for the project.
|
|
289
|
-
# @option opts [String] :fallback_locale_id If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Provide the ID of the locale that should be used as the fallback. Requires `include_empty_translations` to be set to `true`. Mutually exclusive with `use_locale_fallback`.
|
|
290
|
-
# @option opts [Boolean] :use_locale_fallback If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Fallback locale is defined in [locale's settings](/en/api/strings/locales/update-a-locale#body-fallback-locale-id). Requires `include_empty_translations` to be set to `true`. Mutually exclusive with `fallback_locale_id`.
|
|
290
|
+
# @option opts [String] :fallback_locale_id If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Provide the ID of the locale that should be used as the fallback. Requires `include_empty_translations` to be set to `true` unless `fallback_for_unverified_translations` is also set to `true`. Mutually exclusive with `use_locale_fallback`.
|
|
291
|
+
# @option opts [Boolean] :use_locale_fallback If a key has no translation in the locale being downloaded, the translation in the fallback locale will be used. Fallback locale is defined in [locale's settings](/en/api/strings/locales/update-a-locale#body-fallback-locale-id). Requires `include_empty_translations` to be set to `true` unless `fallback_for_unverified_translations` is also set to `true`. Mutually exclusive with `fallback_locale_id`.
|
|
292
|
+
# @option opts [Boolean] :fallback_for_unverified_translations If set to `true`, translations in a non-final state are replaced by the fallback locale's translation at export time. In the simple workflow, \"non-final\" means `unverified`. In the review workflow, it additionally includes `translated` (awaiting review). No stored translations are modified. Requires `fallback_locale_id` or `use_locale_fallback` to be set; a `422` validation error is returned otherwise.
|
|
291
293
|
# @option opts [String] :source_locale_id Provides the source language of a corresponding job as the source language of the generated locale file. This parameter will be ignored unless used in combination with a `tag` parameter indicating a specific job.
|
|
292
294
|
# @option opts [String] :translation_key_prefix Download all translation keys, and remove the specified prefix where possible. Warning: this may create duplicate key names if other keys share the same name after the prefix is removed.
|
|
293
|
-
# @option opts [Boolean] :filter_by_prefix Only download translation keys containing the specified
|
|
295
|
+
# @option opts [Boolean] :filter_by_prefix Only download translation keys containing the prefix specified by `translation_key_prefix`, and remove that prefix from the generated file. Requires `translation_key_prefix` to be set.
|
|
294
296
|
# @option opts [Object] :custom_metadata_filters Custom metadata filters. Provide the name of the metadata field and the value to filter by. Only keys with matching metadata will be included in the download.
|
|
295
297
|
# @option opts [Array<String>] :locale_ids Locale IDs or locale names
|
|
296
298
|
# @option opts [String] :updated_since Only include translations and keys that have been updated since the given date. The date must be in ISO 8601 format (e.g., `2023-01-01T00:00:00Z`).
|
|
@@ -328,6 +330,7 @@ module Phrase
|
|
|
328
330
|
query_params[:'use_last_reviewed_version'] = opts[:'use_last_reviewed_version'] if !opts[:'use_last_reviewed_version'].nil?
|
|
329
331
|
query_params[:'fallback_locale_id'] = opts[:'fallback_locale_id'] if !opts[:'fallback_locale_id'].nil?
|
|
330
332
|
query_params[:'use_locale_fallback'] = opts[:'use_locale_fallback'] if !opts[:'use_locale_fallback'].nil?
|
|
333
|
+
query_params[:'fallback_for_unverified_translations'] = opts[:'fallback_for_unverified_translations'] if !opts[:'fallback_for_unverified_translations'].nil?
|
|
331
334
|
query_params[:'source_locale_id'] = opts[:'source_locale_id'] if !opts[:'source_locale_id'].nil?
|
|
332
335
|
query_params[:'translation_key_prefix'] = opts[:'translation_key_prefix'] if !opts[:'translation_key_prefix'].nil?
|
|
333
336
|
query_params[:'filter_by_prefix'] = opts[:'filter_by_prefix'] if !opts[:'filter_by_prefix'].nil?
|
|
@@ -8,31 +8,31 @@ module Phrase
|
|
|
8
8
|
@api_client = api_client
|
|
9
9
|
end
|
|
10
10
|
# Create a screenshot
|
|
11
|
-
#
|
|
11
|
+
# Creates a screenshot in a project to provide visual context for in-context translation. Attach translation keys to regions of the uploaded image so translators can see where each string appears in your UI. This endpoint accepts a multipart/form-data request with a binary file upload, unlike most Phrase API endpoints that use JSON. Use a multipart form client or the -F flag in curl rather than a JSON body. The screenshot name must be unique within the project (case-insensitive). When name is omitted, it is derived from the uploaded filename. The account must have the Screenshots feature enabled; requests to projects on accounts without it return 403. Creating a screenshot requires a token with the write scope and manage access to the project.
|
|
12
12
|
# @param project_id [String] Project ID
|
|
13
|
+
# @param filename [File] Image file to upload. Accepted formats are JPEG (jpg/jpeg), GIF, and PNG. Maximum file size is 10 MB. Submitting an unsupported format or a file exceeding the size limit returns 422.
|
|
13
14
|
# @param [Hash] opts the optional parameters
|
|
14
15
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
|
15
16
|
# @option opts [String] :branch specify the branch to use
|
|
16
|
-
# @option opts [String] :name
|
|
17
|
-
# @option opts [String] :description
|
|
18
|
-
# @option opts [File] :filename Screenshot file
|
|
17
|
+
# @option opts [String] :name Display name for the screenshot. Must be unique within the project (case-insensitive). When omitted, the name is derived from the uploaded filename.
|
|
18
|
+
# @option opts [String] :description Optional free-text description of the screenshot.
|
|
19
19
|
# @return [Screenshot]
|
|
20
|
-
def screenshot_create(project_id, opts = {})
|
|
21
|
-
data, _status_code, _headers = screenshot_create_with_http_info(project_id, opts)
|
|
20
|
+
def screenshot_create(project_id, filename, opts = {})
|
|
21
|
+
data, _status_code, _headers = screenshot_create_with_http_info(project_id, filename, opts)
|
|
22
22
|
data
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
# Create a screenshot
|
|
26
|
-
#
|
|
26
|
+
# Creates a screenshot in a project to provide visual context for in-context translation. Attach translation keys to regions of the uploaded image so translators can see where each string appears in your UI. This endpoint accepts a multipart/form-data request with a binary file upload, unlike most Phrase API endpoints that use JSON. Use a multipart form client or the -F flag in curl rather than a JSON body. The screenshot name must be unique within the project (case-insensitive). When name is omitted, it is derived from the uploaded filename. The account must have the Screenshots feature enabled; requests to projects on accounts without it return 403. Creating a screenshot requires a token with the write scope and manage access to the project.
|
|
27
27
|
# @param project_id [String] Project ID
|
|
28
|
+
# @param filename [File] Image file to upload. Accepted formats are JPEG (jpg/jpeg), GIF, and PNG. Maximum file size is 10 MB. Submitting an unsupported format or a file exceeding the size limit returns 422.
|
|
28
29
|
# @param [Hash] opts the optional parameters
|
|
29
30
|
# @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
|
|
30
31
|
# @option opts [String] :branch specify the branch to use
|
|
31
|
-
# @option opts [String] :name
|
|
32
|
-
# @option opts [String] :description
|
|
33
|
-
# @option opts [File] :filename Screenshot file
|
|
32
|
+
# @option opts [String] :name Display name for the screenshot. Must be unique within the project (case-insensitive). When omitted, the name is derived from the uploaded filename.
|
|
33
|
+
# @option opts [String] :description Optional free-text description of the screenshot.
|
|
34
34
|
# @return [Array<(Response<(Screenshot)>, Integer, Hash)>] Response<(Screenshot)> data, response status code and response headers
|
|
35
|
-
def screenshot_create_with_http_info(project_id, opts = {})
|
|
35
|
+
def screenshot_create_with_http_info(project_id, filename, opts = {})
|
|
36
36
|
if @api_client.config.debugging
|
|
37
37
|
@api_client.config.logger.debug 'Calling API: ScreenshotsApi.screenshot_create ...'
|
|
38
38
|
end
|
|
@@ -40,6 +40,10 @@ module Phrase
|
|
|
40
40
|
if @api_client.config.client_side_validation && project_id.nil?
|
|
41
41
|
fail ArgumentError, "Missing the required parameter 'project_id' when calling ScreenshotsApi.screenshot_create"
|
|
42
42
|
end
|
|
43
|
+
# verify the required parameter 'filename' is set
|
|
44
|
+
if @api_client.config.client_side_validation && filename.nil?
|
|
45
|
+
fail ArgumentError, "Missing the required parameter 'filename' when calling ScreenshotsApi.screenshot_create"
|
|
46
|
+
end
|
|
43
47
|
# resource path
|
|
44
48
|
local_var_path = '/projects/{project_id}/screenshots'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))
|
|
45
49
|
|
|
@@ -56,10 +60,10 @@ module Phrase
|
|
|
56
60
|
|
|
57
61
|
# form parameters
|
|
58
62
|
form_params = opts[:form_params] || {}
|
|
63
|
+
form_params['filename'] = filename
|
|
59
64
|
form_params['branch'] = opts[:'branch'] if !opts[:'branch'].nil?
|
|
60
65
|
form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
|
|
61
66
|
form_params['description'] = opts[:'description'] if !opts[:'description'].nil?
|
|
62
|
-
form_params['filename'] = opts[:'filename'] if !opts[:'filename'].nil?
|
|
63
67
|
|
|
64
68
|
# http body (model)
|
|
65
69
|
post_body = opts[:body]
|
|
@@ -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
|