calendlyr 0.6.0 → 0.7.0
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 +2 -2
- data/README.md +46 -127
- 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 +42 -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,31 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class User < Object
|
3
|
+
def organization
|
4
|
+
Organization.new({"uri" => current_organization}.merge(client: client))
|
5
|
+
end
|
6
|
+
|
7
|
+
def availability_schedules(**params)
|
8
|
+
client.availability.list_user_schedules(**params.merge(user: uri))
|
9
|
+
end
|
10
|
+
|
11
|
+
def event_types(**params)
|
12
|
+
client.event_types.list(**params.merge(user: uri))
|
13
|
+
end
|
14
|
+
|
15
|
+
def events(**params)
|
16
|
+
client.events.list(**params.merge(user: uri, organization: current_organization))
|
17
|
+
end
|
18
|
+
|
19
|
+
def membership(uuid:)
|
20
|
+
organization.membership(uuid: uuid)
|
21
|
+
end
|
22
|
+
|
23
|
+
def memberships(**params)
|
24
|
+
organization.memberships(**params.merge(user: uri))
|
25
|
+
end
|
26
|
+
|
27
|
+
def busy_times(start_time:, end_time:, **params)
|
28
|
+
client.availability.list_user_busy_times(**params.merge(user: uri, start_time: start_time, end_time: end_time))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class Webhooks::InviteePayload < Object
|
3
|
+
def associated_event
|
4
|
+
client.events.retrieve(uuid: get_slug(event))
|
5
|
+
end
|
6
|
+
|
7
|
+
def associated_routing_form_submission
|
8
|
+
client.routing_forms.retrieve_submission(uuid: get_slug(routing_form_submission))
|
9
|
+
end
|
10
|
+
|
11
|
+
def associated_invitee_no_show
|
12
|
+
client.events.retrieve_invitee_no_show(uuid: get_slug(no_show.uri))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class Webhooks::Subscription < Object
|
3
|
+
def associated_organization
|
4
|
+
Organization.new({"uri" => organization}.merge(client: client))
|
5
|
+
end
|
6
|
+
|
7
|
+
def associated_user
|
8
|
+
client.users.retrieve(uuid: get_slug(user))
|
9
|
+
end
|
10
|
+
|
11
|
+
def associated_creator
|
12
|
+
client.users.retrieve(uuid: get_slug(creator))
|
13
|
+
end
|
14
|
+
|
15
|
+
def active?
|
16
|
+
state == "active"
|
17
|
+
end
|
18
|
+
|
19
|
+
def disabled?
|
20
|
+
state == "disabled"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/calendlyr/resource.rb
CHANGED
@@ -7,7 +7,7 @@ module Calendlyr
|
|
7
7
|
class Resource
|
8
8
|
attr_reader :client
|
9
9
|
|
10
|
-
ERROR_CODES = %w[400 401 403 404
|
10
|
+
ERROR_CODES = %w[400 401 403 404 424 500]
|
11
11
|
|
12
12
|
def initialize(client)
|
13
13
|
@client = client
|
@@ -52,7 +52,7 @@ module Calendlyr
|
|
52
52
|
|
53
53
|
body = JSON.parse(response.read_body)
|
54
54
|
if ERROR_CODES.include? response.code
|
55
|
-
raise
|
55
|
+
raise ResponseErrorHandler.new(response.code, body).error
|
56
56
|
else
|
57
57
|
body
|
58
58
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class AvailabilityResource < Resource
|
3
|
+
# User Busy Time
|
4
|
+
def list_user_busy_times(user:, start_time:, end_time:, **params)
|
5
|
+
response = get_request("user_busy_times", params: {user: user, start_time: start_time, end_time: end_time}.merge(params).compact)
|
6
|
+
Collection.from_response(response, type: Availabilities::UserBusyTime, client: client)
|
7
|
+
end
|
8
|
+
|
9
|
+
# User Schedule
|
10
|
+
def list_user_schedules(user:, **params)
|
11
|
+
response = get_request("user_availability_schedules", params: {user: user}.merge(params).compact)
|
12
|
+
Collection.from_response(response, type: Availabilities::UserSchedule, client: client)
|
13
|
+
end
|
14
|
+
|
15
|
+
def retrieve_user_schedule(uuid:)
|
16
|
+
Availabilities::UserSchedule.new get_request("user_availability_schedules/#{uuid}").dig("resource").merge(client: client)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,5 +3,9 @@ module Calendlyr
|
|
3
3
|
def delete_invitee_data(emails:)
|
4
4
|
post_request("data_compliance/deletion/invitees", body: {emails: emails})
|
5
5
|
end
|
6
|
+
|
7
|
+
def delete_scheduled_event_data(start_time:, end_time:)
|
8
|
+
post_request("data_compliance/deletion/events", body: {start_time: start_time, end_time: end_time})
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class EventResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("scheduled_events", params: params)
|
5
|
+
Collection.from_response(response, type: Event, client: client)
|
6
|
+
end
|
7
|
+
|
8
|
+
def retrieve(uuid:)
|
9
|
+
Event.new get_request("scheduled_events/#{uuid}").dig("resource").merge(client: client)
|
10
|
+
end
|
11
|
+
|
12
|
+
def cancel(uuid:, reason: nil)
|
13
|
+
Events::Cancellation.new post_request("scheduled_events/#{uuid}/cancellation", body: {reason: reason}).dig("resource").merge(client: client)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Invitee
|
17
|
+
def list_invitees(uuid:, **params)
|
18
|
+
response = get_request("scheduled_events/#{uuid}/invitees", params: params)
|
19
|
+
Collection.from_response(response, type: Events::Invitee, client: client)
|
20
|
+
end
|
21
|
+
|
22
|
+
def retrieve_invitee(event_uuid:, invitee_uuid:)
|
23
|
+
Events::Invitee.new get_request("scheduled_events/#{event_uuid}/invitees/#{invitee_uuid}").dig("resource").merge(client: client)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Invitee No Show
|
27
|
+
def retrieve_invitee_no_show(uuid:)
|
28
|
+
Events::InviteeNoShow.new get_request("invitee_no_shows/#{uuid}").dig("resource").merge(client: client)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_invitee_no_show(invitee:)
|
32
|
+
body = {invitee: invitee}
|
33
|
+
Events::InviteeNoShow.new post_request("invitee_no_shows", body: body).dig("resource").merge(client: client)
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_invitee_no_show(uuid:)
|
37
|
+
delete_request("invitee_no_shows/#{uuid}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class EventTypeResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("event_types", params: params)
|
5
|
+
Collection.from_response(response, type: EventType, client: client)
|
6
|
+
end
|
7
|
+
|
8
|
+
def retrieve(uuid:)
|
9
|
+
EventType.new get_request("event_types/#{uuid}").dig("resource").merge(client: client)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_one_off(name:, host:, duration:, date_setting:, location:, **params)
|
13
|
+
body = {name: name, host: host, duration: duration, date_setting: date_setting, location: location}.merge(params)
|
14
|
+
EventType.new post_request("one_off_event_types", body: body).dig("resource").merge(client: client)
|
15
|
+
end
|
16
|
+
|
17
|
+
def list_memberships(event_type:, **params)
|
18
|
+
response = get_request("event_type_memberships", params: {event_type: event_type}.merge(params))
|
19
|
+
Collection.from_response(response, type: EventTypes::Membership, client: client)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Available Times
|
23
|
+
def list_available_times(event_type:, start_time:, end_time:, **params)
|
24
|
+
response = get_request("event_type_available_times", params: {event_type: event_type, start_time: start_time, end_time: end_time}.merge(params))
|
25
|
+
Collection.from_response(response, type: EventTypes::AvailableTime, client: client)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class GroupResource < Resource
|
3
|
+
def list(organization:, **params)
|
4
|
+
response = get_request("groups", params: params.merge(organization: organization))
|
5
|
+
Collection.from_response(response, type: Group, client: client)
|
6
|
+
end
|
7
|
+
|
8
|
+
def retrieve(uuid:)
|
9
|
+
Group.new get_request("groups/#{uuid}").dig("resource").merge(client: client)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Relationships
|
13
|
+
def list_relationships(**params)
|
14
|
+
response = get_request("group_relationships", params: params)
|
15
|
+
Collection.from_response(response, type: Groups::Relationship, client: client)
|
16
|
+
end
|
17
|
+
|
18
|
+
def retrieve_relationship(uuid:)
|
19
|
+
Groups::Relationship.new get_request("group_relationships/#{uuid}").dig("resource").merge(client: client)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class OrganizationResource < Resource
|
3
|
+
def activity_log(organization: nil, **params)
|
4
|
+
response = get_request("activity_log_entries", params: {organization: organization}.merge(params).compact)
|
5
|
+
Collection.from_response(response, type: ActivityLog, client: client)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Memberships
|
9
|
+
def list_memberships(**params)
|
10
|
+
response = get_request("organization_memberships", params: params)
|
11
|
+
Collection.from_response(response, type: Organizations::Membership, client: client)
|
12
|
+
end
|
13
|
+
|
14
|
+
def retrieve_membership(uuid:)
|
15
|
+
Organizations::Membership.new(get_request("organization_memberships/#{uuid}").dig("resource").merge(client: client))
|
16
|
+
end
|
17
|
+
|
18
|
+
def remove_user(uuid:)
|
19
|
+
delete_request("organization_memberships/#{uuid}")
|
20
|
+
end
|
21
|
+
|
22
|
+
# Invitations
|
23
|
+
def list_invitations(uuid:, **params)
|
24
|
+
response = get_request("organizations/#{uuid}/invitations", params: params)
|
25
|
+
Collection.from_response(response, type: Organizations::Invitation, client: client)
|
26
|
+
end
|
27
|
+
|
28
|
+
def retrieve_invitation(org_uuid:, uuid:)
|
29
|
+
Organizations::Invitation.new get_request("organizations/#{org_uuid}/invitations/#{uuid}").dig("resource").merge(client: client)
|
30
|
+
end
|
31
|
+
|
32
|
+
def invite(organization_uuid:, email:)
|
33
|
+
Organizations::Invitation.new post_request("organizations/#{organization_uuid}/invitations", body: {email: email}).dig("resource").merge(client: client)
|
34
|
+
end
|
35
|
+
|
36
|
+
def revoke_invitation(org_uuid:, uuid:)
|
37
|
+
delete_request("organizations/#{org_uuid}/invitations/#{uuid}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class RoutingFormResource < Resource
|
3
|
+
def list(organization:, **params)
|
4
|
+
response = get_request("routing_forms", params: {organization: organization}.merge(params))
|
5
|
+
Collection.from_response(response, type: RoutingForm, client: client)
|
6
|
+
end
|
7
|
+
|
8
|
+
def retrieve(uuid:)
|
9
|
+
RoutingForm.new(get_request("routing_forms/#{uuid}").dig("resource").merge(client: client))
|
10
|
+
end
|
11
|
+
|
12
|
+
# Routing Form Submission
|
13
|
+
def list_submissions(form:, **params)
|
14
|
+
response = get_request("routing_form_submissions", params: {form: form}.merge(params))
|
15
|
+
Collection.from_response(response, type: RoutingForms::Submission, client: client)
|
16
|
+
end
|
17
|
+
|
18
|
+
def retrieve_submission(uuid:)
|
19
|
+
RoutingForms::Submission.new get_request("routing_form_submissions/#{uuid}").dig("resource").merge(client: client)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Calendlyr
|
2
2
|
class SchedulingLinkResource < Resource
|
3
|
-
def create(
|
4
|
-
body = {owner:
|
3
|
+
def create(owner:, max_event_count:, owner_type: "EventType")
|
4
|
+
body = {owner: owner, max_event_count: max_event_count, owner_type: owner_type}
|
5
5
|
SchedulingLink.new post_request("scheduling_links", body: body).dig("resource").merge(client: client)
|
6
6
|
end
|
7
7
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Calendlyr
|
2
|
+
class WebhookResource < Resource
|
3
|
+
def list(organization:, scope:, **params)
|
4
|
+
response = get_request("webhook_subscriptions", params: params.merge(organization: organization, scope: scope).compact)
|
5
|
+
Collection.from_response(response, type: Webhooks::Subscription, client: client)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(url:, events:, organization:, scope:, **params)
|
9
|
+
body = params.merge(url: url, events: events, organization: organization, scope: scope)
|
10
|
+
Webhooks::Subscription.new post_request("webhook_subscriptions", body: body).dig("resource").merge(client: client)
|
11
|
+
end
|
12
|
+
|
13
|
+
def retrieve(webhook_uuid:)
|
14
|
+
Webhooks::Subscription.new get_request("webhook_subscriptions/#{webhook_uuid}").dig("resource").merge(client: client)
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete(webhook_uuid:)
|
18
|
+
delete_request("webhook_subscriptions/#{webhook_uuid}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def sample_webhook_data(event:, organization:, scope:, **params)
|
22
|
+
Object.new get_request("sample_webhook_data", params: params.merge(event: event, organization: organization, scope: scope)).merge(client: client)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/calendlyr/version.rb
CHANGED
data/lib/calendlyr.rb
CHANGED
@@ -3,28 +3,80 @@ require "calendlyr/version"
|
|
3
3
|
module Calendlyr
|
4
4
|
autoload :Client, "calendlyr/client"
|
5
5
|
autoload :Collection, "calendlyr/collection"
|
6
|
-
autoload :Error, "calendlyr/error"
|
7
|
-
autoload :Resource, "calendlyr/resource"
|
8
6
|
autoload :Object, "calendlyr/object"
|
7
|
+
autoload :Resource, "calendlyr/resource"
|
8
|
+
|
9
|
+
# Errors
|
10
|
+
autoload :BadRequest, "calendlyr/error"
|
11
|
+
autoload :Error, "calendlyr/error"
|
12
|
+
autoload :ExternalCalendarEror, "calendlyr/error"
|
13
|
+
autoload :InternalServerError, "calendlyr/error"
|
14
|
+
autoload :NotFound, "calendlyr/error"
|
15
|
+
autoload :PaymentRequired, "calendlyr/error"
|
16
|
+
autoload :PermissionDenied, "calendlyr/error"
|
17
|
+
autoload :ResponseErrorHandler, "calendlyr/error"
|
18
|
+
autoload :Unauthenticated, "calendlyr/error"
|
9
19
|
|
10
20
|
# High-level categories of Calendly API calls
|
11
|
-
autoload :
|
12
|
-
autoload :EventTypeResource, "calendlyr/resources/event_types"
|
13
|
-
autoload :OrganizationResource, "calendlyr/resources/organizations"
|
14
|
-
autoload :EventResource, "calendlyr/resources/events"
|
15
|
-
autoload :EventInviteeResource, "calendlyr/resources/event_invitees"
|
16
|
-
autoload :SchedulingLinkResource, "calendlyr/resources/scheduling_links"
|
17
|
-
autoload :WebhookResource, "calendlyr/resources/webhooks"
|
21
|
+
autoload :AvailabilityResource, "calendlyr/resources/availability"
|
18
22
|
autoload :DataComplianceResource, "calendlyr/resources/data_compliance"
|
23
|
+
autoload :EventResource, "calendlyr/resources/event"
|
24
|
+
autoload :EventTypeResource, "calendlyr/resources/event_type"
|
25
|
+
autoload :GroupResource, "calendlyr/resources/group"
|
26
|
+
autoload :OrganizationResource, "calendlyr/resources/organization"
|
27
|
+
autoload :OutgoingCommunicationResource, "calendlyr/resources/outgoing_communication"
|
28
|
+
autoload :RoutingFormResource, "calendlyr/resources/routing_form"
|
29
|
+
autoload :SchedulingLinkResource, "calendlyr/resources/scheduling_link"
|
30
|
+
autoload :ShareResource, "calendlyr/resources/share"
|
31
|
+
autoload :UserResource, "calendlyr/resources/user"
|
32
|
+
autoload :WebhookResource, "calendlyr/resources/webhook"
|
19
33
|
|
20
34
|
# Classes used to return a nicer object wrapping the response data
|
21
|
-
autoload :
|
22
|
-
autoload :
|
23
|
-
autoload :
|
24
|
-
autoload :
|
25
|
-
autoload :
|
26
|
-
autoload :
|
27
|
-
autoload :SchedulingLink, "calendlyr/objects/
|
28
|
-
autoload :
|
29
|
-
autoload :
|
35
|
+
autoload :ActivityLog, "calendlyr/objects/activity_log"
|
36
|
+
autoload :Event, "calendlyr/objects/event"
|
37
|
+
autoload :EventType, "calendlyr/objects/event_type"
|
38
|
+
autoload :Group, "calendlyr/objects/group"
|
39
|
+
autoload :Organization, "calendlyr/objects/organization"
|
40
|
+
autoload :RoutingForm, "calendlyr/objects/routing_form"
|
41
|
+
autoload :SchedulingLink, "calendlyr/objects/scheduling_link"
|
42
|
+
autoload :Share, "calendlyr/objects/share"
|
43
|
+
autoload :User, "calendlyr/objects/user"
|
44
|
+
|
45
|
+
module Availabilities
|
46
|
+
autoload :Rule, "calendlyr/objects/availabilities/rule"
|
47
|
+
autoload :UserSchedule, "calendlyr/objects/availabilities/user_schedule"
|
48
|
+
autoload :UserBusyTime, "calendlyr/objects/availabilities/user_busy_time"
|
49
|
+
end
|
50
|
+
|
51
|
+
module Events
|
52
|
+
autoload :Cancellation, "calendlyr/objects/events/cancellation"
|
53
|
+
autoload :Guest, "calendlyr/objects/events/guest"
|
54
|
+
autoload :Invitee, "calendlyr/objects/events/invitee"
|
55
|
+
autoload :InviteeNoShow, "calendlyr/objects/events/invitee_no_show"
|
56
|
+
end
|
57
|
+
|
58
|
+
module EventTypes
|
59
|
+
autoload :AvailableTime, "calendlyr/objects/event_types/available_time"
|
60
|
+
autoload :Membership, "calendlyr/objects/event_types/membership"
|
61
|
+
autoload :Profile, "calendlyr/objects/event_types/profile"
|
62
|
+
end
|
63
|
+
|
64
|
+
module Groups
|
65
|
+
autoload :Relationship, "calendlyr/objects/groups/relationship"
|
66
|
+
end
|
67
|
+
|
68
|
+
module Organizations
|
69
|
+
autoload :Invitation, "calendlyr/objects/organizations/invitation"
|
70
|
+
autoload :Membership, "calendlyr/objects/organizations/membership"
|
71
|
+
end
|
72
|
+
|
73
|
+
module RoutingForms
|
74
|
+
autoload :Submission, "calendlyr/objects/routing_forms/submission"
|
75
|
+
end
|
76
|
+
|
77
|
+
module Webhooks
|
78
|
+
autoload :Subscription, "calendlyr/objects/webhooks/subscription"
|
79
|
+
autoload :InviteePayload, "calendlyr/objects/webhooks/invitee_payload"
|
80
|
+
autoload :Payload, "calendlyr/objects/webhooks/payload"
|
81
|
+
end
|
30
82
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class ActivityLogObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
json = JSON.parse(fixture_file("objects/activity_log")).merge(client: client)
|
8
|
+
@activity_log = Calendlyr::ActivityLog.new(json)
|
9
|
+
|
10
|
+
user_uuid = "SDLKJENFJKD123"
|
11
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
12
|
+
stub(path: "users/#{user_uuid}", response: response)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_associated_organization
|
16
|
+
organization = @activity_log.associated_organization
|
17
|
+
|
18
|
+
assert_equal Calendlyr::Organization, organization.class
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_associated_actor
|
22
|
+
user = @activity_log.associated_actor
|
23
|
+
|
24
|
+
assert_equal "John Doe", user.name
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Availabilities
|
6
|
+
class RuleObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
json = JSON.parse(fixture_file("objects/availabilities/rule")).merge(client: client)
|
9
|
+
@rule = Calendlyr::Availabilities::Rule.new(json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_type
|
13
|
+
assert_equal "wday", @rule.type
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_intervals
|
17
|
+
assert_equal 1, @rule.intervals.size
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_wday
|
21
|
+
assert_equal "sunday", @rule.wday
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
module Availabilities
|
5
|
+
class UserBusyTimeObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
response = {body: fixture_file("events/retrieve"), status: 200}
|
8
|
+
stub(path: "scheduled_events/abc123", response: response)
|
9
|
+
json = JSON.parse(fixture_file("objects/availabilities/user_busy_time")).merge(client: client)
|
10
|
+
@user_busy_time = Calendlyr::Availabilities::UserBusyTime.new(json)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_associated_event
|
14
|
+
assert_equal Calendlyr::Event, @user_busy_time.associated_event.class
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_type
|
18
|
+
assert_equal "calendly", @user_busy_time.type
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
module Availabilities
|
6
|
+
class UserScheduleObjectTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
stub(path: "users/abc123", response: {body: fixture_file("users/retrieve"), status: 200})
|
9
|
+
json = JSON.parse(fixture_file("objects/availabilities/user_schedule")).merge(client: client)
|
10
|
+
@user_availability_schedule = Calendlyr::Availabilities::UserSchedule.new(json)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_associated_user
|
14
|
+
assert_equal Calendlyr::User, @user_availability_schedule.associated_user.class
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_availability_schedule
|
18
|
+
assert_equal "America\\/New_York", @user_availability_schedule.timezone
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_availability_rules
|
22
|
+
assert_equal 7, @user_availability_schedule.availability_rules.count
|
23
|
+
assert_equal Calendlyr::Availabilities::Rule, @user_availability_schedule.availability_rules.first.class
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class EventObjectTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
json = JSON.parse(fixture_file("objects/event")).merge(client: client)
|
8
|
+
@event = Calendlyr::Event.new(json)
|
9
|
+
|
10
|
+
user_uuid = "GBGBDCAADAEDCRZ2"
|
11
|
+
response = {body: fixture_file("users/retrieve"), status: 200}
|
12
|
+
stub(path: "users/#{user_uuid}", response: response)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_memberships
|
16
|
+
memberships = @event.memberships
|
17
|
+
|
18
|
+
assert_equal 1, memberships.count
|
19
|
+
assert_equal "John Doe", memberships.first.name
|
20
|
+
assert_instance_of Calendlyr::User, memberships.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_cancel
|
24
|
+
response = {body: fixture_file("events/cancel_invitee"), status: 201}
|
25
|
+
stub(method: :post, path: "scheduled_events/#{@event.uuid}/cancellation", response: response)
|
26
|
+
|
27
|
+
cancellation = @event.cancel(reason: "I'm busy")
|
28
|
+
|
29
|
+
assert_instance_of Calendlyr::Events::Cancellation, cancellation
|
30
|
+
assert_equal "string", cancellation.reason
|
31
|
+
end
|
32
|
+
end
|
@@ -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
|