Module: RubyLokaliseApi::Rest::Projects

Included in:
RubyLokaliseApi::Rest
Defined in:
lib/ruby_lokalise_api/rest/projects.rb

Instance Method Summary collapse

Instance Method Details

#create_project(req_params) ⇒ RubyLokaliseApi::Resources::Project

Creates a project



38
39
40
41
42
43
44
# File 'lib/ruby_lokalise_api/rest/projects.rb', line 38

def create_project(req_params)
  params = { req: req_params }

  data = endpoint(name: 'Projects', params: params).do_post

  resource 'Project', data
end

#destroy_project(project_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a project



65
66
67
68
69
70
71
# File 'lib/ruby_lokalise_api/rest/projects.rb', line 65

def destroy_project(project_id)
  params = { query: project_id }

  data = endpoint(name: 'Projects', params: params).do_delete

  RubyLokaliseApi::Generics::DeletedResource.new data.content
end

#empty_project(project_id) ⇒ RubyLokaliseApi::Generics::EmptiedResource

Empties a project by deleting all keys and translations



78
79
80
81
82
# File 'lib/ruby_lokalise_api/rest/projects.rb', line 78

def empty_project(project_id)
  data = endpoint(name: 'Projects', params: { query: [project_id, :empty] }).do_put

  RubyLokaliseApi::Generics::EmptiedResource.new data.content
end

#project(project_id) ⇒ RubyLokaliseApi::Resources::Project

Returns a single project



11
12
13
14
15
16
17
# File 'lib/ruby_lokalise_api/rest/projects.rb', line 11

def project(project_id)
  params = { query: project_id }

  data = endpoint(name: 'Projects', params: params).do_get

  resource 'Project', data
end

#projects(req_params = {}) ⇒ RubyLokaliseApi::Collections::Projects

Returns a collection of projects

Parameters:

  • req_params (Hash) (defaults to: {})

Returns:

See Also:



24
25
26
27
28
29
30
31
# File 'lib/ruby_lokalise_api/rest/projects.rb', line 24

def projects(req_params = {})
  name = 'Projects'
  params = { req: req_params }

  data = endpoint(name: name, params: params).do_get

  collection name, data
end

#update_project(project_id, req_params) ⇒ RubyLokaliseApi::Resources::Project

Updates a project

Parameters:

  • project_id (String)
  • req_params (Hash)

Returns:

See Also:



52
53
54
55
56
57
58
# File 'lib/ruby_lokalise_api/rest/projects.rb', line 52

def update_project(project_id, req_params)
  params = { query: project_id, req: req_params }

  data = endpoint(name: 'Projects', params: params).do_put

  resource 'Project', data
end