Sha256: 9a7bc669036f7427e18733fe6ddd217c28b0b981a58cdcf43249de1561351ffa

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require 'ruby-lokalise-api/rest/languages'
require 'ruby-lokalise-api/rest/teams'
require 'ruby-lokalise-api/rest/projects'
require 'ruby-lokalise-api/rest/comments'
require 'ruby-lokalise-api/rest/keys'
require 'ruby-lokalise-api/rest/contributors'
require 'ruby-lokalise-api/rest/files'
require 'ruby-lokalise-api/rest/translations'
require 'ruby-lokalise-api/rest/team_users'
require 'ruby-lokalise-api/rest/tasks'
require 'ruby-lokalise-api/rest/snapshots'
require 'ruby-lokalise-api/rest/screenshots'
require 'ruby-lokalise-api/rest/orders'
require 'ruby-lokalise-api/rest/payment_cards'
require 'ruby-lokalise-api/rest/translation_providers'
require 'ruby-lokalise-api/rest/team_user_group'
require 'ruby-lokalise-api/rest/custom_translation_statuses'

module Lokalise
  class Client
    attr_reader :token

    def initialize(token)
      @token = token
    end

    def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil)
      path = klass.endpoint(*endpoint_ids)
      klass.send method, self, path, format_params(params, object_key)
    end

    # Converts `params` to hash with arrays under the `object_key` key.
    # Used in bulk operations
    #
    # @return [Hash]
    def format_params(params, object_key)
      return params unless object_key

      params = [params] unless params.is_a?(Array)
      Hash[object_key, params]
    end

    alias c_r construct_request
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-lokalise-api-2.4.0 lib/ruby-lokalise-api/client.rb
ruby-lokalise-api-2.3.0 lib/ruby-lokalise-api/client.rb