Skip to content

Commit

Permalink
Merge pull request #42 from koshilife/#41_support_cancellation_field
Browse files Browse the repository at this point in the history
support cancellation field in the response of scheduled event endpoints
  • Loading branch information
koshilife committed Feb 26, 2022
2 parents a3745e9 + 6b4b038 commit 7ddd032
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.8.2 - 2022-02-26

- support cancellation field in the response of scheduled event endpoints. (#41)

## 0.8.1 - 2021-10-20

- support new UUID format like 'bbc4f475-6125-435a-b713-2d1634651e10'. (#38, thanks to jameswilliamiii)
Expand Down
12 changes: 9 additions & 3 deletions lib/calendly/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'calendly/models/model_utils'
require 'calendly/models/event_type'
require 'calendly/models/guest'
require 'calendly/models/invitee_cancellation'
require 'calendly/models/invitees_counter'
require 'calendly/models/location'

Expand All @@ -17,6 +18,7 @@ class Event
ASSOCIATION = {
event_type: EventType,
event_guests: Guest,
cancellation: InviteeCancellation,
invitees_counter: InviteesCounter,
location: Location
}.freeze
Expand Down Expand Up @@ -57,14 +59,18 @@ class Event
# Reference to Event Type associated with this event.
attr_accessor :event_type

# @return [Calendly::Location]
# location in this event.
attr_accessor :location
# @return [InviteeCancellation]
# Provides data pertaining to the cancellation of the Invitee.
attr_accessor :cancellation

# @return [InviteesCounter]
# invitees counter.
attr_accessor :invitees_counter

# @return [Calendly::Location]
# location in this event.
attr_accessor :location

# @return [Array<User>]
# Event membership list.
attr_accessor :event_memberships
Expand Down
3 changes: 3 additions & 0 deletions lib/calendly/models/invitee_cancellation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ class InviteeCancellation

# @return [String] Reason that the cancellation occurred.
attr_accessor :reason

# @return [String] Allowed values: host or invitee.
attr_accessor :canceler_type
end
end
2 changes: 1 addition & 1 deletion lib/calendly/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Calendly
VERSION = '0.8.1'
VERSION = '0.8.2'
end
12 changes: 12 additions & 0 deletions test/assert_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def assert_event001(ev)
assert_equal 'https://api.calendly.com/event_types/ET001', ev.event_type.uri
assert_equal 'ET001', ev.event_type.uuid
assert_nil ev.location
assert ev.cancellation.is_a? Calendly::InviteeCancellation
assert_equal 'FooBar', ev.cancellation.canceled_by
assert_equal 'I have to be absent next week, sorry.', ev.cancellation.reason
assert_equal 'invitee', ev.cancellation.canceler_type
assert ev.invitees_counter.is_a? Calendly::InviteesCounter
assert_equal 1, ev.invitees_counter.total
assert_equal 0, ev.invitees_counter.active
Expand Down Expand Up @@ -352,6 +356,7 @@ def assert_event002(ev)
assert_equal 'https://api.calendly.com/event_types/ET002', ev.event_type.uri
assert_equal 'ET002', ev.event_type.uuid
assert_location_tokyo ev.location
assert_nil ev.cancellation
assert ev.invitees_counter.is_a? Calendly::InviteesCounter
assert_equal 1, ev.invitees_counter.total
assert_equal 1, ev.invitees_counter.active
Expand Down Expand Up @@ -390,6 +395,10 @@ def assert_event011(ev)
assert_equal 'https://api.calendly.com/event_types/ET001', ev.event_type.uri
assert_equal 'ET001', ev.event_type.uuid
assert_location_microsoft_teams ev.location
assert ev.cancellation.is_a? Calendly::InviteeCancellation
assert_equal 'FooBar', ev.cancellation.canceled_by
assert_equal 'I have to be absent next week, sorry.', ev.cancellation.reason
assert_equal 'invitee', ev.cancellation.canceler_type
assert ev.invitees_counter.is_a? Calendly::InviteesCounter
assert_equal 1, ev.invitees_counter.total
assert_equal 0, ev.invitees_counter.active
Expand Down Expand Up @@ -422,6 +431,7 @@ def assert_event012(ev)
assert_equal 'https://api.calendly.com/event_types/ET002', ev.event_type.uri
assert_equal 'ET002', ev.event_type.uuid
assert_location_zoom ev.location
assert_nil ev.cancellation
assert ev.invitees_counter.is_a? Calendly::InviteesCounter
assert_equal 1, ev.invitees_counter.total
assert_equal 1, ev.invitees_counter.active
Expand Down Expand Up @@ -454,6 +464,7 @@ def assert_event013(ev)
assert_equal 'https://api.calendly.com/event_types/ET003', ev.event_type.uri
assert_equal 'ET003', ev.event_type.uuid
assert_location_google_meet ev.location
assert_nil ev.cancellation
assert ev.invitees_counter.is_a? Calendly::InviteesCounter
assert_equal 1, ev.invitees_counter.total
assert_equal 1, ev.invitees_counter.active
Expand Down Expand Up @@ -702,6 +713,7 @@ def assert_event301_invitee001(inv)
assert inv.cancellation.is_a? Calendly::InviteeCancellation
assert_equal 'FooBar', inv.cancellation.canceled_by
assert_equal 'I have to be absent next week, sorry.', inv.cancellation.reason
assert_equal 'invitee', inv.cancellation.canceler_type
assert_nil inv.payment

assert_equal 5, inv.questions_and_answers.length
Expand Down
5 changes: 5 additions & 0 deletions test/testdata/scheduled_event_001.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"resource": {
"cancellation": {
"canceled_by": "FooBar",
"reason": "I have to be absent next week, sorry.",
"canceler_type": "invitee"
},
"created_at": "2020-07-10T05:00:00.000000Z",
"end_time": "2020-07-22T02:00:00.000000Z",
"event_guests": [
Expand Down
3 changes: 2 additions & 1 deletion test/testdata/scheduled_event_invitee_301.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"cancel_url": "https://calendly.com/cancellations/INV001",
"cancellation": {
"canceled_by": "FooBar",
"reason": "I have to be absent next week, sorry."
"reason": "I have to be absent next week, sorry.",
"canceler_type": "invitee"
},
"created_at": "2020-08-20T01:00:00.000000Z",
"email": "foobar@example.com",
Expand Down
5 changes: 5 additions & 0 deletions test/testdata/scheduled_events_001.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"collection": [
{
"cancellation": {
"canceled_by": "FooBar",
"reason": "I have to be absent next week, sorry.",
"canceler_type": "invitee"
},
"created_at": "2020-07-10T05:00:00.000000Z",
"end_time": "2020-07-22T02:00:00.000000Z",
"event_guests": [
Expand Down
5 changes: 5 additions & 0 deletions test/testdata/scheduled_events_002_page2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"collection": [
{
"cancellation": {
"canceled_by": "FooBar",
"reason": "I have to be absent next week, sorry.",
"canceler_type": "invitee"
},
"created_at": "2020-07-10T05:00:00.000Z",
"end_time": "2020-07-22T02:00:00.000Z",
"event_guests": [],
Expand Down

0 comments on commit 7ddd032

Please sign in to comment.