class QordobaRubySdk

Constants

BASE

API

CONSUMER_KEY_ERROR

ERROR MESSAGES

COUNTRIES
FILE_BULK1
FILE_BULK2
FILE_EXPORT
FILE_IDS_ERROR
FILE_ID_ERROR
FILE_JSON
FILE_LISTFILES

FILES

FILE_SEGMENT
FILE_SEGMENTS
FILE_TYPES
FILE_UPDATE
FILE_UPLOAD
LANGUAGES
LANGUAGE_ID_ERROR
MILESTONE_ID_ERROR
ORGANIZATION_ID_ERROR
ORG_TEAM

ORGANIZATION

PATH_TO_FILE_ERROR
PING
PROJECT_ID_ERROR
PROJ_DETAIL
PROJ_LIST

PROJECTS

PROJ_STATUS
PROJ_WORKFLOW
SEGMENT_ID_ERROR
TM_ADD_SEGMENT
TM_DELETE_SEGMENT
TM_LIST

TM

TM_SEGMENTS
TM_SHOW
TM_UPDATE_SEGMENT
TM_UPLOAD
VERSION
VERSION_TAG_ERROR

Public Class Methods

new(consumerKey, organizationId, projectId) click to toggle source
Initialize App ==============
# File lib/qordoba_ruby_sdk.rb, line 59
def initialize(consumerKey, organizationId, projectId)
  _validate({ 
    :consumerKey => consumerKey, 
    :organizationId => organizationId, 
    :projectId => projectId
  })

  @consumerKey = consumerKey
  @organizationId = organizationId
  @projectId = projectId

end

Public Instance Methods

_clean(response) click to toggle source
Parse JSON ================
# File lib/qordoba_ruby_sdk.rb, line 105
def _clean(response)
  if response.is_a?(String)
    JSON.parse(response)
  else
    response
  end
end
_validate(hash) click to toggle source
Validate User Inputs ============
# File lib/qordoba_ruby_sdk.rb, line 74
def _validate(hash)
  keys = hash.keys

  keys.each do |key|
    value = hash[key]
    if key == :consumerKey
      raise CONSUMER_KEY_ERROR unless value.kind_of?(String) && value.length == 32 
    elsif key == :organizationId
      raise ORGANIZATION_ID_ERROR unless value.is_a?(Integer) && value.to_s.length == 4
    elsif key == :projectId
      raise PROJECT_ID_ERROR unless value.is_a?(Integer) && value.to_s.length == 4
    elsif key == :languageId
      raise LANGUAGE_ID_ERROR unless value.is_a?(Integer) && value.to_s.length <= 3
    elsif key == :versionTag
      raise VERSION_TAG_ERROR unless value.is_a?(String)
    elsif key == :fileIds
      raise FILE_IDS_ERROR unless value.is_a?(Array) || value.is_a?(Integer)
    elsif key == :fileId
      raise FILE_ID_ERROR unless value.is_a?(Integer)
    elsif key == :segmentId
      raise SEGMENT_ID_ERROR unless value.is_a?(Integer)
    elsif key == :milestoneId
      raise MILESTONE_ID_ERROR unless value.is_a?(Integer) && value.to_s.length == 4
    elsif key == :pathToFile
      raise PATH_TO_FILE_ERROR unless File.exist?(value)
    end
  end
end
countries() click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 126
def countries
  _clean(RestClient.get "#{BASE}/#{COUNTRIES}", 
    { :consumerKey => @consumerKey })
end
file_export(languageId, fileIds) click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 194
def file_export(languageId, fileIds)
  if fileIds.is_a?(Array)
    fileIds = fileIds.join(',')
  end

  _clean(RestClient.post "#{BASE}/#{FILE_EXPORT}", {}.to_json,
    {
      :consumerKey => @consumerKey,
      :projectId => @projectId,
      :fileIds => fileIds,
      :targetLanguageIds => languageId,
      "content-type" => "application/json"
    })
end
file_json(languageId, milestoneId, fileId) click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 239
def file_json(languageId, milestoneId, fileId)
  _clean(RestClient.get "#{BASE}/#{FILE_JSON}",
    { :consumerKey => @consumerKey,
      :projectId => @projectId,
      :languageId => languageId,
      :fileId => fileId,
      :milestoneId => milestoneId })
end
file_list(languageId) click to toggle source
FILE ====================
# File lib/qordoba_ruby_sdk.rb, line 167
def file_list(languageId)
  _clean(RestClient.post "#{BASE}/#{FILE_LISTFILES}", {}.to_json,
    { :consumerKey => @consumerKey,
      :languageId => languageId,
      :projectId => @projectId,
      "content-type" => "application/json" })
end
file_segment(languageId, fileId, segmentId) click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 230
def file_segment(languageId, fileId, segmentId)
  _clean(RestClient.get "#{BASE}/#{FILE_SEGMENT}",
    { :consumerKey => @consumerKey,
      :projectId => @projectId,
      :languageId => languageId,
      :fileId => fileId,
      :segmentId => segmentId })
end
file_segments(languageId, fileId) click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 222
def file_segments(languageId, fileId)
  _clean(RestClient.get "#{BASE}/#{FILE_SEGMENTS}",
    { :consumerKey => @consumerKey,
      :projectId => @projectId,
      :languageId => languageId,
      :fileId => fileId })
end
file_types() click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 175
def file_types
  _clean(RestClient.get "#{BASE}/#{FILE_TYPES}",
    { :consumerKey => @consumerKey,
      :projectId => @projectId })
end
file_update(pathToFile, fileId) click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 209
def file_update(pathToFile, fileId)
  _clean(RestClient.post "#{BASE}/#{FILE_UPDATE}",
    { :file_names => '[]', 
      :file => File.open(pathToFile), 
      :multipart => true
    }, {
      :consumerKey => @consumerKey,
      :projectId => @projectId,
      :fileId => fileId,
      :params => { "type" => "JSON" }
    })
end
file_upload(pathToFile, versionTag) click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 181
def file_upload(pathToFile, versionTag)
  _clean(RestClient.post "#{BASE}/#{FILE_UPLOAD}",
    { :file_names => '[]', 
      :file => File.open(pathToFile), 
      :multipart => true
    }, 
    { :consumerKey => @consumerKey,
      :versionTag => versionTag,
      :projectId => @projectId,
      :organizationId => @organizationId,
      :params => { :type => "JSON" } })
end
languages() click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 121
def languages
  _clean(RestClient.get "#{BASE}/#{LANGUAGES}", 
    { :consumerKey => @consumerKey })
end
organization_team() click to toggle source
Organization ================
# File lib/qordoba_ruby_sdk.rb, line 133
def organization_team
  _clean(RestClient.get "#{BASE}/#{ORG_TEAM}", 
    { :consumerKey => @consumerKey,
      :organizationId => @organizationId })
end
ping() click to toggle source
Getting Started ==============
# File lib/qordoba_ruby_sdk.rb, line 116
def ping
  _clean(RestClient.get "#{BASE}/#{PING}", 
    { :consumerKey => @consumerKey })
end
project_detail() click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 147
def project_detail
  _clean(RestClient.get "#{BASE}/#{PROJ_DETAIL}", 
    { :consumerKey => @consumerKey,
      :projectId => @projectId })
end
project_list() click to toggle source
Project ===================
# File lib/qordoba_ruby_sdk.rb, line 141
def project_list
  _clean(RestClient.get "#{BASE}/#{PROJ_LIST}", 
    { :consumerKey => @consumerKey,
      :organizationId => @organizationId })
end
project_status() click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 153
def project_status
  _clean(RestClient.get "#{BASE}/#{PROJ_STATUS}", 
    { :consumerKey => @consumerKey,
      :projectId => @projectId })
end
project_workflow() click to toggle source
# File lib/qordoba_ruby_sdk.rb, line 159
def project_workflow
  _clean(RestClient.get "#{BASE}/#{PROJ_WORKFLOW}", 
    { :consumerKey => @consumerKey,
      :projectId => @projectId })
end