Class: LingotekCli::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/lingotek-cli/client.rb

Class Method Summary collapse

Class Method Details

.addDocumentWithTargets(id, file_path, format, src_lang, doc_name, vaultId, target_lang, apply_workflow) ⇒ Object



27
28
29
30
31
# File 'lib/lingotek-cli/client.rb', line 27

def addDocumentWithTargets(id, file_path, format, src_lang, doc_name, vaultId, target_lang, apply_workflow)
  file = File.new(file_path)
  api.addDocumentWithTargets(projectId: id, file: file, encoding: file.external_encoding.to_s, format: format, sourceLanguage: src_lang, documentName: doc_name, tmVaultId: vaultId, targetLanguage: target_lang, applyWorkflow: apply_workflow)

end

.addGlossary(name) ⇒ Object



71
72
73
# File 'lib/lingotek-cli/client.rb', line 71

def addGlossary(name)
  api.addGlossary(glossaryName: name, asTerminology: true)
end

.addProject(opts) ⇒ Object



78
79
80
# File 'lib/lingotek-cli/client.rb', line 78

def addProject(opts)
  api.addProject(opts)
end

.addProjectTMVault(id, vault_id, is_public) ⇒ Object



74
75
76
# File 'lib/lingotek-cli/client.rb', line 74

def addProjectTMVault(id, vault_id, is_public)
   api.addProjectTMVault(project_id: id, index_id: vault_id, isPublic: is_public)
end

.addTMVault(vault_name, is_public) ⇒ Object



39
40
41
# File 'lib/lingotek-cli/client.rb', line 39

def addTMVault(vault_name, is_public)
  api.addTMVault(tmVaultName: vault_name, isPublic: is_public)
end

.allowLocalLogin(password, external_id) ⇒ Object



90
91
92
# File 'lib/lingotek-cli/client.rb', line 90

def allowLocalLogin(password, external_id)
  api.allowLocalLogin(password: password, externalId: external_id)
end

.analyzeProject(id, report, vaults) ⇒ Object



33
34
35
36
37
# File 'lib/lingotek-cli/client.rb', line 33

def analyzeProject(id, report, vaults)
  vaults ||= ''
  api.analyzeProject(projectId: id, reportName: report, tmVaultId: vaults.split(','), projectDocuments: true)

end

.apiObject



94
95
96
# File 'lib/lingotek-cli/client.rb', line 94

def api
  @api_conn ||= LingotekClient::Api.new(config['api']['url'], config['oauth']['key'], config['oauth']['secret'], config['api']['external_id'])
end

.configObject



98
99
100
101
102
# File 'lib/lingotek-cli/client.rb', line 98

def config
  FileUtils.mkdir_p(HOME_CONFIG) unless Dir.exists?(HOME_CONFIG)
  FileUtils.touch(SETTINGS_CONFIG) unless File.exists?(SETTINGS_CONFIG)
  @config ||= ParseConfig.new(SETTINGS_CONFIG)
end

.getAnalysis(group) ⇒ Object



51
52
53
# File 'lib/lingotek-cli/client.rb', line 51

def getAnalysis(group)
  api.getAnalysis group: group
end

.listProjectsObject



55
56
57
# File 'lib/lingotek-cli/client.rb', line 55

def listProjects
  api.listProjects
end

.oauth(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lingotek-cli/client.rb', line 13

def oauth( opts = {} )
  key = opts[:key]
  secret = opts[:secret]
  url = opts[:url]
  external_id = opts[:external_id]

  config.add_to_group('oauth', 'key', key) if key
  config.add_to_group('oauth', 'secret', secret) if secret
  config.add_to_group('api', 'url', url) if url
  config.add_to_group('api', 'external_id', external_id) if external_id
  save_config
end

.removeProject(id) ⇒ Object



82
83
84
# File 'lib/lingotek-cli/client.rb', line 82

def removeProject(id)
  api.removeProject projectId: id
end

.save_configObject



104
105
106
107
108
# File 'lib/lingotek-cli/client.rb', line 104

def save_config
  File.open(SETTINGS_CONFIG, 'w') do |f|
    config.write(f)
  end
end

.uploadCSVToGlossary(id, file_path) ⇒ Object



63
64
65
# File 'lib/lingotek-cli/client.rb', line 63

def uploadCSVToGlossary(id, file_path)
  api.uploadCSVToGlossary(glossaryId: id, file: File.new(file_path))
end

.uploadTBXToGlossary(id, file_path) ⇒ Object



67
68
69
# File 'lib/lingotek-cli/client.rb', line 67

def uploadTBXToGlossary(id, file_path)
  api.uploadTBXToGlossary(glossaryId: id, file: File.new(file_path))
end

.uploadTMXToTMVault(id, file_path, name) ⇒ Object



43
44
45
# File 'lib/lingotek-cli/client.rb', line 43

def uploadTMXToTMVault(id, file_path, name)
  api.uploadTMXToTMVault(tmVaultId: id, file: File.new(file_path), name: name)
end

.uploadXliffToTMVault(id, file_path, name) ⇒ Object



47
48
49
# File 'lib/lingotek-cli/client.rb', line 47

def uploadXliffToTMVault(id, file_path, name)
  api.uploadXliffToTMVault(tmVaultId: id, file: File.new(file_path), name: name)
end

.uploadXLSToGlossary(id, file_path) ⇒ Object



59
60
61
# File 'lib/lingotek-cli/client.rb', line 59

def uploadXLSToGlossary(id, file_path)
  api.uploadXLSToGlossary(glossaryId: id, file: File.new(file_path))
end

.validateCredentials(password, external_id) ⇒ Object



86
87
88
# File 'lib/lingotek-cli/client.rb', line 86

def validateCredentials(password, external_id)
  api.validateCredentials(password: password, externalId: external_id)
end