Module: RubyLokaliseApi::Rest::Keys

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

Instance Method Summary collapse

Instance Method Details

#create_keys(project_id, req_params) ⇒ RubyLokaliseApi::Collections::Keys

Creates one or multiple keys in the project

Parameters:

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

Returns:

See Also:



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

def create_keys(project_id, req_params)
  name = 'Keys'
  params = { query: project_id, req: req_params.to_array_obj(:keys) }

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

  collection name, data
end

#destroy_key(project_id, key_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a single key from the project

Parameters:

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

Returns:

See Also:



89
90
91
92
93
94
95
# File 'lib/ruby_lokalise_api/rest/keys.rb', line 89

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

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

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

#destroy_keys(project_id, key_ids) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes multiple keys from the project

Parameters:

  • project_id (String)
  • key_ids (Array, String)

Returns:

See Also:



103
104
105
106
107
108
109
# File 'lib/ruby_lokalise_api/rest/keys.rb', line 103

def destroy_keys(project_id, key_ids)
  params = { query: project_id, req: key_ids.to_array_obj(:keys) }

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

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

#key(project_id, key_id, req_params = {}) ⇒ RubyLokaliseApi::Resources::Key

Returns a single translation key

Parameters:

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

Returns:

See Also:



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

def key(project_id, key_id, req_params = {})
  params = { query: [project_id, key_id], req: req_params }

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

  resource 'Key', data
end

#keys(project_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::Keys

Returns project translation keys

Parameters:

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

Returns:

See Also:



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

def keys(project_id, req_params = {})
  name = 'Keys'
  params = { query: project_id, req: req_params }

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

  collection name, data
end

#update_key(project_id, key_id, req_params = {}) ⇒ RubyLokaliseApi::Resources::Key

Updates a single translation key

Parameters:

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

Returns:

See Also:



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

def update_key(project_id, key_id, req_params = {})
  params = { query: [project_id, key_id], req: req_params }

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

  resource 'Key', data
end

#update_keys(project_id, req_params) ⇒ RubyLokaliseApi::Collections::Keys

Updates multiple keys in the project

Parameters:

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

Returns:

See Also:



74
75
76
77
78
79
80
81
# File 'lib/ruby_lokalise_api/rest/keys.rb', line 74

def update_keys(project_id, req_params)
  name = 'Keys'
  params = { query: project_id, req: req_params.to_array_obj(:keys) }

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

  collection name, data
end