Module: RubyLokaliseApi::Rest::Contributors

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

Instance Method Summary collapse

Instance Method Details

#contributor(project_id, contributor_id) ⇒ RubyLokaliseApi::Resources::Contributor

Returns a single contributor

Parameters:

  • project_id (String)
  • contributor_id (String, Integer)

Returns:

See Also:



14
15
16
17
18
19
20
# File 'lib/ruby_lokalise_api/rest/contributors.rb', line 14

def contributor(project_id, contributor_id)
  params = { query: [project_id, contributor_id] }

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

  resource 'Contributor', data
end

#contributors(project_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::Contributors

Returns project contributors

Parameters:

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

Returns:

See Also:



28
29
30
31
32
33
34
35
# File 'lib/ruby_lokalise_api/rest/contributors.rb', line 28

def contributors(project_id, req_params = {})
  name = 'Contributors'
  params = { query: project_id, req: req_params }

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

  collection name, data
end

#create_contributors(project_id, req_params) ⇒ RubyLokaliseApi::Collections::Contributors

Creates one or multiple contributors for a project

Parameters:

  • project_id (String)
  • req_params (Hash, Array)

Returns:

See Also:



43
44
45
46
47
48
49
50
# File 'lib/ruby_lokalise_api/rest/contributors.rb', line 43

def create_contributors(project_id, req_params)
  name = 'Contributors'
  params = { query: project_id, req: req_params.to_array_obj(:contributors) }

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

  collection name, data
end

#destroy_contributor(project_id, contributor_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a single contributor from the project

Parameters:

  • project_id (String)
  • contributor_id (String, Integer)

Returns:

See Also:



73
74
75
76
77
78
79
# File 'lib/ruby_lokalise_api/rest/contributors.rb', line 73

def destroy_contributor(project_id, contributor_id)
  params = { query: [project_id, contributor_id] }

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

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

#update_contributor(project_id, contributor_id, req_params) ⇒ RubyLokaliseApi::Resources::Contributor

Updates a contributor for a project

Parameters:

  • project_id (String)
  • contributor_id (String, Integer)
  • req_params (Hash)

Returns:

See Also:



59
60
61
62
63
64
65
# File 'lib/ruby_lokalise_api/rest/contributors.rb', line 59

def update_contributor(project_id, contributor_id, req_params)
  params = { query: [project_id, contributor_id], req: req_params }

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

  resource 'Contributor', data
end