ruby-lokalise-api 10.1.0 → 10.2.1
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/lib/ruby_lokalise_api/collections/translation_memories.rb +11 -0
- data/lib/ruby_lokalise_api/concerns/hash_accessible.rb +1 -1
- data/lib/ruby_lokalise_api/connection.rb +7 -7
- data/lib/ruby_lokalise_api/data/collection_attributes.yml +3 -0
- data/lib/ruby_lokalise_api/data/resource_attributes.yml +3 -0
- data/lib/ruby_lokalise_api/endpoints/translation_memories_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/error.rb +2 -1
- data/lib/ruby_lokalise_api/{generics.rb → operation_results.rb} +2 -2
- data/lib/ruby_lokalise_api/request.rb +20 -11
- data/lib/ruby_lokalise_api/resources/base.rb +6 -2
- data/lib/ruby_lokalise_api/resources/translation_memory.rb +11 -0
- data/lib/ruby_lokalise_api/response.rb +8 -3
- data/lib/ruby_lokalise_api/rest/branches.rb +4 -4
- data/lib/ruby_lokalise_api/rest/comments.rb +2 -2
- data/lib/ruby_lokalise_api/rest/contributors.rb +2 -2
- data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +4 -4
- data/lib/ruby_lokalise_api/rest/files.rb +4 -4
- data/lib/ruby_lokalise_api/rest/glossary_terms.rb +2 -2
- data/lib/ruby_lokalise_api/rest/keys.rb +4 -4
- data/lib/ruby_lokalise_api/rest/languages.rb +2 -2
- data/lib/ruby_lokalise_api/rest/payment_cards.rb +2 -2
- data/lib/ruby_lokalise_api/rest/projects.rb +4 -4
- data/lib/ruby_lokalise_api/rest/screenshots.rb +2 -2
- data/lib/ruby_lokalise_api/rest/snapshots.rb +2 -2
- data/lib/ruby_lokalise_api/rest/tasks.rb +2 -2
- data/lib/ruby_lokalise_api/rest/team_user_groups.rb +2 -2
- data/lib/ruby_lokalise_api/rest/team_users.rb +2 -2
- data/lib/ruby_lokalise_api/rest/translation_memories.rb +22 -0
- data/lib/ruby_lokalise_api/rest/webhooks.rb +4 -4
- data/lib/ruby_lokalise_api/rest.rb +1 -0
- data/lib/ruby_lokalise_api/utils/attributes.rb +2 -2
- data/lib/ruby_lokalise_api/utils/classes.rb +4 -2
- data/lib/ruby_lokalise_api/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95a837c152b23193f3377a61b049cbf44e3fb3e3c308b58351769b8035c8ca1d
|
|
4
|
+
data.tar.gz: 6c79d9e467ad4cfff60ff8c55d8576a4e019071c099b1eb52e84500e9cdc9827
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 719d946855640266d60d6ae8751b7774b250503d54a2a102821ac8cae141941cde8635c71568d9303a244d8d2f96e7fd0c7e65caf547bda6fac27205421f6bf2
|
|
7
|
+
data.tar.gz: 36751c1d439846fca179f0ca203da926041173b9312984efef67e610e71e97529de3632f07c4f834c82565f46908a666e4f7c7272eb2a83e4e111ef1386dbd57
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyLokaliseApi
|
|
4
|
+
module Collections
|
|
5
|
+
class TranslationMemories < Base
|
|
6
|
+
ENDPOINT = RubyLokaliseApi::Endpoints::TranslationMemoriesEndpoint
|
|
7
|
+
RESOURCE = RubyLokaliseApi::Resources::TranslationMemory
|
|
8
|
+
DATA_KEY = 'translation_memories'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module RubyLokaliseApi
|
|
4
|
-
# Module
|
|
4
|
+
# Module for setting up Faraday connections
|
|
5
5
|
module Connection
|
|
6
6
|
# Creates a new Faraday object with specified params
|
|
7
7
|
#
|
|
@@ -18,7 +18,7 @@ module RubyLokaliseApi
|
|
|
18
18
|
private
|
|
19
19
|
|
|
20
20
|
def options(endpoint, params)
|
|
21
|
-
req_params =
|
|
21
|
+
req_params = base_options(endpoint)
|
|
22
22
|
client = endpoint.client
|
|
23
23
|
|
|
24
24
|
add_token_header(req_params, client) if client_responds_to_token?(client)
|
|
@@ -26,7 +26,7 @@ module RubyLokaliseApi
|
|
|
26
26
|
# Set Content-Type if required (skip for GET requests)
|
|
27
27
|
add_content_type_header(req_params, params, endpoint)
|
|
28
28
|
|
|
29
|
-
req_params[:headers][
|
|
29
|
+
req_params[:headers]['Accept-Encoding'] = 'gzip,deflate'
|
|
30
30
|
|
|
31
31
|
req_params
|
|
32
32
|
end
|
|
@@ -43,16 +43,16 @@ module RubyLokaliseApi
|
|
|
43
43
|
|
|
44
44
|
# Conditionally adds the Content-Type header
|
|
45
45
|
def add_content_type_header(req_params, params, endpoint)
|
|
46
|
-
return
|
|
46
|
+
return if params[:get_request] || endpoint.req_params.nil?
|
|
47
47
|
|
|
48
48
|
req_params[:headers]['Content-Type'] = 'application/json'
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def
|
|
51
|
+
def base_options(endpoint)
|
|
52
52
|
{
|
|
53
53
|
headers: {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
'Accept' => 'application/json',
|
|
55
|
+
'User-Agent' => "ruby-lokalise-api gem/#{RubyLokaliseApi::VERSION}"
|
|
56
56
|
},
|
|
57
57
|
url: endpoint.client.api_host || endpoint.base_url
|
|
58
58
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyLokaliseApi
|
|
4
|
+
module Endpoints
|
|
5
|
+
class TranslationMemoriesEndpoint < MainEndpoint
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def base_query(project_id, *_args)
|
|
9
|
+
{
|
|
10
|
+
projects: project_id,
|
|
11
|
+
'translation-memories': nil
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -60,6 +60,7 @@ module RubyLokaliseApi
|
|
|
60
60
|
423 => RubyLokaliseApi::Error::Locked,
|
|
61
61
|
429 => RubyLokaliseApi::Error::TooManyRequests,
|
|
62
62
|
500 => RubyLokaliseApi::Error::ServerError,
|
|
63
|
+
501 => RubyLokaliseApi::Error::NotImplemented,
|
|
63
64
|
502 => RubyLokaliseApi::Error::BadGateway,
|
|
64
65
|
503 => RubyLokaliseApi::Error::ServiceUnavailable,
|
|
65
66
|
504 => RubyLokaliseApi::Error::GatewayTimeout
|
|
@@ -68,7 +69,7 @@ module RubyLokaliseApi
|
|
|
68
69
|
class << self
|
|
69
70
|
# Create a new error from an HTTP response
|
|
70
71
|
def from_response(body)
|
|
71
|
-
msg = if body.respond_to?(:key)
|
|
72
|
+
msg = if body.respond_to?(:key?)
|
|
72
73
|
body.key?('error') ? body['error']['message'] : body['message']
|
|
73
74
|
else
|
|
74
75
|
body
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module RubyLokaliseApi
|
|
4
|
-
#
|
|
5
|
-
class
|
|
4
|
+
# Lightweight objects representing results of API operations
|
|
5
|
+
class OperationResults
|
|
6
6
|
include RubyLokaliseApi::Concerns::HashAccessible
|
|
7
7
|
|
|
8
8
|
DeletedResource = Class.new(self)
|
|
@@ -9,7 +9,7 @@ module RubyLokaliseApi
|
|
|
9
9
|
# Sends a GET request
|
|
10
10
|
def get(endpoint)
|
|
11
11
|
respond_with(
|
|
12
|
-
connection(endpoint, get_request: true).get(
|
|
12
|
+
connection(endpoint, get_request: true).get(normalize_path(endpoint.uri), endpoint.req_params),
|
|
13
13
|
endpoint
|
|
14
14
|
)
|
|
15
15
|
end
|
|
@@ -17,7 +17,7 @@ module RubyLokaliseApi
|
|
|
17
17
|
# Sends a POST request
|
|
18
18
|
def post(endpoint)
|
|
19
19
|
respond_with(
|
|
20
|
-
connection(endpoint).post(
|
|
20
|
+
connection(endpoint).post(normalize_path(endpoint.uri), request_body(endpoint)),
|
|
21
21
|
endpoint
|
|
22
22
|
)
|
|
23
23
|
end
|
|
@@ -25,7 +25,7 @@ module RubyLokaliseApi
|
|
|
25
25
|
# Sends a PUT request
|
|
26
26
|
def put(endpoint)
|
|
27
27
|
respond_with(
|
|
28
|
-
connection(endpoint).put(
|
|
28
|
+
connection(endpoint).put(normalize_path(endpoint.uri), request_body(endpoint)),
|
|
29
29
|
endpoint
|
|
30
30
|
)
|
|
31
31
|
end
|
|
@@ -33,8 +33,7 @@ module RubyLokaliseApi
|
|
|
33
33
|
# Sends a PATCH request
|
|
34
34
|
def patch(endpoint)
|
|
35
35
|
respond_with(
|
|
36
|
-
connection(endpoint).patch(
|
|
37
|
-
endpoint.req_params.nil? ? nil : custom_dump(endpoint.req_params)),
|
|
36
|
+
connection(endpoint).patch(normalize_path(endpoint.uri), request_body(endpoint)),
|
|
38
37
|
endpoint
|
|
39
38
|
)
|
|
40
39
|
end
|
|
@@ -42,8 +41,8 @@ module RubyLokaliseApi
|
|
|
42
41
|
# Sends a DELETE request
|
|
43
42
|
def delete(endpoint)
|
|
44
43
|
respond_with(
|
|
45
|
-
connection(endpoint).delete(
|
|
46
|
-
req.body =
|
|
44
|
+
connection(endpoint).delete(normalize_path(endpoint.uri)) do |req|
|
|
45
|
+
req.body = request_body(endpoint)
|
|
47
46
|
end,
|
|
48
47
|
endpoint
|
|
49
48
|
)
|
|
@@ -52,16 +51,26 @@ module RubyLokaliseApi
|
|
|
52
51
|
private
|
|
53
52
|
|
|
54
53
|
# Get rid of double slashes in the `path`, leading and trailing slash
|
|
55
|
-
def
|
|
54
|
+
def normalize_path(path)
|
|
56
55
|
path.delete_prefix('/').gsub(%r{//}, '/').gsub(%r{/+\z}, '')
|
|
57
56
|
end
|
|
58
57
|
|
|
58
|
+
def request_body(endpoint)
|
|
59
|
+
return if endpoint.req_params.nil?
|
|
60
|
+
|
|
61
|
+
custom_dump(endpoint.req_params)
|
|
62
|
+
end
|
|
63
|
+
|
|
59
64
|
def raise_on_error!(response, body)
|
|
60
|
-
return unless
|
|
65
|
+
return unless error_response?(response, body)
|
|
61
66
|
|
|
62
67
|
respond_with_error(response.status, body)
|
|
63
68
|
end
|
|
64
69
|
|
|
70
|
+
def error_response?(response, body)
|
|
71
|
+
!response.success? || (body.respond_to?(:key?) && body.key?('error'))
|
|
72
|
+
end
|
|
73
|
+
|
|
65
74
|
def respond_with(response, endpoint)
|
|
66
75
|
body = parse_response_body(response)
|
|
67
76
|
|
|
@@ -77,9 +86,9 @@ module RubyLokaliseApi
|
|
|
77
86
|
end
|
|
78
87
|
|
|
79
88
|
def respond_with_error(code, body)
|
|
80
|
-
|
|
89
|
+
error_class = RubyLokaliseApi::Error::ERRORS.fetch(code, RubyLokaliseApi::Error)
|
|
81
90
|
|
|
82
|
-
raise
|
|
91
|
+
raise error_class.from_response(body)
|
|
83
92
|
end
|
|
84
93
|
end
|
|
85
94
|
end
|
|
@@ -26,7 +26,7 @@ module RubyLokaliseApi
|
|
|
26
26
|
|
|
27
27
|
# Deletes the current resource
|
|
28
28
|
def destroy
|
|
29
|
-
RubyLokaliseApi::
|
|
29
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new(
|
|
30
30
|
reinit_endpoint.do_delete.content
|
|
31
31
|
)
|
|
32
32
|
end
|
|
@@ -40,7 +40,11 @@ module RubyLokaliseApi
|
|
|
40
40
|
# Delegates instance method calls to the client methods
|
|
41
41
|
def delegate_call(from, to = nil)
|
|
42
42
|
define_method(from) do |*args|
|
|
43
|
-
@self_endpoint.client.
|
|
43
|
+
@self_endpoint.client.public_send(
|
|
44
|
+
to || from,
|
|
45
|
+
*read_main_params,
|
|
46
|
+
*args
|
|
47
|
+
)
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
end
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module RubyLokaliseApi
|
|
4
|
-
#
|
|
4
|
+
# Wraps a Lokalise API response and its metadata
|
|
5
5
|
class Response
|
|
6
6
|
# Lokalise returns pagination info in special headers
|
|
7
|
-
PAGINATION_HEADERS = %w[
|
|
8
|
-
|
|
7
|
+
PAGINATION_HEADERS = %w[
|
|
8
|
+
x-pagination-total-count
|
|
9
|
+
x-pagination-page-count
|
|
10
|
+
x-pagination-limit
|
|
11
|
+
x-pagination-page
|
|
12
|
+
x-pagination-next-cursor
|
|
13
|
+
].freeze
|
|
9
14
|
|
|
10
15
|
attr_reader :content, :endpoint, :headers
|
|
11
16
|
|
|
@@ -64,7 +64,7 @@ module RubyLokaliseApi
|
|
|
64
64
|
# Deletes a branch
|
|
65
65
|
#
|
|
66
66
|
# @see https://developers.lokalise.com/reference/delete-a-branch
|
|
67
|
-
# @return [RubyLokaliseApi::
|
|
67
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
68
68
|
# @param project_id [String]
|
|
69
69
|
# @param branch_id [String, Integer]
|
|
70
70
|
def destroy_branch(project_id, branch_id)
|
|
@@ -72,13 +72,13 @@ module RubyLokaliseApi
|
|
|
72
72
|
|
|
73
73
|
data = endpoint(name: 'Branches', params: params).do_delete
|
|
74
74
|
|
|
75
|
-
RubyLokaliseApi::
|
|
75
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# Merges two branches
|
|
79
79
|
#
|
|
80
80
|
# @see https://developers.lokalise.com/reference/merge-a-branch
|
|
81
|
-
# @return [RubyLokaliseApi::
|
|
81
|
+
# @return [RubyLokaliseApi::OperationResults::MergedBranches]
|
|
82
82
|
# @param project_id [String]
|
|
83
83
|
# @param branch_id [String, Integer]
|
|
84
84
|
# @param req_params [Hash]
|
|
@@ -87,7 +87,7 @@ module RubyLokaliseApi
|
|
|
87
87
|
|
|
88
88
|
data = endpoint(name: 'Branches', params: params).do_post
|
|
89
89
|
|
|
90
|
-
RubyLokaliseApi::
|
|
90
|
+
RubyLokaliseApi::OperationResults::MergedBranches.new data.content
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -70,7 +70,7 @@ module RubyLokaliseApi
|
|
|
70
70
|
# Deletes a single key comment
|
|
71
71
|
#
|
|
72
72
|
# @see https://developers.lokalise.com/reference/delete-a-comment
|
|
73
|
-
# @return [RubyLokaliseApi::
|
|
73
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
74
74
|
# @param project_id [String]
|
|
75
75
|
# @param key_id [String, Integer]
|
|
76
76
|
# @param comment_id [String, Integer]
|
|
@@ -79,7 +79,7 @@ module RubyLokaliseApi
|
|
|
79
79
|
|
|
80
80
|
data = endpoint(name: 'KeyComments', params: params).do_delete
|
|
81
81
|
|
|
82
|
-
RubyLokaliseApi::
|
|
82
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -80,7 +80,7 @@ module RubyLokaliseApi
|
|
|
80
80
|
# Deletes a single contributor from the project
|
|
81
81
|
#
|
|
82
82
|
# @see https://developers.lokalise.com/reference/delete-a-contributor
|
|
83
|
-
# @return [RubyLokaliseApi::
|
|
83
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
84
84
|
# @param project_id [String]
|
|
85
85
|
# @param contributor_id [String, Integer]
|
|
86
86
|
def destroy_contributor(project_id, contributor_id)
|
|
@@ -88,7 +88,7 @@ module RubyLokaliseApi
|
|
|
88
88
|
|
|
89
89
|
data = endpoint(name: 'Contributors', params: params).do_delete
|
|
90
90
|
|
|
91
|
-
RubyLokaliseApi::
|
|
91
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
end
|
|
@@ -64,7 +64,7 @@ module RubyLokaliseApi
|
|
|
64
64
|
# Deletes a custom translation status
|
|
65
65
|
#
|
|
66
66
|
# @see https://developers.lokalise.com/reference/delete-a-status
|
|
67
|
-
# @return [RubyLokaliseApi::
|
|
67
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
68
68
|
# @param project_id [String]
|
|
69
69
|
# @param status_id [Integer, String]
|
|
70
70
|
def destroy_custom_translation_status(project_id, status_id)
|
|
@@ -72,20 +72,20 @@ module RubyLokaliseApi
|
|
|
72
72
|
|
|
73
73
|
data = endpoint(name: 'CustomTranslationStatuses', params: params).do_delete
|
|
74
74
|
|
|
75
|
-
RubyLokaliseApi::
|
|
75
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# Retrieves an array of available colors that can be assigned to custom translation statuses
|
|
79
79
|
#
|
|
80
80
|
# @see https://developers.lokalise.com/reference/retrieve-available-colors
|
|
81
|
-
# @return [RubyLokaliseApi::
|
|
81
|
+
# @return [RubyLokaliseApi::OperationResults::CustomStatusAvailableColors]
|
|
82
82
|
# @param project_id [String]
|
|
83
83
|
def custom_translation_status_colors(project_id)
|
|
84
84
|
params = { query: [project_id, :colors] }
|
|
85
85
|
|
|
86
86
|
data = endpoint(name: 'CustomTranslationStatuses', params: params).do_get
|
|
87
87
|
|
|
88
|
-
RubyLokaliseApi::
|
|
88
|
+
RubyLokaliseApi::OperationResults::CustomStatusAvailableColors.new data.content
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
@@ -39,7 +39,7 @@ module RubyLokaliseApi
|
|
|
39
39
|
# Downloads translation files from the project
|
|
40
40
|
#
|
|
41
41
|
# @see https://developers.lokalise.com/reference/download-files
|
|
42
|
-
# @return [RubyLokaliseApi::
|
|
42
|
+
# @return [RubyLokaliseApi::OperationResults::DownloadBundle]
|
|
43
43
|
# @param project_id [String]
|
|
44
44
|
# @param req_params [Hash]
|
|
45
45
|
def download_files(project_id, req_params)
|
|
@@ -47,7 +47,7 @@ module RubyLokaliseApi
|
|
|
47
47
|
|
|
48
48
|
data = endpoint(name: 'Files', params: params).do_post
|
|
49
49
|
|
|
50
|
-
RubyLokaliseApi::
|
|
50
|
+
RubyLokaliseApi::OperationResults::DownloadBundle.new data.content
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Downloads translation files from the project asynchronously
|
|
@@ -72,7 +72,7 @@ module RubyLokaliseApi
|
|
|
72
72
|
# Only the "Documents" projects are supported
|
|
73
73
|
#
|
|
74
74
|
# @see https://developers.lokalise.com/reference/delete-a-file
|
|
75
|
-
# @return [RubyLokaliseApi::
|
|
75
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
76
76
|
# @param project_id [String]
|
|
77
77
|
# @param file_id [String, Integer]
|
|
78
78
|
def destroy_file(project_id, file_id)
|
|
@@ -80,7 +80,7 @@ module RubyLokaliseApi
|
|
|
80
80
|
|
|
81
81
|
data = endpoint(name: 'Files', params: params).do_delete
|
|
82
82
|
|
|
83
|
-
RubyLokaliseApi::
|
|
83
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -67,7 +67,7 @@ module RubyLokaliseApi
|
|
|
67
67
|
# Deletes one or multiple glossary terms from the project
|
|
68
68
|
#
|
|
69
69
|
# @see https://developers.lokalise.com/reference/delete-glossary-terms
|
|
70
|
-
# @return [RubyLokaliseApi::
|
|
70
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
71
71
|
# @param project_id [String]
|
|
72
72
|
# @param term_ids [Array, String]
|
|
73
73
|
def destroy_glossary_terms(project_id, term_ids)
|
|
@@ -75,7 +75,7 @@ module RubyLokaliseApi
|
|
|
75
75
|
|
|
76
76
|
data = endpoint(name: 'GlossaryTerms', params: params).do_delete
|
|
77
77
|
|
|
78
|
-
RubyLokaliseApi::
|
|
78
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -83,7 +83,7 @@ module RubyLokaliseApi
|
|
|
83
83
|
# Deletes a single key from the project
|
|
84
84
|
#
|
|
85
85
|
# @see https://developers.lokalise.com/reference/delete-a-key
|
|
86
|
-
# @return [RubyLokaliseApi::
|
|
86
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
87
87
|
# @param project_id [String]
|
|
88
88
|
# @param key_id [String, Integer]
|
|
89
89
|
def destroy_key(project_id, key_id)
|
|
@@ -91,13 +91,13 @@ module RubyLokaliseApi
|
|
|
91
91
|
|
|
92
92
|
data = endpoint(name: 'Keys', params: params).do_delete
|
|
93
93
|
|
|
94
|
-
RubyLokaliseApi::
|
|
94
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
# Deletes multiple keys from the project
|
|
98
98
|
#
|
|
99
99
|
# @see https://developers.lokalise.com/reference/delete-multiple-keys
|
|
100
|
-
# @return [RubyLokaliseApi::
|
|
100
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
101
101
|
# @param project_id [String]
|
|
102
102
|
# @param key_ids [Array, String]
|
|
103
103
|
def destroy_keys(project_id, key_ids)
|
|
@@ -105,7 +105,7 @@ module RubyLokaliseApi
|
|
|
105
105
|
|
|
106
106
|
data = endpoint(name: 'Keys', params: params).do_delete
|
|
107
107
|
|
|
108
|
-
RubyLokaliseApi::
|
|
108
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
end
|
|
@@ -81,7 +81,7 @@ module RubyLokaliseApi
|
|
|
81
81
|
# Deletes a single language from the project
|
|
82
82
|
#
|
|
83
83
|
# @see https://developers.lokalise.com/reference/delete-a-language
|
|
84
|
-
# @return [RubyLokaliseApi::
|
|
84
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
85
85
|
# @param project_id [String]
|
|
86
86
|
# @param language_id [String, Integer]
|
|
87
87
|
def destroy_project_language(project_id, language_id)
|
|
@@ -89,7 +89,7 @@ module RubyLokaliseApi
|
|
|
89
89
|
|
|
90
90
|
data = endpoint(name: 'ProjectLanguages', params: params).do_delete
|
|
91
91
|
|
|
92
|
-
RubyLokaliseApi::
|
|
92
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|
|
@@ -46,14 +46,14 @@ module RubyLokaliseApi
|
|
|
46
46
|
# Deletes a payment card
|
|
47
47
|
#
|
|
48
48
|
# @see https://developers.lokalise.com/reference/delete-a-card
|
|
49
|
-
# @return [RubyLokaliseApi::
|
|
49
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
50
50
|
# @param card_id [String, Integer]
|
|
51
51
|
def destroy_payment_card(card_id)
|
|
52
52
|
params = { query: card_id }
|
|
53
53
|
|
|
54
54
|
data = endpoint(name: 'PaymentCards', params: params).do_delete
|
|
55
55
|
|
|
56
|
-
RubyLokaliseApi::
|
|
56
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -60,25 +60,25 @@ module RubyLokaliseApi
|
|
|
60
60
|
# Deletes a project
|
|
61
61
|
#
|
|
62
62
|
# @see https://developers.lokalise.com/reference/delete-a-project
|
|
63
|
-
# @return [RubyLokaliseApi::
|
|
63
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
64
64
|
# @param project_id [String]
|
|
65
65
|
def destroy_project(project_id)
|
|
66
66
|
params = { query: project_id }
|
|
67
67
|
|
|
68
68
|
data = endpoint(name: 'Projects', params: params).do_delete
|
|
69
69
|
|
|
70
|
-
RubyLokaliseApi::
|
|
70
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
# Empties a project by deleting all keys and translations
|
|
74
74
|
#
|
|
75
75
|
# @see https://developers.lokalise.com/reference/empty-a-project
|
|
76
|
-
# @return [RubyLokaliseApi::
|
|
76
|
+
# @return [RubyLokaliseApi::OperationResults::EmptiedResource]
|
|
77
77
|
# @param project_id [String]
|
|
78
78
|
def empty_project(project_id)
|
|
79
79
|
data = endpoint(name: 'Projects', params: { query: [project_id, :empty] }).do_put
|
|
80
80
|
|
|
81
|
-
RubyLokaliseApi::
|
|
81
|
+
RubyLokaliseApi::OperationResults::EmptiedResource.new data.content
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -68,7 +68,7 @@ module RubyLokaliseApi
|
|
|
68
68
|
# Deletes a screenshot
|
|
69
69
|
#
|
|
70
70
|
# @see https://developers.lokalise.com/reference/delete-a-screenshot
|
|
71
|
-
# @return [RubyLokaliseApi::
|
|
71
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
72
72
|
# @param project_id [String]
|
|
73
73
|
# @param screenshot_id [String, Integer]
|
|
74
74
|
def destroy_screenshot(project_id, screenshot_id)
|
|
@@ -76,7 +76,7 @@ module RubyLokaliseApi
|
|
|
76
76
|
|
|
77
77
|
data = endpoint(name: 'Screenshots', params: params).do_delete
|
|
78
78
|
|
|
79
|
-
RubyLokaliseApi::
|
|
79
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
end
|
|
@@ -52,7 +52,7 @@ module RubyLokaliseApi
|
|
|
52
52
|
# Deletes a snapshot
|
|
53
53
|
#
|
|
54
54
|
# @see https://developers.lokalise.com/reference/delete-a-snapshot
|
|
55
|
-
# @return [RubyLokaliseApi::
|
|
55
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
56
56
|
# @param project_id [String]
|
|
57
57
|
# @param snapshot_id [String, Integer]
|
|
58
58
|
def destroy_snapshot(project_id, snapshot_id)
|
|
@@ -60,7 +60,7 @@ module RubyLokaliseApi
|
|
|
60
60
|
|
|
61
61
|
data = endpoint(name: 'Snapshots', params: params).do_delete
|
|
62
62
|
|
|
63
|
-
RubyLokaliseApi::
|
|
63
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -65,7 +65,7 @@ module RubyLokaliseApi
|
|
|
65
65
|
# Deletes a task
|
|
66
66
|
#
|
|
67
67
|
# @see https://developers.lokalise.com/reference/delete-a-task
|
|
68
|
-
# @return [RubyLokaliseApi::
|
|
68
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
69
69
|
# @param project_id [String]
|
|
70
70
|
# @param task_id [String, Integer]
|
|
71
71
|
def destroy_task(project_id, task_id)
|
|
@@ -73,7 +73,7 @@ module RubyLokaliseApi
|
|
|
73
73
|
|
|
74
74
|
data = endpoint(name: 'Tasks', params: params).do_delete
|
|
75
75
|
|
|
76
|
-
RubyLokaliseApi::
|
|
76
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
@@ -66,7 +66,7 @@ module RubyLokaliseApi
|
|
|
66
66
|
# Deletes a team user group
|
|
67
67
|
#
|
|
68
68
|
# @see https://developers.lokalise.com/reference/delete-a-group
|
|
69
|
-
# @return [RubyLokaliseApi::
|
|
69
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
70
70
|
# @param team_id [String, Integer]
|
|
71
71
|
# @param group_id [String, Integer]
|
|
72
72
|
def destroy_team_user_group(team_id, group_id)
|
|
@@ -74,7 +74,7 @@ module RubyLokaliseApi
|
|
|
74
74
|
|
|
75
75
|
data = endpoint(name: 'TeamUserGroups', params: params).do_delete
|
|
76
76
|
|
|
77
|
-
RubyLokaliseApi::
|
|
77
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
# Adds projects to the group
|
|
@@ -50,7 +50,7 @@ module RubyLokaliseApi
|
|
|
50
50
|
# Deletes a team user
|
|
51
51
|
#
|
|
52
52
|
# @see https://developers.lokalise.com/reference/delete-a-team-user
|
|
53
|
-
# @return [RubyLokaliseApi::
|
|
53
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
54
54
|
# @param team_id [String, Integer]
|
|
55
55
|
# @param user_id [String, Integer]
|
|
56
56
|
def destroy_team_user(team_id, user_id)
|
|
@@ -58,7 +58,7 @@ module RubyLokaliseApi
|
|
|
58
58
|
|
|
59
59
|
data = endpoint(name: 'TeamUsers', params: params).do_delete
|
|
60
60
|
|
|
61
|
-
RubyLokaliseApi::
|
|
61
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyLokaliseApi
|
|
4
|
+
module Rest
|
|
5
|
+
module TranslationMemories
|
|
6
|
+
# Returns project translation memories
|
|
7
|
+
#
|
|
8
|
+
# @see https://developers.lokalise.com/reference/list-project-translation-memories
|
|
9
|
+
# @return [RubyLokaliseApi::Collections::TranslationMemories]
|
|
10
|
+
# @param project_id [String]
|
|
11
|
+
# @param req_params [Hash]
|
|
12
|
+
def translation_memories(project_id)
|
|
13
|
+
name = 'TranslationMemories'
|
|
14
|
+
params = { query: project_id }
|
|
15
|
+
puts endpoint(name: name, params: params).inspect
|
|
16
|
+
data = endpoint(name: name, params: params).do_get
|
|
17
|
+
|
|
18
|
+
collection name, data
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -64,7 +64,7 @@ module RubyLokaliseApi
|
|
|
64
64
|
# Regenerates webhook secret
|
|
65
65
|
#
|
|
66
66
|
# @see https://developers.lokalise.com/reference/regenerate-a-webhook-secret
|
|
67
|
-
# @return [RubyLokaliseApi::
|
|
67
|
+
# @return [RubyLokaliseApi::OperationResults::RegeneratedWebhookSecret]
|
|
68
68
|
# @param project_id [String]
|
|
69
69
|
# @param webhook_id [String]
|
|
70
70
|
def regenerate_webhook_secret(project_id, webhook_id)
|
|
@@ -72,13 +72,13 @@ module RubyLokaliseApi
|
|
|
72
72
|
|
|
73
73
|
data = endpoint(name: 'Webhooks', params: params).do_patch
|
|
74
74
|
|
|
75
|
-
RubyLokaliseApi::
|
|
75
|
+
RubyLokaliseApi::OperationResults::RegeneratedWebhookSecret.new data.content
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# Deletes a webhook
|
|
79
79
|
#
|
|
80
80
|
# @see https://developers.lokalise.com/reference/delete-a-webhook
|
|
81
|
-
# @return [RubyLokaliseApi::
|
|
81
|
+
# @return [RubyLokaliseApi::OperationResults::DeletedResource]
|
|
82
82
|
# @param project_id [String]
|
|
83
83
|
# @param webhook_id [String]
|
|
84
84
|
def destroy_webhook(project_id, webhook_id)
|
|
@@ -86,7 +86,7 @@ module RubyLokaliseApi
|
|
|
86
86
|
|
|
87
87
|
data = endpoint(name: 'Webhooks', params: params).do_delete
|
|
88
88
|
|
|
89
|
-
RubyLokaliseApi::
|
|
89
|
+
RubyLokaliseApi::OperationResults::DeletedResource.new data.content
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end
|
|
@@ -26,7 +26,7 @@ module RubyLokaliseApi
|
|
|
26
26
|
#
|
|
27
27
|
# @return [String]
|
|
28
28
|
def unify(name)
|
|
29
|
-
UNIFIED_RESOURCES.find { |
|
|
29
|
+
UNIFIED_RESOURCES.find { |resource| name.include?(resource) } || name
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# Loads attributes from a YAML file
|
|
@@ -34,7 +34,7 @@ module RubyLokaliseApi
|
|
|
34
34
|
# @param filename [String] The filename to load attributes from
|
|
35
35
|
# @return [Hash] The loaded attributes hash
|
|
36
36
|
def load_attributes(filename)
|
|
37
|
-
YAML.
|
|
37
|
+
YAML.safe_load_file(File.expand_path("../data/#{filename}", __dir__)).freeze
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module RubyLokaliseApi
|
|
4
|
-
# Basic
|
|
4
|
+
# Basic utility methods
|
|
5
5
|
module Utils
|
|
6
6
|
module Classes
|
|
7
|
-
refine
|
|
7
|
+
refine Module do
|
|
8
8
|
# Extracts the base name of a class, removing any module nesting.
|
|
9
9
|
#
|
|
10
10
|
# @return [String] The base class name
|
|
11
11
|
def base_name
|
|
12
12
|
name.split('::').last
|
|
13
13
|
end
|
|
14
|
+
end
|
|
14
15
|
|
|
16
|
+
refine Object do
|
|
15
17
|
# Converts the object to an array, unless it is already an array.
|
|
16
18
|
#
|
|
17
19
|
# @return [Array] The object wrapped in an array if not already an array
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-lokalise-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 10.1
|
|
4
|
+
version: 10.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ilya Krukowski
|
|
@@ -298,6 +298,7 @@ files:
|
|
|
298
298
|
- lib/ruby_lokalise_api/collections/team_user_groups.rb
|
|
299
299
|
- lib/ruby_lokalise_api/collections/team_users.rb
|
|
300
300
|
- lib/ruby_lokalise_api/collections/teams.rb
|
|
301
|
+
- lib/ruby_lokalise_api/collections/translation_memories.rb
|
|
301
302
|
- lib/ruby_lokalise_api/collections/translation_providers.rb
|
|
302
303
|
- lib/ruby_lokalise_api/collections/translations.rb
|
|
303
304
|
- lib/ruby_lokalise_api/collections/v1/audit_logs.rb
|
|
@@ -336,6 +337,7 @@ files:
|
|
|
336
337
|
- lib/ruby_lokalise_api/endpoints/team_user_groups_endpoint.rb
|
|
337
338
|
- lib/ruby_lokalise_api/endpoints/team_users_endpoint.rb
|
|
338
339
|
- lib/ruby_lokalise_api/endpoints/teams_endpoint.rb
|
|
340
|
+
- lib/ruby_lokalise_api/endpoints/translation_memories_endpoint.rb
|
|
339
341
|
- lib/ruby_lokalise_api/endpoints/translation_providers_endpoint.rb
|
|
340
342
|
- lib/ruby_lokalise_api/endpoints/translations_endpoint.rb
|
|
341
343
|
- lib/ruby_lokalise_api/endpoints/users_endpoint.rb
|
|
@@ -343,10 +345,10 @@ files:
|
|
|
343
345
|
- lib/ruby_lokalise_api/endpoints/v1/main_endpoint.rb
|
|
344
346
|
- lib/ruby_lokalise_api/endpoints/webhooks_endpoint.rb
|
|
345
347
|
- lib/ruby_lokalise_api/error.rb
|
|
346
|
-
- lib/ruby_lokalise_api/generics.rb
|
|
347
348
|
- lib/ruby_lokalise_api/json_handler.rb
|
|
348
349
|
- lib/ruby_lokalise_api/oauth2/auth.rb
|
|
349
350
|
- lib/ruby_lokalise_api/oauth2_client.rb
|
|
351
|
+
- lib/ruby_lokalise_api/operation_results.rb
|
|
350
352
|
- lib/ruby_lokalise_api/request.rb
|
|
351
353
|
- lib/ruby_lokalise_api/resources/base.rb
|
|
352
354
|
- lib/ruby_lokalise_api/resources/branch.rb
|
|
@@ -375,6 +377,7 @@ files:
|
|
|
375
377
|
- lib/ruby_lokalise_api/resources/team_user_billing_details.rb
|
|
376
378
|
- lib/ruby_lokalise_api/resources/team_user_group.rb
|
|
377
379
|
- lib/ruby_lokalise_api/resources/translation.rb
|
|
380
|
+
- lib/ruby_lokalise_api/resources/translation_memory.rb
|
|
378
381
|
- lib/ruby_lokalise_api/resources/translation_provider.rb
|
|
379
382
|
- lib/ruby_lokalise_api/resources/user.rb
|
|
380
383
|
- lib/ruby_lokalise_api/resources/v1/audit_log.rb
|
|
@@ -403,6 +406,7 @@ files:
|
|
|
403
406
|
- lib/ruby_lokalise_api/rest/team_user_groups.rb
|
|
404
407
|
- lib/ruby_lokalise_api/rest/team_users.rb
|
|
405
408
|
- lib/ruby_lokalise_api/rest/teams.rb
|
|
409
|
+
- lib/ruby_lokalise_api/rest/translation_memories.rb
|
|
406
410
|
- lib/ruby_lokalise_api/rest/translation_providers.rb
|
|
407
411
|
- lib/ruby_lokalise_api/rest/translations.rb
|
|
408
412
|
- lib/ruby_lokalise_api/rest/users.rb
|
|
@@ -439,7 +443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
439
443
|
- !ruby/object:Gem::Version
|
|
440
444
|
version: '0'
|
|
441
445
|
requirements: []
|
|
442
|
-
rubygems_version: 4.0.
|
|
446
|
+
rubygems_version: 4.0.22
|
|
443
447
|
specification_version: 4
|
|
444
448
|
summary: Ruby interface to the Lokalise API
|
|
445
449
|
test_files: []
|