lib/ruby_lokalise_api/rest/snapshots.rb in ruby-lokalise-api-7.2.0 vs lib/ruby_lokalise_api/rest/snapshots.rb in ruby-lokalise-api-8.0.0.rc1
- old
+ new
@@ -1,47 +1,67 @@
# frozen_string_literal: true
module RubyLokaliseApi
module Rest
module Snapshots
- # Returns all snapshots for the given project
+ # Returns project snapshots
#
# @see https://developers.lokalise.com/reference/list-all-snapshots
- # @return [RubyLokaliseApi::Collection::Snapshot<RubyLokaliseApi::Resources::Snapshot>]
+ # @return [RubyLokaliseApi::Collections::Snapshots]
# @param project_id [String]
- # @param params [Hash]
- def snapshots(project_id, params = {})
- c_r RubyLokaliseApi::Collections::Snapshot, :all, project_id, params
+ # @param req_params [Hash]
+ 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
- # Creates snapshot for the given project
+ # Creates a snapshot
#
# @see https://developers.lokalise.com/reference/create-a-snapshot
# @return [RubyLokaliseApi::Resources::Snapshot]
# @param project_id [String]
- # @param params [Hash]
- def create_snapshot(project_id, params = {})
- c_r RubyLokaliseApi::Resources::Snapshot, :create, project_id, params
+ # @param req_params [Hash]
+ 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
- # Restore project from the given snapshot by producing project's copy
+ # Restores a snapshot by creating a project copy
#
# @see https://developers.lokalise.com/reference/restore-a-snapshot
# @return [RubyLokaliseApi::Resources::Project]
# @param project_id [String]
# @param snapshot_id [String, Integer]
def restore_snapshot(project_id, snapshot_id)
- c_r RubyLokaliseApi::Resources::Snapshot, :restore, [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
- # Deletes snapshot
+ # Deletes a snapshot
#
# @see https://developers.lokalise.com/reference/delete-a-snapshot
- # @return [Hash]
+ # @return [RubyLokaliseApi::Generics::DeletedResource]
# @param project_id [String]
# @param snapshot_id [String, Integer]
def destroy_snapshot(project_id, snapshot_id)
- c_r RubyLokaliseApi::Resources::Snapshot, :destroy, [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
end
end
end