Module: Crowdin::ApiResources::Tasks

Defined in:
lib/crowdin-api/api_resources/tasks.rb

Instance Method Summary collapse

Instance Method Details

#add_task(query = {}, project_id = config.project_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/crowdin-api/api_resources/tasks.rb', line 18

def add_task(query = {}, project_id = config.project_id)
  project_id || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/projects/#{project_id}/tasks",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#delete_task(task_id = nil, project_id = config.project_id) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/crowdin-api/api_resources/tasks.rb', line 54

def delete_task(task_id = nil, project_id = config.project_id)
  task_id    || raise_parameter_is_required_error(:task_id)
  project_id || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :delete,
    "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}"
  )
  Web::SendRequest.new(request).perform
end

#edit_task(task_id = nil, query = {}, project_id = config.project_id) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/crowdin-api/api_resources/tasks.rb', line 66

def edit_task(task_id = nil, query = {}, project_id = config.project_id)
  task_id    || raise_parameter_is_required_error(:task_id)
  project_id || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :patch,
    "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#edit_task_archived_status(task_id = nil, query = {}) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/crowdin-api/api_resources/tasks.rb', line 89

def edit_task_archived_status(task_id = nil, query = {})
  task_id || raise_parameter_is_required_error(:task_id)

  request = Web::Request.new(
    connection,
    :patch,
    "#{config.target_api_url}/user/tasks/#{task_id}",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#export_task_strings(task_id = nil, destination = nil, project_id = config.project_id) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/crowdin-api/api_resources/tasks.rb', line 30

def export_task_strings(task_id = nil, destination = nil, project_id = config.project_id)
  task_id    || raise_parameter_is_required_error(:task_id)
  project_id || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}/exports"
  )
  Web::SendRequest.new(request, destination).perform
end

#get_task(task_id = nil, project_id = config.project_id) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/crowdin-api/api_resources/tasks.rb', line 42

def get_task(task_id = nil, project_id = config.project_id)
  task_id    || raise_parameter_is_required_error(:task_id)
  project_id || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/projects/#{project_id}/tasks/#{task_id}"
  )
  Web::SendRequest.new(request).perform
end

#list_tasks(query = {}, project_id = config.project_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/crowdin-api/api_resources/tasks.rb', line 6

def list_tasks(query = {}, project_id = config.project_id)
  project_id || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/projects/#{project_id}/tasks",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#list_user_tasks(query = {}) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/crowdin-api/api_resources/tasks.rb', line 79

def list_user_tasks(query = {})
  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/user/tasks",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end