lingotek-client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/VERSION +1 -0
- data/lib/VERSION +1 -0
- data/lib/lingotek-client/api.rb +58 -0
- data/lib/lingotek-client/api_schema.rb +178 -0
- data/lib/lingotek-client/schema.rb +37 -0
- data/lib/lingotek-client/version.rb +3 -0
- data/lib/lingotek-client.rb +5 -0
- data/update_schema/table.html +1481 -0
- data/update_schema/test +357 -0
- data/update_schema/update_schema +52 -0
- metadata +109 -0
data/LICENSE
ADDED
File without changes
|
data/README.md
ADDED
File without changes
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
require_relative './schema'
|
5
|
+
|
6
|
+
module LingotekClient
|
7
|
+
class Api
|
8
|
+
|
9
|
+
def initialize(url, key, secret, external_id)
|
10
|
+
@url = URI.parse(url)
|
11
|
+
@key = key
|
12
|
+
@secret = secret
|
13
|
+
@external_id = external_id
|
14
|
+
generate_token
|
15
|
+
RestClient.reset_before_execution_procs
|
16
|
+
RestClient.add_before_execution_proc do |req, params|
|
17
|
+
@access_token.sign! req
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(method, *args, &block)
|
22
|
+
inputs = args.first || {}
|
23
|
+
|
24
|
+
LingotekClient::Schema.validate!(method, inputs.keys )
|
25
|
+
# retrive the file params
|
26
|
+
file_upload_params = inputs.select { |k,v| v.is_a? File }
|
27
|
+
inputs.delete_if { |k,v| v.is_a? File }
|
28
|
+
post(method, inputs, file_upload_params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_token
|
32
|
+
consumer = OAuth::Consumer.new(@key, @secret, site: site, :request_token_path => "", :authorize_path => "", :access_token_path => "", :http_method => :post)
|
33
|
+
@access_token = OAuth::AccessToken.new(consumer)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
|
39
|
+
def post(method, params = {}, file_upload_params = {})
|
40
|
+
params[:externalId] ||= @external_id
|
41
|
+
RestClient.post(url_path(method, params), file_upload_params)
|
42
|
+
end
|
43
|
+
|
44
|
+
def url_path(method, params)
|
45
|
+
"#{site}#{@url.path}#{method}?#{URI.encode_www_form(params)}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def site
|
49
|
+
"#{@url.scheme}://#{@url.host}:#{@url.port}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# client = LingotekClient::Api.new('http://10.0.11.152:8080/lingopoint/api/4/', 'test', 'test123', 'shane@lingotek.com')
|
56
|
+
# puts client.listLanguageSkills
|
57
|
+
# puts client.listAssignedProjects
|
58
|
+
|
@@ -0,0 +1,178 @@
|
|
1
|
+
module APISchema
|
2
|
+
def schema
|
3
|
+
{
|
4
|
+
acceptExternalInvite: { required: [:invite_id], optional: []},
|
5
|
+
addCommunityDictionaryEntry: { required: [:type, :entry], optional: []},
|
6
|
+
addCompany: { required: [:companyName], optional: []},
|
7
|
+
addContact: { required: [:userEmail], optional: [:comment]},
|
8
|
+
addContentDocument: { required: [:projectId, :content, :documentName, :sourceLanguage, :tmVaultId, :format], optional: [:documentDesc, :note, :srxFileContents, :itsFileContents, :fprmFileContents, :secondaryFilter, :secondaryFprmFileContents, :placeholderMode, :priority]},
|
9
|
+
addDocument: { required: [:projectId, :file, :documentName, :format, :encoding, :sourceLanguage, :tmVaultId], optional: [:tmTarget, :zipFile, :note, :srxFile, :itsFile, :fprmFile, :secondaryFilter, :secondaryFprmFile, :placeholderMode, :priority]},
|
10
|
+
addDocumentURL: { required: [:projectId, :url, :sourceLanguage, :tmVaultId], optional: [:format, :target, :tmTarget, :template, :depth, :srxFile, :itsFile, :fprmFile, :secondaryFilter, :secondaryFprmFile, :placeholderMode, :priority]},
|
11
|
+
addDocumentWithTargets: { required: [:projectId, :file, :applyWorkflow, :documentName, :format, :encoding, :phaseTemplateId, :sourceLanguage, :tmVaultId], optional: [:targetLanguage, :targetAsJSON, :tmTarget, :zipFile]},
|
12
|
+
addGlossary: { required: [:glossaryName, :asTerminology], optional: []},
|
13
|
+
addLabel: { required: [:name], optional: [:status]},
|
14
|
+
addPhase: { required: [:translationTargetId, :phaseName], optional: [:phaseDescription, :isCommunityAccess, :isSelfAssigned]},
|
15
|
+
addPhaseTemplate: { required: [:phaseTemplateName], optional: [], is_deprecated: true},
|
16
|
+
addPhaseToTemplate: { required: [:phaseTemplateId, :phaseName], optional: [:phaseDescription, :isCommunityAccess, :isSelfAssigned], is_deprecated: true},
|
17
|
+
addPreference: { required: [:key], optional: [:value]},
|
18
|
+
addProject: { required: [:projectName], optional: [:projectDueDate, :companyId, :workflowId, :searchPublic]},
|
19
|
+
addProjectDictionary: { required: [:project_id, :dictionary_id], optional: []},
|
20
|
+
addProjectMT: { required: [:project_id, :mt_engine_name], optional: []},
|
21
|
+
addProjectTMVault: { required: [:tmVaultName, :project_id, :index_id], optional: [:isPublic]},
|
22
|
+
addSegmentLabelTemplate: { required: [:segmentLabelTemplateName], optional: [:segmentLabels]},
|
23
|
+
addSegmentLabelToTemplate: { required: [:segmentLabelTemplateName, :segmentLabels], optional: []},
|
24
|
+
addTeam: { required: [:name], optional: [:description, :image]},
|
25
|
+
addTeamLead: { required: [:teamId, :clientId], optional: []},
|
26
|
+
addTeamMember: { required: [:teamId, :clientId], optional: []},
|
27
|
+
addTMVault: { required: [:tmVaultName], optional: [:isPublic]},
|
28
|
+
addTranslationTarget: { required: [:documentId, :applyWorkflow, :targetLanguage], optional: []},
|
29
|
+
analyzeDocument: { required: [:documentId], optional: []},
|
30
|
+
analyzeProject: { required: [:projectId], optional: [:documentId]},
|
31
|
+
applyPhaseTemplate: { required: [:translationTargetId, :phaseTemplateId], optional: [], is_deprecated: true},
|
32
|
+
applySegmentLabelTemplate: { required: [:documentId, :segmentLabelTemplateName], optional: []},
|
33
|
+
assignPhaseTranslator: { required: [:phaseId, :translatorUserId], optional: []},
|
34
|
+
assignProjectManager: { required: [:projectId], optional: [:managerLoginName, :managerUserId]},
|
35
|
+
assignSelf: { required: [:phaseId], optional: []},
|
36
|
+
backgroundJobProgress: { required: [:queueId], optional: [], is_deprecated: true},
|
37
|
+
declineExternalInvite: { required: [:invite_id, :phase], optional: []},
|
38
|
+
dismissPhaseTranslator: { required: [:phaseId, :translatorUserId], optional: []},
|
39
|
+
dismissProjectManager: { required: [:projectId, :managerUserId], optional: []},
|
40
|
+
documentSegments: { required: [:documentId], optional: []},
|
41
|
+
downloadDocument: { required: [:documentId, :targetLanguage], optional: [:useSource, :useAttributions]},
|
42
|
+
downloadDocumentAsCSV: { required: [:documentId, :targetLanguage], optional: []},
|
43
|
+
downloadDocumentAsSkeleton: { required: [:documentId], optional: []},
|
44
|
+
downloadDocumentAsTMX: { required: [:documentId], optional: [:targetLanguage]},
|
45
|
+
downloadDocumentAsXliff: { required: [:documentId], optional: [:targetLanguage]},
|
46
|
+
downloadDocumentContent: { required: [:documentId, :targetLanguage], optional: []},
|
47
|
+
downloadExport: { required: [:resourceType, :exportId], optional: []},
|
48
|
+
downloadGlossaryAsCSV: { required: [:glossaryId, :sourceLanguage], optional: [:targetLanguage], is_deprecated: true},
|
49
|
+
downloadGlossaryAsTBX: { required: [:glossaryId, :sourceLanguage], optional: [:targetLanguage], is_deprecated: true},
|
50
|
+
downloadTMVaultAsTMX: { required: [:tmVaultId, :sourceLanguage], optional: [:targetLanguage], is_deprecated: true},
|
51
|
+
downloadTMVaultAsXliff: { required: [:tmVaultId, :sourceLanguage], optional: [:targetLanguage], is_deprecated: true},
|
52
|
+
editClientCommunityPreference: { required: [:key, :value], optional: []},
|
53
|
+
editCompany: { required: [:companyId], optional: [:companyName]},
|
54
|
+
editContact: { required: [:contactId], optional: [:comment]},
|
55
|
+
editDocument: { required: [:documentId], optional: [:documentName, :tmVaultId]},
|
56
|
+
editDocumentSetting: { required: [:documentId, :type, :key, :value], optional: []},
|
57
|
+
editGlossary: { required: [:glossaryId], optional: [:glossaryName]},
|
58
|
+
editLabel: { required: [:id], optional: [:name, :status, :order, :offset, :move_to_label, :show_percent_complete]},
|
59
|
+
editPhase: { required: [:phaseId], optional: [:phaseName, :phaseDescription, :isCommunityAccess, :isSelfAssigned]},
|
60
|
+
editPhaseTemplate: { required: [:phaseTemplateId], optional: [:phaseTemplateName], is_deprecated: true},
|
61
|
+
editPreference: { required: [:key, :value], optional: []},
|
62
|
+
editProject: { required: [:projectId], optional: [:projectName, :projectDueDate, :companyId, :searchPublic]},
|
63
|
+
editProjectSetting: { required: [:projectId, :type, :key, :value], optional: []},
|
64
|
+
editSegmentLabelTemplate: { required: [:segmentLabelTemplateName], optional: []},
|
65
|
+
editTMVault: { required: [:tmVaultId], optional: [:tmVaultName, :isPublic]},
|
66
|
+
editTranslationTarget: { required: [:translationTargetId], optional: []},
|
67
|
+
exportResource: { required: [:resourceType, :resourceId, :format, :targetLanguages, :sourceLanguage], optional: []},
|
68
|
+
findLabel: { required: [:name, :limit], optional: []},
|
69
|
+
findTM: { required: [:tmVaultId, :sourceLang, :targetLang], optional: [:searchText, :startDate, :endDate]},
|
70
|
+
flushDocumentProgress: { required: [:documentId], optional: []},
|
71
|
+
getClientCommunityPreference: { required: [:key], optional: []},
|
72
|
+
getCMSKey: { required: [], optional: []},
|
73
|
+
getCommunityDictionary: { required: [:type], optional: []},
|
74
|
+
getCommunityPreference: { required: [:key, :type], optional: []},
|
75
|
+
getCompany: { required: [:companyId], optional: []},
|
76
|
+
getContact: { required: [:contactId], optional: []},
|
77
|
+
getDashboardLink: { required: [], optional: []},
|
78
|
+
getDocument: { required: [:documentId], optional: []},
|
79
|
+
getDocumentProgress: { required: [:documentId], optional: []},
|
80
|
+
getDocumentSetting: { required: [:documentId, :type, :key], optional: []},
|
81
|
+
getExternalInvites: { required: [:invite_id], optional: []},
|
82
|
+
getGlossary: { required: [:glossaryId], optional: []},
|
83
|
+
getLabel: { required: [], optional: [:id, :name]},
|
84
|
+
getPhase: { required: [:phaseId], optional: []},
|
85
|
+
getPhaseTemplate: { required: [:phaseTemplateId], optional: [], is_deprecated: true},
|
86
|
+
getPreference: { required: [:key], optional: []},
|
87
|
+
getPriorityJobWorkbenchLink: { required: [], optional: []},
|
88
|
+
getProject: { required: [:projectId], optional: []},
|
89
|
+
getProjectSetting: { required: [:projectId, :type, :key], optional: []},
|
90
|
+
getSegmentLabelTemplate: { required: [:segmentLabelTemplateName], optional: []},
|
91
|
+
getTMVault: { required: [:tmVaultId], optional: []},
|
92
|
+
getTranslationTarget: { required: [:translationTargetId], optional: []},
|
93
|
+
getUsers: { required: [:search, :limit, :community], optional: []},
|
94
|
+
getVaultLanguages: { required: [:tmVaultId], optional: []},
|
95
|
+
getWorkbenchLink: { required: [:documentId, :phaseId, :invite_id, :embedded], optional: [:redirectURL]},
|
96
|
+
ignoreSegment: { required: [:segmentId, :documentId], optional: []},
|
97
|
+
importCommunityDictionary: { required: [:type, :file, :delimiter], optional: []},
|
98
|
+
joinTeam: { required: [:teamId], optional: []},
|
99
|
+
leaveTeam: { required: [:teamId], optional: []},
|
100
|
+
listAssignedProjects: { required: [], optional: []},
|
101
|
+
listCommunities: { required: [], optional: []},
|
102
|
+
listCompanies: { required: [], optional: []},
|
103
|
+
listContacts: { required: [], optional: []},
|
104
|
+
listDefaultPhaseTemplates: { required: [], optional: [], is_deprecated: true},
|
105
|
+
listDocuments: { required: [:documentId], optional: []},
|
106
|
+
listDocumentSegmentLabels: { required: [:documentId], optional: []},
|
107
|
+
listDocumentSegments: { required: [:documentId], optional: []},
|
108
|
+
listDocumentTranslationSegments: { required: [:documentId, :targetLanguage], optional: []},
|
109
|
+
listGlossaries: { required: [], optional: []},
|
110
|
+
listJobs: { required: [], optional: []},
|
111
|
+
listLabels: { required: [], optional: []},
|
112
|
+
listLanguages: { required: [], optional: [:language]},
|
113
|
+
listLanguageSkills: { required: [], optional: []},
|
114
|
+
listLeaderboardRange: { required: [], optional: [:teamName, :startDate, :endDate]},
|
115
|
+
listLeaderboardResults: { required: [], optional: [:teamName, :maxResults]},
|
116
|
+
listPhases: { required: [:translationTargetId], optional: []},
|
117
|
+
listPhaseTemplates: { required: [], optional: [], is_deprecated: true},
|
118
|
+
listProjects: { required: [], optional: []},
|
119
|
+
listSegmentLabelTemplates: { required: [], optional: []},
|
120
|
+
listTeamMembers: { required: [:teamId], optional: []},
|
121
|
+
listTeams: { required: [], optional: []},
|
122
|
+
listTMDocuments: { required: [:tmVaultId], optional: []},
|
123
|
+
listTMVaults: { required: [], optional: []},
|
124
|
+
listTranslationTargets: { required: [:documentId], optional: []},
|
125
|
+
listUserStats: { required: [], optional: []},
|
126
|
+
listWorkflows: { required: [], optional: []},
|
127
|
+
machineTranslateDocument: { required: [:documentId, :engineId, :phaseId], optional: []},
|
128
|
+
markPhaseComplete: { required: [:phaseId], optional: []},
|
129
|
+
MTSegments: { required: [:documentId, :json], optional: []},
|
130
|
+
pollClientReport: { required: [:report_name], optional: []},
|
131
|
+
pollDocumentAnalysis: { required: [:documentId], optional: []},
|
132
|
+
pollDocumentImport: { required: [:documentId], optional: []},
|
133
|
+
pollGlossaryImport: { required: [:glossaryUploadId], optional: []},
|
134
|
+
pollProjectAnalysis: { required: [:projectId], optional: []},
|
135
|
+
pollTMVaultImport: { required: [:tmVaultUploadId], optional: []},
|
136
|
+
prefillDocument: { required: [:phaseId, :tmVaultId, :tmVaultThreshold, :lockTMVault, :lockTerminology, :overwrite, :completePhase], optional: []},
|
137
|
+
regardSegment: { required: [:segmentId, :documentId], optional: []},
|
138
|
+
removeClientCommunityPreference: { required: [:key], optional: []},
|
139
|
+
removeCommunityDictionaryEntry: { required: [:type, :entry], optional: []},
|
140
|
+
removeCompany: { required: [:companyId], optional: []},
|
141
|
+
removeContact: { required: [:contactId], optional: []},
|
142
|
+
removeDocument: { required: [:documentId], optional: []},
|
143
|
+
removeGlossary: { required: [:glossaryId], optional: []},
|
144
|
+
removeLabel: { required: [:id], optional: []},
|
145
|
+
removePhase: { required: [:phaseId], optional: []},
|
146
|
+
removePhaseFromTemplate: { required: [:phaseTemplateId, :phaseParameterSetId], optional: []},
|
147
|
+
removePhaseTemplate: { required: [:phaseTemplateId], optional: [], is_deprecated: true},
|
148
|
+
removePreference: { required: [:key], optional: []},
|
149
|
+
removeProject: { required: [:projectId], optional: []},
|
150
|
+
removeSegmentLabelFromTemplate: { required: [:segmentLabelTemplateName, :segmentLabels], optional: []},
|
151
|
+
removeSegmentLabelTemplate: { required: [:segmentLabelTemplateName], optional: []},
|
152
|
+
removeTeam: { required: [:teamId], optional: []},
|
153
|
+
removeTeamLead: { required: [:teamId, :clientId], optional: []},
|
154
|
+
removeTeamMember: { required: [:teamId, :clientId], optional: []},
|
155
|
+
removeTM: { required: [:tmVaultId, :tid], optional: []},
|
156
|
+
removeTMVault: { required: [:tmVaultId], optional: []},
|
157
|
+
removeTranslationTarget: { required: [:translationTargetId], optional: []},
|
158
|
+
removeUploadedTMFromVault: { required: [:id], optional: []},
|
159
|
+
saveLabelTemplate: { required: [:name], optional: [:labels]},
|
160
|
+
saveSegment: { required: [:sourceText, :targetText, :targetLanguage, :documentId, :overwrite], optional: []},
|
161
|
+
searchGlossary: { required: [:glossaryId, :text, :sourceLanguage, :targetLanguage], optional: [:count]},
|
162
|
+
setCommunityConcurrentUsers: { required: [:community, :users], optional: []},
|
163
|
+
setProfileAttributes: { required: [], optional: [:name, :email, :login_id, :phone, :company, :native_language, :location, :notes, :on_leaderboard, :oldpword, :newpword, :source, :old_source, :target, :old_target, :experience, :rate, :rush_rate, :currency, :per, :service_note, :notifications_project_complete, :notifications_assigned_document, :notifications_available_community_document, :notifications_phase_ready]},
|
164
|
+
translatorsForLanguage: { required: [:sourceLang, :targetLang], optional: []},
|
165
|
+
updateContentDocument: { required: [:documentId, :content], optional: [:srxFileContents, :itsFileContents, :fprmFileContents, :secondaryFprmFileContents]},
|
166
|
+
updateDocument: { required: [:documentId, :file], optional: []},
|
167
|
+
updateTM: { required: [:tmVaultId, :tid, :translation], optional: []},
|
168
|
+
uploadCSVToGlossary: { required: [:glossaryId, :file], optional: [:delimiter]},
|
169
|
+
uploadTBXToGlossary: { required: [:glossaryId, :file], optional: []},
|
170
|
+
uploadTMXToTMVault: { required: [:tmVaultId, :file, :name], optional: []},
|
171
|
+
uploadXliffToTMVault: { required: [:tmVaultId, :file, :name], optional: []},
|
172
|
+
uploadXLSToGlossary: { required: [:glossaryId, :file], optional: []},
|
173
|
+
userState: { required: [:clientId], optional: []},
|
174
|
+
allowLocalLogin: { required: [:password], optional: []},
|
175
|
+
validateCredentials: { required: [:password], optional: []},
|
176
|
+
}
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './api_schema'
|
3
|
+
|
4
|
+
module LingotekClient
|
5
|
+
class Schema
|
6
|
+
class << self
|
7
|
+
include APISchema
|
8
|
+
|
9
|
+
def validate!(method, inputs)
|
10
|
+
m = method.to_sym
|
11
|
+
validate_method!(m) && validate_required_input!(m, inputs) && validate_invalid_input!(m, inputs)
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid_methods
|
15
|
+
schema.map{ |k,v| k }
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_method!(m)
|
19
|
+
throw Exception.new "'#{m}' invalid method" unless valid_methods.include?(m)
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate_invalid_input!(m, inputs)
|
24
|
+
invalid_input = inputs - (schema[m][:required] + schema[m][:optional])
|
25
|
+
throw Exception.new "'#{invalid_input.join(',')}' invalid input" unless invalid_input.empty?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_required_input!(m, inputs)
|
30
|
+
missing_required = schema[m][:required] - inputs.map{ |i| i.to_sym }
|
31
|
+
throw Exception.new "'#{missing_required.join(',')}' required input" unless missing_required.empty?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|