toptranslation_api 2.5.1 → 4.0.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/lib/toptranslation/connection.rb +21 -43
- data/lib/toptranslation/resource/document.rb +0 -32
- data/lib/toptranslation/resource/document_list.rb +0 -5
- data/lib/toptranslation/resource/project.rb +3 -5
- data/lib/toptranslation/resource/project_document_list.rb +6 -0
- data/lib/toptranslation/resource/translation_list.rb +1 -1
- data/lib/toptranslation/resource/upload.rb +2 -1
- data/lib/toptranslation/version.rb +1 -1
- data/lib/toptranslation_api.rb +1 -3
- metadata +17 -32
- data/lib/toptranslation/resource/string.rb +0 -64
- data/lib/toptranslation/resource/string_list.rb +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 700cce0881675c0dafc87f6b0164c4de80495fc146ff9487584c1c2d7d1abf02
|
|
4
|
+
data.tar.gz: 23384b7748432e0d96ac60f45dba8e6e1c0219fe6c0ed53fdd70c54b7a2e3388
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 770ef06cea32101858e51b52c0ac6322315174ed484f01ee16809d44242a4d639d12bb18861cb9fbc4ffb0959605095a310ef0255749f595ec8361ea0409617a
|
|
7
|
+
data.tar.gz: 710217d985fd2fd1094de9f4d3152cdb8452599b9b414303ad063c326ce6d1b818ef2fa1875a586d23e0c89e658574f35a5463edbea9f584a8c14ed33296e3ec
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module Toptranslation
|
|
2
|
-
class Connection
|
|
3
|
-
attr_accessor :
|
|
2
|
+
class Connection
|
|
3
|
+
attr_accessor :verbose, :access_token
|
|
4
|
+
|
|
5
|
+
API_VERSION = 'v2'.freeze
|
|
4
6
|
|
|
5
7
|
def initialize(options = {})
|
|
6
8
|
@base_url = options[:base_url] || 'https://api.toptranslation.com'
|
|
@@ -11,15 +13,15 @@ module Toptranslation
|
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def get(path, options = {})
|
|
14
|
-
transform_response(request(:get, path, options)
|
|
16
|
+
transform_response(request(:get, path, options))
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def post(path, options = {})
|
|
18
|
-
transform_response(request(:post, path, options)
|
|
20
|
+
transform_response(request(:post, path, options))
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def patch(path, options = {})
|
|
22
|
-
transform_response(request(:patch, path, options)
|
|
24
|
+
transform_response(request(:patch, path, options))
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def download(url, path, &block)
|
|
@@ -28,10 +30,12 @@ module Toptranslation
|
|
|
28
30
|
download_uri(uri, path, &block)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
# Uploads go directly to the document store (castor): the response
|
|
34
|
+
# carries the document token that authorizes further use of the file.
|
|
35
|
+
def upload(filepath, _type = 'document', &block)
|
|
36
|
+
uri = URI.parse("#{@files_url}/v2/documents")
|
|
33
37
|
file = File.new(filepath)
|
|
34
|
-
upload_file(file,
|
|
38
|
+
upload_file(file, uri, &block)
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
def sign_in!(options)
|
|
@@ -43,7 +47,7 @@ module Toptranslation
|
|
|
43
47
|
application_id: 'pollux'
|
|
44
48
|
}.merge(options)
|
|
45
49
|
|
|
46
|
-
@access_token = post('/auth/sign_in', sign_in_options
|
|
50
|
+
@access_token = post('/auth/sign_in', sign_in_options)['access_token']
|
|
47
51
|
|
|
48
52
|
puts "# Requested access token #{@access_token}" if @verbose
|
|
49
53
|
|
|
@@ -52,12 +56,8 @@ module Toptranslation
|
|
|
52
56
|
|
|
53
57
|
private
|
|
54
58
|
|
|
55
|
-
def version(options)
|
|
56
|
-
options[:version] || 0
|
|
57
|
-
end
|
|
58
|
-
|
|
59
59
|
def request(method, path, options)
|
|
60
|
-
url = "#{@base_url}
|
|
60
|
+
url = "#{@base_url}/#{API_VERSION}#{path}"
|
|
61
61
|
puts "# #{method}-request #{url}" if @verbose
|
|
62
62
|
puts "options: #{prepare_request_options(options, method)}" if @verbose
|
|
63
63
|
RestClient.send(method, url, prepare_request_options(options, method))
|
|
@@ -66,30 +66,13 @@ module Toptranslation
|
|
|
66
66
|
raise e
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def
|
|
70
|
-
@upload_token ||= request_upload_token
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def request_upload_token
|
|
74
|
-
puts '# Requesting upload-token' if @verbose
|
|
75
|
-
token = post('/upload_tokens')['upload_token']
|
|
76
|
-
puts "# Upload-token retrieved: #{token}" if @verbose
|
|
77
|
-
token
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def transform_response(response, options)
|
|
69
|
+
def transform_response(response)
|
|
81
70
|
puts response if @verbose
|
|
82
|
-
|
|
83
|
-
if version(options) == 2
|
|
84
|
-
parsed
|
|
85
|
-
else
|
|
86
|
-
parsed['data']
|
|
87
|
-
end
|
|
71
|
+
JSON.parse(response)
|
|
88
72
|
end
|
|
89
73
|
|
|
90
74
|
def prepare_request_options(options, method)
|
|
91
75
|
request_options = options.dup
|
|
92
|
-
request_options.delete(:version)
|
|
93
76
|
if [:post, :patch].include? method
|
|
94
77
|
request_options.merge(auth_params)
|
|
95
78
|
else
|
|
@@ -139,22 +122,17 @@ module Toptranslation
|
|
|
139
122
|
end
|
|
140
123
|
end
|
|
141
124
|
|
|
142
|
-
def upload_file(file,
|
|
143
|
-
last_upload_size = 0
|
|
144
|
-
|
|
125
|
+
def upload_file(file, uri)
|
|
145
126
|
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
146
127
|
request = Net::HTTP::Post.new(uri)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
yield progress.upload_size - last_upload_size if block_given?
|
|
151
|
-
last_upload_size = progress.upload_size
|
|
152
|
-
end
|
|
128
|
+
# stable per upload (not per attempt): the document store recognizes
|
|
129
|
+
# retries and returns the already created document instead of a duplicate
|
|
130
|
+
request.set_form({ 'file' => file, 'idempotency_key' => SecureRandom.uuid }, 'multipart/form-data')
|
|
153
131
|
|
|
154
132
|
http.request(request)
|
|
155
133
|
end
|
|
156
134
|
|
|
157
|
-
transform_response(response.body
|
|
135
|
+
transform_response(response.body)
|
|
158
136
|
end
|
|
159
137
|
end
|
|
160
138
|
end
|
|
@@ -8,17 +8,6 @@ module Toptranslation::Resource
|
|
|
8
8
|
update_from_response(options)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def add_translation(filepath, locale_code, options = {})
|
|
12
|
-
upload = Upload.new(@connection).upload(filepath)
|
|
13
|
-
|
|
14
|
-
response = @connection.post("/documents/#{@identifier}/translations", options.merge(
|
|
15
|
-
document_store_id: upload.document_store_id,
|
|
16
|
-
document_token: upload.document_token,
|
|
17
|
-
locale_code: locale_code,
|
|
18
|
-
sha1: upload.sha1
|
|
19
|
-
))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
11
|
def download_url(locale_code, options = {})
|
|
23
12
|
params = { file_format: options[:file_format], locale_code: locale_code }.compact
|
|
24
13
|
@connection.get("/documents/#{@identifier}/download", params: params)['download_url']
|
|
@@ -36,24 +25,8 @@ module Toptranslation::Resource
|
|
|
36
25
|
@connection.download(download_url(locale_code, options), download_path, &block)
|
|
37
26
|
end
|
|
38
27
|
|
|
39
|
-
def save
|
|
40
|
-
response = @connection.patch("/documents/#{@identifier}", remote_hash)
|
|
41
|
-
update_and_return_from_response(response)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def strings
|
|
45
|
-
StringList.new(@connection, document_identifier: @identifier)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
28
|
private
|
|
49
29
|
|
|
50
|
-
def update_and_return_from_response(response)
|
|
51
|
-
if response
|
|
52
|
-
update_from_response(response)
|
|
53
|
-
self
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
30
|
def update_from_response(response)
|
|
58
31
|
@identifier = response['identifier'] if response['identifier']
|
|
59
32
|
@name = response['name'] if response['name']
|
|
@@ -70,10 +43,5 @@ module Toptranslation::Resource
|
|
|
70
43
|
end
|
|
71
44
|
end
|
|
72
45
|
|
|
73
|
-
def remote_hash
|
|
74
|
-
hash = {}
|
|
75
|
-
hash[:name] = @name if @name
|
|
76
|
-
hash
|
|
77
|
-
end
|
|
78
46
|
end
|
|
79
47
|
end
|
|
@@ -7,11 +7,6 @@ module Toptranslation::Resource
|
|
|
7
7
|
@options = options
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def find(identifier)
|
|
11
|
-
result = @connection.get("/documents/#{identifier}")
|
|
12
|
-
Document.new(@connection, result)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
10
|
def each
|
|
16
11
|
documents.each { |document| yield Document.new(@connection, document) }
|
|
17
12
|
end
|
|
@@ -33,10 +33,6 @@ module Toptranslation::Resource
|
|
|
33
33
|
ProjectDocumentList.new(@connection, options)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def strings
|
|
37
|
-
StringList.new(@connection, project_identifier: @identifier)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
36
|
def save
|
|
41
37
|
response = @identifier ? update_remote_project : create_remote_project
|
|
42
38
|
update_and_return_from_response(response)
|
|
@@ -62,11 +58,13 @@ module Toptranslation::Resource
|
|
|
62
58
|
def update_from_response(response)
|
|
63
59
|
@identifier = response['identifier'] if response['identifier']
|
|
64
60
|
@created_at = DateTime.parse(response['created_at']) if response['created_at']
|
|
65
|
-
@locales = response['locales'].inject([]) do |accu, locale_data|
|
|
61
|
+
@locales = Array(response['locales']).inject([]) do |accu, locale_data|
|
|
66
62
|
locale = Locale.new(locale_data)
|
|
67
63
|
@source_locale = locale if locale_data['is_source_locale'] # Set source locale of the project
|
|
68
64
|
accu << locale
|
|
69
65
|
end
|
|
66
|
+
# API v2 liefert die Ausgangssprache zusätzlich als eigenes Feld
|
|
67
|
+
@source_locale = Locale.new(response['source_locale']) if response['source_locale']
|
|
70
68
|
@name = response['name'] if response['name']
|
|
71
69
|
end
|
|
72
70
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
module Toptranslation::Resource
|
|
2
2
|
class ProjectDocumentList < DocumentList
|
|
3
|
+
# projektbezogener Lookup — API v2 kennt kein unscoped GET /documents/:id
|
|
4
|
+
def find(identifier)
|
|
5
|
+
result = @connection.get("/projects/#{@options[:project_identifier]}/documents/#{identifier}")
|
|
6
|
+
Document.new(@connection, result)
|
|
7
|
+
end
|
|
8
|
+
|
|
3
9
|
def create(name, path, options = {})
|
|
4
10
|
response = @connection.post("/projects/#{@options[:project_identifier]}/documents", options.merge(name: name, path: path))
|
|
5
11
|
Document.new(@connection, response)
|
|
@@ -19,7 +19,7 @@ module Toptranslation::Resource
|
|
|
19
19
|
private
|
|
20
20
|
|
|
21
21
|
def translations
|
|
22
|
-
@connection.get(
|
|
22
|
+
@connection.get('/translations', params: { order_identifier: @options[:order_identifier] }) if @options[:order_identifier]
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -12,7 +12,8 @@ module Toptranslation::Resource
|
|
|
12
12
|
response = @connection.upload(filepath, type, &block)
|
|
13
13
|
|
|
14
14
|
@document_store_id = response['identifier']
|
|
15
|
-
|
|
15
|
+
# Document-Store v2 nennt das Feld token
|
|
16
|
+
@document_token = response['token'] || response['document_token']
|
|
16
17
|
@sha1 = response['sha1']
|
|
17
18
|
|
|
18
19
|
self
|
data/lib/toptranslation_api.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'json'
|
|
2
|
+
require 'securerandom'
|
|
2
3
|
require 'rest-client'
|
|
3
|
-
require 'net/http/uploadprogress'
|
|
4
4
|
require 'toptranslation/client'
|
|
5
5
|
require 'toptranslation/connection'
|
|
6
6
|
require 'toptranslation/resource/document'
|
|
@@ -14,8 +14,6 @@ require 'toptranslation/resource/project'
|
|
|
14
14
|
require 'toptranslation/resource/project_list'
|
|
15
15
|
require 'toptranslation/resource/quote'
|
|
16
16
|
require 'toptranslation/resource/reference_document'
|
|
17
|
-
require 'toptranslation/resource/string_list'
|
|
18
|
-
require 'toptranslation/resource/string'
|
|
19
17
|
require 'toptranslation/resource/translation'
|
|
20
18
|
require 'toptranslation/resource/translation_list'
|
|
21
19
|
require 'toptranslation/resource/upload'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: toptranslation_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Toptranslation GmbH
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-08-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -24,20 +24,6 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '2.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: net-http-uploadprogress
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2.0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2.0'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: rest-client
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -98,30 +84,30 @@ dependencies:
|
|
|
98
84
|
name: rubocop
|
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
|
100
86
|
requirements:
|
|
101
|
-
- - "
|
|
87
|
+
- - ">="
|
|
102
88
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 0
|
|
89
|
+
version: '0'
|
|
104
90
|
type: :development
|
|
105
91
|
prerelease: false
|
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
93
|
requirements:
|
|
108
|
-
- - "
|
|
94
|
+
- - ">="
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 0
|
|
96
|
+
version: '0'
|
|
111
97
|
- !ruby/object:Gem::Dependency
|
|
112
98
|
name: rubocop-rspec
|
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
|
114
100
|
requirements:
|
|
115
|
-
- - "
|
|
101
|
+
- - ">="
|
|
116
102
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
103
|
+
version: '0'
|
|
118
104
|
type: :development
|
|
119
105
|
prerelease: false
|
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
107
|
requirements:
|
|
122
|
-
- - "
|
|
108
|
+
- - ">="
|
|
123
109
|
- !ruby/object:Gem::Version
|
|
124
|
-
version:
|
|
110
|
+
version: '0'
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
112
|
name: vcr
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -170,8 +156,6 @@ files:
|
|
|
170
156
|
- lib/toptranslation/resource/project_list.rb
|
|
171
157
|
- lib/toptranslation/resource/quote.rb
|
|
172
158
|
- lib/toptranslation/resource/reference_document.rb
|
|
173
|
-
- lib/toptranslation/resource/string.rb
|
|
174
|
-
- lib/toptranslation/resource/string_list.rb
|
|
175
159
|
- lib/toptranslation/resource/translation.rb
|
|
176
160
|
- lib/toptranslation/resource/translation_list.rb
|
|
177
161
|
- lib/toptranslation/resource/upload.rb
|
|
@@ -181,8 +165,9 @@ files:
|
|
|
181
165
|
homepage: https://github.com/toptranslation/toptranslation_ruby
|
|
182
166
|
licenses:
|
|
183
167
|
- MIT
|
|
184
|
-
metadata:
|
|
185
|
-
|
|
168
|
+
metadata:
|
|
169
|
+
rubygems_mfa_required: 'true'
|
|
170
|
+
post_install_message:
|
|
186
171
|
rdoc_options: []
|
|
187
172
|
require_paths:
|
|
188
173
|
- lib
|
|
@@ -190,15 +175,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
190
175
|
requirements:
|
|
191
176
|
- - ">="
|
|
192
177
|
- !ruby/object:Gem::Version
|
|
193
|
-
version:
|
|
178
|
+
version: 3.0.0
|
|
194
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
180
|
requirements:
|
|
196
181
|
- - ">="
|
|
197
182
|
- !ruby/object:Gem::Version
|
|
198
183
|
version: '0'
|
|
199
184
|
requirements: []
|
|
200
|
-
rubygems_version: 3.
|
|
201
|
-
signing_key:
|
|
185
|
+
rubygems_version: 3.5.9
|
|
186
|
+
signing_key:
|
|
202
187
|
specification_version: 4
|
|
203
188
|
summary: A ruby client for the Toptranslation API
|
|
204
189
|
test_files: []
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
module Toptranslation::Resource
|
|
2
|
-
class String
|
|
3
|
-
attr_reader :identifier, :updated_at, :created_at
|
|
4
|
-
attr_accessor :value, :state, :project_identifier, :document_identifier, :key, :comment, :context, :array_index, :plural_form, :locale_code
|
|
5
|
-
|
|
6
|
-
def initialize(connection, options = {})
|
|
7
|
-
@connection = connection
|
|
8
|
-
@options = options
|
|
9
|
-
|
|
10
|
-
update_from_response(options)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def save
|
|
14
|
-
response = @identifier ? update_remote_string : create_remote_string
|
|
15
|
-
update_and_return_from_response(response)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def update_remote_string
|
|
21
|
-
@connection.patch("/strings/#{@identifier}", remote_hash)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def create_remote_string
|
|
25
|
-
@connection.post('/strings', remote_hash)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def update_and_return_from_response(response)
|
|
29
|
-
if response
|
|
30
|
-
update_from_response(response)
|
|
31
|
-
self
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def update_from_response(response)
|
|
36
|
-
@identifier = response['identifier'] if response['identifier']
|
|
37
|
-
@key = response['key'] if response['key']
|
|
38
|
-
@value = response['value'] if response['value']
|
|
39
|
-
@state = response['state'] if response['state']
|
|
40
|
-
@comment = response['comment'] if response['comment']
|
|
41
|
-
@context = response['context'] if response['context']
|
|
42
|
-
@array_index = response['array_index'] if response['array_index']
|
|
43
|
-
@plural_form = response['plural_form'] if response['plural_form']
|
|
44
|
-
@locale_code = response['locale_code'] if response['locale_code']
|
|
45
|
-
@project_identifier = response['project_identifier'] if response['project_identifier']
|
|
46
|
-
@document_identifier = response['document_identifier'] if response['document_identifier']
|
|
47
|
-
@updated_at = DateTime.parse(response['updated_at']) if response['updated_at']
|
|
48
|
-
@created_at = DateTime.parse(response['created_at']) if response['created_at']
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def remote_hash
|
|
52
|
-
hash = {}
|
|
53
|
-
hash[:key] = @key if @key
|
|
54
|
-
hash[:value] = @value if @value
|
|
55
|
-
hash[:state] = @state if @state
|
|
56
|
-
hash[:comment] = @comment if @comment
|
|
57
|
-
hash[:locale_code] = @locale_code if @locale_code
|
|
58
|
-
hash[:plural_form] = @plural_form if @plural_form
|
|
59
|
-
hash[:project_identifier] = @project_identifier if @project_identifier
|
|
60
|
-
hash[:document_identifier] = @document_identifier if @document_identifier
|
|
61
|
-
hash
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Toptranslation::Resource
|
|
2
|
-
class StringList
|
|
3
|
-
include Enumerable
|
|
4
|
-
|
|
5
|
-
def initialize(connection, options = {})
|
|
6
|
-
@connection = connection
|
|
7
|
-
@options = options
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def find(identifier)
|
|
11
|
-
result = @connection.get("/strings/#{identifier}")
|
|
12
|
-
Document.new(@connection, result)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def each
|
|
16
|
-
strings.each { |string| yield String.new(@connection, string) }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def create(options = {})
|
|
20
|
-
project_identifier = options['project_identifier'] || @options[:project_identifier]
|
|
21
|
-
document_identifier = options['document_identifier'] || @options[:document_identifier]
|
|
22
|
-
|
|
23
|
-
String.new(@connection, options.merge('project_identifier' => project_identifier, 'document_identifier' => document_identifier))
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def strings
|
|
29
|
-
@connection.get('/strings', params: { project_identifier: @options[:project_identifier], document_identifier: @options[:document_identifier] })
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|