Module: Crowdin::ApiResources::Translations

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

Instance Method Summary collapse

Instance Method Details

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



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

def apply_pre_translation(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}/pre-translations",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#build_project_directory_translation(directory_id = nil, query = {}, project_id = config.project_id) ⇒ Object



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

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

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

#build_project_file_translation(file_id = nil, query = {}, destination = nil, project_id = config.project_id) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/crowdin-api/api_resources/translations.rb', line 43

def build_project_file_translation(file_id = nil, query = {}, destination = nil, project_id = config.project_id)
  file_id    || raise_parameter_is_required_error(:file_id)
  project_id || raise_project_id_is_required_error

  etag = query.delete(:eTag)
  headers = etag ? { 'If-None-Match' => etag } : {}

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}",
    { params: query, headers: headers }
  )
  Web::SendRequest.new(request, destination).perform
end

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



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/crowdin-api/api_resources/translations.rb', line 71

def build_project_translation(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}/translations/builds",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#cancel_build(build_id = nil, project_id = config.project_id) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/crowdin-api/api_resources/translations.rb', line 120

def cancel_build(build_id = nil, project_id = config.project_id)
  build_id   || raise_parameter_is_required_error(:build_id)
  project_id || raise_project_id_is_required_error

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

#check_project_build_status(build_id = nil, project_id = config.project_id) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/crowdin-api/api_resources/translations.rb', line 108

def check_project_build_status(build_id = nil, project_id = config.project_id)
  build_id   || raise_parameter_is_required_error(:build_id)
  project_id || raise_project_id_is_required_error

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

#download_project_translations(build_id = nil, destination = nil, project_id = config.project_id) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/crowdin-api/api_resources/translations.rb', line 96

def download_project_translations(build_id = nil, destination = nil, project_id = config.project_id)
  build_id    || raise_parameter_is_required_error(:build_id)
  project_id  || raise_project_id_is_required_error

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}/download"
  )
  Web::SendRequest.new(request, destination).perform
end

#export_project_translation(query = {}, destination = nil, project_id = config.project_id) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/crowdin-api/api_resources/translations.rb', line 132

def export_project_translation(query = {}, destination = nil, 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}/translations/exports",
    { params: query }
  )
  Web::SendRequest.new(request, destination).perform
end

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



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/crowdin-api/api_resources/translations.rb', line 59

def list_project_builds(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}/translations/builds",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#pre_translation_status(pre_translation_id = nil, project_id = config.project_id) ⇒ Object



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

def pre_translation_status(pre_translation_id = nil, project_id = config.project_id)
  pre_translation_id || raise_parameter_is_required_error(:pre_translation_id)
  project_id         || raise_project_id_is_required_error

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

#upload_translations(language_id = nil, query = {}, project_id = config.project_id) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/crowdin-api/api_resources/translations.rb', line 83

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

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