calendlyr 0.7.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +9 -5
- data/.gitignore +3 -1
- data/CHANGELOG.md +98 -0
- data/README.md +209 -73
- data/calendlyr.gemspec +8 -6
- data/docs/resources/activity_log/list_activity_log_entries.md +2 -1
- data/docs/resources/availabilities/user_availability_schedule.md +3 -2
- data/docs/resources/availabilities/user_busy_time.md +3 -2
- data/docs/resources/data_compliance.md +1 -1
- data/docs/resources/event_types/availability_schedule.md +28 -0
- data/docs/resources/event_types/available_time.md +15 -11
- data/docs/resources/event_types/event_type.md +21 -9
- data/docs/resources/event_types/membership.md +15 -16
- data/docs/resources/events/cancellation.md +1 -1
- data/docs/resources/events/event.md +6 -5
- data/docs/resources/events/invitee.md +18 -0
- data/docs/resources/events/invitee_no_show.md +2 -1
- data/docs/resources/groups/group.md +2 -1
- data/docs/resources/locations/location.md +16 -0
- data/docs/resources/organizations/membership.md +3 -2
- data/docs/resources/organizations/organization.md +13 -9
- data/docs/resources/outgoing_communications/outgoing_communication.md +28 -0
- data/docs/resources/routing_forms/routing_form.md +2 -1
- data/docs/resources/routing_forms/submission.md +2 -1
- data/docs/resources/scheduling_links/scheduling_link.md +26 -0
- data/docs/resources/share.md +4 -10
- data/docs/resources/webhooks/invitee_payload.md +10 -16
- data/docs/resources/webhooks/payload.md +32 -3
- data/docs/resources/webhooks/sample.md +23 -0
- data/docs/resources/webhooks/subscription.md +10 -6
- data/lib/calendlyr/client.rb +7 -2
- data/lib/calendlyr/collection.rb +42 -9
- data/lib/calendlyr/configuration.rb +24 -0
- data/lib/calendlyr/error.rb +65 -27
- data/lib/calendlyr/object.rb +85 -13
- data/lib/calendlyr/objects/event_type.rb +0 -4
- data/lib/calendlyr/objects/event_types/availability_schedule.rb +8 -0
- data/lib/calendlyr/objects/event_types/available_time.rb +5 -1
- data/lib/calendlyr/objects/event_types/membership.rb +4 -7
- data/lib/calendlyr/objects/events/invitee.rb +1 -1
- data/lib/calendlyr/objects/location.rb +4 -0
- data/lib/calendlyr/objects/organization.rb +0 -4
- data/lib/calendlyr/objects/outgoing_communication.rb +6 -0
- data/lib/calendlyr/objects/scheduling_link.rb +2 -5
- data/lib/calendlyr/objects/share.rb +0 -5
- data/lib/calendlyr/objects/webhooks/payload.rb +30 -0
- data/lib/calendlyr/resource.rb +84 -12
- data/lib/calendlyr/resources/availability.rb +14 -2
- data/lib/calendlyr/resources/event_types.rb +45 -5
- data/lib/calendlyr/resources/events.rb +20 -2
- data/lib/calendlyr/resources/groups.rb +14 -2
- data/lib/calendlyr/resources/locations.rb +13 -0
- data/lib/calendlyr/resources/organizations.rb +25 -3
- data/lib/calendlyr/resources/outgoing_communications.rb +11 -3
- data/lib/calendlyr/resources/routing_forms.rb +14 -2
- data/lib/calendlyr/resources/scheduling_links.rb +5 -2
- data/lib/calendlyr/resources/shares.rb +1 -0
- data/lib/calendlyr/resources/webhooks.rb +11 -3
- data/lib/calendlyr/version.rb +1 -1
- data/lib/calendlyr/webhook.rb +105 -0
- data/lib/calendlyr.rb +50 -0
- data/logos/calendlyr.png +0 -0
- data/logos/calendlyr_bg_white.png +0 -0
- data/test/calendlyr/client_test.rb +29 -0
- data/test/calendlyr/collection_test.rb +168 -0
- data/test/calendlyr/configuration_test.rb +157 -0
- data/test/calendlyr/object_test.rb +82 -1
- data/test/calendlyr/objects/event_type_test.rb +0 -15
- data/test/calendlyr/objects/event_types/availability_schedule_test.rb +20 -0
- data/test/calendlyr/objects/events/cancellation_test.rb +1 -1
- data/test/calendlyr/objects/events/guest_test.rb +1 -1
- data/test/calendlyr/objects/events/invitee_no_show_test.rb +1 -1
- data/test/calendlyr/objects/events/invitee_test.rb +10 -3
- data/test/calendlyr/objects/location_test.rb +22 -0
- data/test/calendlyr/objects/organization_test.rb +0 -8
- data/test/calendlyr/objects/organizations/invitation_test.rb +1 -1
- data/test/calendlyr/objects/share_test.rb +3 -9
- data/test/calendlyr/objects/webhooks/payload_test.rb +15 -0
- data/test/calendlyr/resource_test.rb +456 -2
- data/test/calendlyr/resources/availabilities/user_busy_times_test.rb +26 -0
- data/test/calendlyr/resources/availabilities/user_schedules_test.rb +25 -0
- data/test/calendlyr/resources/data_compliance_test.rb +1 -4
- data/test/calendlyr/resources/event_types_test.rb +132 -0
- data/test/calendlyr/resources/events_test.rb +87 -0
- data/test/calendlyr/resources/groups_test.rb +54 -0
- data/test/calendlyr/resources/locations_test.rb +30 -0
- data/test/calendlyr/resources/organizations_test.rb +96 -2
- data/test/calendlyr/resources/outgoing_communications_test.rb +34 -8
- data/test/calendlyr/resources/routing_forms_test.rb +57 -0
- data/test/calendlyr/resources/scheduling_links_test.rb +31 -6
- data/test/calendlyr/resources/shares_test.rb +15 -0
- data/test/calendlyr/resources/webhooks_test.rb +63 -5
- data/test/calendlyr/webhook_test.rb +292 -0
- data/test/fixtures/activity_log/list_page2.json +30 -0
- data/test/fixtures/event_invitees/list_page2.json +35 -0
- data/test/fixtures/event_invitees/retrieve.json +11 -1
- data/test/fixtures/event_type_availability_schedules/list.json +17 -0
- data/test/fixtures/event_type_availability_schedules/update.json +3 -0
- data/test/fixtures/event_type_available_times/list.json +0 -12
- data/test/fixtures/event_type_memberships/list.json +43 -0
- data/test/fixtures/event_type_memberships/list_page2.json +33 -0
- data/test/fixtures/event_types/create.json +30 -0
- data/test/fixtures/event_types/list_page2.json +37 -0
- data/test/fixtures/event_types/update.json +30 -0
- data/test/fixtures/events/create_invitee.json +37 -0
- data/test/fixtures/events/list_page2.json +29 -0
- data/test/fixtures/events/retrieve.json +12 -2
- data/test/fixtures/group_relationships/list_page2.json +35 -0
- data/test/fixtures/groups/list_page2.json +16 -0
- data/test/fixtures/locations/list.json +16 -0
- data/test/fixtures/locations/list_page2.json +16 -0
- data/test/fixtures/objects/event.json +10 -2
- data/test/fixtures/objects/event_types/availability_schedule.json +6 -0
- data/test/fixtures/objects/location.json +5 -0
- data/test/fixtures/organizations/list_invitations_page2.json +18 -0
- data/test/fixtures/organizations/list_memberships_page2.json +26 -0
- data/test/fixtures/organizations/retrieve.json +11 -0
- data/test/fixtures/outgoing_communications/list.json +4 -6
- data/test/fixtures/outgoing_communications/list_page2.json +21 -0
- data/test/fixtures/routing_forms/list_page2.json +17 -0
- data/test/fixtures/routing_forms/list_routing_form_submission_page2.json +29 -0
- data/test/fixtures/user_availability_schedules/list_page1.json +16 -0
- data/test/fixtures/user_availability_schedules/list_page2.json +16 -0
- data/test/fixtures/user_busy_times/list_page1.json +18 -0
- data/test/fixtures/user_busy_times/list_page2.json +13 -0
- data/test/fixtures/webhooks/list_page2.json +23 -0
- data/test/fixtures/webhooks/sample.json +55 -94
- data/test/test_helper.rb +19 -7
- metadata +70 -27
- data/docs/resources/scheduling_link.md +0 -26
- data/test/calendlyr/objects/event_types/available_time_test.rb +0 -20
- data/test/calendlyr/objects/event_types/membership_test.rb +0 -32
- data/test/calendlyr/objects/scheduling_link_test.rb +0 -17
- data/test/calendlyr/resources/event_types/membership_test.rb +0 -22
- data/test/fixtures/objects/event_types/available_time.json +0 -6
- data/test/fixtures/objects/event_types/membership.json +0 -65
- data/test/fixtures/objects/scheduling_links/event_type.json +0 -5
|
@@ -38,4 +38,91 @@ class EventsResourceTest < Minitest::Test
|
|
|
38
38
|
assert_equal "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2", event.uri
|
|
39
39
|
assert_equal "15 Minute Meeting", event.name
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
def test_list_with_bare_user_uuid
|
|
43
|
+
bare_uuid = "abc123"
|
|
44
|
+
expanded = "https://api.calendly.com/users/#{bare_uuid}"
|
|
45
|
+
stub(path: "scheduled_events?user=#{expanded}", response: {body: fixture_file("events/list"), status: 200})
|
|
46
|
+
|
|
47
|
+
events = client.events.list(user: bare_uuid)
|
|
48
|
+
|
|
49
|
+
assert_equal Calendlyr::Collection, events.class
|
|
50
|
+
assert_equal 1, events.data.count
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_create_invitee
|
|
54
|
+
body = {
|
|
55
|
+
event_type: "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA",
|
|
56
|
+
start_time: "2019-08-07T06:05:04.321123Z",
|
|
57
|
+
invitee: {
|
|
58
|
+
name: "John Doe",
|
|
59
|
+
email: "test@example.com",
|
|
60
|
+
timezone: "America/New_York"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
stub(method: :post, path: "invitees", response: {body: fixture_file("events/create_invitee"), status: 201})
|
|
64
|
+
invitee = client.events.create_invitee(**body)
|
|
65
|
+
|
|
66
|
+
assert_equal Calendlyr::Events::Invitee, invitee.class
|
|
67
|
+
assert_equal "test@example.com", invitee.email
|
|
68
|
+
assert_equal "John Doe", invitee.name
|
|
69
|
+
assert_equal "active", invitee.status
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_create_invitee_with_bare_event_type_uuid
|
|
73
|
+
bare_uuid = "ET-456"
|
|
74
|
+
expanded = "https://api.calendly.com/event_types/#{bare_uuid}"
|
|
75
|
+
body = {
|
|
76
|
+
event_type: expanded,
|
|
77
|
+
start_time: "2019-08-07T06:05:04.321123Z",
|
|
78
|
+
invitee: {name: "John Doe", email: "test@example.com", timezone: "America/New_York"}
|
|
79
|
+
}
|
|
80
|
+
stub(method: :post, path: "invitees", body: body, response: {body: fixture_file("events/create_invitee"), status: 201})
|
|
81
|
+
|
|
82
|
+
invitee = client.events.create_invitee(
|
|
83
|
+
event_type: bare_uuid,
|
|
84
|
+
start_time: "2019-08-07T06:05:04.321123Z",
|
|
85
|
+
invitee: {name: "John Doe", email: "test@example.com", timezone: "America/New_York"}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
assert_equal Calendlyr::Events::Invitee, invitee.class
|
|
89
|
+
assert_equal "test@example.com", invitee.email
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_create_invitee_no_show_with_bare_invitee_uuid
|
|
93
|
+
bare_uuid = "INV-789"
|
|
94
|
+
expanded = "https://api.calendly.com/invitees/#{bare_uuid}"
|
|
95
|
+
stub(method: :post, path: "invitee_no_shows", body: {invitee: expanded}, response: {body: fixture_file("events/create_invitee_no_show"), status: 201})
|
|
96
|
+
|
|
97
|
+
no_show = client.events.create_invitee_no_show(invitee: bare_uuid)
|
|
98
|
+
|
|
99
|
+
assert_equal Calendlyr::Events::InviteeNoShow, no_show.class
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_list_all_returns_all_pages
|
|
103
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
104
|
+
page2_path = "scheduled_events?user=#{@user_uri}&organization=#{@organization_uri}&page_token=#{token}"
|
|
105
|
+
stub(path: page2_path, response: {body: fixture_file("events/list_page2"), status: 200})
|
|
106
|
+
|
|
107
|
+
events = client.events.list_all(user: @user_uri, organization: @organization_uri)
|
|
108
|
+
|
|
109
|
+
assert_equal Array, events.class
|
|
110
|
+
assert_equal 2, events.size
|
|
111
|
+
assert_equal Calendlyr::Event, events.first.class
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_list_all_invitees_returns_all_pages
|
|
115
|
+
event_uuid = "abc123"
|
|
116
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
117
|
+
page1_path = "scheduled_events/#{event_uuid}/invitees"
|
|
118
|
+
page2_path = "scheduled_events/#{event_uuid}/invitees?page_token=#{token}"
|
|
119
|
+
stub(path: page1_path, response: {body: fixture_file("event_invitees/list"), status: 200})
|
|
120
|
+
stub(path: page2_path, response: {body: fixture_file("event_invitees/list_page2"), status: 200})
|
|
121
|
+
|
|
122
|
+
invitees = client.events.list_all_invitees(uuid: event_uuid)
|
|
123
|
+
|
|
124
|
+
assert_equal Array, invitees.class
|
|
125
|
+
assert_equal 2, invitees.size
|
|
126
|
+
assert_equal Calendlyr::Events::Invitee, invitees.first.class
|
|
127
|
+
end
|
|
41
128
|
end
|
|
@@ -14,6 +14,29 @@ class GroupsResourceTest < Minitest::Test
|
|
|
14
14
|
assert_instance_of Calendlyr::Group, groups.data.first
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def test_list_with_bare_org_uuid
|
|
18
|
+
bare_uuid = "AAAAAAAAAAAAAAAA"
|
|
19
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
20
|
+
response = {body: fixture_file("groups/list"), status: 200}
|
|
21
|
+
stub(path: "groups?organization=#{expanded}", response: response)
|
|
22
|
+
|
|
23
|
+
groups = client.groups.list(organization: bare_uuid)
|
|
24
|
+
|
|
25
|
+
assert_equal 1, groups.data.size
|
|
26
|
+
assert_instance_of Calendlyr::Group, groups.data.first
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_list_relationships_with_bare_org_uuid
|
|
30
|
+
bare_uuid = "AAAAAAAAAAAAAAAA"
|
|
31
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
32
|
+
response = {body: fixture_file("group_relationships/list"), status: 200}
|
|
33
|
+
stub(path: "group_relationships?organization=#{expanded}", response: response)
|
|
34
|
+
|
|
35
|
+
relationships = client.groups.list_relationships(organization: bare_uuid)
|
|
36
|
+
|
|
37
|
+
assert_equal Calendlyr::Collection, relationships.class
|
|
38
|
+
end
|
|
39
|
+
|
|
17
40
|
def test_retrieve
|
|
18
41
|
uuid = "abc123"
|
|
19
42
|
response = {body: fixture_file("group_relationships/retrieve"), status: 200}
|
|
@@ -23,4 +46,35 @@ class GroupsResourceTest < Minitest::Test
|
|
|
23
46
|
assert_instance_of Calendlyr::Groups::Relationship, relationship
|
|
24
47
|
assert_equal "member", relationship.role
|
|
25
48
|
end
|
|
49
|
+
|
|
50
|
+
def test_list_all_returns_all_pages
|
|
51
|
+
organization = "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA"
|
|
52
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
53
|
+
page1_response = {body: fixture_file("groups/list"), status: 200}
|
|
54
|
+
page2_response = {body: fixture_file("groups/list_page2"), status: 200}
|
|
55
|
+
stub(path: "groups?organization=#{organization}", response: page1_response)
|
|
56
|
+
stub(path: "groups?organization=#{organization}&page_token=#{token}", response: page2_response)
|
|
57
|
+
|
|
58
|
+
groups = client.groups.list_all(organization: organization)
|
|
59
|
+
|
|
60
|
+
assert_equal Array, groups.class
|
|
61
|
+
assert_equal 2, groups.size
|
|
62
|
+
assert_equal Calendlyr::Group, groups.first.class
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_list_all_relationships_returns_all_pages
|
|
66
|
+
bare_uuid = "AAAAAAAAAAAAAAAA"
|
|
67
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
68
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
69
|
+
page1_response = {body: fixture_file("group_relationships/list"), status: 200}
|
|
70
|
+
page2_response = {body: fixture_file("group_relationships/list_page2"), status: 200}
|
|
71
|
+
stub(path: "group_relationships?organization=#{expanded}", response: page1_response)
|
|
72
|
+
stub(path: "group_relationships?organization=#{expanded}&page_token=#{token}", response: page2_response)
|
|
73
|
+
|
|
74
|
+
relationships = client.groups.list_all_relationships(organization: bare_uuid)
|
|
75
|
+
|
|
76
|
+
assert_equal Array, relationships.class
|
|
77
|
+
assert_equal 4, relationships.size
|
|
78
|
+
assert_equal Calendlyr::Groups::Relationship, relationships.first.class
|
|
79
|
+
end
|
|
26
80
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class LocationsResourceTest < Minitest::Test
|
|
6
|
+
def setup
|
|
7
|
+
list_response = {body: fixture_file("locations/list"), status: 200}
|
|
8
|
+
stub(path: "locations", response: list_response)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_list
|
|
12
|
+
locations = client.locations.list
|
|
13
|
+
|
|
14
|
+
assert_equal Calendlyr::Collection, locations.class
|
|
15
|
+
assert_equal Calendlyr::Location, locations.data.first.class
|
|
16
|
+
assert_equal 1, locations.data.count
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_list_all_returns_all_pages
|
|
20
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
21
|
+
page2_response = {body: fixture_file("locations/list_page2"), status: 200}
|
|
22
|
+
stub(path: "locations?page_token=#{token}", response: page2_response)
|
|
23
|
+
|
|
24
|
+
locations = client.locations.list_all
|
|
25
|
+
|
|
26
|
+
assert_equal Array, locations.class
|
|
27
|
+
assert_equal 2, locations.size
|
|
28
|
+
assert_equal Calendlyr::Location, locations.first.class
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
require "test_helper"
|
|
4
4
|
|
|
5
5
|
class OrganizationsResourceTest < Minitest::Test
|
|
6
|
+
def test_retrieve
|
|
7
|
+
organization_uuid = "012345678901234567890"
|
|
8
|
+
stub(path: "organizations/#{organization_uuid}", response: {body: fixture_file("organizations/retrieve"), status: 200})
|
|
9
|
+
|
|
10
|
+
organization = client.organizations.retrieve(uuid: organization_uuid)
|
|
11
|
+
|
|
12
|
+
assert_equal Calendlyr::Organization, organization.class
|
|
13
|
+
assert_equal "https://api.calendly.com/organizations/012345678901234567890", organization.uri
|
|
14
|
+
assert_equal "Sales Team", organization.name
|
|
15
|
+
assert_equal "professional", organization.plan
|
|
16
|
+
end
|
|
17
|
+
|
|
6
18
|
def test_invite
|
|
7
19
|
organization_uuid = "ABCDABCDABCDABCD"
|
|
8
20
|
email = "email@example.com"
|
|
@@ -58,8 +70,8 @@ class OrganizationsResourceTest < Minitest::Test
|
|
|
58
70
|
|
|
59
71
|
# Memberships
|
|
60
72
|
def test_list_memberships
|
|
61
|
-
user_uri = "abc123"
|
|
62
|
-
organization_uri = "abc123"
|
|
73
|
+
user_uri = "https://api.calendly.com/users/abc123"
|
|
74
|
+
organization_uri = "https://api.calendly.com/organizations/abc123"
|
|
63
75
|
response = {body: fixture_file("organizations/list_memberships"), status: 200}
|
|
64
76
|
stub(path: "organization_memberships?user=#{user_uri}&organization=#{organization_uri}", response: response)
|
|
65
77
|
memberships = client.organizations.list_memberships(user: user_uri, organization: organization_uri)
|
|
@@ -70,6 +82,41 @@ class OrganizationsResourceTest < Minitest::Test
|
|
|
70
82
|
assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token
|
|
71
83
|
end
|
|
72
84
|
|
|
85
|
+
def test_activity_log_with_bare_org_uuid
|
|
86
|
+
bare_uuid = "ORG-2"
|
|
87
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
88
|
+
response = {body: fixture_file("activity_log/list"), status: 200}
|
|
89
|
+
stub(path: "activity_log_entries?organization=#{expanded}", response: response)
|
|
90
|
+
|
|
91
|
+
result = client.organizations.activity_log(organization: bare_uuid)
|
|
92
|
+
|
|
93
|
+
assert_equal Calendlyr::Collection, result.class
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_list_memberships_with_bare_user_uuid
|
|
97
|
+
bare_uuid = "USER-1"
|
|
98
|
+
expanded = "https://api.calendly.com/users/#{bare_uuid}"
|
|
99
|
+
response = {body: fixture_file("organizations/list_memberships"), status: 200}
|
|
100
|
+
stub(path: "organization_memberships?user=#{expanded}", response: response)
|
|
101
|
+
|
|
102
|
+
memberships = client.organizations.list_memberships(user: bare_uuid)
|
|
103
|
+
|
|
104
|
+
assert_equal Calendlyr::Collection, memberships.class
|
|
105
|
+
assert_equal 1, memberships.data.count
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_list_memberships_with_bare_org_uuid
|
|
109
|
+
bare_uuid = "ORG-1"
|
|
110
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
111
|
+
response = {body: fixture_file("organizations/list_memberships"), status: 200}
|
|
112
|
+
stub(path: "organization_memberships?organization=#{expanded}", response: response)
|
|
113
|
+
|
|
114
|
+
memberships = client.organizations.list_memberships(organization: bare_uuid)
|
|
115
|
+
|
|
116
|
+
assert_equal Calendlyr::Collection, memberships.class
|
|
117
|
+
assert_equal 1, memberships.data.count
|
|
118
|
+
end
|
|
119
|
+
|
|
73
120
|
def test_retrieve_membership
|
|
74
121
|
membership_uuid = "abc123"
|
|
75
122
|
response = {body: fixture_file("organizations/retrieve_membership"), status: 200}
|
|
@@ -88,4 +135,51 @@ class OrganizationsResourceTest < Minitest::Test
|
|
|
88
135
|
stub(method: :delete, path: "organization_memberships/#{membership_uuid}", response: response)
|
|
89
136
|
assert client.organizations.remove_user(uuid: membership_uuid)
|
|
90
137
|
end
|
|
138
|
+
|
|
139
|
+
def test_list_all_memberships_returns_all_pages
|
|
140
|
+
user_uri = "https://api.calendly.com/users/abc123"
|
|
141
|
+
organization_uri = "https://api.calendly.com/organizations/abc123"
|
|
142
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
143
|
+
page1_response = {body: fixture_file("organizations/list_memberships"), status: 200}
|
|
144
|
+
page2_response = {body: fixture_file("organizations/list_memberships_page2"), status: 200}
|
|
145
|
+
stub(path: "organization_memberships?user=#{user_uri}&organization=#{organization_uri}", response: page1_response)
|
|
146
|
+
stub(path: "organization_memberships?user=#{user_uri}&organization=#{organization_uri}&page_token=#{token}", response: page2_response)
|
|
147
|
+
|
|
148
|
+
memberships = client.organizations.list_all_memberships(user: user_uri, organization: organization_uri)
|
|
149
|
+
|
|
150
|
+
assert_equal Array, memberships.class
|
|
151
|
+
assert_equal 2, memberships.size
|
|
152
|
+
assert_equal Calendlyr::Organizations::Membership, memberships.first.class
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_list_all_invitations_returns_all_pages
|
|
156
|
+
organization_uuid = "abc123"
|
|
157
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
158
|
+
page1_response = {body: fixture_file("organizations/list_invitations"), status: 200}
|
|
159
|
+
page2_response = {body: fixture_file("organizations/list_invitations_page2"), status: 200}
|
|
160
|
+
stub(path: "organizations/#{organization_uuid}/invitations", response: page1_response)
|
|
161
|
+
stub(path: "organizations/#{organization_uuid}/invitations?page_token=#{token}", response: page2_response)
|
|
162
|
+
|
|
163
|
+
invitations = client.organizations.list_all_invitations(uuid: organization_uuid)
|
|
164
|
+
|
|
165
|
+
assert_equal Array, invitations.class
|
|
166
|
+
assert_equal 2, invitations.size
|
|
167
|
+
assert_equal Calendlyr::Organizations::Invitation, invitations.first.class
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def test_list_all_activity_log_returns_all_pages
|
|
171
|
+
bare_uuid = "ORG-2"
|
|
172
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
173
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
174
|
+
page1_response = {body: fixture_file("activity_log/list"), status: 200}
|
|
175
|
+
page2_response = {body: fixture_file("activity_log/list_page2"), status: 200}
|
|
176
|
+
stub(path: "activity_log_entries?organization=#{expanded}", response: page1_response)
|
|
177
|
+
stub(path: "activity_log_entries?organization=#{expanded}&page_token=#{token}", response: page2_response)
|
|
178
|
+
|
|
179
|
+
entries = client.organizations.list_all_activity_log(organization: bare_uuid)
|
|
180
|
+
|
|
181
|
+
assert_equal Array, entries.class
|
|
182
|
+
assert_equal 2, entries.size
|
|
183
|
+
assert_equal Calendlyr::ActivityLog, entries.first.class
|
|
184
|
+
end
|
|
91
185
|
end
|
|
@@ -4,13 +4,39 @@ require "test_helper"
|
|
|
4
4
|
|
|
5
5
|
class OutgoingCommunicationsResourceTest < Minitest::Test
|
|
6
6
|
def test_list
|
|
7
|
-
|
|
8
|
-
stub(path: "outgoing_communications", response:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
assert_equal Calendlyr::
|
|
13
|
-
assert_equal
|
|
14
|
-
assert_equal
|
|
7
|
+
organization_uri = "https://api.calendly.com/organizations/abc123"
|
|
8
|
+
stub(path: "outgoing_communications?organization=#{organization_uri}", response: {body: fixture_file("outgoing_communications/list"), status: 200})
|
|
9
|
+
|
|
10
|
+
communications = client.outgoing_communications.list(organization: organization_uri)
|
|
11
|
+
|
|
12
|
+
assert_equal Calendlyr::Collection, communications.class
|
|
13
|
+
assert_equal Calendlyr::OutgoingCommunication, communications.data.first.class
|
|
14
|
+
assert_equal 1, communications.data.count
|
|
15
|
+
assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", communications.next_page_token
|
|
16
|
+
assert_equal "sms", communications.data.first.type
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_list_with_bare_org_uuid
|
|
20
|
+
bare_uuid = "abc123"
|
|
21
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
22
|
+
stub(path: "outgoing_communications?organization=#{expanded}", response: {body: fixture_file("outgoing_communications/list"), status: 200})
|
|
23
|
+
|
|
24
|
+
communications = client.outgoing_communications.list(organization: bare_uuid)
|
|
25
|
+
|
|
26
|
+
assert_equal Calendlyr::Collection, communications.class
|
|
27
|
+
assert_equal 1, communications.data.count
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_list_all_returns_all_pages
|
|
31
|
+
organization_uri = "https://api.calendly.com/organizations/abc123"
|
|
32
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
33
|
+
stub(path: "outgoing_communications?organization=#{organization_uri}", response: {body: fixture_file("outgoing_communications/list"), status: 200})
|
|
34
|
+
stub(path: "outgoing_communications?organization=#{organization_uri}&page_token=#{token}", response: {body: fixture_file("outgoing_communications/list_page2"), status: 200})
|
|
35
|
+
|
|
36
|
+
communications = client.outgoing_communications.list_all(organization: organization_uri)
|
|
37
|
+
|
|
38
|
+
assert_equal Array, communications.class
|
|
39
|
+
assert_equal 2, communications.size
|
|
40
|
+
assert_equal Calendlyr::OutgoingCommunication, communications.first.class
|
|
15
41
|
end
|
|
16
42
|
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class RoutingFormsResourceTest < Minitest::Test
|
|
6
|
+
def test_list_with_bare_org_uuid
|
|
7
|
+
bare_uuid = "ORG-123"
|
|
8
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
9
|
+
stub(path: "routing_forms?organization=#{expanded}", response: {body: fixture_file("routing_forms/list"), status: 200})
|
|
10
|
+
|
|
11
|
+
forms = client.routing_forms.list(organization: bare_uuid)
|
|
12
|
+
|
|
13
|
+
assert_equal Calendlyr::Collection, forms.class
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_list_submissions_with_bare_form_uuid
|
|
17
|
+
bare_uuid = "FORM-123"
|
|
18
|
+
expanded = "https://api.calendly.com/routing_forms/#{bare_uuid}"
|
|
19
|
+
stub(path: "routing_form_submissions?form=#{expanded}", response: {body: fixture_file("routing_forms/list_routing_form_submission"), status: 200})
|
|
20
|
+
|
|
21
|
+
submissions = client.routing_forms.list_submissions(form: bare_uuid)
|
|
22
|
+
|
|
23
|
+
assert_equal Calendlyr::Collection, submissions.class
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_list_all_returns_all_pages
|
|
27
|
+
bare_uuid = "ORG-123"
|
|
28
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
29
|
+
token = "d8T0LKQ1XsC2utmPlI7TFPpHX4SSfoGl"
|
|
30
|
+
page1_response = {body: fixture_file("routing_forms/list"), status: 200}
|
|
31
|
+
page2_response = {body: fixture_file("routing_forms/list_page2"), status: 200}
|
|
32
|
+
stub(path: "routing_forms?organization=#{expanded}", response: page1_response)
|
|
33
|
+
stub(path: "routing_forms?organization=#{expanded}&page_token=#{token}", response: page2_response)
|
|
34
|
+
|
|
35
|
+
forms = client.routing_forms.list_all(organization: bare_uuid)
|
|
36
|
+
|
|
37
|
+
assert_equal Array, forms.class
|
|
38
|
+
assert_equal 2, forms.size
|
|
39
|
+
assert_equal Calendlyr::RoutingForm, forms.first.class
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_list_all_submissions_returns_all_pages
|
|
43
|
+
bare_uuid = "FORM-123"
|
|
44
|
+
expanded = "https://api.calendly.com/routing_forms/#{bare_uuid}"
|
|
45
|
+
token = "d8T0LKQ1XsC2utmPlI7TFPpHX4SSfoGl"
|
|
46
|
+
page1_response = {body: fixture_file("routing_forms/list_routing_form_submission"), status: 200}
|
|
47
|
+
page2_response = {body: fixture_file("routing_forms/list_routing_form_submission_page2"), status: 200}
|
|
48
|
+
stub(path: "routing_form_submissions?form=#{expanded}", response: page1_response)
|
|
49
|
+
stub(path: "routing_form_submissions?form=#{expanded}&page_token=#{token}", response: page2_response)
|
|
50
|
+
|
|
51
|
+
submissions = client.routing_forms.list_all_submissions(form: bare_uuid)
|
|
52
|
+
|
|
53
|
+
assert_equal Array, submissions.class
|
|
54
|
+
assert_equal 2, submissions.size
|
|
55
|
+
assert_equal Calendlyr::RoutingForms::Submission, submissions.first.class
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -4,12 +4,37 @@ require "test_helper"
|
|
|
4
4
|
|
|
5
5
|
class SchedulingLinksResourceTest < Minitest::Test
|
|
6
6
|
def test_create
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
response = {body: fixture_file("scheduling_links/create"), status: 201}
|
|
11
|
-
stub(method: :post, path: "scheduling_links", body: {owner: owner_uri, max_event_count: max_event_count, owner_type: owner_type}, response: response)
|
|
7
|
+
event_type_uri = "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2"
|
|
8
|
+
body = {max_event_count: 1, owner: event_type_uri, owner_type: "EventType"}
|
|
9
|
+
stub(method: :post, path: "scheduling_links", body: body, response: {body: fixture_file("scheduling_links/create"), status: 201})
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
link = client.scheduling_links.create(owner: event_type_uri)
|
|
12
|
+
|
|
13
|
+
assert_equal Calendlyr::SchedulingLink, link.class
|
|
14
|
+
assert_equal "https://calendly.com/d/abcd-brv8/15-minute-meeting", link.booking_url
|
|
15
|
+
assert_equal event_type_uri, link.owner
|
|
16
|
+
assert_equal "EventType", link.owner_type
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_create_with_bare_event_type_uuid
|
|
20
|
+
bare_uuid = "GBGBDCAADAEDCRZ2"
|
|
21
|
+
expanded = "https://api.calendly.com/event_types/#{bare_uuid}"
|
|
22
|
+
body = {max_event_count: 1, owner: expanded, owner_type: "EventType"}
|
|
23
|
+
stub(method: :post, path: "scheduling_links", body: body, response: {body: fixture_file("scheduling_links/create"), status: 201})
|
|
24
|
+
|
|
25
|
+
link = client.scheduling_links.create(owner: bare_uuid)
|
|
26
|
+
|
|
27
|
+
assert_equal Calendlyr::SchedulingLink, link.class
|
|
28
|
+
assert_equal "https://calendly.com/d/abcd-brv8/15-minute-meeting", link.booking_url
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_create_with_custom_max_event_count
|
|
32
|
+
event_type_uri = "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2"
|
|
33
|
+
body = {max_event_count: 5, owner: event_type_uri, owner_type: "EventType"}
|
|
34
|
+
stub(method: :post, path: "scheduling_links", body: body, response: {body: fixture_file("scheduling_links/create"), status: 201})
|
|
35
|
+
|
|
36
|
+
link = client.scheduling_links.create(owner: event_type_uri, max_event_count: 5)
|
|
37
|
+
|
|
38
|
+
assert_equal Calendlyr::SchedulingLink, link.class
|
|
14
39
|
end
|
|
15
40
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class SharesResourceTest < Minitest::Test
|
|
6
|
+
def test_create_with_bare_event_type_uuid
|
|
7
|
+
bare_uuid = "ET-99"
|
|
8
|
+
expanded = "https://api.calendly.com/event_types/#{bare_uuid}"
|
|
9
|
+
stub(method: :post, path: "shares", body: {event_type: expanded}, response: {body: fixture_file("shares/create"), status: 201})
|
|
10
|
+
|
|
11
|
+
share = client.shares.create(event_type: bare_uuid)
|
|
12
|
+
|
|
13
|
+
assert_equal Calendlyr::Share, share.class
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -37,6 +37,30 @@ class WebhooksResourceTest < Minitest::Test
|
|
|
37
37
|
assert_equal webhook.active?, true
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
def test_list_with_bare_org_uuid
|
|
41
|
+
bare_uuid = "abc123"
|
|
42
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
43
|
+
scope = "organization"
|
|
44
|
+
response = {body: fixture_file("webhooks/list"), status: 200}
|
|
45
|
+
stub(path: "webhook_subscriptions?organization=#{expanded}&scope=#{scope}", response: response)
|
|
46
|
+
|
|
47
|
+
webhooks = client.webhooks.list(organization: bare_uuid, scope: scope)
|
|
48
|
+
|
|
49
|
+
assert_equal Calendlyr::Collection, webhooks.class
|
|
50
|
+
assert_equal 1, webhooks.data.count
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_create_with_bare_org_uuid
|
|
54
|
+
bare_uuid = "abc123"
|
|
55
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
56
|
+
body = {url: "https://blah.foo/bar", events: ["invitee.created"], organization: expanded, scope: "user", user: "https://api.calendly.com/users/abc123"}
|
|
57
|
+
stub(method: :post, path: "webhook_subscriptions", body: body, response: {body: fixture_file("webhooks/create"), status: 201})
|
|
58
|
+
|
|
59
|
+
result = client.webhooks.create(url: "https://blah.foo/bar", events: ["invitee.created"], organization: bare_uuid, scope: "user", user: "https://api.calendly.com/users/abc123")
|
|
60
|
+
|
|
61
|
+
assert result
|
|
62
|
+
end
|
|
63
|
+
|
|
40
64
|
def test_delete
|
|
41
65
|
webhook_uuid = "abc123"
|
|
42
66
|
response = {body: fixture_file("webhooks/delete")}
|
|
@@ -44,11 +68,45 @@ class WebhooksResourceTest < Minitest::Test
|
|
|
44
68
|
assert client.webhooks.delete(webhook_uuid: webhook_uuid)
|
|
45
69
|
end
|
|
46
70
|
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
def test_list_all_returns_all_pages
|
|
72
|
+
organization_uri = "https://api.calendly.com/organizations/abc123"
|
|
73
|
+
scope = "user"
|
|
74
|
+
token = "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi"
|
|
75
|
+
page1_response = {body: fixture_file("webhooks/list"), status: 200}
|
|
76
|
+
page2_response = {body: fixture_file("webhooks/list_page2"), status: 200}
|
|
77
|
+
stub(path: "webhook_subscriptions?organization=#{organization_uri}&scope=#{scope}", response: page1_response)
|
|
78
|
+
stub(path: "webhook_subscriptions?organization=#{organization_uri}&scope=#{scope}&page_token=#{token}", response: page2_response)
|
|
79
|
+
|
|
80
|
+
webhooks = client.webhooks.list_all(organization: organization_uri, scope: scope)
|
|
81
|
+
|
|
82
|
+
assert_equal Array, webhooks.class
|
|
83
|
+
assert_equal 2, webhooks.size
|
|
84
|
+
assert_equal Calendlyr::Webhooks::Subscription, webhooks.first.class
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_sample
|
|
88
|
+
organization_uri = "https://api.calendly.com/organizations/abc123"
|
|
89
|
+
event = "invitee.created"
|
|
90
|
+
scope = "organization"
|
|
91
|
+
stub(path: "sample_webhook_data?event=#{event}&organization=#{organization_uri}&scope=#{scope}", response: {body: fixture_file("webhooks/sample"), status: 200})
|
|
92
|
+
|
|
93
|
+
result = client.webhooks.sample(event: event, organization: organization_uri, scope: scope)
|
|
94
|
+
|
|
95
|
+
assert_equal Hash, result.class
|
|
96
|
+
assert_equal "invitee.created", result["event"]
|
|
97
|
+
assert result.key?("payload")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_sample_with_bare_org_uuid
|
|
101
|
+
bare_uuid = "abc123"
|
|
102
|
+
expanded = "https://api.calendly.com/organizations/#{bare_uuid}"
|
|
103
|
+
event = "invitee.created"
|
|
104
|
+
scope = "organization"
|
|
105
|
+
stub(path: "sample_webhook_data?event=#{event}&organization=#{expanded}&scope=#{scope}", response: {body: fixture_file("webhooks/sample"), status: 200})
|
|
106
|
+
|
|
107
|
+
result = client.webhooks.sample(event: event, organization: bare_uuid, scope: scope)
|
|
50
108
|
|
|
51
|
-
assert_equal
|
|
52
|
-
assert_equal "invitee.created",
|
|
109
|
+
assert_equal Hash, result.class
|
|
110
|
+
assert_equal "invitee.created", result["event"]
|
|
53
111
|
end
|
|
54
112
|
end
|