ruby-lokalise-api 7.1.1 → 8.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_lokalise_api/base_client.rb +2 -34
- data/lib/ruby_lokalise_api/client.rb +2 -31
- data/lib/ruby_lokalise_api/collections/base.rb +97 -70
- data/lib/ruby_lokalise_api/collections/branches.rb +11 -0
- data/lib/ruby_lokalise_api/collections/contributors.rb +10 -0
- data/lib/ruby_lokalise_api/collections/custom_translation_statuses.rb +10 -0
- data/lib/ruby_lokalise_api/collections/files.rb +10 -0
- data/lib/ruby_lokalise_api/collections/key_comments.rb +11 -0
- data/lib/ruby_lokalise_api/collections/keys.rb +10 -0
- data/lib/ruby_lokalise_api/collections/orders.rb +10 -0
- data/lib/ruby_lokalise_api/collections/payment_cards.rb +10 -0
- data/lib/ruby_lokalise_api/collections/project_comments.rb +12 -0
- data/lib/ruby_lokalise_api/collections/project_languages.rb +11 -0
- data/lib/ruby_lokalise_api/collections/projects.rb +10 -0
- data/lib/ruby_lokalise_api/collections/queued_processes.rb +11 -0
- data/lib/ruby_lokalise_api/collections/screenshots.rb +10 -0
- data/lib/ruby_lokalise_api/collections/segments.rb +10 -0
- data/lib/ruby_lokalise_api/collections/snapshots.rb +10 -0
- data/lib/ruby_lokalise_api/collections/system_languages.rb +11 -0
- data/lib/ruby_lokalise_api/collections/tasks.rb +10 -0
- data/lib/ruby_lokalise_api/collections/team_user_groups.rb +11 -0
- data/lib/ruby_lokalise_api/collections/team_users.rb +10 -0
- data/lib/ruby_lokalise_api/collections/teams.rb +10 -0
- data/lib/ruby_lokalise_api/collections/translation_providers.rb +10 -0
- data/lib/ruby_lokalise_api/collections/translations.rb +10 -0
- data/lib/ruby_lokalise_api/collections/webhooks.rb +10 -0
- data/lib/ruby_lokalise_api/concerns/attrs_loadable.rb +31 -0
- data/lib/ruby_lokalise_api/concerns/hash_accessible.rb +16 -0
- data/lib/ruby_lokalise_api/concerns/unsupportable.rb +16 -0
- data/lib/ruby_lokalise_api/connection.rb +18 -9
- data/lib/ruby_lokalise_api/data/collection_attributes.yml +52 -0
- data/lib/ruby_lokalise_api/data/{attributes.yml → resource_attributes.yml} +64 -6
- data/lib/ruby_lokalise_api/endpoints/base_endpoint.rb +66 -0
- data/lib/ruby_lokalise_api/endpoints/branches_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/contributors_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/custom_translation_statuses_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/files_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/jwts_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/key_comments_endpoint.rb +17 -0
- data/lib/ruby_lokalise_api/endpoints/keys_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/main_endpoint.rb +25 -0
- data/lib/ruby_lokalise_api/endpoints/oauth2/oauth2_endpoint.rb +33 -0
- data/lib/ruby_lokalise_api/endpoints/orders_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/payment_cards_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/project_comments_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/project_languages_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/projects_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/queued_processes_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/screenshots_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/segments_endpoint.rb +17 -0
- data/lib/ruby_lokalise_api/endpoints/snapshots_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/system_languages_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/tasks_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/team_user_billing_details_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/team_user_groups_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/team_users_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/teams_endpoint.rb +13 -0
- data/lib/ruby_lokalise_api/endpoints/translation_providers_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/translations_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/webhooks_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/error.rb +1 -0
- data/lib/ruby_lokalise_api/generics.rb +25 -0
- data/lib/ruby_lokalise_api/json_handler.rb +1 -2
- data/lib/ruby_lokalise_api/oauth2/auth.rb +33 -39
- data/lib/ruby_lokalise_api/oauth2_client.rb +3 -0
- data/lib/ruby_lokalise_api/request.rb +66 -18
- data/lib/ruby_lokalise_api/resources/base.rb +41 -181
- data/lib/ruby_lokalise_api/resources/branch.rb +2 -21
- data/lib/ruby_lokalise_api/resources/comment.rb +11 -0
- data/lib/ruby_lokalise_api/resources/contributor.rb +1 -9
- data/lib/ruby_lokalise_api/resources/custom_translation_status.rb +1 -13
- data/lib/ruby_lokalise_api/resources/file.rb +2 -16
- data/lib/ruby_lokalise_api/resources/jwt.rb +2 -5
- data/lib/ruby_lokalise_api/resources/key.rb +5 -8
- data/lib/ruby_lokalise_api/resources/oauth2_refreshed_token.rb +9 -0
- data/lib/ruby_lokalise_api/resources/oauth2_token.rb +9 -0
- data/lib/ruby_lokalise_api/resources/order.rb +2 -9
- data/lib/ruby_lokalise_api/resources/payment_card.rb +2 -8
- data/lib/ruby_lokalise_api/resources/project.rb +85 -16
- data/lib/ruby_lokalise_api/resources/project_language.rb +2 -10
- data/lib/ruby_lokalise_api/resources/queued_process.rb +3 -10
- data/lib/ruby_lokalise_api/resources/screenshot.rb +1 -9
- data/lib/ruby_lokalise_api/resources/segment.rb +2 -11
- data/lib/ruby_lokalise_api/resources/snapshot.rb +3 -18
- data/lib/ruby_lokalise_api/resources/system_language.rb +2 -1
- data/lib/ruby_lokalise_api/resources/task.rb +1 -9
- data/lib/ruby_lokalise_api/resources/team.rb +2 -0
- data/lib/ruby_lokalise_api/resources/team_user.rb +1 -9
- data/lib/ruby_lokalise_api/resources/team_user_billing_details.rb +10 -5
- data/lib/ruby_lokalise_api/resources/team_user_group.rb +6 -14
- data/lib/ruby_lokalise_api/resources/translation.rb +2 -9
- data/lib/ruby_lokalise_api/resources/translation_provider.rb +2 -9
- data/lib/ruby_lokalise_api/resources/webhook.rb +2 -16
- data/lib/ruby_lokalise_api/response.rb +50 -0
- data/lib/ruby_lokalise_api/rest/branches.rb +52 -27
- data/lib/ruby_lokalise_api/rest/comments.rb +48 -23
- data/lib/ruby_lokalise_api/rest/contributors.rb +47 -23
- data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +60 -36
- data/lib/ruby_lokalise_api/rest/files.rb +43 -24
- data/lib/ruby_lokalise_api/rest/jwts.rb +21 -0
- data/lib/ruby_lokalise_api/rest/keys.rb +67 -34
- data/lib/ruby_lokalise_api/rest/languages.rb +57 -28
- data/lib/ruby_lokalise_api/rest/orders.rb +36 -14
- data/lib/ruby_lokalise_api/rest/payment_cards.rb +29 -12
- data/lib/ruby_lokalise_api/rest/projects.rb +55 -32
- data/lib/ruby_lokalise_api/rest/queued_processes.rb +21 -13
- data/lib/ruby_lokalise_api/rest/screenshots.rb +45 -20
- data/lib/ruby_lokalise_api/rest/segments.rb +31 -18
- data/lib/ruby_lokalise_api/rest/snapshots.rb +34 -14
- data/lib/ruby_lokalise_api/rest/tasks.rb +41 -19
- data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +33 -12
- data/lib/ruby_lokalise_api/rest/team_user_groups.rb +82 -50
- data/lib/ruby_lokalise_api/rest/team_users.rb +35 -18
- data/lib/ruby_lokalise_api/rest/teams.rb +10 -5
- data/lib/ruby_lokalise_api/rest/translation_providers.rb +24 -9
- data/lib/ruby_lokalise_api/rest/translations.rb +28 -15
- data/lib/ruby_lokalise_api/rest/webhooks.rb +54 -30
- data/lib/ruby_lokalise_api/rest.rb +31 -0
- data/lib/ruby_lokalise_api/utils/attributes.rb +37 -0
- data/lib/ruby_lokalise_api/utils/classes.rb +24 -0
- data/lib/ruby_lokalise_api/utils/keys.rb +29 -0
- data/lib/ruby_lokalise_api/utils/loaders.rb +24 -0
- data/lib/ruby_lokalise_api/utils/strings.rb +20 -0
- data/lib/ruby_lokalise_api/version.rb +1 -1
- data/lib/ruby_lokalise_api.rb +6 -2
- data/ruby-lokalise-api.gemspec +2 -2
- metadata +76 -41
- data/lib/ruby_lokalise_api/base_request.rb +0 -73
- data/lib/ruby_lokalise_api/collections/branch.rb +0 -15
- data/lib/ruby_lokalise_api/collections/contributor.rb +0 -13
- data/lib/ruby_lokalise_api/collections/custom_translation_status.rb +0 -15
- data/lib/ruby_lokalise_api/collections/file.rb +0 -13
- data/lib/ruby_lokalise_api/collections/key.rb +0 -20
- data/lib/ruby_lokalise_api/collections/key_comment.rb +0 -14
- data/lib/ruby_lokalise_api/collections/order.rb +0 -13
- data/lib/ruby_lokalise_api/collections/payment_card.rb +0 -13
- data/lib/ruby_lokalise_api/collections/project.rb +0 -13
- data/lib/ruby_lokalise_api/collections/project_comment.rb +0 -13
- data/lib/ruby_lokalise_api/collections/project_language.rb +0 -13
- data/lib/ruby_lokalise_api/collections/queued_process.rb +0 -15
- data/lib/ruby_lokalise_api/collections/screenshot.rb +0 -13
- data/lib/ruby_lokalise_api/collections/segment.rb +0 -15
- data/lib/ruby_lokalise_api/collections/snapshot.rb +0 -13
- data/lib/ruby_lokalise_api/collections/system_language.rb +0 -13
- data/lib/ruby_lokalise_api/collections/task.rb +0 -13
- data/lib/ruby_lokalise_api/collections/team.rb +0 -13
- data/lib/ruby_lokalise_api/collections/team_user.rb +0 -13
- data/lib/ruby_lokalise_api/collections/team_user_group.rb +0 -15
- data/lib/ruby_lokalise_api/collections/translation.rb +0 -13
- data/lib/ruby_lokalise_api/collections/translation_provider.rb +0 -13
- data/lib/ruby_lokalise_api/collections/webhook.rb +0 -13
- data/lib/ruby_lokalise_api/oauth2/refresh.rb +0 -16
- data/lib/ruby_lokalise_api/oauth2/token.rb +0 -16
- data/lib/ruby_lokalise_api/resources/key_comment.rb +0 -19
- data/lib/ruby_lokalise_api/resources/project_comment.rb +0 -10
- data/lib/ruby_lokalise_api/rest/jwt.rb +0 -15
- data/lib/ruby_lokalise_api/utils/attribute_helpers.rb +0 -86
- data/lib/ruby_lokalise_api/utils/endpoint_helpers.rb +0 -14
- data/lib/ruby_lokalise_api/utils/string_utils.rb +0 -33
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module Collections
|
5
|
-
class TeamUserGroup < Base
|
6
|
-
DATA_KEY = 'UserGroup'
|
7
|
-
|
8
|
-
class << self
|
9
|
-
def endpoint(team_id, *_args)
|
10
|
-
path_from teams: [team_id, 'groups']
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module OAuth2
|
5
|
-
class Refresh
|
6
|
-
attr_reader :access_token, :expires_in, :scope, :token_type
|
7
|
-
|
8
|
-
def initialize(raw_params)
|
9
|
-
@access_token = raw_params['access_token']
|
10
|
-
@expires_in = raw_params['expires_in']
|
11
|
-
@scope = raw_params['scope']
|
12
|
-
@token_type = raw_params['token_type']
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module OAuth2
|
5
|
-
class Token
|
6
|
-
attr_reader :access_token, :refresh_token, :expires_in, :token_type
|
7
|
-
|
8
|
-
def initialize(raw_params)
|
9
|
-
@access_token = raw_params['access_token']
|
10
|
-
@refresh_token = raw_params['refresh_token']
|
11
|
-
@expires_in = raw_params['expires_in']
|
12
|
-
@token_type = raw_params['token_type']
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module Resources
|
5
|
-
class KeyComment < Base
|
6
|
-
DATA_KEY = 'Comment'
|
7
|
-
ID_KEY = 'comment_id'
|
8
|
-
supports :destroy, [:reload_data, '', :find]
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def endpoint(project_id, key_id, comment_id = nil)
|
12
|
-
path_from projects: project_id,
|
13
|
-
keys: key_id,
|
14
|
-
comments: comment_id
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module Rest
|
5
|
-
module Jwt
|
6
|
-
# Returns a JWT that can be used to work with OTA
|
7
|
-
#
|
8
|
-
# @see https://developers.lokalise.com/reference/get-ota-jwt
|
9
|
-
# @return [RubyLokaliseApi::Resources::Jwt]
|
10
|
-
def jwt
|
11
|
-
c_r RubyLokaliseApi::Resources::Jwt, :find, nil, {}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module Utils
|
5
|
-
module AttributeHelpers
|
6
|
-
using RubyLokaliseApi::Utils::StringUtils
|
7
|
-
|
8
|
-
UNIFIED_RESOURCES = %w[comment language].freeze
|
9
|
-
|
10
|
-
# Returns the name of the API resource for the given class.
|
11
|
-
# Most class names correspond to resource names (eg, `Project`, `Team`)
|
12
|
-
# but some may differ (`ProjectComment` corresponds to `Comment` resource).
|
13
|
-
# The resource name is in lowercase, with underscores as separators.
|
14
|
-
# Some resources also have different pluralization rules. For example,
|
15
|
-
# "CustomTranslationStatus" is "CustomTranslationStatuses" (-es postfix).
|
16
|
-
# To address that, we try to fetch `DATA_KEY_PLURAL` set for the individual class.
|
17
|
-
#
|
18
|
-
# @return [String]
|
19
|
-
# @param model_class [String]
|
20
|
-
# @param plural [Boolean] Should the returned value be pluralized?
|
21
|
-
def data_key_for(model_class:, plural: false, collection: false)
|
22
|
-
data_key_plural = get_key(
|
23
|
-
name: 'DATA_KEY_PLURAL',
|
24
|
-
model_class: model_class,
|
25
|
-
collection: true,
|
26
|
-
strict: true
|
27
|
-
)
|
28
|
-
|
29
|
-
return data_key_plural if collection && data_key_plural
|
30
|
-
|
31
|
-
data_key = get_key name: 'DATA_KEY', model_class: model_class, collection: collection
|
32
|
-
|
33
|
-
return data_key unless plural
|
34
|
-
|
35
|
-
"#{data_key}s"
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns key used to determine resource id (for example `user_id` or `project_id`).
|
39
|
-
# Most ids corresponds to resources' class names, but some may differ (for instance,
|
40
|
-
# `Contributor` has `user_id` attribute).
|
41
|
-
#
|
42
|
-
# @return [String]
|
43
|
-
# @param model_class [String]
|
44
|
-
def id_key_for(model_class)
|
45
|
-
get_key name: 'ID_KEY', model_class: model_class
|
46
|
-
end
|
47
|
-
|
48
|
-
# Loads attributes for the given resource based on its name
|
49
|
-
#
|
50
|
-
# @return [Array<String>]
|
51
|
-
def attributes_for(klass)
|
52
|
-
@attributes ||= YAML.load_file(File.expand_path('../data/attributes.yml', __dir__)).freeze
|
53
|
-
|
54
|
-
name = unify klass.name.snakecase
|
55
|
-
@attributes[name]
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def get_key(name:, model_class:, collection: false, strict: false)
|
61
|
-
key = if collection && Module.const_defined?("RubyLokaliseApi::Collections::#{model_class}::#{name}")
|
62
|
-
Module.const_get "RubyLokaliseApi::Collections::#{model_class}::#{name}"
|
63
|
-
elsif Module.const_defined? "RubyLokaliseApi::Resources::#{model_class}::#{name}"
|
64
|
-
Module.const_get "RubyLokaliseApi::Resources::#{model_class}::#{name}"
|
65
|
-
else
|
66
|
-
strict ? nil : model_class
|
67
|
-
end
|
68
|
-
|
69
|
-
# Sometimes key is nil
|
70
|
-
key ? key.snakecase : key
|
71
|
-
end
|
72
|
-
|
73
|
-
# Unify some resources' names (eg, `ProjectComment` and `KeyComment` have the same
|
74
|
-
# attributes which are stored under `comment`)
|
75
|
-
#
|
76
|
-
# @return [String]
|
77
|
-
def unify(name)
|
78
|
-
UNIFIED_RESOURCES.each do |u_a|
|
79
|
-
return u_a if name.match?(/#{u_a}/)
|
80
|
-
end
|
81
|
-
|
82
|
-
name
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLokaliseApi
|
4
|
-
module Utils
|
5
|
-
module EndpointHelpers
|
6
|
-
def path_from(raw_mapping)
|
7
|
-
template = Addressable::Template.new '{/segments*}'
|
8
|
-
template.expand(
|
9
|
-
segments: raw_mapping.to_a.flatten
|
10
|
-
).to_s
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Initial code taken from Facets gem by Rubyworks
|
4
|
-
# https://github.com/rubyworks/facets/blob/master/lib/core/facets/string/snakecase.rb
|
5
|
-
|
6
|
-
module RubyLokaliseApi
|
7
|
-
module Utils
|
8
|
-
module StringUtils
|
9
|
-
refine String do
|
10
|
-
# Underscore a string such that camelcase, dashes and spaces are
|
11
|
-
# replaced by underscores.
|
12
|
-
def snakecase
|
13
|
-
base_class_name.
|
14
|
-
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
15
|
-
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
16
|
-
tr('-', '_').
|
17
|
-
gsub(/\s/, '_').
|
18
|
-
gsub(/__+/, '_').
|
19
|
-
downcase
|
20
|
-
end
|
21
|
-
|
22
|
-
# Turn `Module::Nested::ClassName` to just `ClassName`
|
23
|
-
def base_class_name
|
24
|
-
split('::').last
|
25
|
-
end
|
26
|
-
|
27
|
-
def remove_trailing_slash
|
28
|
-
delete_suffix '/'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|