Class: Crowdin::Client

Inherits:
Object
  • Object
show all
Includes:
ApiResources::Languages, ApiResources::Projects, ApiResources::SourceFiles, ApiResources::Storages, ApiResources::TranslationStatus, ApiResources::Translations
Defined in:
lib/crowdin-api/client/client.rb,
lib/crowdin-api/client/version.rb

Constant Summary collapse

VERSION =
'1.0.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ApiResources::Translations

#apply_pre_translation, #build_project_directory_translation, #build_project_file_translation, #build_project_translation, #cancel_build, #check_project_build_status, #download_project_translations, #export_project_translation, #list_project_builds, #pre_translation_status, #upload_translations

Methods included from ApiResources::TranslationStatus

#get_branch_progress, #get_directory_progress, #get_file_progress, #get_language_progress, #get_project_progress, #get_qa_progress

Methods included from ApiResources::Storages

#add_storage, #delete_storage, #get_storage, #list_storages

Methods included from ApiResources::SourceFiles

#add_branch, #add_directory, #add_file, #delete_branch, #delete_directory, #delete_file, #download_file, #edit_branch, #edit_directory, #edit_file, #get_branch, #get_directory, #get_file, #get_file_revision, #list_branches, #list_directories, #list_file_revisions, #list_files, #update_or_restore_file

Methods included from ApiResources::Projects

#add_group, #add_project, #delete_group, #delete_project, #edit_group, #edit_project, #get_group, #get_project, #list_groups, #list_projects

Methods included from ApiResources::Languages

#add_custom_language, #delete_custom_language, #edit_custom_language, #get_language, #list_languages

Constructor Details

#initialize {|config| ... } ⇒ Client

Returns a new instance of Client.

Yields:

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/crowdin-api/client/client.rb', line 32

def initialize
  raise ArgumentError, 'block with configurations not given' unless block_given?

  @config = Crowdin::Configuration.new
  yield config

  check_logger

  set_rest_client_proxy!

  build_options
  build_connection
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



28
29
30
# File 'lib/crowdin-api/client/client.rb', line 28

def config
  @config
end

#connectionObject (readonly)

Returns the value of attribute connection.



30
31
32
# File 'lib/crowdin-api/client/client.rb', line 30

def connection
  @connection
end

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/crowdin-api/client/client.rb', line 29

def options
  @options
end

Instance Method Details

#log!(message) ⇒ Object



46
47
48
49
50
# File 'lib/crowdin-api/client/client.rb', line 46

def log!(message)
  return true unless config.logger_enabled?

  logger.debug(message)
end

#logger=(logger) ⇒ Object



52
53
54
55
# File 'lib/crowdin-api/client/client.rb', line 52

def logger=(logger)
  @logger = logger
  config.enable_logger = true
end