Module: Crowdin::ApiResources::Glossaries

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

Instance Method Summary collapse

Instance Method Details

#add_glossary(query = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 16

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

#add_term(glossary_id = nil, query = {}) ⇒ Object



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

def add_term(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

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

#check_glossary_export_status(glossary_id = nil, export_id = nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 73

def check_glossary_export_status(glossary_id = nil, export_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  export_id   || raise_parameter_is_required_error(:export_id)

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}"
  )
  Web::SendRequest.new(request).perform
end

#check_glossary_import_status(glossary_id = nil, import_id = nil) ⇒ Object



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

def check_glossary_import_status(glossary_id = nil, import_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  import_id   || raise_parameter_is_required_error(:import_id)

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/glossaries/#{glossary_id}/imports/#{import_id}"
  )
  Web::SendRequest.new(request).perform
end

#clear_glossary(glossary_id = nil, query = {}) ⇒ Object



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

def clear_glossary(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

  response = ::RestClient::Request.execute(
    {
      method: :delete,
      url: config.base_url + config.target_api_url + "/glossaries/#{glossary_id}/terms",
      payload: query.to_json
    }.merge(@options)
  )

  response.body.empty? ? response.code : JSON.parse(response.body)
rescue StandardError => e
  e.message
end

#delete_concept(glossary_id = nil, concept_id = nil) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 235

def delete_concept(glossary_id = nil, concept_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  concept_id || raise_parameter_is_required_error(:concept_id)

  request = Web::Request.new(
    connection,
    :delete,
    "#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}"
  )
  Web::SendRequest.new(request).perform
end

#delete_glossary(glossary_id = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 38

def delete_glossary(glossary_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)

  request = Web::Request.new(
    connection,
    :delete,
    "#{config.target_api_url}/glossaries/#{glossary_id}"
  )
  Web::SendRequest.new(request).perform
end

#delete_term(glossary_id = nil, term_id = nil) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 173

def delete_term(glossary_id = nil, term_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  term_id     || raise_parameter_is_required_error(:term_id)

  request = Web::Request.new(
    connection,
    :delete,
    "#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
  )
  Web::SendRequest.new(request).perform
end

#download_glossary(glossary_id = nil, export_id = nil, destination = nil) ⇒ Object



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

def download_glossary(glossary_id = nil, export_id = nil, destination = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  export_id   || raise_parameter_is_required_error(:export_id)

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}/download"
  )
  Web::SendRequest.new(request, destination).perform
end

#edit_glossary(glossary_id = nil, query = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 49

def edit_glossary(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

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

#edit_term(glossary_id = nil, term_id = nil, query = {}) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 185

def edit_term(glossary_id = nil, term_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  term_id     || raise_parameter_is_required_error(:term_id)

  request = Web::Request.new(
    connection,
    :patch,
    "#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#export_glossary(query = {}, glossary_id = nil, destination = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 61

def export_glossary(query = {}, glossary_id = nil, destination = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/glossaries/#{glossary_id}/exports",
    { params: query }
  )
  Web::SendRequest.new(request, destination).perform
end

#get_concept(glossary_id = nil, concept_id = nil) ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 210

def get_concept(glossary_id = nil, concept_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  concept_id || raise_parameter_is_required_error(:concept_id)

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}"
  )
  Web::SendRequest.new(request).perform
end

#get_glossary(glossary_id = nil, query = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 26

def get_glossary(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

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

#get_term(glossary_id = nil, term_id = nil) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 161

def get_term(glossary_id = nil, term_id = nil)
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  term_id     || raise_parameter_is_required_error(:term_id)

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
  )
  Web::SendRequest.new(request).perform
end

#import_glossary(glossary_id = nil, query = {}) ⇒ Object



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

def import_glossary(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

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

#list_concepts(glossary_id = nil, query = {}) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 198

def list_concepts(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

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

#list_glossaries(query = {}) ⇒ Object



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

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

#list_terms(glossary_id = nil, query = {}) ⇒ Object



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

def list_terms(glossary_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)

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

#search_glossaries_concordance(project_id = nil, query = {}) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 247

def search_glossaries_concordance(project_id = nil, query = {})
  project_id || raise_project_id_is_required_error

  %i[source_language_id target_language_id expression].each do |param|
    query[param] || raise_parameter_is_required_error(param)
  end

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

#update_concept(glossary_id = nil, concept_id = nil, query = {}) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/crowdin-api/api_resources/glossaries.rb', line 222

def update_concept(glossary_id = nil, concept_id = nil, query = {})
  glossary_id || raise_parameter_is_required_error(:glossary_id)
  concept_id || raise_parameter_is_required_error(:concept_id)

  request = Web::Request.new(
    connection,
    :put,
    "#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end