Class: RubyLokaliseApi::Client
- Inherits:
-
Object
- Object
- RubyLokaliseApi::Client
- Includes:
- Rest::Branches, Rest::Comments, Rest::Contributors, Rest::CustomTranslationStatuses, Rest::Files, Rest::Keys, Rest::Languages, Rest::Orders, Rest::PaymentCards, Rest::Projects, Rest::QueuedProcesses, Rest::Screenshots, Rest::Segments, Rest::Snapshots, Rest::Tasks, Rest::TeamUserBillingDetails, Rest::TeamUserGroups, Rest::TeamUsers, Rest::Teams, Rest::TranslationProviders, Rest::Translations, Rest::Webhooks
- Defined in:
- lib/ruby_lokalise_api/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#token_header ⇒ Object
readonly
Returns the value of attribute token_header.
Instance Method Summary collapse
-
#construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil) ⇒ Object
(also: #c_r)
rubocop:disable Metrics/ParameterLists Constructs request to perform the specified action.
-
#format_params(params, object_key) ⇒ Hash
Converts ‘params` to hash with arrays under the `object_key` key.
-
#initialize(token, params = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Rest::Webhooks
#create_webhook, #destroy_webhook, #regenerate_webhook_secret, #update_webhook, #webhook, #webhooks
Methods included from Rest::Translations
#translation, #translations, #update_translation
Methods included from Rest::TranslationProviders
#translation_provider, #translation_providers
Methods included from Rest::Teams
Methods included from Rest::TeamUsers
#destroy_team_user, #team_user, #team_users, #update_team_user
Methods included from Rest::TeamUserGroups
#add_projects_to_group, #add_users_to_group, #create_team_user_group, #destroy_team_user_group, #remove_projects_from_group, #remove_users_from_group, #team_user_group, #team_user_groups, #update_team_user_group
Methods included from Rest::TeamUserBillingDetails
#create_team_user_billing_details, #team_user_billing_details, #update_team_user_billing_details
Methods included from Rest::Tasks
#create_task, #destroy_task, #task, #tasks, #update_task
Methods included from Rest::Snapshots
#create_snapshot, #destroy_snapshot, #restore_snapshot, #snapshots
Methods included from Rest::Segments
#segment, #segments, #update_segment
Methods included from Rest::Screenshots
#create_screenshots, #destroy_screenshot, #screenshot, #screenshots, #update_screenshot
Methods included from Rest::QueuedProcesses
#queued_process, #queued_processes
Methods included from Rest::Projects
#create_project, #destroy_project, #empty_project, #project, #projects, #update_project
Methods included from Rest::PaymentCards
#create_payment_card, #destroy_payment_card, #payment_card, #payment_cards
Methods included from Rest::Orders
#create_order, #order, #orders
Methods included from Rest::Languages
#create_languages, #destroy_language, #language, #project_languages, #system_languages, #update_language
Methods included from Rest::Keys
#create_keys, #destroy_key, #destroy_keys, #key, #keys, #update_key, #update_keys
Methods included from Rest::Files
#destroy_file, #download_files, #files, #upload_file
Methods included from Rest::CustomTranslationStatuses
#create_translation_status, #destroy_translation_status, #translation_status, #translation_status_colors, #translation_statuses, #update_translation_status
Methods included from Rest::Contributors
#contributor, #contributors, #create_contributors, #destroy_contributor, #update_contributor
Methods included from Rest::Comments
#comment, #comments, #create_comments, #destroy_comment, #project_comments
Methods included from Rest::Branches
#branch, #branches, #create_branch, #destroy_branch, #merge_branch, #update_branch
Constructor Details
#initialize(token, params = {}) ⇒ Client
Returns a new instance of Client.
31 32 33 34 35 36 |
# File 'lib/ruby_lokalise_api/client.rb', line 31 def initialize(token, params = {}) @token = token @timeout = params.fetch(:timeout, nil) @open_timeout = params.fetch(:open_timeout, nil) @token_header = 'x-api-token' end |
Instance Attribute Details
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
29 30 31 |
# File 'lib/ruby_lokalise_api/client.rb', line 29 def open_timeout @open_timeout end |
#timeout ⇒ Object
Returns the value of attribute timeout.
29 30 31 |
# File 'lib/ruby_lokalise_api/client.rb', line 29 def timeout @timeout end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
28 29 30 |
# File 'lib/ruby_lokalise_api/client.rb', line 28 def token @token end |
#token_header ⇒ Object (readonly)
Returns the value of attribute token_header.
28 29 30 |
# File 'lib/ruby_lokalise_api/client.rb', line 28 def token_header @token_header end |
Instance Method Details
#construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil) ⇒ Object Also known as: c_r
rubocop:disable Metrics/ParameterLists Constructs request to perform the specified action
46 47 48 49 50 51 |
# File 'lib/ruby_lokalise_api/client.rb', line 46 def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil) path = klass.endpoint(*endpoint_ids) formatted_params = format_params(params, object_key) formatted_params[:_initial_path] = klass.endpoint(*initial_ids) if initial_ids klass.send method, self, path, formatted_params end |
#format_params(params, object_key) ⇒ Hash
Converts ‘params` to hash with arrays under the `object_key` key. Used in bulk operations
58 59 60 61 62 63 |
# File 'lib/ruby_lokalise_api/client.rb', line 58 def format_params(params, object_key) return params unless object_key params = [params] unless params.is_a?(Array) {object_key => params} end |