Class: Smartling::Job

Inherits:
Api
  • Object
show all
Defined in:
lib/smartling/job.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Job

Returns a new instance of Job.



5
6
7
8
# File 'lib/smartling/job.rb', line 5

def initialize(args = {})
  super(args)
  @project_id = args[:projectId]
end

Instance Method Details

#add_file(job_id, file_uri, locales) ⇒ Object



36
37
38
39
40
# File 'lib/smartling/job.rb', line 36

def add_file(job_id, file_uri, locales)
  keys = { fileUri: file_uri, targetLocaleIds: locales }
  uri = uri("jobs-api/v3/projects/#{@project_id}/jobs/#{job_id}/file/add", keys)
  return post(uri, uri.params)
end

#authorize(job_id) ⇒ Object



42
43
44
45
# File 'lib/smartling/job.rb', line 42

def authorize(job_id)
  uri = uri("jobs-api/v3/projects/#{@project_id}/jobs/#{job_id}/authorize")
  return post(uri, uri.params)
end

#create(name) ⇒ Object



20
21
22
23
24
# File 'lib/smartling/job.rb', line 20

def create(name)
  keys = { jobName: name }
  uri = uri("jobs-api/v3/projects/#{@project_id}/jobs", keys)
  return post(uri, uri.params)
end

#detail(job_id) ⇒ Object



15
16
17
18
# File 'lib/smartling/job.rb', line 15

def detail(job_id)
  uri = uri("/jobs-api/v3/projects/#{@project_id}/jobs/#{job_id}")
  return get(uri)
end

#files(job_id) ⇒ Object



31
32
33
34
# File 'lib/smartling/job.rb', line 31

def files(job_id)
  uri = uri("jobs-api/v3/projects/#{@project_id}/jobs/#{job_id}/files")
  return get(uri)
end

#find_or_create(name) ⇒ Object



26
27
28
29
# File 'lib/smartling/job.rb', line 26

def find_or_create(name)
  list['items'].find do |job| job['jobName'] == name end ||
    create(name)
end

#listObject



10
11
12
13
# File 'lib/smartling/job.rb', line 10

def list
  uri = uri("jobs-api/v3/projects/#{@project_id}/jobs")
  return get(uri)
end