Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update item collection request #18

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- Add new request: list items linked to a collection.
- Add new request: Create a job from its workflow.
- Add new request: Update a collection's item.
- Add new request: Update a job's cell.
- Add new request: Delete a collection's item.
- Fetch the details for the given user.

## [0.4.0] - 2023-09-12

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module KazeClient

# @author [email protected]
# Delete a collection item
# @see KazeClient::Request
# @see KazeClient::Utils::FinalRequest
# @see KazeClient::Utils::AuthentifiedRequest
# @since 0.4.1
class DeleteCollectionItemRequest < Utils::FinalRequest

include Utils::AuthentifiedRequest

# @param collection_id [String]
# @param item_id [String]
def initialize(collection_id, item_id)
super(:delete, "api/collections/#{collection_id}/items/#{item_id}")
end

end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module KazeClient

# @author [email protected]
# Update a collection item
# @see KazeClient::Request
# @see KazeClient::Utils::FinalRequest
# @see KazeClient::Utils::AuthentifiedRequest
# @since 0.4.1
class UpdateCollectionItemRequest < Utils::FinalRequest

include Utils::AuthentifiedRequest

# @param collection_id [String]
# @param item_id [String]
# @param payload [Hash]
def initialize(collection_id, item_id, payload)
super(:put, "api/collections/#{collection_id}/items/#{item_id}")

@body = payload
end

end

end
39 changes: 39 additions & 0 deletions lib/kaze_client/request/requests/jobs/update_job_cell_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

module KazeClient

# @author [email protected]
# Update a given job cell.
# @see KazeClient::Request
# @see KazeClient::Utils::FinalRequest
# @see KazeClient::Utils::AuthentifiedRequest
# @since 0.4.1
class UpdateJobCellRequest < Utils::FinalRequest

include Utils::AuthentifiedRequest

# @return [String] The id of the target job.
attr_reader :job_id

# @return [String] The id of the target cell.
attr_reader :cell_id

# @return [Hash] The workflow used to update the cell.
attr_reader :cell_data

def initialize(job_id, cell_id, cell_data, skip_version_check: false)
super(:put, "api/jobs/#{job_id}/cells/#{cell_id}")

@body = {
data: {
cell_id => {
data: cell_data
}
},
skip_version_check: skip_version_check ? 1 : 0
}
end

end

end
21 changes: 21 additions & 0 deletions lib/kaze_client/request/requests/user_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module KazeClient

# @author [email protected]
# Show a given user's informations.
# @see KazeClient::Request
# @see KazeClient::Utils::FinalRequest
# @see KazeClient::Utils::AuthentifiedRequest
# @since 0.4.1
class UserRequest < Utils::FinalRequest

include Utils::AuthentifiedRequest

def initialize(user_id)
super(:get, "api/users/#{user_id}")
end

end

end
4 changes: 4 additions & 0 deletions lib/kaze_client/requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require_relative 'request/requests/jobs/cancel_job_request'
require_relative 'request/requests/jobs/add_tag_request'
require_relative 'request/requests/jobs/complete_step_request'
require_relative 'request/requests/jobs/update_job_cell_request'

# => Collections
require_relative 'request/requests/collections/collection_request'
Expand All @@ -34,7 +35,9 @@
require_relative 'request/requests/collections/items/items_request'
require_relative 'request/requests/collections/items/create_link_request'
require_relative 'request/requests/collections/items/create_collection_item_request'
require_relative 'request/requests/collections/items/update_collection_item_request'
require_relative 'request/requests/collections/items/linked_collections_request'
require_relative 'request/requests/collections/items/delete_collection_item_request'

# => Tags
require_relative 'request/requests/tags/tag_request'
Expand All @@ -47,3 +50,4 @@
require_relative 'request/requests/upload_image_request'
require_relative 'request/requests/upload_attachment_request'
require_relative 'request/requests/users_request'
require_relative 'request/requests/user_request'
Loading