Module: Crowdin::ApiResources::SourceFiles
- Included in:
- Client
- Defined in:
- lib/crowdin-api/api-resources/source_files.rb
Instance Method Summary collapse
- #add_branch(query = {}, project_id = config.project_id) ⇒ Object
- #add_directory(query = {}, project_id = config.project_id) ⇒ Object
-
#add_file(query = {}, project_id = config.project_id) ⇒ Object
Add custom language.
- #delete_branch(branch_id = nil, project_id = config.project_id) ⇒ Object
- #delete_directory(directory_id = nil, project_id = config.project_id) ⇒ Object
- #delete_file(file_id = nil, project_id = config.project_id) ⇒ Object
- #download_file(destination = nil, file_id = nil, project_id = config.project_id) ⇒ Object
- #edit_branch(branch_id = nil, query = {}) ⇒ Object
- #edit_directory(directory_id = nil, query = {}) ⇒ Object
- #edit_file(file_id = nil, query = {}) ⇒ Object
- #get_branch(branch_id = nil, project_id = config.project_id) ⇒ Object
- #get_directory(directory_id = nil, project_id = config.project_id) ⇒ Object
- #get_file(file_id = nil, project_id = config.project_id) ⇒ Object
- #get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id) ⇒ Object
- #list_branches(query = {}, project_id = config.project_id) ⇒ Object
- #list_directories(query = {}, project_id = config.project_id) ⇒ Object
-
#list_file_revisions(file_id = nil, query = {}) ⇒ Object
List file revisions.
- #list_files(query = {}, project_id = config.project_id) ⇒ Object
- #update_or_restore_file(file_id = nil, query = {}) ⇒ Object
Instance Method Details
#add_branch(query = {}, project_id = config.project_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 19 def add_branch(query = {}, project_id = config.project_id) project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :post, "/projects/#{project_id}/branches", query ) request.perform end |
#add_directory(query = {}, project_id = config.project_id) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 87 def add_directory(query = {}, project_id = config.project_id) project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :post, "/projects/#{project_id}/directories", query ) request.perform end |
#add_file(query = {}, project_id = config.project_id) ⇒ Object
Add custom language.
Parameters
-
:projectId[Integer] - Project Identifier. Get via list_projects. Can be initialized with the Crowdin Client -
:storageId[Integer] - Storage Identifier. Get via list_storages -
:name[String] - File name. Note: Can’t contain \ / : * ? “ < > | symbols. ZIP files are not allowed.
Example
when you’re initialized Crowdin Client with a project_id
crowdin.add_file(storage_id: your_storage_id, name: 'your_filename')
or you can use the specified project_id
crowdin.add_file({}, your_project_id)
173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 173 def add_file(query = {}, project_id = config.project_id) project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :post, "/projects/#{project_id}/files", query ) request.perform end |
#delete_branch(branch_id = nil, project_id = config.project_id) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 45 def delete_branch(branch_id = nil, project_id = config.project_id) branch_id || raise(ArgumentError, ':branch_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :delete, "/projects/#{project_id}/branches/#{branch_id}" ) request.perform end |
#delete_directory(directory_id = nil, project_id = config.project_id) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 113 def delete_directory(directory_id = nil, project_id = config.project_id) directory_id || raise(ArgumentError, ':directory_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :delete, "/projects/#{project_id}/directories/#{directory_id}" ) request.perform end |
#delete_file(file_id = nil, project_id = config.project_id) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 215 def delete_file(file_id = nil, project_id = config.project_id) file_id || raise(ArgumentError, ':file_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :delete, "/projects/#{project_id}/files/#{file_id}" ) request.perform end |
#download_file(destination = nil, file_id = nil, project_id = config.project_id) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 244 def download_file(destination = nil, file_id = nil, project_id = config.project_id) destination || raise(ArgumentError, ':destination is required for downlaods') file_id || raise(ArgumentError, ':file_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/files/#{file_id}/download", {}, {}, destination ) request.perform end |
#edit_branch(branch_id = nil, query = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 58 def edit_branch(branch_id = nil, query = {}) project_id = query[:project_id] || config.project_id branch_id || raise(ArgumentError, ':branch_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :patch, "/projects/#{project_id}/branches/#{branch_id}", query ) request.perform end |
#edit_directory(directory_id = nil, query = {}) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 126 def edit_directory(directory_id = nil, query = {}) project_id = query[:project_id] || config.project_id directory_id || raise(ArgumentError, ':directory_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :patch, "/projects/#{project_id}/directories/#{directory_id}", query ) request.perform end |
#edit_file(file_id = nil, query = {}) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 228 def edit_file(file_id = nil, query = {}) project_id = query[:project_id] || config.project_id file_id || raise(ArgumentError, ':file_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :patch, "/projects/#{project_id}/files/#{file_id}", query ) request.perform end |
#get_branch(branch_id = nil, project_id = config.project_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 32 def get_branch(branch_id = nil, project_id = config.project_id) branch_id || raise(ArgumentError, ':branch_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/branches/#{branch_id}" ) request.perform end |
#get_directory(directory_id = nil, project_id = config.project_id) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 100 def get_directory(directory_id = nil, project_id = config.project_id) directory_id || raise(ArgumentError, ':directory_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/directories/#{directory_id}" ) request.perform end |
#get_file(file_id = nil, project_id = config.project_id) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 186 def get_file(file_id = nil, project_id = config.project_id) file_id || raise(ArgumentError, ':file_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/files/#{file_id}" ) request.perform end |
#get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id) ⇒ Object
298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 298 def get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id) file_id || raise(ArgumentError, ':file_id is required') revision_id || raise(ArgumentError, ':revision_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/files/#{file_id}/revisions/#{revision_id}" ) request.perform end |
#list_branches(query = {}, project_id = config.project_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 6 def list_branches(query = {}, project_id = config.project_id) project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/branches", query ) request.perform end |
#list_directories(query = {}, project_id = config.project_id) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 74 def list_directories(query = {}, project_id = config.project_id) project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/directories", query ) request.perform end |
#list_file_revisions(file_id = nil, query = {}) ⇒ Object
List file revisions.
Parameters
-
:projectId[Integer] - Project Identifier. Get via list_projects. Can be initialized with the Crowdin Client -
:fileId[Integer] - File Identifier. Get via list_files
Optional:
-
:limit[Integer 1..500] - A maximum number of items to retrieve, default - 25 -
:offset[Integer >= 0] - A starting offset in the collection, default - 0
Example
when you’re initialized Crowdin Client with a project_id
crowdin.list_file_revisions(your_file_id, { limit: your_value })
or you can use the specified project_id
crowdin.list_file_revisions(your_file_id, { project_id: your_project_id ..})
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 282 def list_file_revisions(file_id = nil, query = {}) project_id = query[:project_id] || config.project_id file_id || raise(ArgumentError, ':file_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/files/#{file_id}/revisions", query ) request.perform end |
#list_files(query = {}, project_id = config.project_id) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 142 def list_files(query = {}, project_id = config.project_id) project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :get, "/projects/#{project_id}/files", query ) request.perform end |
#update_or_restore_file(file_id = nil, query = {}) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/crowdin-api/api-resources/source_files.rb', line 199 def update_or_restore_file(file_id = nil, query = {}) project_id = query[:project_id] || config.project_id file_id || raise(ArgumentError, ':file_id is required') project_id || raise(ArgumentError, ':project_id is required in parameters or when initialize Client') request = Web::Request.new( self, :put, "/projects/#{project_id}/files/#{file_id}", query ) request.perform end |