From 4ca26da518318b0c3ae45fdc30fd49199b68ae47 Mon Sep 17 00:00:00 2001 From: Dinesh Budhayer Date: Sat, 16 Jan 2021 09:42:43 +0545 Subject: [PATCH] added delete method --- README.md | 6 +++++- lib/click_up.rb | 1 + lib/click_up/api_operations/delete.rb | 14 ++++++++++++++ lib/click_up/connection_manager.rb | 5 +++++ lib/click_up/hierarchy/folder.rb | 1 + lib/click_up/hierarchy/list.rb | 1 + lib/click_up/hierarchy/space.rb | 1 + lib/click_up/hierarchy/task.rb | 1 + lib/click_up/version.rb | 2 +- 9 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lib/click_up/api_operations/delete.rb diff --git a/README.md b/README.md index b051e31..796daa0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ClickUp API Ruby Library - ClickUp API solution for Ruby. As of now, it doesn't support OAuth Authentication. You can only use personal token based authentication. + ClickUp API solution for Ruby. As of `v0.1.1`, it doesn't support OAuth Authentication. You can only use personal token based authentication. # Getting Started @@ -38,6 +38,8 @@ ClickUp::Space.all(team_id: 3451451) ClickUp::Space.create(team_id: 3451451, name: 'Space From API') ClickUp::Space.get(323455) + +ClickUp::Space.delete(323455) ``` ## Folder @@ -45,6 +47,8 @@ ClickUp::Space.get(323455) ClickUp::Folder.create(space_id: 323455, name: 'Folder From API') ClickUp::Folder.get(756376) + +ClickUp::Folder.delete(756376) ``` ## List diff --git a/lib/click_up.rb b/lib/click_up.rb index 5bcde49..2dee144 100644 --- a/lib/click_up.rb +++ b/lib/click_up.rb @@ -11,6 +11,7 @@ require 'click_up/api_operations/create' require 'click_up/api_operations/get' require 'click_up/api_operations/all' +require 'click_up/api_operations/delete' require 'click_up/hierarchy/team' require 'click_up/hierarchy/space' diff --git a/lib/click_up/api_operations/delete.rb b/lib/click_up/api_operations/delete.rb new file mode 100644 index 0000000..1a2f14b --- /dev/null +++ b/lib/click_up/api_operations/delete.rb @@ -0,0 +1,14 @@ +module ClickUp + module APIOperations + module Delete + def delete(id=nil, **opts) + params = opts.clone + unless params.has_key?(:id) || id + raise ParamRequiredError, "id is a required parameter.", "id" + end + params[:id] = id ? id : params[:id] + execute_request(:delete, resource_path(params)) + end + end + end +end \ No newline at end of file diff --git a/lib/click_up/connection_manager.rb b/lib/click_up/connection_manager.rb index 444019e..e403097 100644 --- a/lib/click_up/connection_manager.rb +++ b/lib/click_up/connection_manager.rb @@ -20,6 +20,11 @@ def post format_response(net_http_response.body) end + def delete + net_http_response = https_client.delete(resource_url.path, default_headers) + format_response(net_http_response.body) + end + private def resource_url uri = URI("#{api_base}#{namespace}#{path}") diff --git a/lib/click_up/hierarchy/folder.rb b/lib/click_up/hierarchy/folder.rb index 8cfd4ff..c2c2e50 100644 --- a/lib/click_up/hierarchy/folder.rb +++ b/lib/click_up/hierarchy/folder.rb @@ -5,6 +5,7 @@ class Folder < APIResource extend ClickUp::APIOperations::All extend ClickUp::APIOperations::Create extend ClickUp::APIOperations::Get + extend ClickUp::APIOperations::Delete class << self def index_path(params={}) diff --git a/lib/click_up/hierarchy/list.rb b/lib/click_up/hierarchy/list.rb index bb315e5..7e40fbf 100644 --- a/lib/click_up/hierarchy/list.rb +++ b/lib/click_up/hierarchy/list.rb @@ -5,6 +5,7 @@ class List < APIResource extend ClickUp::APIOperations::All extend ClickUp::APIOperations::Create extend ClickUp::APIOperations::Get + extend ClickUp::APIOperations::Delete class << self def index_path(params={}) diff --git a/lib/click_up/hierarchy/space.rb b/lib/click_up/hierarchy/space.rb index 1c2fd9d..e56b24b 100644 --- a/lib/click_up/hierarchy/space.rb +++ b/lib/click_up/hierarchy/space.rb @@ -5,6 +5,7 @@ class Space < APIResource extend ClickUp::APIOperations::All extend ClickUp::APIOperations::Create extend ClickUp::APIOperations::Get + extend ClickUp::APIOperations::Delete class << self def index_path(params={}) diff --git a/lib/click_up/hierarchy/task.rb b/lib/click_up/hierarchy/task.rb index cab31e6..eb42fc8 100644 --- a/lib/click_up/hierarchy/task.rb +++ b/lib/click_up/hierarchy/task.rb @@ -5,6 +5,7 @@ class Task < APIResource extend ClickUp::APIOperations::All extend ClickUp::APIOperations::Create extend ClickUp::APIOperations::Get + extend ClickUp::APIOperations::Delete class << self def index_path(params={}) diff --git a/lib/click_up/version.rb b/lib/click_up/version.rb index fc19fe2..f8eb6ce 100644 --- a/lib/click_up/version.rb +++ b/lib/click_up/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ClickUp - VERSION = "0.1.0" + VERSION = "0.1.1" end \ No newline at end of file