smartling_api 0.2.0 → 0.4.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.buildkite/pipeline.yaml +6 -0
- data/.github/CODEOWNERS +1 -0
- data/.gitignore +1 -1
- data/.ruby-version +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +75 -0
- data/README.md +36 -98
- data/doc/api.md +102 -0
- data/lib/smartling_api/clients/smartling.rb +8 -4
- data/lib/smartling_api/errors/raise_error.rb +1 -2
- data/lib/smartling_api/file.rb +28 -4
- data/lib/smartling_api/version.rb +1 -1
- data/smartling_api.gemspec +17 -17
- metadata +25 -92
- data/bin/console +0 -14
- data/bin/setup +0 -8
- /data/{redbubble.png → doc/redbubble.png} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e4adb93edca4bbdeaca56ecdf6d8e2a5cb53596f7df8b9e47c0da196ba75917
|
4
|
+
data.tar.gz: e1ccc0348b8699432d67bcc5a04a7b21797eeaf079023576ef0a8a331c7d8ee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 777aa405239ebc273d161a5a2385c0162c3a7c06fc6b842e85654a09efed64736755ab8b7435b6781a23181218842825a312c7fc0e7304cf85c2a84360380080
|
7
|
+
data.tar.gz: 00f0ab77725201897c61e9102f1eab88e240aed172e783793edaa56af36b81bf891bc2064fe4163482b415dad454baf60926afa80e56841309b71d9331a229fb
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @redbubble/core
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/Gemfile
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in smartling_api.gemspec
|
4
6
|
gemspec
|
7
|
+
|
8
|
+
# Dev dependencies:
|
9
|
+
group :development do
|
10
|
+
gem "bundler", "~> 2.4"
|
11
|
+
gem "pry", "~> 0.14.2"
|
12
|
+
gem "rake", "~> 13.1"
|
13
|
+
gem "rspec", "~> 3.12"
|
14
|
+
gem "simplecov", require: false
|
15
|
+
gem "webmock", "~> 3.19"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
smartling_api (0.4.0.pre.1)
|
5
|
+
faraday (~> 2.7)
|
6
|
+
faraday-multipart (~> 1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.8.5)
|
12
|
+
public_suffix (>= 2.0.2, < 6.0)
|
13
|
+
base64 (0.2.0)
|
14
|
+
coderay (1.1.3)
|
15
|
+
crack (0.4.5)
|
16
|
+
rexml
|
17
|
+
diff-lcs (1.5.0)
|
18
|
+
docile (1.4.0)
|
19
|
+
faraday (2.7.12)
|
20
|
+
base64
|
21
|
+
faraday-net_http (>= 2.0, < 3.1)
|
22
|
+
ruby2_keywords (>= 0.0.4)
|
23
|
+
faraday-multipart (1.0.4)
|
24
|
+
multipart-post (~> 2)
|
25
|
+
faraday-net_http (3.0.2)
|
26
|
+
hashdiff (1.0.1)
|
27
|
+
method_source (1.0.0)
|
28
|
+
multipart-post (2.3.0)
|
29
|
+
pry (0.14.2)
|
30
|
+
coderay (~> 1.1)
|
31
|
+
method_source (~> 1.0)
|
32
|
+
public_suffix (5.0.4)
|
33
|
+
rake (13.1.0)
|
34
|
+
rexml (3.2.6)
|
35
|
+
rspec (3.12.0)
|
36
|
+
rspec-core (~> 3.12.0)
|
37
|
+
rspec-expectations (~> 3.12.0)
|
38
|
+
rspec-mocks (~> 3.12.0)
|
39
|
+
rspec-core (3.12.2)
|
40
|
+
rspec-support (~> 3.12.0)
|
41
|
+
rspec-expectations (3.12.3)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.12.0)
|
44
|
+
rspec-mocks (3.12.6)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.12.0)
|
47
|
+
rspec-support (3.12.1)
|
48
|
+
ruby2_keywords (0.0.5)
|
49
|
+
simplecov (0.22.0)
|
50
|
+
docile (~> 1.1)
|
51
|
+
simplecov-html (~> 0.11)
|
52
|
+
simplecov_json_formatter (~> 0.1)
|
53
|
+
simplecov-html (0.12.3)
|
54
|
+
simplecov_json_formatter (0.1.4)
|
55
|
+
webmock (3.19.1)
|
56
|
+
addressable (>= 2.8.0)
|
57
|
+
crack (>= 0.3.2)
|
58
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
aarch64-linux
|
62
|
+
arm64-darwin-22
|
63
|
+
x86_64-linux
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
bundler (~> 2.4)
|
67
|
+
pry (~> 0.14.2)
|
68
|
+
rake (~> 13.1)
|
69
|
+
rspec (~> 3.12)
|
70
|
+
simplecov
|
71
|
+
smartling_api!
|
72
|
+
webmock (~> 3.19)
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
2.4.10
|
data/README.md
CHANGED
@@ -1,28 +1,44 @@
|
|
1
|
-
|
1
|
+
Smartling Api
|
2
|
+
=============
|
2
3
|
|
3
|
-
|
4
|
+
[![Code Climate](https://codeclimate.com/github/redbubble/smartling_api/badges/gpa.svg)](https://codeclimate.com/github/redbubble/smartling_api)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/smartling_api.svg)](https://badge.fury.io/rb/smartling_api)
|
6
|
+
![Docs](https://inch-ci.org/github/redbubble/smartling_api.svg?branch=master)
|
7
|
+
|
8
|
+
Overview
|
9
|
+
--------
|
4
10
|
|
5
11
|
Ruby wrapper for accessing the Smartling Translation API V2.
|
6
12
|
|
7
|
-
The Smartling Translation API lets developers
|
13
|
+
The Smartling Translation API lets developers internationalize their website or app by automating the translation and integration of their site content. Developers can upload resource files and download the translated files in a language of their choosing. There are options to allow for professional translation, community translation and machine translation.
|
8
14
|
|
9
15
|
[Smartling API V2](http://docs.smartling.com/pages/API/v2/)
|
10
16
|
|
11
|
-
|
17
|
+
|
18
|
+
Installation
|
19
|
+
------------
|
20
|
+
|
21
|
+
### Requirements
|
12
22
|
|
13
23
|
- ruby 2.0+
|
14
24
|
|
15
|
-
|
25
|
+
### Setup
|
16
26
|
|
17
27
|
Add this line to your application's Gemfile:
|
18
28
|
|
19
|
-
gem 'smartling_api', '0.
|
29
|
+
gem 'smartling_api', '~> 0.4.0'
|
30
|
+
|
31
|
+
### Run Tests
|
20
32
|
|
21
|
-
|
33
|
+
bundle exec rspec
|
22
34
|
|
23
|
-
### Configure
|
24
35
|
|
25
|
-
|
36
|
+
Usage
|
37
|
+
-----
|
38
|
+
|
39
|
+
### Config
|
40
|
+
|
41
|
+
You will need to configure smartling user id and secret. In Rails you would put it in an initializer file. eg. `<project_home>/config/smartling_api.rb`
|
26
42
|
|
27
43
|
SmartlingApi.configure do |config|
|
28
44
|
config.id = <id>
|
@@ -34,92 +50,11 @@ You can obtain an id, secret via [Create Authentication Tokens](http://docs.smar
|
|
34
50
|
|
35
51
|
The `project_id` is optional. If you are only using a single `project_id` per application then you may add your `project_id` here. If not you will have to pass the `project_id` when you create your api call. Examples below.
|
36
52
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
### Retrieve Access Token
|
41
|
-
|
42
|
-
- [Authenticate API](http://docs.smartling.com/pages/API/v2/Authentication/Authenticate). Retrieve OAuth2 access token to be used with each api call.
|
43
|
-
|
44
|
-
|
45
|
-
> SmartlingApi::Authentication.new.access_token
|
46
|
-
=> "Token"
|
47
|
-
|
48
|
-
The Authentication API will throw `SmartlingApi::Errors::Credentials` if the Smartling id and/or secret has not been set.
|
49
|
-
|
50
|
-
## Project Api
|
51
|
-
|
52
|
-
Create a Project Api via,
|
53
|
-
|
54
|
-
@param `token`: Optional ( Will default to using authentication api to retrieve access token )
|
55
|
-
|
56
|
-
@param `project_id`: Optional ( Will default to using configured project_id )
|
57
|
-
|
58
|
-
> SmartlingApi::Project.new
|
59
|
-
or
|
60
|
-
> SmartlingApi::Project.new(token: 'token', project_id: 'project_id')
|
61
|
-
|
62
|
-
|
63
|
-
- [List Locales API](http://docs.smartling.com/pages/API/v2/Projects/List-Projects/). Retrieve a list of all locales available.
|
64
|
-
|
65
|
-
> SmartlingApi::Project.new.list_locales
|
66
|
-
=> { "locales" => [{ "localeId" => "de-DE", "description" => "German (Germany)" }, ...] }
|
67
|
-
|
68
|
-
|
69
|
-
## File Api
|
70
|
-
Create a Project Api via,
|
71
|
-
|
72
|
-
@param `token`: Optional ( Will default to using authentication api to retrieve access token )
|
73
|
-
|
74
|
-
@param `project_id`: Optional ( Will default to using configured project_id )
|
75
|
-
|
76
|
-
> SmartlingApi::File.new
|
77
|
-
or
|
78
|
-
> SmartlingApi::File.new(token: 'token', project_id: 'project_id')
|
79
|
-
|
80
|
-
|
81
|
-
- [Delete File API](http://docs.smartling.com/pages/API/v2/FileAPI/Delete/). Delete a file within Smartling.
|
82
|
-
|
83
|
-
@param `file_uri`: File path within Smartling to delete
|
84
|
-
|
85
|
-
> SmartlingApi::File.new.delete(file_uri: '/translations/website')
|
86
|
-
=> { "code" => "SUCCESS" }
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
- [Download Locale File API](http://docs.smartling.com/pages/API/v2/FileAPI/Download-File/Single-Locale/). Returns the content of a file for the given locale and path.
|
91
|
-
|
92
|
-
@param `file_uri`: File path within Smartling to download
|
93
|
-
|
94
|
-
@param `locale_id`: Locale Id of file to download
|
95
|
-
|
96
|
-
> SmartlingApi::File.new.download_locale(locale_id: 'fr-Fr', file_uri: '/translation/website')
|
97
|
-
=> "translations"
|
98
|
-
|
99
|
-
|
100
|
-
- [List File API](http://docs.smartling.com/pages/API/v2/FileAPI/List/). Retrieve list of files for a given project.
|
101
|
-
|
102
|
-
@param `**options`: Additional options for the given request. NOTE: If using a hash as parameters ensure all keys are symbols and then use `**options`. See Smartling API Doc for options.
|
103
|
-
|
104
|
-
> SmartlingApi::File.new.list_files(uriMask: '.json')
|
105
|
-
=> [{"fileUri" => "[/translate/file.json]", ...}]
|
106
|
-
|
107
|
-
|
108
|
-
- [Upload File API](http://docs.smartling.com/pages/API/v2/FileAPI/Upload-File/). Upload a file to the given path.
|
109
|
-
|
110
|
-
@param `file_path`: Location of file to upload
|
111
|
-
|
112
|
-
@param `file_uri`: File path within smartling
|
113
|
-
|
114
|
-
@param `file_type`: Type of file to upload. See Smartling API DOC for types.
|
115
|
-
|
116
|
-
@param `**options`: Additional options for the given request. NOTE: If using a hash as parameters ensure all keys are symbols and then use `**options`. See Smartling API Doc for options.
|
53
|
+
### API Reference
|
117
54
|
|
118
|
-
|
119
|
-
=> { "code" => "SUCCESS" }
|
120
|
-
|
55
|
+
Reference documentation on accessing the smartling api can be found on: [Api documentation](./doc/api.md)
|
121
56
|
|
122
|
-
|
57
|
+
### Errors
|
123
58
|
|
124
59
|
SmartlingApi will handle errors according to the response received from Smartling. The errors that might be thrown on a request are,
|
125
60
|
|
@@ -131,7 +66,8 @@ SmartlingApi will handle errors according to the response received from Smartlin
|
|
131
66
|
|
132
67
|
The errors all inherit, and will default to `SmartlingApi::Errors::Client` if any other response other than 2xx or 3xx is received.
|
133
68
|
|
134
|
-
|
69
|
+
Todo
|
70
|
+
----
|
135
71
|
|
136
72
|
The following apis still need to be implemented:
|
137
73
|
|
@@ -144,20 +80,22 @@ The following apis still need to be implemented:
|
|
144
80
|
- File Api: Last Modified: Single Locale
|
145
81
|
- File Api: Last Modified: All Locales
|
146
82
|
- File Api: Import Translations
|
147
|
-
- File Api: Get Translations
|
83
|
+
- ~~File Api: Get Translations~~
|
148
84
|
- File Api: Download Translated Files: Original File
|
149
85
|
- File Api: Download Translated Files: Multiple Locales as ZIP
|
150
86
|
- File Api: Download Translated Files: All Locales as ZIP
|
151
87
|
- File Api: Download Translated Files: All Locales in one File - CSV
|
152
88
|
|
153
|
-
|
89
|
+
Maintainers
|
90
|
+
-------
|
154
91
|
|
155
|
-
[![](/redbubble.png)][redbubble]
|
92
|
+
[![](/doc/redbubble.png)][redbubble]
|
156
93
|
|
157
94
|
smartling api is maintained and funded by [Redbubble][redbubble].
|
158
95
|
|
159
96
|
[redbubble]: https://www.redbubble.com
|
160
97
|
|
161
|
-
|
98
|
+
License
|
99
|
+
-------
|
162
100
|
|
163
101
|
Licensed under [MIT](./LICENCE.txt)
|
data/doc/api.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
API Documentation
|
2
|
+
=================
|
3
|
+
|
4
|
+
Authentication Api
|
5
|
+
------------------
|
6
|
+
|
7
|
+
**Retrieve Access Token**
|
8
|
+
|
9
|
+
- [Authenticate API](http://docs.smartling.com/pages/API/v2/Authentication/Authenticate). Retrieve OAuth2 access token to be used with each api call.
|
10
|
+
|
11
|
+
|
12
|
+
> SmartlingApi::Authentication.new.access_token
|
13
|
+
=> "Token"
|
14
|
+
|
15
|
+
The Authentication API will throw `SmartlingApi::Errors::Credentials` if the Smartling id and/or secret has not been set.
|
16
|
+
|
17
|
+
Project Api
|
18
|
+
-----------
|
19
|
+
|
20
|
+
Create a Project Api via,
|
21
|
+
|
22
|
+
@param `token`: Optional ( Will default to using authentication api to retrieve access token )
|
23
|
+
|
24
|
+
@param `project_id`: Optional ( Will default to using configured project_id )
|
25
|
+
|
26
|
+
> SmartlingApi::Project.new
|
27
|
+
or
|
28
|
+
> SmartlingApi::Project.new(token: 'token', project_id: 'project_id')
|
29
|
+
|
30
|
+
|
31
|
+
- [List Locales API](http://docs.smartling.com/pages/API/v2/Projects/List-Projects/). Retrieve a list of all locales available.
|
32
|
+
|
33
|
+
> SmartlingApi::Project.new.list_locales
|
34
|
+
=> [{ "localeId" => "de-DE", "description" => "German (Germany)" }, ...]
|
35
|
+
|
36
|
+
|
37
|
+
File Api
|
38
|
+
--------
|
39
|
+
|
40
|
+
Create a Project Api via,
|
41
|
+
|
42
|
+
@param `token`: Optional ( Will default to using authentication api to retrieve access token )
|
43
|
+
|
44
|
+
@param `project_id`: Optional ( Will default to using configured project_id )
|
45
|
+
|
46
|
+
> SmartlingApi::File.new
|
47
|
+
or
|
48
|
+
> SmartlingApi::File.new(token: 'token', project_id: 'project_id')
|
49
|
+
|
50
|
+
|
51
|
+
- [Delete File API](http://docs.smartling.com/pages/API/v2/FileAPI/Delete/). Delete a file within Smartling.
|
52
|
+
|
53
|
+
@param `file_uri`: File path within Smartling to delete
|
54
|
+
|
55
|
+
> SmartlingApi::File.new.delete(file_uri: '/translations/website')
|
56
|
+
=> { "code" => "SUCCESS" }
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
- [Download Locale File API](http://docs.smartling.com/pages/API/v2/FileAPI/Download-File/Single-Locale/). Returns the content of a file for the given locale and path.
|
61
|
+
|
62
|
+
@param `file_uri`: File path within Smartling to download
|
63
|
+
|
64
|
+
@param `locale_id`: Locale Id of file to download
|
65
|
+
|
66
|
+
> SmartlingApi::File.new.download_locale(locale_id: 'fr-Fr', file_uri: '/translation/website')
|
67
|
+
=> "translations"
|
68
|
+
|
69
|
+
|
70
|
+
- [List File API](http://docs.smartling.com/pages/API/v2/FileAPI/List/). Retrieve list of files for a given project.
|
71
|
+
|
72
|
+
@param `**options`: Additional options for the given request. NOTE: If using a hash as parameters ensure all keys are symbols and then use `**options`. See Smartling API Doc for options.
|
73
|
+
|
74
|
+
> SmartlingApi::File.new.list_files(uriMask: '.json')
|
75
|
+
=> [{"fileUri" => "[/translate/file.json]", ...}]
|
76
|
+
|
77
|
+
|
78
|
+
- [Upload File API](http://docs.smartling.com/pages/API/v2/FileAPI/Upload-File/). Upload a file to the given path.
|
79
|
+
|
80
|
+
@param `file_path`: Location of file to upload
|
81
|
+
|
82
|
+
@param `file_uri`: File path within smartling
|
83
|
+
|
84
|
+
@param `file_type`: Type of file to upload. See Smartling API DOC for types.
|
85
|
+
|
86
|
+
@param `**options`: Additional options for the given request. NOTE: If using a hash as parameters ensure all keys are symbols and then use `**options`. See Smartling API Doc for options.
|
87
|
+
|
88
|
+
SmartlingApi::File.new.upload(file_path: 'website.pot', file_uri: '/translation/website', file_type: 'gettext')
|
89
|
+
=> { "code" => "SUCCESS" }
|
90
|
+
|
91
|
+
- [Get Translations](http://docs.smartling.com/pages/API/v2/FileAPI/Get-Translations/). Get Translations
|
92
|
+
|
93
|
+
@param `file_path`: Location of file to upload
|
94
|
+
|
95
|
+
@param `file_uri`: File path within smartling
|
96
|
+
|
97
|
+
@param `locale_id`: Locale Id of translatable locale
|
98
|
+
|
99
|
+
@param `**options`: Additional options for the given request. NOTE: If using a hash as parameters ensure all keys are symbols and then use `**options`. See Smartling API Doc for options.
|
100
|
+
|
101
|
+
SmartlingApi::File.new.get_translations(file_path: 'website.pot', file_uri: '/translation/website', locale_id: 'de-DE')
|
102
|
+
=> 'msgid \"clothing\"\\nmsgstr \"Bekleidung\"'
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
2
|
require 'smartling_api/errors/raise_error'
|
4
3
|
|
5
4
|
module SmartlingApi
|
@@ -53,7 +52,10 @@ module SmartlingApi
|
|
53
52
|
# @return [Hash] Response returned from request
|
54
53
|
# @raise [Errors::Client] If response does not return a 2xx or 3xx
|
55
54
|
def upload(url:, token:, body:)
|
56
|
-
multipart_connection.post(url, body, header(token)).body
|
55
|
+
response = multipart_connection.post(url, body, header(token)).body
|
56
|
+
return response if response.is_a?(String)
|
57
|
+
|
58
|
+
response.fetch('response')
|
57
59
|
end
|
58
60
|
|
59
61
|
# Download a file from smartling for the given url
|
@@ -80,8 +82,9 @@ module SmartlingApi
|
|
80
82
|
|
81
83
|
faraday.response :json, content_type: /\bjson$/
|
82
84
|
|
83
|
-
faraday.adapter :net_http
|
84
85
|
faraday.use Errors::RaiseError
|
86
|
+
|
87
|
+
faraday.adapter Faraday.default_adapter
|
85
88
|
end
|
86
89
|
end
|
87
90
|
|
@@ -92,8 +95,9 @@ module SmartlingApi
|
|
92
95
|
|
93
96
|
faraday.response :json, content_type: /\bjson$/
|
94
97
|
|
95
|
-
faraday.adapter :net_http
|
96
98
|
faraday.use Errors::RaiseError
|
99
|
+
|
100
|
+
faraday.adapter Faraday.default_adapter
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
2
|
require 'smartling_api/errors/not_found'
|
4
3
|
require 'smartling_api/errors/client'
|
5
4
|
require 'smartling_api/errors/internal_server'
|
@@ -8,7 +7,7 @@ require 'smartling_api/errors/unprocessable_entity'
|
|
8
7
|
module SmartlingApi
|
9
8
|
module Errors
|
10
9
|
# Middleware for Faraday error handling
|
11
|
-
class RaiseError < Faraday::
|
10
|
+
class RaiseError < Faraday::Middleware
|
12
11
|
# Mapping of Smartling Error response
|
13
12
|
ERRORS = {
|
14
13
|
404 => NotFound,
|
data/lib/smartling_api/file.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
4
|
+
require 'faraday/multipart'
|
2
5
|
require 'smartling_api/clients/smartling'
|
3
6
|
require 'smartling_api/authentication'
|
4
7
|
|
@@ -56,9 +59,9 @@ module SmartlingApi
|
|
56
59
|
# @return [Hash] Details of upload
|
57
60
|
def upload(file_path:, file_uri:, file_type:, **options)
|
58
61
|
body = {
|
59
|
-
file:
|
60
|
-
fileUri:
|
61
|
-
fileType: file_type
|
62
|
+
file: Faraday::UploadIO.new(file_path, 'text/plain'),
|
63
|
+
fileUri: file_uri,
|
64
|
+
fileType: file_type,
|
62
65
|
}.merge(options)
|
63
66
|
|
64
67
|
smartling.upload(url: "/files-api/v2/projects/#{project_id}/file", token: token, body: body)
|
@@ -77,7 +80,28 @@ module SmartlingApi
|
|
77
80
|
smartling.post(url: "/files-api/v2/projects/#{project_id}/file/delete", token: token, body: { fileUri: file_uri })
|
78
81
|
end
|
79
82
|
|
80
|
-
|
83
|
+
# Temporarily uploads a file, then returns a translated version for requested locales.
|
84
|
+
#
|
85
|
+
# @see http://docs.smartling.com/pages/API/v2/FileAPI/Get-Translations/
|
86
|
+
#
|
87
|
+
# @example Get Translations
|
88
|
+
# SmartlingApi::File.new.get_translations(file: 'translations.pot', file_uri: '/translations/website.pot') #=> { "code" => "SUCCESS" }
|
89
|
+
#
|
90
|
+
# @param file_path [String] File path of contents to upload
|
91
|
+
# @param file_uri [String] File path within Smartling to base off
|
92
|
+
# @param locale_id [String] Locale id for the given file
|
93
|
+
# @param options [Hash] Additional options for the given request.
|
94
|
+
# @return [Hash] Details of tranlsations
|
95
|
+
def get_translations(file_path:, file_uri:, locale_id:, **options)
|
96
|
+
body = {
|
97
|
+
file: Faraday::UploadIO.new(file_path, 'text/plain'),
|
98
|
+
fileUri: file_uri,
|
99
|
+
}.merge(options)
|
100
|
+
|
101
|
+
smartling.upload(url: "/files-api/v2/projects/#{project_id}/locales/#{locale_id}/file/get-translations", token: token, body: body)
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
81
105
|
|
82
106
|
attr_reader :smartling, :token, :project_id
|
83
107
|
|
data/smartling_api.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'smartling_api/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'smartling_api'
|
8
9
|
spec.version = SmartlingApi::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Redbubble']
|
11
|
+
spec.email = ['developers@redbubble.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'THIS GEM IS EXTREMELY DEPRECATED - DO NOT USE'
|
14
|
+
spec.homepage = 'https://github.com/redbubble/smartling_api'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
18
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 2.7.8'
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'faraday', '~> 2.7'
|
25
|
+
spec.add_runtime_dependency 'faraday-multipart', '~> 1.0'
|
20
26
|
|
21
|
-
spec.
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.4"
|
24
|
-
spec.add_development_dependency "webmock", "~> 2.1"
|
25
|
-
spec.add_development_dependency "pry", "~> 0.10"
|
26
|
-
spec.add_runtime_dependency "faraday", "~> 0.9"
|
27
|
-
spec.add_runtime_dependency "faraday_middleware", "~> 0.9"
|
27
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,126 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartling_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Redbubble
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.11'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.11'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.4'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.4'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: webmock
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.1'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.10'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.10'
|
83
13
|
- !ruby/object:Gem::Dependency
|
84
14
|
name: faraday
|
85
15
|
requirement: !ruby/object:Gem::Requirement
|
86
16
|
requirements:
|
87
17
|
- - "~>"
|
88
18
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
19
|
+
version: '2.7'
|
90
20
|
type: :runtime
|
91
21
|
prerelease: false
|
92
22
|
version_requirements: !ruby/object:Gem::Requirement
|
93
23
|
requirements:
|
94
24
|
- - "~>"
|
95
25
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
26
|
+
version: '2.7'
|
97
27
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
28
|
+
name: faraday-multipart
|
99
29
|
requirement: !ruby/object:Gem::Requirement
|
100
30
|
requirements:
|
101
31
|
- - "~>"
|
102
32
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
33
|
+
version: '1.0'
|
104
34
|
type: :runtime
|
105
35
|
prerelease: false
|
106
36
|
version_requirements: !ruby/object:Gem::Requirement
|
107
37
|
requirements:
|
108
38
|
- - "~>"
|
109
39
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
111
|
-
description:
|
40
|
+
version: '1.0'
|
41
|
+
description:
|
112
42
|
email:
|
113
43
|
- developers@redbubble.com
|
114
44
|
executables: []
|
115
45
|
extensions: []
|
116
46
|
extra_rdoc_files: []
|
117
47
|
files:
|
48
|
+
- ".buildkite/pipeline.yaml"
|
49
|
+
- ".github/CODEOWNERS"
|
118
50
|
- ".gitignore"
|
51
|
+
- ".ruby-version"
|
119
52
|
- Gemfile
|
53
|
+
- Gemfile.lock
|
120
54
|
- LICENCE.txt
|
121
55
|
- README.md
|
122
|
-
-
|
123
|
-
-
|
56
|
+
- doc/api.md
|
57
|
+
- doc/redbubble.png
|
124
58
|
- lib/smartling_api.rb
|
125
59
|
- lib/smartling_api/authentication.rb
|
126
60
|
- lib/smartling_api/clients/smartling.rb
|
@@ -134,13 +68,13 @@ files:
|
|
134
68
|
- lib/smartling_api/file.rb
|
135
69
|
- lib/smartling_api/project.rb
|
136
70
|
- lib/smartling_api/version.rb
|
137
|
-
- redbubble.png
|
138
71
|
- smartling_api.gemspec
|
139
|
-
homepage: https://
|
72
|
+
homepage: https://github.com/redbubble/smartling_api
|
140
73
|
licenses:
|
141
74
|
- MIT
|
142
|
-
metadata:
|
143
|
-
|
75
|
+
metadata:
|
76
|
+
rubygems_mfa_required: 'true'
|
77
|
+
post_install_message:
|
144
78
|
rdoc_options: []
|
145
79
|
require_paths:
|
146
80
|
- lib
|
@@ -148,16 +82,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
82
|
requirements:
|
149
83
|
- - ">="
|
150
84
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
85
|
+
version: 2.7.8
|
152
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
87
|
requirements:
|
154
|
-
- - "
|
88
|
+
- - ">"
|
155
89
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
90
|
+
version: 1.3.1
|
157
91
|
requirements: []
|
158
|
-
|
159
|
-
|
160
|
-
signing_key:
|
92
|
+
rubygems_version: 3.4.10
|
93
|
+
signing_key:
|
161
94
|
specification_version: 4
|
162
|
-
summary:
|
95
|
+
summary: THIS GEM IS EXTREMELY DEPRECATED - DO NOT USE
|
163
96
|
test_files: []
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "smartling_api"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
File without changes
|