Skip to content

Commit

Permalink
Merge pull request #5 from Cielo24/feature/CLC-715
Browse files Browse the repository at this point in the history
CLC-715: Add modify_job action
  • Loading branch information
ccoakley committed Apr 18, 2016
2 parents c26a819 + b384d7f commit 2e4d481
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cielo24_cli/lib/cielo24_cli/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ def authorize
puts 'Authorized successfully'
end

desc 'modify_job', 'Modify a job'
option *job_id_option
option *fidelity_option
option *turn_around_hours_option
option *priority_option
# always required (hidden)
option *username_option
option *password_option
option *securekey_option
option *api_token_option
def modify_job
puts 'Modifying job parameters...'
actions = initialize_actions
token = get_token(actions)
actions.modify_job(token, options[:j], fidelity=options[:f], turnaround_hours=options[:T], priority=options[:P])
puts 'Job modified successfully'
end

desc 'add_media_to_job', 'Add media to job'
option *job_id_option
option *media_url_option
Expand Down
9 changes: 9 additions & 0 deletions cielo24_gem/lib/cielo24/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Actions
REMOVE_API_KEY_PATH = '/api/account/remove_api_key'
CREATE_JOB_PATH = '/api/job/new'
AUTHORIZE_JOB_PATH = '/api/job/authorize'
MODIFY_JOB_PATH = '/api/job/modify'
DELETE_JOB_PATH = '/api/job/del'
GET_JOB_INFO_PATH = '/api/job/info'
GET_JOB_LIST_PATH = '/api/job/list'
Expand Down Expand Up @@ -118,6 +119,14 @@ def authorize_job(api_token, job_id)
WebUtils.http_request(@base_url + AUTHORIZE_JOB_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
end

def modify_job(api_token, job_id, fidelity=nil, turnaround_hours=nil, priority=nil)
query_hash = init_job_req_dict(api_token, job_id)
query_hash[:transcription_fidelity] = fidelity unless fidelity.nil?
query_hash[:priority] = priority unless priority.nil?
query_hash[:turnaround_hours] = turnaround_hours unless turnaround_hours.nil?
WebUtils.http_request(@base_url + MODIFY_JOB_PATH, 'POST', WebUtils::BASIC_TIMEOUT, query_hash)
end

def delete_job(api_token, job_id)
query_hash = init_job_req_dict(api_token, job_id)
response = WebUtils.get_json(@base_url + DELETE_JOB_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
Expand Down
7 changes: 7 additions & 0 deletions cielo24_gem/test/job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def test_authorize_job
@actions.authorize_job(@api_token, @job_id)
end

def test_modify_job
@actions.modify_job(@api_token, @job_id,
fidelity=Fidelity::PROFESSIONAL,
turnaround_hours=36,
priority=Priority::ECONOMY)
end

def test_delete_job
@task_id = @actions.delete_job(@api_token, @job_id)
assert_equal(32, @task_id.length)
Expand Down

0 comments on commit 2e4d481

Please sign in to comment.