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



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

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



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

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



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

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



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/crowdin-api/api_resources/translations.rb', line 145

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



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

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



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

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

#edit_pre_translations(pre_translation_id = nil, query = {}, project_id = config.project_id) ⇒ Object



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

def edit_pre_translations(pre_translation_id = nil, query = {}, 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,
    :patch,
    "#{config.target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

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



157
158
159
160
161
162
163
164
165
166
167
# File 'lib/crowdin-api/api_resources/translations.rb', line 157

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_pre_translations(query = {}, project_id = config.project_id) ⇒ Object



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

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

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



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

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



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

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