Module: RubyLokaliseApi::Rest::Comments

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

Instance Method Summary collapse

Instance Method Details

#comment(project_id, key_id, comment_id) ⇒ RubyLokaliseApi::Resources::Comment

Returns a single key comment

Parameters:

  • project_id (String)
  • key_id (String, Integer)
  • comment_id (String, Integer)

Returns:

See Also:



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

def comment(project_id, key_id, comment_id)
  params = { query: [project_id, key_id, comment_id] }

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

  resource 'Comment', data
end

#comments(project_id, key_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::KeyComments

Returns all comments for a key

Parameters:

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

Returns:

See Also:



30
31
32
33
34
35
36
37
# File 'lib/ruby_lokalise_api/rest/comments.rb', line 30

def comments(project_id, key_id, req_params = {})
  name = 'KeyComments'
  params = { query: [project_id, key_id], req: req_params }

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

  collection name, data
end

#create_comments(project_id, key_id, req_params) ⇒ RubyLokaliseApi::Collections::KeyComments

Creates one or multiple comments for a key

Parameters:

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

Returns:

See Also:



61
62
63
64
65
66
67
68
# File 'lib/ruby_lokalise_api/rest/comments.rb', line 61

def create_comments(project_id, key_id, req_params)
  name = 'KeyComments'
  params = { query: [project_id, key_id], req: req_params.to_array_obj(:comments) }

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

  collection name, data
end

#destroy_comment(project_id, key_id, comment_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a single key comment

Parameters:

  • project_id (String)
  • key_id (String, Integer)
  • comment_id (String, Integer)

Returns:

See Also:



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

def destroy_comment(project_id, key_id, comment_id)
  params = { query: [project_id, key_id, comment_id] }

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

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

#project_comments(project_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::ProjectComments

Returns all comments for a project

Parameters:

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

Returns:

See Also:



45
46
47
48
49
50
51
52
# File 'lib/ruby_lokalise_api/rest/comments.rb', line 45

def project_comments(project_id, req_params = {})
  name = 'ProjectComments'
  params = { query: project_id, req: req_params }

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

  collection name, data
end