Skip to content

Commit

Permalink
added delete method
Browse files Browse the repository at this point in the history
  • Loading branch information
ayerdines committed Jan 16, 2021
1 parent cf1bbe8 commit 4ca26da
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -38,13 +38,17 @@ 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
```ruby
ClickUp::Folder.create(space_id: 323455, name: 'Folder From API')

ClickUp::Folder.get(756376)

ClickUp::Folder.delete(756376)
```

## List
Expand Down
1 change: 1 addition & 0 deletions lib/click_up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 14 additions & 0 deletions lib/click_up/api_operations/delete.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions lib/click_up/connection_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
1 change: 1 addition & 0 deletions lib/click_up/hierarchy/folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down
1 change: 1 addition & 0 deletions lib/click_up/hierarchy/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down
1 change: 1 addition & 0 deletions lib/click_up/hierarchy/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down
1 change: 1 addition & 0 deletions lib/click_up/hierarchy/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down
2 changes: 1 addition & 1 deletion lib/click_up/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ClickUp
VERSION = "0.1.0"
VERSION = "0.1.1"
end

0 comments on commit 4ca26da

Please sign in to comment.