Module: RubyLokaliseApi::Rest::Snapshots

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

Instance Method Summary collapse

Instance Method Details

#create_snapshot(project_id, req_params = {}) ⇒ RubyLokaliseApi::Resources::Snapshot

Creates a snapshot

Parameters:

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

Returns:

See Also:



27
28
29
30
31
32
33
# File 'lib/ruby_lokalise_api/rest/snapshots.rb', line 27

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

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

  resource 'Snapshot', data
end

#destroy_snapshot(project_id, snapshot_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a snapshot

Parameters:

  • project_id (String)
  • snapshot_id (String, Integer)

Returns:

See Also:



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

def destroy_snapshot(project_id, snapshot_id)
  params = { query: [project_id, snapshot_id] }

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

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

#restore_snapshot(project_id, snapshot_id) ⇒ RubyLokaliseApi::Resources::Project

Restores a snapshot by creating a project copy

Parameters:

  • project_id (String)
  • snapshot_id (String, Integer)

Returns:

See Also:



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

def restore_snapshot(project_id, snapshot_id)
  params = { query: [project_id, snapshot_id] }

  response = endpoint(name: 'Snapshots', params: params).do_post

  # We restore a project so its endpoint is different
  response.patch_endpoint_with endpoint(name: 'Projects', params: { query: [project_id] })

  resource 'Project', response
end

#snapshots(project_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::Snapshots

Returns project snapshots

Parameters:

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

Returns:

See Also:



12
13
14
15
16
17
18
19
# File 'lib/ruby_lokalise_api/rest/snapshots.rb', line 12

def snapshots(project_id, req_params = {})
  name = 'Snapshots'
  params = { query: project_id, req: req_params }

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

  collection name, data
end