Module: Crowdin::ApiResources::TranslationMemory

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

Instance Method Summary collapse

Instance Method Details

#add_tm(query = {}) ⇒ Object



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

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

#check_tm_export_status(tm_id = nil, export_id = nil) ⇒ Object



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

def check_tm_export_status(tm_id = nil, export_id = nil)
  tm_id     || raise_parameter_is_required_error(:tm_id)
  export_id || raise_parameter_is_required_error(:export_id)

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

#check_tm_import_status(tm_id = nil, import_id = nil) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/crowdin-api/api_resources/translation_memory.rb', line 118

def check_tm_import_status(tm_id = nil, import_id = nil)
  tm_id     || raise_parameter_is_required_error(:tm_id)
  import_id || raise_parameter_is_required_error(:import_id)

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

#clear_tm(tm_id = nil) ⇒ Object



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

def clear_tm(tm_id = nil)
  tm_id || raise_parameter_is_required_error(:tm_id)

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

#delete_tm(tm_id = nil) ⇒ Object



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

def delete_tm(tm_id = nil)
  tm_id || raise_parameter_is_required_error(:tm_id)

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

#download_tm(tm_id = nil, export_id = nil, destination = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/crowdin-api/api_resources/translation_memory.rb', line 94

def download_tm(tm_id = nil, export_id = nil, destination = nil)
  tm_id     || raise_parameter_is_required_error(:tm_id)
  export_id || raise_parameter_is_required_error(:export_id)

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

#edit_tm(tm_id = nil, query = {}) ⇒ Object



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

def edit_tm(tm_id = nil, query = {})
  tm_id || raise_parameter_is_required_error(:tm_id)

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

#export_tm(tm_id = nil) ⇒ Object



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

def export_tm(tm_id = nil)
  tm_id || raise_parameter_is_required_error(:tm_id)

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/tms/#{tm_id}/exports"
  )
  Web::SendRequest.new(request).perform
end

#get_tm(tm_id = nil) ⇒ Object



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

def get_tm(tm_id = nil)
  tm_id || raise_parameter_is_required_error(:tm_id)

  request = Web::Request.new(
    connection,
    :get,
    "#{config.target_api_url}/tms/#{tm_id}"
  )
  Web::SendRequest.new(request).perform
end

#import_tm(tm_id = nil, query = {}) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/crowdin-api/api_resources/translation_memory.rb', line 106

def import_tm(tm_id = nil, query = {})
  tm_id || raise_parameter_is_required_error(:tm_id)

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

#list_tms(query = {}) ⇒ Object



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

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

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



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

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

  %i[source_language_id target_language_id expression auto_substitution min_relevant].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}/tms/concordance",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end