Class: Crowdin::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/crowdin-api/client/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
# File 'lib/crowdin-api/client/configuration.rb', line 15

def initialize
  @target_api_url = '/api/v2'
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



5
6
7
# File 'lib/crowdin-api/client/configuration.rb', line 5

def api_token
  @api_token
end

#enable_loggerObject Also known as: logger_enabled?

Returns the value of attribute enable_logger.



10
11
12
# File 'lib/crowdin-api/client/configuration.rb', line 10

def enable_logger
  @enable_logger
end

#organization_domainObject

Returns the value of attribute organization_domain.



7
8
9
# File 'lib/crowdin-api/client/configuration.rb', line 7

def organization_domain
  @organization_domain
end

#project_idObject

Returns the value of attribute project_id.



6
7
8
# File 'lib/crowdin-api/client/configuration.rb', line 6

def project_id
  @project_id
end

#request_timeoutObject

Returns the value of attribute request_timeout.



8
9
10
# File 'lib/crowdin-api/client/configuration.rb', line 8

def request_timeout
  @request_timeout
end

#target_api_urlObject (readonly)

Returns the value of attribute target_api_url.



13
14
15
# File 'lib/crowdin-api/client/configuration.rb', line 13

def target_api_url
  @target_api_url
end

Instance Method Details

#base_urlObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/crowdin-api/client/configuration.rb', line 36

def base_url
  @base_url ||=
    if !!organization_domain
      if organization_domain.include?('.com')
        "https://#{organization_domain}"
      else
        "https://#{organization_domain}.api.crowdin.com"
      end
    else
      'https://api.crowdin.com'
    end
end

#headersObject



27
28
29
30
31
32
33
34
# File 'lib/crowdin-api/client/configuration.rb', line 27

def headers
  {
    'Accept'        => 'application/json',
    'Authorization' => "Bearer #{api_token}",
    'Content-Type'  => 'application/json',
    'User-Agent'    => "crowdin-rb/#{Crowdin::Client::VERSION}/#{RUBY_VERSION}/#{RUBY_PLATFORM}"
  }
end

#optionsObject



19
20
21
22
23
24
25
# File 'lib/crowdin-api/client/configuration.rb', line 19

def options
  {
    headers: {},
    timeout: request_timeout,
    json:    true
  }
end