calendlyr 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +7 -8
- data/CHANGELOG.md +7 -2
- data/README.md +59 -140
- data/calendlyr.gemspec +0 -1
- data/docs/resources/activity_log/list_activity_log_entries.md +34 -0
- data/docs/resources/availabilities/availability_rule.md +5 -0
- data/docs/resources/availabilities/user_availability_schedule.md +50 -0
- data/docs/resources/availabilities/user_busy_time.md +28 -0
- data/docs/resources/data_compliance.md +19 -0
- data/docs/resources/event_types/available_time.md +21 -0
- data/docs/resources/event_types/event_type.md +55 -0
- data/docs/resources/event_types/membership.md +29 -0
- data/docs/resources/event_types/profile.md +13 -0
- data/docs/resources/events/cancellation.md +18 -0
- data/docs/resources/events/event.md +62 -0
- data/docs/resources/events/guest.md +5 -0
- data/docs/resources/events/invitee.md +28 -0
- data/docs/resources/events/invitee_no_show.md +49 -0
- data/docs/resources/groups/group.md +56 -0
- data/docs/resources/groups/relationship.md +54 -0
- data/docs/resources/organizations/invitation.md +65 -0
- data/docs/resources/organizations/membership.md +58 -0
- data/docs/resources/organizations/organization.md +149 -0
- data/docs/resources/pagination.md +21 -0
- data/docs/resources/routing_forms/routing_form.md +48 -0
- data/docs/resources/routing_forms/submission.md +40 -0
- data/docs/resources/scheduling_link.md +26 -0
- data/docs/resources/share.md +28 -0
- data/docs/resources/user.md +111 -0
- data/docs/resources/webhooks/invitee_payload.md +42 -0
- data/docs/resources/webhooks/payload.md +5 -0
- data/docs/resources/webhooks/subscription.md +96 -0
- data/lib/calendlyr/client.rb +18 -2
- data/lib/calendlyr/collection.rb +2 -2
- data/lib/calendlyr/error.rb +37 -1
- data/lib/calendlyr/object.rb +6 -2
- data/lib/calendlyr/objects/activity_log.rb +11 -0
- data/lib/calendlyr/objects/availabilities/rule.rb +4 -0
- data/lib/calendlyr/objects/availabilities/user_busy_time.rb +7 -0
- data/lib/calendlyr/objects/availabilities/user_schedule.rb +13 -0
- data/lib/calendlyr/objects/event.rb +11 -0
- data/lib/calendlyr/objects/event_type.rb +15 -0
- data/lib/calendlyr/objects/event_types/available_time.rb +4 -0
- data/lib/calendlyr/objects/event_types/membership.rb +11 -0
- data/lib/calendlyr/objects/event_types/profile.rb +7 -0
- data/lib/calendlyr/objects/events/cancellation.rb +4 -0
- data/lib/calendlyr/objects/events/guest.rb +4 -0
- data/lib/calendlyr/objects/events/invitee.rb +11 -0
- data/lib/calendlyr/objects/events/invitee_no_show.rb +7 -0
- data/lib/calendlyr/objects/group.rb +15 -0
- data/lib/calendlyr/objects/groups/relationship.rb +15 -0
- data/lib/calendlyr/objects/organization.rb +67 -0
- data/lib/calendlyr/objects/organizations/invitation.rb +15 -0
- data/lib/calendlyr/objects/organizations/membership.rb +15 -0
- data/lib/calendlyr/objects/routing_form.rb +11 -0
- data/lib/calendlyr/objects/routing_forms/submission.rb +7 -0
- data/lib/calendlyr/objects/scheduling_link.rb +9 -0
- data/lib/calendlyr/objects/share.rb +9 -0
- data/lib/calendlyr/objects/user.rb +31 -0
- data/lib/calendlyr/objects/webhooks/invitee_payload.rb +15 -0
- data/lib/calendlyr/objects/webhooks/payload.rb +4 -0
- data/lib/calendlyr/objects/webhooks/subscription.rb +23 -0
- data/lib/calendlyr/resource.rb +2 -2
- data/lib/calendlyr/resources/availability.rb +19 -0
- data/lib/calendlyr/resources/data_compliance.rb +4 -0
- data/lib/calendlyr/resources/event.rb +40 -0
- data/lib/calendlyr/resources/event_type.rb +28 -0
- data/lib/calendlyr/resources/group.rb +22 -0
- data/lib/calendlyr/resources/organization.rb +40 -0
- data/lib/calendlyr/resources/outgoing_communication.rb +8 -0
- data/lib/calendlyr/resources/routing_form.rb +22 -0
- data/lib/calendlyr/resources/{scheduling_links.rb → scheduling_link.rb} +2 -2
- data/lib/calendlyr/resources/share.rb +8 -0
- data/lib/calendlyr/resources/user.rb +11 -0
- data/lib/calendlyr/resources/webhook.rb +25 -0
- data/lib/calendlyr/version.rb +1 -1
- data/lib/calendlyr.rb +70 -18
- data/test/calendlyr/objects/activity_log_test.rb +26 -0
- data/test/calendlyr/objects/availabilities/rule_test.rb +24 -0
- data/test/calendlyr/objects/availabilities/user_busy_time_test.rb +21 -0
- data/test/calendlyr/objects/availabilities/user_schedule_test.rb +26 -0
- data/test/calendlyr/objects/event_test.rb +32 -0
- data/test/calendlyr/objects/event_type_test.rb +43 -0
- data/test/calendlyr/objects/event_types/available_time_test.rb +20 -0
- data/test/calendlyr/objects/event_types/membership_test.rb +32 -0
- data/test/calendlyr/objects/event_types/profile_test.rb +23 -0
- data/test/calendlyr/objects/events/cancellation_test.rb +16 -0
- data/test/calendlyr/objects/events/guest_test.rb +16 -0
- data/test/calendlyr/objects/events/invitee_no_show_test.rb +23 -0
- data/test/calendlyr/objects/events/invitee_test.rb +35 -0
- data/test/calendlyr/objects/group_test.rb +40 -0
- data/test/calendlyr/objects/groups/relationship_test.rb +43 -0
- data/test/calendlyr/objects/organization_test.rb +157 -0
- data/test/calendlyr/objects/organizations/invitation_test.rb +34 -0
- data/test/calendlyr/objects/organizations/membership_test.rb +38 -0
- data/test/calendlyr/objects/routing_form_test.rb +26 -0
- data/test/calendlyr/objects/routing_forms/submission_test.rb +22 -0
- data/test/calendlyr/objects/scheduling_link_test.rb +17 -0
- data/test/calendlyr/objects/share_test.rb +19 -0
- data/test/calendlyr/objects/user_test.rb +81 -0
- data/test/calendlyr/objects/webhooks/invite_payload_test.rb +42 -0
- data/test/calendlyr/objects/webhooks/payload_test.rb +16 -0
- data/test/calendlyr/objects/webhooks/subscription_test.rb +42 -0
- data/test/calendlyr/resource_test.rb +12 -3
- data/test/calendlyr/resources/availabilities/user_busy_times_test.rb +31 -0
- data/test/calendlyr/resources/availabilities/user_schedules_test.rb +37 -0
- data/test/calendlyr/resources/data_compliance_test.rb +11 -0
- data/test/calendlyr/resources/event_types/membership_test.rb +22 -0
- data/test/calendlyr/resources/event_types_test.rb +55 -10
- data/test/calendlyr/resources/events/invitee_test.rb +31 -0
- data/test/calendlyr/resources/events_test.rb +22 -10
- data/test/calendlyr/resources/groups_test.rb +26 -0
- data/test/calendlyr/resources/organizations_test.rb +36 -100
- data/test/calendlyr/resources/outgoing_communications_test.rb +16 -0
- data/test/calendlyr/resources/scheduling_links_test.rb +1 -1
- data/test/calendlyr/resources/users_test.rb +9 -33
- data/test/calendlyr/resources/webhooks_test.rb +22 -13
- data/test/fixtures/activity_log/list.json +38 -0
- data/test/fixtures/availabilities/user_busy_times_list.json +39 -0
- data/test/fixtures/availabilities/user_schedules_list.json +93 -0
- data/test/fixtures/availabilities/user_schedules_retrieve.json +22 -0
- data/test/fixtures/data_compliance/delete_scheduled_event_data.json +1 -0
- data/test/fixtures/event_invitees/list.json +6 -6
- data/test/fixtures/event_invitees/retrieve.json +3 -3
- data/test/fixtures/event_type_available_times/list.json +22 -0
- data/test/fixtures/event_type_hosts/list.json +76 -0
- data/test/fixtures/event_types/create_one_off.json +45 -0
- data/test/fixtures/event_types/list.json +18 -4
- data/test/fixtures/event_types/retrieve.json +13 -2
- data/test/fixtures/events/cancel_invitee.json +8 -0
- data/test/fixtures/events/create_invitee_no_show.json +7 -0
- data/test/fixtures/events/delete_invitee_no_show.json +1 -0
- data/test/fixtures/events/retrieve_invitee_no_show.json +7 -0
- data/test/fixtures/group_relationships/list.json +83 -0
- data/test/fixtures/group_relationships/retrieve.json +29 -0
- data/test/fixtures/groups/list.json +19 -0
- data/test/fixtures/groups/retrieve.json +9 -0
- data/test/fixtures/objects/activity_log.json +24 -0
- data/test/fixtures/objects/availabilities/rule.json +10 -0
- data/test/fixtures/objects/availabilities/user_busy_time.json +10 -0
- data/test/fixtures/objects/availabilities/user_schedule.json +69 -0
- data/test/fixtures/objects/availability_rule.json +10 -0
- data/test/fixtures/objects/event.json +36 -0
- data/test/fixtures/objects/event_type.json +91 -0
- data/test/fixtures/objects/event_type_host.json +65 -0
- data/test/fixtures/objects/event_types/available_time.json +6 -0
- data/test/fixtures/objects/event_types/membership.json +65 -0
- data/test/fixtures/objects/event_types/profile.json +5 -0
- data/test/fixtures/objects/events/cancellation.json +6 -0
- data/test/fixtures/objects/events/guest.json +5 -0
- data/test/fixtures/objects/events/invitee.json +46 -0
- data/test/fixtures/objects/events/invitee_no_show.json +5 -0
- data/test/fixtures/objects/group.json +7 -0
- data/test/fixtures/objects/groups/relationship.json +27 -0
- data/test/fixtures/objects/organization.json +8 -0
- data/test/fixtures/objects/organizations/invitation.json +10 -0
- data/test/fixtures/objects/organizations/membership.json +18 -0
- data/test/fixtures/objects/routing_form.json +28 -0
- data/test/fixtures/objects/routing_forms/submission.json +27 -0
- data/test/fixtures/objects/scheduling_links/event_type.json +5 -0
- data/test/fixtures/objects/share.json +43 -0
- data/test/fixtures/objects/user.json +13 -0
- data/test/fixtures/objects/webhooks/invite_payload.json +83 -0
- data/test/fixtures/objects/webhooks/payload.json +66 -0
- data/test/fixtures/objects/webhooks/subscription.json +15 -0
- data/test/fixtures/organization_memberships/list.json +29 -0
- data/test/fixtures/organization_memberships/retrieve.json +20 -0
- data/test/fixtures/organizations/list_invitations.json +4 -4
- data/test/fixtures/organizations/list_memberships.json +12 -9
- data/test/fixtures/organizations/retrieve_invitation.json +3 -3
- data/test/fixtures/organizations/retrieve_membership.json +3 -3
- data/test/fixtures/outgoing_communications/list.json +26 -0
- data/test/fixtures/resources/401.json +2 -2
- data/test/fixtures/resources/403.json +1 -1
- data/test/fixtures/resources/403_payment_required.json +4 -0
- data/test/fixtures/resources/424.json +4 -0
- data/test/fixtures/routing_forms/list.json +39 -0
- data/test/fixtures/routing_forms/list_routing_form_submission.json +38 -0
- data/test/fixtures/routing_forms/retrieve.json +30 -0
- data/test/fixtures/routing_forms/retrieve_routing_form_submission.json +29 -0
- data/test/fixtures/shares/create.json +45 -0
- data/test/fixtures/user_availability_schedules/list.json +93 -0
- data/test/fixtures/user_availability_schedules/retrieve.json +22 -0
- data/test/fixtures/user_busy_times/list.json +39 -0
- data/test/fixtures/users/reload.json +5 -4
- data/test/fixtures/users/retrieve.json +5 -4
- data/test/fixtures/webhooks/create.json +4 -4
- data/test/fixtures/webhooks/list.json +4 -4
- data/test/fixtures/webhooks/retrieve.json +4 -4
- data/test/fixtures/webhooks/sample.json +105 -0
- metadata +159 -62
- data/lib/calendlyr/objects/event_invitees.rb +0 -4
- data/lib/calendlyr/objects/event_types.rb +0 -4
- data/lib/calendlyr/objects/events.rb +0 -4
- data/lib/calendlyr/objects/invitations.rb +0 -11
- data/lib/calendlyr/objects/memberships.rb +0 -7
- data/lib/calendlyr/objects/organizations.rb +0 -35
- data/lib/calendlyr/objects/scheduling_links.rb +0 -4
- data/lib/calendlyr/objects/users.rb +0 -19
- data/lib/calendlyr/objects/webhooks.rb +0 -11
- data/lib/calendlyr/resources/event_invitees.rb +0 -12
- data/lib/calendlyr/resources/event_types.rb +0 -12
- data/lib/calendlyr/resources/events.rb +0 -12
- data/lib/calendlyr/resources/organizations.rb +0 -33
- data/lib/calendlyr/resources/users.rb +0 -11
- data/lib/calendlyr/resources/webhooks.rb +0 -21
- data/test/calendlyr/resources/event_invitees_test.rb +0 -29
- data/test/fixtures/resources/409.json +0 -4
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class EventTypeObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
json = JSON.parse(fixture_file("objects/event_type")).merge(client: client)
|
8
|
+
@event_type = Calendlyr::EventType.new(json)
|
9
|
+
|
10
|
+
event_type_uri = "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA"
|
11
|
+
@start_time = "2020-01-02T20:00:00.000000Z"
|
12
|
+
@end_time = "2020-01-07T24:00:00.000000Z"
|
13
|
+
|
14
|
+
response = {body: fixture_file("event_type_available_times/list"), status: 200}
|
15
|
+
stub(path: "event_type_available_times?event_type=#{event_type_uri}&start_time=#{@start_time}&end_time=#{@end_time}", response: response)
|
16
|
+
|
17
|
+
event_type_uri = "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA"
|
18
|
+
response = {body: fixture_file("shares/create"), status: 201}
|
19
|
+
stub(method: :post, path: "shares", body: {event_type: event_type_uri}, response: response)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_associated_profile
|
23
|
+
profile = @event_type.associated_profile
|
24
|
+
|
25
|
+
assert_equal Calendlyr::EventTypes::Profile, profile.class
|
26
|
+
assert_equal "Tamara Jones", profile.name
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_create_share
|
30
|
+
share = @event_type.create_share
|
31
|
+
|
32
|
+
assert_instance_of Calendlyr::Share, share
|
33
|
+
assert_equal 1, share.scheduling_links.size
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_available_times
|
37
|
+
available_times = @event_type.available_times(start_time: @start_time, end_time: @end_time)
|
38
|
+
|
39
|
+
assert 3, available_times.data.size
|
40
|
+
assert "available", available_times.data.first.status
|
41
|
+
assert_instance_of Calendlyr::EventTypes::AvailableTime, available_times.data.first
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module EventTypes
|
6
|
+
class AvailableTimeObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/event_types/available_time")).merge(client: client)
|
9
|
+
@available_time = Calendlyr::EventTypes::AvailableTime.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_status
|
13
|
+
assert_equal "available", @available_time.status
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_invitees_remaining
|
17
|
+
assert_equal 2, @available_time.invitees_remaining
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module EventTypes
|
6
|
+
class MembershipObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/event_types/membership")).merge(client: client)
|
9
|
+
@membership = Calendlyr::EventTypes::Membership.new(json)
|
10
|
+
|
11
|
+
event_type_uuid = "AAAAAAAAAAAAAAAA"
|
12
|
+
response = {body: fixture_file("event_types/retrieve"), status: 200}
|
13
|
+
stub(path: "event_types/#{event_type_uuid}", response: response)
|
14
|
+
|
15
|
+
user_uuid = "AAAAAAAAAAAAAAAA"
|
16
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
17
|
+
stub(path: "users/#{user_uuid}", response: response)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_associated_event_type
|
21
|
+
event_type = @membership.associated_event_type
|
22
|
+
|
23
|
+
assert_equal "15 Minute Meeting", event_type.name
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_associated_member
|
27
|
+
member = @membership.associated_member
|
28
|
+
|
29
|
+
assert_equal "John Doe", member.name
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module EventTypes
|
6
|
+
class ProfileObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/event_types/profile")).merge(client: client)
|
9
|
+
@profile = Calendlyr::EventTypes::Profile.new(json)
|
10
|
+
|
11
|
+
owner_uuid = "AAAAAAAAAAAAAAAA"
|
12
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
13
|
+
stub(path: "users/#{owner_uuid}", response: response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_associated_owner
|
17
|
+
owner = @profile.associated_owner
|
18
|
+
|
19
|
+
assert_equal "John Doe", owner.name
|
20
|
+
assert_equal Calendlyr::User, owner.class
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Events
|
6
|
+
class CancellationObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/events/cancellation")).merge(client: client)
|
9
|
+
@cancellation = Calendlyr::Events::Cancellation.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_canceled_by
|
13
|
+
assert "string", @cancellation.canceled_by
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Events
|
6
|
+
class GuestObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/events/guest")).merge(client: client)
|
9
|
+
@guest = Calendlyr::Events::Guest.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_email
|
13
|
+
assert "user@example.com", @guest.email
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Events
|
6
|
+
class InviteeNoShowObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/events/invitee_no_show")).merge(client: client)
|
9
|
+
@invitee_no_show = Calendlyr::Events::InviteeNoShow.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_created_at
|
13
|
+
assert "2019-01-02T03:04:05.678123Z", @invitee_no_show.created_at
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_delete
|
17
|
+
response = {body: fixture_file("events/delete_invitee_no_show"), status: 204}
|
18
|
+
stub(method: :delete, path: "invitee_no_shows/#{@invitee_no_show.uuid}", response: response)
|
19
|
+
|
20
|
+
assert @invitee_no_show.delete
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Events
|
6
|
+
class InviteeObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/events/invitee")).merge(client: client)
|
9
|
+
@invitee = Calendlyr::Events::Invitee.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_email
|
13
|
+
assert "user@example.com", @invitee.email
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_cancel
|
17
|
+
response = {body: fixture_file("events/cancel_invitee"), status: 201}
|
18
|
+
stub(method: :post, path: "scheduled_events/#{@invitee.uuid}/cancellation", response: response)
|
19
|
+
|
20
|
+
cancellation = @invitee.cancel(reason: "I'm busy")
|
21
|
+
|
22
|
+
assert_instance_of Calendlyr::Events::Cancellation, cancellation
|
23
|
+
assert_equal "host", cancellation.canceler_type
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_no_shows
|
27
|
+
response = {body: fixture_file("events/create_invitee_no_show"), status: 201}
|
28
|
+
stub(method: :post, path: "invitee_no_shows", body: {invitee: @invitee.uri}, response: response)
|
29
|
+
|
30
|
+
no_show = @invitee.create_no_shows
|
31
|
+
|
32
|
+
assert_instance_of Calendlyr::Events::InviteeNoShow, no_show
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class GroupObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
json = JSON.parse(fixture_file("objects/group")).merge(client: client)
|
8
|
+
@group = Calendlyr::Group.new(json)
|
9
|
+
|
10
|
+
@start_time = "2020-01-02T20:00:00.000000Z"
|
11
|
+
@end_time = "2020-01-07T24:00:00.000000Z"
|
12
|
+
|
13
|
+
group_uri = "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA"
|
14
|
+
response = {body: fixture_file("events/list"), status: 200}
|
15
|
+
stub(path: "scheduled_events?group=#{group_uri}", response: response)
|
16
|
+
|
17
|
+
response = {body: fixture_file("group_relationships/list"), status: 200}
|
18
|
+
stub(path: "group_relationships?group=#{group_uri}", response: response)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_associated_organization
|
22
|
+
organization = @group.associated_organization
|
23
|
+
|
24
|
+
assert_equal Calendlyr::Organization, organization.class
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_events
|
28
|
+
events = @group.events
|
29
|
+
|
30
|
+
assert_equal 1, events.data.size
|
31
|
+
assert_equal Calendlyr::Event, events.data.first.class
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_group_relationships
|
35
|
+
group_relationships = @group.group_relationships
|
36
|
+
|
37
|
+
assert_equal 3, group_relationships.data.size
|
38
|
+
assert_equal Calendlyr::Groups::Relationship, group_relationships.data.first.class
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Groups
|
6
|
+
class RelationshipObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/groups/relationship")).merge(client: client)
|
9
|
+
@relationship = Calendlyr::Groups::Relationship.new(json)
|
10
|
+
|
11
|
+
group_uuid = "AAAAAAAAAAAAAAAA"
|
12
|
+
response = {body: fixture_file("groups/retrieve"), status: 200}
|
13
|
+
stub(path: "groups/#{group_uuid}", response: response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_associated_organization
|
17
|
+
organization = @relationship.associated_organization
|
18
|
+
|
19
|
+
assert_equal Calendlyr::Organization, organization.class
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_associated_group
|
23
|
+
group = @relationship.associated_group
|
24
|
+
|
25
|
+
assert_equal "Sales Team", group.name
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_associated_owner
|
29
|
+
organization_membership_uuid = "AAAAAAAAAAAAAAAA"
|
30
|
+
response = {body: fixture_file("organization_memberships/retrieve"), status: 200}
|
31
|
+
stub(path: "organization_memberships/#{organization_membership_uuid}", response: response)
|
32
|
+
|
33
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
34
|
+
stub(path: "users/AAAAAAAAAAAAAAAA", response: response)
|
35
|
+
|
36
|
+
owner = @relationship.associated_owner
|
37
|
+
|
38
|
+
assert_equal Calendlyr::Organizations::Membership, owner.class
|
39
|
+
assert_equal Calendlyr::User, owner.associated_user.class
|
40
|
+
assert_equal "John Doe", owner.associated_user.name
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class OrganizatonObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
json = JSON.parse(fixture_file("objects/organization")).merge(client: client)
|
8
|
+
@organization = Calendlyr::Organization.new(json)
|
9
|
+
|
10
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
11
|
+
stub(path: "users/AAAAAAAAAAAAAAAA", response: response)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_activity_logs
|
15
|
+
response = {body: fixture_file("activity_log/list"), status: 200}
|
16
|
+
stub(path: "activity_log_entries?organization=#{@organization.uri}", response: response)
|
17
|
+
|
18
|
+
activity_logs = @organization.activity_logs
|
19
|
+
|
20
|
+
assert_equal 1, activity_logs.data.size
|
21
|
+
assert_instance_of Calendlyr::ActivityLog, activity_logs.data.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_events
|
25
|
+
response = {body: fixture_file("events/list"), status: 200}
|
26
|
+
stub(path: "scheduled_events?organization=#{@organization.uri}", response: response)
|
27
|
+
|
28
|
+
events = @organization.events
|
29
|
+
|
30
|
+
assert_equal 1, events.data.size
|
31
|
+
assert_instance_of Calendlyr::Event, events.data.first
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_event_types
|
35
|
+
response = {body: fixture_file("event_types/list"), status: 200}
|
36
|
+
stub(path: "event_types?organization=#{@organization.uri}", response: response)
|
37
|
+
|
38
|
+
event_types = @organization.event_types
|
39
|
+
|
40
|
+
assert_equal 1, event_types.data.size
|
41
|
+
assert_instance_of Calendlyr::EventType, event_types.data.first
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_routing_forms
|
45
|
+
response = {body: fixture_file("routing_forms/list"), status: 200}
|
46
|
+
stub(path: "routing_forms?organization=#{@organization.uri}", response: response)
|
47
|
+
|
48
|
+
routing_forms = @organization.routing_forms
|
49
|
+
|
50
|
+
assert_equal 1, routing_forms.data.size
|
51
|
+
assert_instance_of Calendlyr::RoutingForm, routing_forms.data.first
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_groups
|
55
|
+
response = {body: fixture_file("groups/list"), status: 200}
|
56
|
+
stub(path: "groups?organization=#{@organization.uri}", response: response)
|
57
|
+
|
58
|
+
groups = @organization.groups
|
59
|
+
|
60
|
+
assert_equal 1, groups.data.size
|
61
|
+
assert_instance_of Calendlyr::Group, groups.data.first
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_group_relationships
|
65
|
+
response = {body: fixture_file("group_relationships/list"), status: 200}
|
66
|
+
stub(path: "group_relationships?organization=#{@organization.uri}", response: response)
|
67
|
+
|
68
|
+
group_relationships = @organization.group_relationships
|
69
|
+
|
70
|
+
assert_equal 3, group_relationships.data.size
|
71
|
+
assert_instance_of Calendlyr::Groups::Relationship, group_relationships.data.first
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_memberships
|
75
|
+
response = {body: fixture_file("organization_memberships/list"), status: 200}
|
76
|
+
stub(path: "organization_memberships?organization=#{@organization.uri}", response: response)
|
77
|
+
|
78
|
+
memberships = @organization.memberships
|
79
|
+
|
80
|
+
assert_equal 1, memberships.data.size
|
81
|
+
assert_instance_of Calendlyr::Organizations::Membership, memberships.data.first
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_membership
|
85
|
+
response = {body: fixture_file("organization_memberships/retrieve"), status: 200}
|
86
|
+
stub(path: "organization_memberships/AAAAAAAAAAAAAAAA", response: response)
|
87
|
+
|
88
|
+
membership = @organization.membership(uuid: "AAAAAAAAAAAAAAAA")
|
89
|
+
|
90
|
+
assert_instance_of Calendlyr::User, membership.associated_user
|
91
|
+
assert_instance_of Calendlyr::Organizations::Membership, membership
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_webhooks
|
95
|
+
scope = "user"
|
96
|
+
response = {body: fixture_file("webhooks/list"), status: 200}
|
97
|
+
stub(path: "webhook_subscriptions?organization=#{@organization.uri}&scope=#{scope}", response: response)
|
98
|
+
webhooks = @organization.webhooks(scope: scope)
|
99
|
+
|
100
|
+
assert_instance_of Calendlyr::Collection, webhooks
|
101
|
+
assert_instance_of Calendlyr::Webhooks::Subscription, webhooks.data.first
|
102
|
+
assert_equal 1, webhooks.data.count
|
103
|
+
assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", webhooks.next_page_token
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_create_webhook
|
107
|
+
user_uri = "https://api.calendly.com/users/AAAAAAAAAAAAAAAA"
|
108
|
+
body = {url: "https://blah.foo/bar", events: ["invitee.created"], scope: "user", user: user_uri}
|
109
|
+
stub(method: :post, path: "webhook_subscriptions", body: body.merge(organization: @organization.uri), response: {body: fixture_file("webhooks/create"), status: 201})
|
110
|
+
|
111
|
+
assert @organization.create_webhook(**body)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_sample_webhook_data
|
115
|
+
stub(path: "sample_webhook_data?event=invitee.created&scope=organization&organization=https://api.calendly.com/organizations/012345678901234567890", response: {body: fixture_file("webhooks/sample"), status: 200})
|
116
|
+
webhook_data = @organization.sample_webhook_data(event: "invitee.created", scope: "organization")
|
117
|
+
|
118
|
+
assert_instance_of Calendlyr::Object, webhook_data
|
119
|
+
assert_equal "invitee.created", webhook_data.event
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_invite_user
|
123
|
+
email = "email@example.com"
|
124
|
+
response = {body: fixture_file("organizations/invite"), status: 201}
|
125
|
+
stub(method: :post, path: "organizations/#{@organization.uuid}/invitations", body: {email: email}, response: response)
|
126
|
+
invitation = @organization.invite_user(email: email)
|
127
|
+
|
128
|
+
assert_instance_of Calendlyr::Organizations::Invitation, invitation
|
129
|
+
assert_equal email, invitation.email
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_invitations
|
133
|
+
response = {body: fixture_file("organizations/list_invitations"), status: 200}
|
134
|
+
stub(path: "organizations/#{@organization.uuid}/invitations", response: response)
|
135
|
+
invitations = @organization.invitations
|
136
|
+
|
137
|
+
assert_instance_of Calendlyr::Collection, invitations
|
138
|
+
assert_instance_of Calendlyr::Organizations::Invitation, invitations.data.first
|
139
|
+
assert_equal 1, invitations.count
|
140
|
+
assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", invitations.next_page_token
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_organization_invitation
|
144
|
+
response = {body: fixture_file("organizations/retrieve_invitation"), status: 200}
|
145
|
+
stub(path: "organizations/#{@organization.uuid}/invitations/abc123", response: response)
|
146
|
+
invitation = @organization.invitation(invitation_uuid: "abc123")
|
147
|
+
|
148
|
+
assert_instance_of Calendlyr::Organizations::Invitation, invitation
|
149
|
+
assert_equal "test@example.com", invitation.email
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_revoke_invitation
|
153
|
+
response = {body: fixture_file("organizations/revoke_invitation"), status: 200}
|
154
|
+
stub(method: :delete, path: "organizations/#{@organization.uuid}/invitations/abc123", response: response)
|
155
|
+
assert @organization.revoke_invitation(invitation_uuid: "abc123")
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Organizations
|
6
|
+
class InvitationObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/organizations/invitation")).merge(client: client)
|
9
|
+
@invitation = Calendlyr::Organizations::Invitation.new(json)
|
10
|
+
|
11
|
+
response = {body: fixture_file("organizations/revoke_invitation"), status: 204}
|
12
|
+
stub(method: :delete, path: "organizations/#{@invitation.associated_organization.uuid}/invitations/#{@invitation.uuid}", response: response)
|
13
|
+
|
14
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
15
|
+
stub(path: "users/#{Calendlyr::Object.get_slug(@invitation.user)}", response: response)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_associated_organization
|
19
|
+
organization = @invitation.associated_organization
|
20
|
+
|
21
|
+
assert_equal Calendlyr::Organization, organization.class
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_associated_user
|
25
|
+
user = @invitation.associated_user
|
26
|
+
|
27
|
+
assert_equal "John Doe", user.name
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_revoke
|
31
|
+
assert @invitation.revoke
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Organizations
|
6
|
+
class MembershipObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/organizations/membership")).merge(client: client)
|
9
|
+
@membership = Calendlyr::Organizations::Membership.new(json)
|
10
|
+
|
11
|
+
owner_uri = "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA"
|
12
|
+
response = {body: fixture_file("group_relationships/list"), status: 200}
|
13
|
+
stub(path: "group_relationships?owner=#{owner_uri}", response: response)
|
14
|
+
|
15
|
+
user_uuid = "AAAAAAAAAAAAAAAA"
|
16
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
17
|
+
stub(path: "users/#{user_uuid}", response: response)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_associated_organization
|
21
|
+
organization = @membership.associated_organization
|
22
|
+
|
23
|
+
assert_equal Calendlyr::Organization, organization.class
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_associated_user
|
27
|
+
user = @membership.associated_user
|
28
|
+
|
29
|
+
assert_equal "John Doe", user.name
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_group_relationships
|
33
|
+
group_relationships = @membership.group_relationships
|
34
|
+
|
35
|
+
assert_equal Calendlyr::Groups::Relationship, group_relationships.data.first.class
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class RoutingFormObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
json = JSON.parse(fixture_file("objects/routing_form")).merge(client: client)
|
8
|
+
@routing_form = Calendlyr::RoutingForm.new(json)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_associated_organization
|
12
|
+
organization = @routing_form.associated_organization
|
13
|
+
|
14
|
+
assert_instance_of Calendlyr::Organization, organization
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_submissions
|
18
|
+
response = {body: fixture_file("routing_forms/list_routing_form_submission"), status: 200}
|
19
|
+
stub(path: "routing_form_submissions?form=#{@routing_form.uri}", response: response)
|
20
|
+
|
21
|
+
submissions = @routing_form.submissions
|
22
|
+
|
23
|
+
assert_equal 1, submissions.data.size
|
24
|
+
assert_instance_of Calendlyr::RoutingForms::Submission, submissions.data.first
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module RoutingForms
|
6
|
+
class SubmissionObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/routing_forms/submission")).merge(client: client)
|
9
|
+
@submission = Calendlyr::RoutingForms::Submission.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_associated_routing_form
|
13
|
+
uuid = "AAAAAAAAAAAAAAAA"
|
14
|
+
response = {body: fixture_file("routing_forms/retrieve"), status: 200}
|
15
|
+
stub(path: "routing_forms/#{uuid}", response: response)
|
16
|
+
|
17
|
+
routing_form = @submission.associated_routing_form
|
18
|
+
|
19
|
+
assert_equal Calendlyr::RoutingForm, routing_form.class
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class ScheduleLinkObjectTest < Minitest::Test
|
6
|
+
def test_event_type
|
7
|
+
json = JSON.parse(fixture_file("objects/scheduling_links/event_type")).merge(client: client)
|
8
|
+
@scheduling_link = Calendlyr::SchedulingLink.new(json)
|
9
|
+
|
10
|
+
response = {body: fixture_file("event_types/retrieve"), status: 200}
|
11
|
+
stub(path: "event_types/GBGBDCAADAEDCRZ2", response: response)
|
12
|
+
|
13
|
+
event_type = @scheduling_link.event_type
|
14
|
+
|
15
|
+
assert_equal Calendlyr::EventType, event_type.class
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class ShareObjectTest < Minitest::Test
|
6
|
+
def test_associated_scheduling_links
|
7
|
+
json = JSON.parse(fixture_file("objects/share")).merge(client: client)
|
8
|
+
@share = Calendlyr::Share.new(json)
|
9
|
+
|
10
|
+
response = {body: fixture_file("event_types/retrieve"), status: 200}
|
11
|
+
stub(path: "event_types/AAAAAAAAAAAAAAAA", response: response)
|
12
|
+
|
13
|
+
scheculing_links = @share.associated_scheduling_links
|
14
|
+
|
15
|
+
assert_equal 1, scheculing_links.size
|
16
|
+
assert_equal Calendlyr::SchedulingLink, scheculing_links.first.class
|
17
|
+
assert_equal Calendlyr::EventType, scheculing_links.first.event_type.class
|
18
|
+
end
|
19
|
+
end
|