Skip to content

Commit

Permalink
Add interface to delete a calendar
Browse files Browse the repository at this point in the history
Ribose API offers `DELETE /calendar/calendar/:calendar_id` endpoint
that allows us to delete a particular calendar and this commit use
that endpoint and provides a ruby binding for that endpoint.

```ruby
Ribose::Calendar.delete(calendar_id)
```
  • Loading branch information
abunashir committed Oct 18, 2017
1 parent 46f6937 commit dbbaea7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@ Ribose::Calendar.create(
)
```

#### Delete a calendar

```ruby
Ribose::Calendar.delete(calendar_id)
```

### User

#### Create a signup request
Expand Down
8 changes: 8 additions & 0 deletions lib/ribose/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ class Calendar < Ribose::Base
include Ribose::Actions::Fetch
include Ribose::Actions::Create

def delete
Ribose::Request.delete(resource_path)
end

def self.delete(calendar_id)
new(resource_id: calendar_id).delete
end

private

def resource
Expand Down
11 changes: 11 additions & 0 deletions spec/ribose/calendar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@
expect(calendar.owner_type).to eq("User")
end
end

describe ".delete" do
it "removes a valid user calendar" do
calendar_id = 123_456_789
stub_ribose_calendar_delete_api(calendar_id)

expect do
Ribose::Calendar.delete(calendar_id)
end.not_to raise_error
end
end
end
6 changes: 6 additions & 0 deletions spec/support/fake_ribose_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def stub_ribose_calendar_create_api(attributes)
)
end

def stub_ribose_calendar_delete_api(calender_id)
stub_api_response(
:delete, "calendar/calendar/#{calender_id}", filename: "empty"
)
end

def stub_ribose_app_user_create_api(attributes)
stub_api_response(
:post,
Expand Down

0 comments on commit dbbaea7

Please sign in to comment.