ruby-lokalise-api 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +1 -1
- data/lib/ruby-lokalise-api/client.rb +15 -4
- data/lib/ruby-lokalise-api/collections/base.rb +3 -2
- data/lib/ruby-lokalise-api/data/attributes.json +16 -12
- data/lib/ruby-lokalise-api/request.rb +1 -1
- data/lib/ruby-lokalise-api/resources/base.rb +20 -6
- data/lib/ruby-lokalise-api/resources/file.rb +0 -1
- data/lib/ruby-lokalise-api/resources/project_language.rb +1 -1
- data/lib/ruby-lokalise-api/resources/team_user_group.rb +2 -1
- data/lib/ruby-lokalise-api/resources/translation_provider.rb +3 -0
- data/lib/ruby-lokalise-api/rest/team_user_group.rb +4 -4
- data/lib/ruby-lokalise-api/version.rb +1 -1
- data/ruby-lokalise-api.gemspec +1 -1
- data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +1 -1
- data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +27 -21
- data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +12 -0
- data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +4 -2
- data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +2 -3
- data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +84 -0
- data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +1 -0
- data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +5 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0454c459770b754104d8ff3c40ea857176d3642fd48819f2395c021c89ed1ec
|
4
|
+
data.tar.gz: 97dc4a77f36ab857edd8da3e0d2ec192fe87696485965379c20189d5911cb9c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec8413f84b1fae0a3aeb08f5393dd816f3928c174d7f181b4080bf30d441f84c2f6e071826a1a14eaa692283a1d9446734c53d7393a961d19606721a1ec56841
|
7
|
+
data.tar.gz: 6a0d6cf801b0a4adda4aa0eb7a7bef55e1009f382d1d977508a8ff605c65502f18a277c6ec0014b44ec1d2656304021b30d5bd5d3672d4888273b4a4066d9061
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 3.
|
3
|
+
## 3.1.0 (08-Jul-20)
|
4
|
+
|
5
|
+
* Added all recently introduced attributes for the following endpoints: `Contributor` and `Key`
|
6
|
+
* Better support for method chaining and data reloading
|
7
|
+
* API now supports only background file uploads, and the `queue` parameter doesn't have any effect anymore. Therefore, removed all code and docs related to sync uploading.
|
8
|
+
|
9
|
+
## 3.0.0 (18-May-20)
|
4
10
|
|
5
11
|
* **Breaking change** Uploading files in the background is now a preferred method, and the only method in version 3. Synchronous uploading is still supported and allowed in version 2 but will be removed in the near future. Find more info [in the docs](https://github.com/lokalise/ruby-lokalise-api#upload-translation-file).
|
6
12
|
* Added support for [background import](https://github.com/lokalise/ruby-lokalise-api#upload-translation-file). Background import will return a queued process with the status of the job:
|
data/README.md
CHANGED
@@ -481,7 +481,7 @@ Exports project files as a `.zip` bundle and makes them available to download (t
|
|
481
481
|
|
482
482
|
[Doc](https://app.lokalise.com/api2docs/curl/#transition-upload-a-file-post)
|
483
483
|
|
484
|
-
Starting from
|
484
|
+
Starting from July 2020, **background uploading is the only method of importing translation files**.
|
485
485
|
|
486
486
|
```ruby
|
487
487
|
@client.upload_file(project_id, params) # Input:
|
@@ -28,14 +28,25 @@ module Lokalise
|
|
28
28
|
|
29
29
|
def initialize(token, params = {})
|
30
30
|
@token = token
|
31
|
-
@timeout = params.fetch(:timeout
|
32
|
-
@open_timeout = params.fetch(:open_timeout
|
31
|
+
@timeout = params.fetch(:timeout, nil)
|
32
|
+
@open_timeout = params.fetch(:open_timeout, nil)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
# rubocop:disable Metrics/ParameterLists
|
36
|
+
# Constructs request to perform the specified action
|
37
|
+
# @param klass The actual class to call the method upon
|
38
|
+
# @param method [Symbol] The method to call (:new, :update, :create etc)
|
39
|
+
# @param endpoint_ids [Array, Hash] IDs that are used to generate the proper path to the endpoint
|
40
|
+
# @param params [Array, Hash] Request parameters
|
41
|
+
# @param object_key [String, Symbol] Key that should be used to wrap parameters into
|
42
|
+
# @param initial_ids [Array] IDs that should be used to generate base endpoint path. The base path is used for method chaining
|
43
|
+
def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil)
|
36
44
|
path = klass.endpoint(*endpoint_ids)
|
37
|
-
|
45
|
+
formatted_params = format_params(params, object_key)
|
46
|
+
formatted_params[:_initial_path] = klass.endpoint(*initial_ids) if initial_ids
|
47
|
+
klass.send method, self, path, formatted_params
|
38
48
|
end
|
49
|
+
# rubocop:enable Metrics/ParameterLists
|
39
50
|
|
40
51
|
# Converts `params` to hash with arrays under the `object_key` key.
|
41
52
|
# Used in bulk operations
|
@@ -9,7 +9,7 @@ module Lokalise
|
|
9
9
|
extend Lokalise::Utils::EndpointHelpers
|
10
10
|
|
11
11
|
attr_reader :total_pages, :total_results, :results_per_page, :current_page, :collection,
|
12
|
-
:project_id, :team_id, :request_params, :client, :path, :branch
|
12
|
+
:project_id, :team_id, :request_params, :client, :path, :branch, :user_id
|
13
13
|
|
14
14
|
# Initializes a new collection based on the response
|
15
15
|
#
|
@@ -19,9 +19,10 @@ module Lokalise
|
|
19
19
|
def initialize(response, params = {})
|
20
20
|
produce_collection_for response
|
21
21
|
populate_pagination_data_for response
|
22
|
-
# Project, team id and branch may not be present in some cases
|
22
|
+
# Project, team id, user id, and branch may not be present in some cases
|
23
23
|
@project_id = response['content']['project_id']
|
24
24
|
@team_id = response['content']['team_id']
|
25
|
+
@user_id = response['content']['user_id']
|
25
26
|
@branch = response['content']['branch']
|
26
27
|
@request_params = params
|
27
28
|
@client = response['client']
|
@@ -21,11 +21,11 @@
|
|
21
21
|
"email",
|
22
22
|
"fullname",
|
23
23
|
"created_at",
|
24
|
+
"created_at_timestamp",
|
24
25
|
"is_admin",
|
25
26
|
"is_reviewer",
|
26
27
|
"languages",
|
27
|
-
"admin_rights"
|
28
|
-
"created_at_timestamp"
|
28
|
+
"admin_rights"
|
29
29
|
],
|
30
30
|
"custom_translation_status": [
|
31
31
|
"status_id",
|
@@ -39,6 +39,7 @@
|
|
39
39
|
"key": [
|
40
40
|
"key_id",
|
41
41
|
"created_at",
|
42
|
+
"created_at_timestamp",
|
42
43
|
"key_name",
|
43
44
|
"filenames",
|
44
45
|
"description",
|
@@ -55,7 +56,10 @@
|
|
55
56
|
"base_words",
|
56
57
|
"char_limit",
|
57
58
|
"custom_attributes",
|
58
|
-
"
|
59
|
+
"modified_at",
|
60
|
+
"modified_at_timestamp",
|
61
|
+
"translations_modified_at",
|
62
|
+
"translations_modified_at_timestamp"
|
59
63
|
],
|
60
64
|
"language": [
|
61
65
|
"lang_id",
|
@@ -70,6 +74,7 @@
|
|
70
74
|
"card_id",
|
71
75
|
"status",
|
72
76
|
"created_at",
|
77
|
+
"created_at_timestamp",
|
73
78
|
"created_by",
|
74
79
|
"created_by_email",
|
75
80
|
"source_language_iso",
|
@@ -81,8 +86,7 @@
|
|
81
86
|
"translation_tier",
|
82
87
|
"translation_tier_name",
|
83
88
|
"briefing",
|
84
|
-
"total"
|
85
|
-
"created_at_timestamp"
|
89
|
+
"total"
|
86
90
|
],
|
87
91
|
"payment_card": [
|
88
92
|
"card_id",
|
@@ -96,10 +100,10 @@
|
|
96
100
|
"name",
|
97
101
|
"description",
|
98
102
|
"created_at",
|
103
|
+
"created_at_timestamp",
|
99
104
|
"created_by",
|
100
105
|
"created_by_email",
|
101
106
|
"team_id",
|
102
|
-
"created_at_timestamp",
|
103
107
|
"base_language_id",
|
104
108
|
"base_language_iso",
|
105
109
|
"settings",
|
@@ -132,9 +136,9 @@
|
|
132
136
|
"snapshot_id",
|
133
137
|
"title",
|
134
138
|
"created_at",
|
139
|
+
"created_at_timestamp",
|
135
140
|
"created_by",
|
136
|
-
"created_by_email"
|
137
|
-
"created_at_timestamp"
|
141
|
+
"created_by_email"
|
138
142
|
],
|
139
143
|
"task": [
|
140
144
|
"task_id",
|
@@ -168,18 +172,18 @@
|
|
168
172
|
"team_id",
|
169
173
|
"name",
|
170
174
|
"created_at",
|
175
|
+
"created_at_timestamp",
|
171
176
|
"plan",
|
172
177
|
"quota_usage",
|
173
|
-
"quota_allowed"
|
174
|
-
"created_at_timestamp"
|
178
|
+
"quota_allowed"
|
175
179
|
],
|
176
180
|
"team_user": [
|
177
181
|
"user_id",
|
178
182
|
"email",
|
179
183
|
"fullname",
|
180
184
|
"created_at",
|
181
|
-
"
|
182
|
-
"
|
185
|
+
"created_at_timestamp",
|
186
|
+
"role"
|
183
187
|
],
|
184
188
|
"team_user_group": [
|
185
189
|
"group_id",
|
@@ -52,7 +52,7 @@ module Lokalise
|
|
52
52
|
|
53
53
|
# Get rid of double slashes in the `path`, leading and trailing slash
|
54
54
|
def prepare(path)
|
55
|
-
path.
|
55
|
+
path.delete_prefix('/').gsub(%r{//}, '/').gsub(%r{/+\z}, '')
|
56
56
|
end
|
57
57
|
|
58
58
|
def respond_with(response, client)
|
@@ -8,7 +8,7 @@ module Lokalise
|
|
8
8
|
include Lokalise::Utils::AttributeHelpers
|
9
9
|
extend Lokalise::Utils::EndpointHelpers
|
10
10
|
|
11
|
-
attr_reader :raw_data, :project_id, :client, :path, :branch
|
11
|
+
attr_reader :raw_data, :project_id, :client, :path, :branch, :user_id, :team_id
|
12
12
|
|
13
13
|
# Initializes a new resource based on the response.
|
14
14
|
# `endpoint_generator` is used in cases when a new instance is generated
|
@@ -20,10 +20,7 @@ module Lokalise
|
|
20
20
|
# @return [Lokalise::Resources::Base]
|
21
21
|
def initialize(response, endpoint_generator = nil)
|
22
22
|
populate_attributes_for response['content']
|
23
|
-
|
24
|
-
@raw_data = response['content']
|
25
|
-
@project_id = response['content']['project_id']
|
26
|
-
@branch = response['content']['branch']
|
23
|
+
extract_common_attributes_for response['content']
|
27
24
|
@client = response['client']
|
28
25
|
@path = infer_path_from response, endpoint_generator
|
29
26
|
end
|
@@ -48,11 +45,16 @@ module Lokalise
|
|
48
45
|
# Usage: `supports :update, :destroy, [:complex_method, '/sub/path', :update]`
|
49
46
|
def supports(*methods)
|
50
47
|
methods.each do |m_data|
|
48
|
+
# `method_name` - the method that the resource should support
|
49
|
+
# `sub_path` - a string that has to be appended to a base path
|
50
|
+
# `c_method` - method name to delegate the work to
|
51
51
|
method_name, sub_path, c_method =
|
52
52
|
m_data.is_a?(Array) ? m_data : [m_data, '', m_data]
|
53
|
+
|
53
54
|
define_method method_name do |params = {}|
|
54
55
|
path = instance_variable_get(:@path)
|
55
|
-
# If there's a sub_path
|
56
|
+
# If there's a sub_path which is a string,
|
57
|
+
# preserve the initial path to allow further chaining
|
56
58
|
params = params.merge(_initial_path: path) if sub_path
|
57
59
|
self.class.send c_method, instance_variable_get(:@client),
|
58
60
|
path + sub_path, params
|
@@ -174,6 +176,18 @@ module Lokalise
|
|
174
176
|
instance_variable_set "@#{attr}", value
|
175
177
|
end
|
176
178
|
end
|
179
|
+
|
180
|
+
# Extracts all common attributes that resources have.
|
181
|
+
# Some of them may be absent in certain cases.
|
182
|
+
# rubocop:disable Naming/MemoizedInstanceVariableName
|
183
|
+
def extract_common_attributes_for(content)
|
184
|
+
@raw_data = content
|
185
|
+
@project_id ||= content['project_id']
|
186
|
+
@user_id ||= content['user_id']
|
187
|
+
@team_id ||= content['team_id']
|
188
|
+
@branch ||= content['branch']
|
189
|
+
end
|
190
|
+
# rubocop:enable Naming/MemoizedInstanceVariableName
|
177
191
|
end
|
178
192
|
end
|
179
193
|
end
|
@@ -9,7 +9,8 @@ module Lokalise
|
|
9
9
|
[:add_projects, '/projects/add', :update],
|
10
10
|
[:remove_projects, '/projects/remove', :update],
|
11
11
|
[:add_users, '/members/add', :update],
|
12
|
-
[:remove_users, '/members/remove', :update]
|
12
|
+
[:remove_users, '/members/remove', :update],
|
13
|
+
[:reload_data, '', :find]
|
13
14
|
|
14
15
|
class << self
|
15
16
|
def endpoint(team_id, team_user_group_id = nil, *actions)
|
@@ -62,7 +62,7 @@ module Lokalise
|
|
62
62
|
def add_projects_to_group(team_id, group_id, project_ids)
|
63
63
|
c_r Lokalise::Resources::TeamUserGroup, :update,
|
64
64
|
[team_id, group_id, 'projects', 'add'],
|
65
|
-
project_ids, :projects
|
65
|
+
project_ids, :projects, [team_id, group_id]
|
66
66
|
end
|
67
67
|
|
68
68
|
# Removes projects from the given group
|
@@ -75,7 +75,7 @@ module Lokalise
|
|
75
75
|
def remove_projects_from_group(team_id, group_id, project_ids)
|
76
76
|
c_r Lokalise::Resources::TeamUserGroup, :update,
|
77
77
|
[team_id, group_id, 'projects', 'remove'],
|
78
|
-
project_ids, :projects
|
78
|
+
project_ids, :projects, [team_id, group_id]
|
79
79
|
end
|
80
80
|
|
81
81
|
# Adds users to the given group
|
@@ -88,7 +88,7 @@ module Lokalise
|
|
88
88
|
def add_users_to_group(team_id, group_id, users_ids)
|
89
89
|
c_r Lokalise::Resources::TeamUserGroup, :update,
|
90
90
|
[team_id, group_id, 'members', 'add'],
|
91
|
-
users_ids, :users
|
91
|
+
users_ids, :users, [team_id, group_id]
|
92
92
|
end
|
93
93
|
|
94
94
|
# Removes users from the given group
|
@@ -101,7 +101,7 @@ module Lokalise
|
|
101
101
|
def remove_users_from_group(team_id, group_id, users_ids)
|
102
102
|
c_r Lokalise::Resources::TeamUserGroup, :update,
|
103
103
|
[team_id, group_id, 'members', 'remove'],
|
104
|
-
users_ids, :users
|
104
|
+
users_ids, :users, [team_id, group_id]
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
data/ruby-lokalise-api.gemspec
CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
35
35
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
|
36
36
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
37
|
-
spec.add_development_dependency 'vcr', '~>
|
37
|
+
spec.add_development_dependency 'vcr', '~> 6.0'
|
38
38
|
end
|
@@ -52,7 +52,7 @@ RSpec.describe Lokalise::Client do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
expect(process).to be_an_instance_of(Lokalise::Resources::QueuedProcess)
|
55
|
-
expect(process.process_id).to eq('
|
55
|
+
expect(process.process_id).to eq('85c42bf5eff44648ca2f01f9db67b7d306a2f282')
|
56
56
|
expect(process.status).to eq('queued')
|
57
57
|
|
58
58
|
reloaded_process = VCR.use_cassette('upload_file_queued_reload') do
|
@@ -11,56 +11,62 @@ RSpec.describe Lokalise::Client do
|
|
11
11
|
test_client.keys project_id
|
12
12
|
end.collection
|
13
13
|
|
14
|
-
expect(keys.count).to eq(
|
14
|
+
expect(keys.count).to eq(8)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'supports pagination' do
|
18
18
|
keys = VCR.use_cassette('all_keys_pagination') do
|
19
|
-
test_client.keys project_id, limit:
|
19
|
+
test_client.keys project_id, limit: 2, page: 3
|
20
20
|
end
|
21
21
|
|
22
|
-
expect(keys.collection.count).to eq(
|
23
|
-
expect(keys.total_results).to eq(
|
24
|
-
expect(keys.total_pages).to eq(
|
25
|
-
expect(keys.results_per_page).to eq(
|
26
|
-
expect(keys.current_page).to eq(
|
22
|
+
expect(keys.collection.count).to eq(2)
|
23
|
+
expect(keys.total_results).to eq(8)
|
24
|
+
expect(keys.total_pages).to eq(4)
|
25
|
+
expect(keys.results_per_page).to eq(2)
|
26
|
+
expect(keys.current_page).to eq(3)
|
27
27
|
|
28
|
-
expect(keys.next_page?).to eq(
|
29
|
-
expect(keys.last_page?).to eq(
|
30
|
-
expect(keys.prev_page?).to eq(
|
31
|
-
expect(keys.first_page?).to eq(
|
28
|
+
expect(keys.next_page?).to eq(true)
|
29
|
+
expect(keys.last_page?).to eq(false)
|
30
|
+
expect(keys.prev_page?).to eq(true)
|
31
|
+
expect(keys.first_page?).to eq(false)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
specify '#key' do
|
36
36
|
key = VCR.use_cassette('key') do
|
37
|
-
test_client.key project_id,
|
37
|
+
test_client.key project_id, 44_596_066, disable_references: 0
|
38
38
|
end
|
39
39
|
|
40
|
-
expect(key.key_id).to eq(
|
41
|
-
expect(key.
|
42
|
-
expect(key.
|
43
|
-
expect(key.
|
40
|
+
expect(key.key_id).to eq(44_596_066)
|
41
|
+
expect(key.project_id).to eq(project_id)
|
42
|
+
expect(key.branch).to eq('master')
|
43
|
+
expect(key.created_at).to eq('2020-05-11 11:20:33 (Etc/UTC)')
|
44
|
+
expect(key.created_at_timestamp).to eq(1_589_196_033)
|
45
|
+
expect(key.key_name['ios']).to eq('static_pages:index:welcome')
|
46
|
+
expect(key.filenames['web']).to eq('%LANG_ISO%.yml')
|
44
47
|
expect(key.description).to eq('')
|
45
48
|
expect(key.platforms).to eq(%w[web])
|
46
49
|
expect(key.tags).to eq([])
|
47
|
-
expect(key.comments
|
48
|
-
expect(key.comments[1]['comment_id']).to eq(800_632)
|
50
|
+
expect(key.comments).to eq([])
|
49
51
|
expect(key.screenshots).to eq([])
|
50
52
|
expect(key.translations.first['modified_by_email']).to eq('bodrovis@protonmail.com')
|
51
53
|
expect(key.is_plural).to eq(false)
|
52
54
|
expect(key.plural_name).to eq('')
|
53
|
-
expect(key.is_hidden).to eq(
|
55
|
+
expect(key.is_hidden).to eq(true)
|
54
56
|
expect(key.is_archived).to eq(false)
|
55
57
|
expect(key.context).to eq('')
|
58
|
+
expect(key.base_words).to eq(1)
|
56
59
|
expect(key.char_limit).to eq(0)
|
57
60
|
expect(key.custom_attributes).to eq('')
|
58
|
-
expect(key.
|
61
|
+
expect(key.modified_at).to eq('2020-05-11 11:20:33 (Etc/UTC)')
|
62
|
+
expect(key.modified_at_timestamp).to eq(1_589_196_033)
|
63
|
+
expect(key.translations_modified_at).to eq('2020-05-15 10:44:42 (Etc/UTC)')
|
64
|
+
expect(key.translations_modified_at_timestamp).to eq(1_589_539_482)
|
59
65
|
end
|
60
66
|
|
61
67
|
specify '#reload_data' do
|
62
68
|
key = VCR.use_cassette('key') do
|
63
|
-
test_client.key project_id,
|
69
|
+
test_client.key project_id, 44_596_066, disable_references: 0
|
64
70
|
end
|
65
71
|
|
66
72
|
reloaded_key = VCR.use_cassette('key') do
|
@@ -63,6 +63,18 @@ RSpec.describe Lokalise::Client do
|
|
63
63
|
expect(language.plural_forms).to eq(%w[one other])
|
64
64
|
end
|
65
65
|
|
66
|
+
specify '#reload_data' do
|
67
|
+
language = VCR.use_cassette('language') do
|
68
|
+
test_client.language project_id, language_id
|
69
|
+
end
|
70
|
+
|
71
|
+
reloaded_language = VCR.use_cassette('language') do
|
72
|
+
language.reload_data
|
73
|
+
end
|
74
|
+
|
75
|
+
expect(reloaded_language.lang_id).to eq(language.lang_id)
|
76
|
+
end
|
77
|
+
|
66
78
|
specify '#create_languages' do
|
67
79
|
language = VCR.use_cassette('create_languages') do
|
68
80
|
test_client.create_languages project_id, lang_iso: 'ab', custom_name: 'rspec lang'
|
@@ -7,9 +7,10 @@ RSpec.describe Lokalise::Client do
|
|
7
7
|
it 'returns all payment cards' do
|
8
8
|
cards = VCR.use_cassette('all_payment_cards') do
|
9
9
|
test_client.payment_cards
|
10
|
-
end
|
10
|
+
end
|
11
11
|
|
12
|
-
|
12
|
+
expect(cards.user_id).to eq(20_181)
|
13
|
+
card = cards.collection.first
|
13
14
|
expect(card.card_id).to eq(1774)
|
14
15
|
expect(card.last4).to eq('0358')
|
15
16
|
end
|
@@ -49,6 +50,7 @@ RSpec.describe Lokalise::Client do
|
|
49
50
|
test_client.payment_card card_id
|
50
51
|
end
|
51
52
|
|
53
|
+
expect(card.user_id).to eq(20_181)
|
52
54
|
expect(card.card_id).to eq(card_id)
|
53
55
|
expect(card.brand).to eq('Visa')
|
54
56
|
expect(card.last4).to eq('4242')
|
@@ -3,7 +3,7 @@
|
|
3
3
|
RSpec.describe Lokalise::Client do
|
4
4
|
let(:project_id) { '803826145ba90b42d5d860.46800099' }
|
5
5
|
let(:process_id) { '3b943469e6b3e324b5bdad639b122a623e6e7a1a' }
|
6
|
-
let(:queued_process_id) { '
|
6
|
+
let(:queued_process_id) { '85c42bf5eff44648ca2f01f9db67b7d306a2f282' }
|
7
7
|
|
8
8
|
describe '#queued_processes' do
|
9
9
|
it 'returns all queued processes' do
|
@@ -13,7 +13,6 @@ RSpec.describe Lokalise::Client do
|
|
13
13
|
|
14
14
|
expect(processes.branch).to eq('master')
|
15
15
|
processes = processes.collection
|
16
|
-
puts processes.count
|
17
16
|
expect(processes.count).to eq(8)
|
18
17
|
expect(processes.first.process_id).to eq(process_id)
|
19
18
|
end
|
@@ -45,7 +44,7 @@ RSpec.describe Lokalise::Client do
|
|
45
44
|
test_client.queued_process project_id, queued_process_id
|
46
45
|
end
|
47
46
|
|
48
|
-
expect(queued_process.status).to eq('
|
47
|
+
expect(queued_process.status).to eq('finished')
|
49
48
|
|
50
49
|
reloaded_process = VCR.use_cassette('upload_file_queued_reload') do
|
51
50
|
queued_process.reload_data
|
@@ -45,6 +45,11 @@ RSpec.describe Lokalise::Client do
|
|
45
45
|
expect(group.team_id).to eq(team_id)
|
46
46
|
expect(group.projects.first).to eq('803826145ba90b42d5d860.46800099')
|
47
47
|
expect(group.members[1]).to eq(25_753)
|
48
|
+
|
49
|
+
reloaded_group = VCR.use_cassette('team_user_group') do
|
50
|
+
group.reload_data
|
51
|
+
end
|
52
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
48
53
|
end
|
49
54
|
|
50
55
|
specify '#create_team_user_group' do
|
@@ -60,6 +65,11 @@ RSpec.describe Lokalise::Client do
|
|
60
65
|
|
61
66
|
expect(group.name).to eq('RSpec group')
|
62
67
|
expect(group.team_id).to eq(team_id)
|
68
|
+
|
69
|
+
reloaded_group = VCR.use_cassette('created_team_user_group') do
|
70
|
+
group.reload_data
|
71
|
+
end
|
72
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
63
73
|
end
|
64
74
|
|
65
75
|
specify '#update_team_user_group' do
|
@@ -91,6 +101,16 @@ RSpec.describe Lokalise::Client do
|
|
91
101
|
expect(group.team_id).to eq(team_id)
|
92
102
|
expect(group.group_id).to eq(third_group_id)
|
93
103
|
expect(group.projects).to include(project_id)
|
104
|
+
|
105
|
+
reloaded_group = VCR.use_cassette('another_team_user_group') do
|
106
|
+
group.reload_data
|
107
|
+
end
|
108
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
109
|
+
|
110
|
+
group = VCR.use_cassette('add_projects_to_group') do
|
111
|
+
group.add_projects projects: [project_id]
|
112
|
+
end
|
113
|
+
expect(group.group_id).to eq(third_group_id)
|
94
114
|
end
|
95
115
|
|
96
116
|
specify '#remove_projects_from_group' do
|
@@ -101,6 +121,16 @@ RSpec.describe Lokalise::Client do
|
|
101
121
|
expect(group.group_id).to eq(third_group_id)
|
102
122
|
expect(group.team_id).to eq(team_id)
|
103
123
|
expect(group.projects).to be_empty
|
124
|
+
|
125
|
+
reloaded_group = VCR.use_cassette('another_team_user_group') do
|
126
|
+
group.reload_data
|
127
|
+
end
|
128
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
129
|
+
|
130
|
+
group = VCR.use_cassette('remove_projects_from_group') do
|
131
|
+
group.remove_projects projects: [project_id]
|
132
|
+
end
|
133
|
+
expect(group.group_id).to eq(third_group_id)
|
104
134
|
end
|
105
135
|
|
106
136
|
specify '#add_users_to_group' do
|
@@ -111,6 +141,15 @@ RSpec.describe Lokalise::Client do
|
|
111
141
|
expect(group.team_id).to eq(team_id)
|
112
142
|
expect(group.group_id).to eq(third_group_id)
|
113
143
|
expect(group.members).to include(user_id)
|
144
|
+
|
145
|
+
reloaded_group = VCR.use_cassette('another_team_user_group') do
|
146
|
+
group.reload_data
|
147
|
+
end
|
148
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
149
|
+
|
150
|
+
group = VCR.use_cassette('add_users_to_group') do
|
151
|
+
group.add_users users: [user_id]
|
152
|
+
end
|
114
153
|
end
|
115
154
|
|
116
155
|
specify '#remove_users_from_group' do
|
@@ -121,6 +160,15 @@ RSpec.describe Lokalise::Client do
|
|
121
160
|
expect(group.group_id).to eq(third_group_id)
|
122
161
|
expect(group.team_id).to eq(team_id)
|
123
162
|
expect(group.members).to be_empty
|
163
|
+
|
164
|
+
reloaded_group = VCR.use_cassette('another_team_user_group') do
|
165
|
+
group.reload_data
|
166
|
+
end
|
167
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
168
|
+
|
169
|
+
group = VCR.use_cassette('remove_users_from_group') do
|
170
|
+
group.remove_users users: [user_id]
|
171
|
+
end
|
124
172
|
end
|
125
173
|
|
126
174
|
context 'when team user group methods are chained' do
|
@@ -160,6 +208,15 @@ RSpec.describe Lokalise::Client do
|
|
160
208
|
expect(group.group_id).to eq(group_id)
|
161
209
|
expect(group.projects).to include(another_project_id)
|
162
210
|
|
211
|
+
group = VCR.use_cassette('add_project_to_group_chained') do
|
212
|
+
group.add_projects(projects: [another_project_id])
|
213
|
+
end
|
214
|
+
|
215
|
+
reloaded_group = VCR.use_cassette('team_user_group') do
|
216
|
+
group.reload_data
|
217
|
+
end
|
218
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
219
|
+
|
163
220
|
group = VCR.use_cassette('remove_project_from_group_chained') do
|
164
221
|
group.remove_projects(projects: [another_project_id])
|
165
222
|
end
|
@@ -167,6 +224,15 @@ RSpec.describe Lokalise::Client do
|
|
167
224
|
expect(group.team_id).to eq(team_id)
|
168
225
|
expect(group.group_id).to eq(group_id)
|
169
226
|
expect(group.projects).not_to include(another_project_id)
|
227
|
+
|
228
|
+
group = VCR.use_cassette('remove_project_from_group_chained') do
|
229
|
+
group.remove_projects(projects: [another_project_id])
|
230
|
+
end
|
231
|
+
|
232
|
+
reloaded_group = VCR.use_cassette('team_user_group') do
|
233
|
+
group.reload_data
|
234
|
+
end
|
235
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
170
236
|
end
|
171
237
|
|
172
238
|
it 'supports users management' do
|
@@ -182,6 +248,15 @@ RSpec.describe Lokalise::Client do
|
|
182
248
|
expect(group.group_id).to eq(group_id)
|
183
249
|
expect(group.members).to include(user_id)
|
184
250
|
|
251
|
+
group = VCR.use_cassette('add_user_to_group_chained') do
|
252
|
+
group.add_users(users: [user_id])
|
253
|
+
end
|
254
|
+
|
255
|
+
reloaded_group = VCR.use_cassette('team_user_group') do
|
256
|
+
group.reload_data
|
257
|
+
end
|
258
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
259
|
+
|
185
260
|
group = VCR.use_cassette('remove_user_from_group_chained') do
|
186
261
|
group.remove_users(users: [user_id])
|
187
262
|
end
|
@@ -189,6 +264,15 @@ RSpec.describe Lokalise::Client do
|
|
189
264
|
expect(group.team_id).to eq(team_id)
|
190
265
|
expect(group.group_id).to eq(group_id)
|
191
266
|
expect(group.members).not_to include(user_id)
|
267
|
+
|
268
|
+
group = VCR.use_cassette('remove_user_from_group_chained') do
|
269
|
+
group.remove_users(users: [user_id])
|
270
|
+
end
|
271
|
+
|
272
|
+
reloaded_group = VCR.use_cassette('team_user_group') do
|
273
|
+
group.reload_data
|
274
|
+
end
|
275
|
+
expect(reloaded_group.group_id).to eq(group.group_id)
|
192
276
|
end
|
193
277
|
end
|
194
278
|
end
|
@@ -33,6 +33,7 @@ RSpec.describe Lokalise::Client do
|
|
33
33
|
test_client.team_user team_id, '20181'
|
34
34
|
end
|
35
35
|
|
36
|
+
expect(team_user.team_id).to eq(team_id)
|
36
37
|
expect(team_user.user_id).to eq(20_181)
|
37
38
|
expect(team_user.email).to eq('bodrovis@protonmail.com')
|
38
39
|
expect(team_user.fullname).to eq('Ilya B')
|
@@ -39,5 +39,10 @@ RSpec.describe Lokalise::Client do
|
|
39
39
|
expect(provider.description.start_with?('At')).to eq(true)
|
40
40
|
expect(provider.tiers.first['title']).to eq('Native speaker')
|
41
41
|
expect(provider.pairs.first['price_per_word']).to eq('0.05')
|
42
|
+
|
43
|
+
reloaded_provider = VCR.use_cassette('translation_provider') do
|
44
|
+
provider.reload_data
|
45
|
+
end
|
46
|
+
expect(reloaded_provider.provider_id).to eq(provider.provider_id)
|
42
47
|
end
|
43
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lokalise-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bodrov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
187
|
+
version: '6.0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
194
|
+
version: '6.0'
|
195
195
|
description: Opinionated Ruby client for the Lokalise platform API allowing to work
|
196
196
|
with translations, projects, users and other resources as with Ruby objects.
|
197
197
|
email:
|
@@ -334,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
334
|
- !ruby/object:Gem::Version
|
335
335
|
version: '0'
|
336
336
|
requirements: []
|
337
|
-
rubygems_version: 3.1.
|
337
|
+
rubygems_version: 3.1.4
|
338
338
|
signing_key:
|
339
339
|
specification_version: 4
|
340
340
|
summary: Ruby interface to the Lokalise API
|