diff --git a/README.md b/README.md index 77b29d4..c975bf5 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,15 @@ [![](https://img.shields.io/github/license/araluce/calendlyr)](https://github.com/araluce/calendlyr/blob/master/LICENSE.txt) [![](https://github.com/araluce/calendlyr/actions/workflows/ci.yml/badge.svg)](https://github.com/araluce/calendlyr/actions) [![codecov](https://codecov.io/gh/araluce/calendlyr/branch/master/graph/badge.svg?token=YSUU4PHM6Y)](https://codecov.io/gh/araluce/calendlyr) +![example workflow](https://github.com/araluce/calendlyr/actions/workflows/ci.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/calendlyr.svg)](https://badge.fury.io/rb/calendlyr) -# Calendly API Rubygem LITE version +# Calendly API Rubygem Easy and complete rubygem for [Calendly](https://calendly.com/). Currently supports [API v2](https://calendly.stoplight.io/docs/api-docs). Just needed a Personal Access Token. -> If you need a Oauth authentication maybe you need [calendly-api-ruby-client](https://github.com/koshilife/calendly-api-ruby-client) - ## Dependencies No dependencies :tada: @@ -19,87 +18,76 @@ We know about the importance of not add dependencies that you don't want. ## 📚 Docs -* [Installation](docs/1_installation.md) -* [Usage](docs/2_usage.md) -* **Resources** - * [Pagination](/docs/resources/1_pagination.md) - * **Availability** - * [UserBusyTime](/docs/resources/availability/1_user_busy_time.md) - * [UserAvailabilitySchedule](/docs/resources/availability/2_user_availability_schedule.md) - * [Data Compliance](/docs/resources/2_data_compliance.md) - * [User](/docs/resources/user.md) - -### Event Types -````ruby -client.event_types.list user_uri: "user_uri", organization_uri: "organization_uri" -client.event_types.retrieve event_type_uuid: "id" -```` - -### Events -````ruby -client.events.list user_uri: "user_uri", organization_uri: "organization_uri" -client.events.retrieve event_uuid: "event_uuid" -```` - -### Event Invitees -````ruby -client.event_invitees.list event_uuid: "event_uuid" -client.event_invitees.retrieve event_uuid: "event_uuid", invitee_uuid: "invitee_uuid" -```` - -### Scheduling Links -````ruby -client.scheduling_links.create owner_uri: "owner_uri", max_event_count: 1, owner_type: "EventType" -```` - -### Organizations -````ruby -# Create invitation -client.organizations.invite(organization_uuid: "organization_uuid", email: "test@test.com") -client.organization.invite(email: "test@test.com") -# List invitations -client.organizations.list_invitations(organization_uuid: "organization_uuid") -client.organization.list_invitations -# Get invitation -client.organizations.retrieve_invitation(organization_uuid: "organization_uuid", invitation_uuid: "invitation_uuid") -client.organization.invitation(invitation_uuid: "invitation_uuid") -# Revoke invitation -client.organizations.revoke_invitation(organization_uuid: "organization_uuid", invitation_uuid: "organization_uuid") -client.organization.revoke_invitation(invitation_uuid: "organization_uuid") -invitation = client.organization.invitation(invitation_uuid: "invitation_uuid") -invitation.revoke - -# List memberships -client.organizations.list_memberships -client.organization.memberships -# Get membership -client.organizations.retrieve_membership(membership_uuid: "membership_uuid") -# Remove membership -client.organizations.remove_user(membership_uuid: "membership_uuid") - -client.organization.events - -# List/Creaete webhooks -client.organization.list_webhooks(scope: "scope") -client.organization.create_webhook(url: "post_callback_url", events: ["invitee.canceled", "invitee.created"], scope: "scope") - -# List activity log -client.organization.activity_log -```` - -### Webhooks +### Installation + +Add this line to your application's Gemfile: + ```ruby -client.webhooks.list(organization_uri: "organization_uri", scope: "scope") -client.webhooks.create(url: "post_callback_url", events: ["invitee.canceled", "invitee.created"], organization_uri: "organization_uri", scope: "scope") -client.webhooks.retrieve(webhook_uuid: "webhook_uuid") -client.webhooks.delete(webhook_uuid: "webhook_uuid") +gem 'calendlyr' ``` -### Data Compliance +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install calendlyr + +### Usage + +To access the API, you'll need to create a `Calendlyr::Client` and pass in your token. You can generate your Personal Access Token at [https://calendly.com/integrations/api_webhooks](https://calendly.com/integrations/api_webhooks) + ```ruby -client.data_compliance.delete_invitee_data +client = Calendlyr::Client.new(token: ENV["CALENDLY_TOKEN"]) ``` +The client then gives you access to each of the resources. + + +### Resources + +The gem maps as closely as we can to the Calendly API so you can easily convert API examples to gem code. + +Responses are created as objects like `Calendlyr::Event`. Having types like `Calendlyr::User` is handy for understanding what type of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way. + +* [Pagination](docs/resources/pagination.md) +* **Activity Log** + * [Calendlyr::ActivityLog](docs/resources/activity_log/list_activity_log_entries.md) +* **Availabilities** + * [Calendlyr::Availabilities::Rule](docs/resources/availabilities/availability_rule.md) + * [Calendlyr::Availabilities::UserSchedule](docs/resources/availabilities/user_availability_schedule.md) + * [Calendlyr::Availabilities::UserBusyTime](docs/resources/availabilities/user_busy_time.md) +* [Data Compliance](docs/resources/data_compliance.md) +* **Event Types** + * [Calendlyr::EventType](docs/resources/event_types/event_type.md) + * [Calendlyr::EventTypes::AvailableTime](docs/resources/event_types/available_time.md) + * [Calendlyr::EventTypes::Membership](docs/resources/event_types/membership.md) + * [Calendlyr::EventTypes::Profile](docs/resources/event_types/profile.md) +* **Groups** + * [Calendlyr::Group](docs/resources/groups/group.md) + * [Calendlyr::Groups::Relationship](docs/resources/groups/relationship.md) +* **Organizations** + * [Calendlyr::Organization](docs/resources/organizations/organization.md) + * [Calendlyr::Organizations::Invitation](docs/resources/organizations/invitation.md) + * [Calendlyr::Organizations::Membership](docs/resources/organizations/membership.md) +* **Routing Forms** + * [Calendlyr::RoutingForm](docs/resources/routing_forms/routing_form.md) + * [Calendlyr::RoutingForms::Submission](docs/resources/routing_forms/submission.md) +* **Schedule Events** + * [Calendlyr::Event](docs/resources/events/event.md) + * [Calendlyr::Events::Cancellation](docs/resources/events/cancellation.md) + * [Calendlyr::Events::Guest](docs/resources/events/guest.md) + * [Calendlyr::Events::Invitee](docs/resources/events/invitee.md) + * [Calendlyr::Events::InviteeNoShow](docs/resources/events/invitee_no_show.md) +* [Scheduled Links](docs/resources/scheduling_link.md) +* [Shares](docs/resources/share.md) +* [Users](docs/resources/user.md) +* **Webhooks** + * [Calendlyr::Webhooks::Subscription](docs/resources/webhooks/subscription.md) + * [Calendlyr::Webhooks::Payload](docs/resources/webhooks/payload.md) + * [Calendlyr::Webhooks::InviteePayload](docs/resources/webhooks/invitee_payload.md) + ## Contributing 1. Fork it ( https://github.com/araluce/calendlyr/fork ) diff --git a/docs/1_installation.md b/docs/1_installation.md deleted file mode 100644 index 3346f6c..0000000 --- a/docs/1_installation.md +++ /dev/null @@ -1,21 +0,0 @@ -# Installing Calendlyr - -## Gemfile - -Add this line to your application's Gemfile: - -```ruby -gem 'calendlyr' -``` - -And then execute: - - $ bundle - -Or install it yourself as: - - $ gem install calendlyr - -## Next - -See [Usage](/docs/2_usage.md) diff --git a/docs/2_usage.md b/docs/2_usage.md deleted file mode 100644 index 76f2ed9..0000000 --- a/docs/2_usage.md +++ /dev/null @@ -1,13 +0,0 @@ -# Usage - -To access the API, you'll need to create a `Calendlyr::Client` and pass in your token. You can generate your Personal Access Token at [https://calendly.com/integrations/api_webhooks](https://calendly.com/integrations/api_webhooks) - -```ruby -client = Calendlyr::Client.new(token: ENV["CALENDLY_TOKEN"]) -``` - -The client then gives you access to each of the resources. - -## Next - -See [Resources](/docs/3_resources.md) diff --git a/docs/3_resources.md b/docs/3_resources.md deleted file mode 100644 index d18024f..0000000 --- a/docs/3_resources.md +++ /dev/null @@ -1,9 +0,0 @@ -# Resources - -The gem maps as closely as we can to the Calendly API so you can easily convert API examples to gem code. - -Responses are created as objects like `Calendlyr::Event`. Having types like `Calendlyr::User` is handy for understanding what type of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way. - -## Next - -See [Pagination](/docs/resources/1_pagination.md) diff --git a/docs/resources/activity_log/list_activity_log_entries.md b/docs/resources/activity_log/list_activity_log_entries.md new file mode 100644 index 0000000..a222d33 --- /dev/null +++ b/docs/resources/activity_log/list_activity_log_entries.md @@ -0,0 +1,34 @@ +# List Activity Log Entries Calendlyr::ActivityLog + +This endpoint requires an Enterprise subscription. + +## Client requests + +### List + +Returns a list of activity log entries + +Visit official [API Doc](https://developer.calendly.com/api-docs/d37c7f031f339-list-activity-log-entries) + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +client.organizations.activity_log(organization: `organization_uri`) +#=> #> +``` + +## Object methods + +### Associated Organization + +```ruby +user_busy_time.associated_organization +#=> # +``` + +### Associated Actor + +```ruby +user_busy_time.associated_actor +#=> # +``` diff --git a/docs/resources/availabilities/availability_rule.md b/docs/resources/availabilities/availability_rule.md new file mode 100644 index 0000000..eff6fab --- /dev/null +++ b/docs/resources/availabilities/availability_rule.md @@ -0,0 +1,5 @@ +# Availability Rule Calendlyr::Availabilities::Rule + +The rules for an availability schedule. + +Visit official [API Doc](https://developer.calendly.com/api-docs/3546c792f5695-availability-rule) diff --git a/docs/resources/availabilities/user_availability_schedule.md b/docs/resources/availabilities/user_availability_schedule.md new file mode 100644 index 0000000..b57bee3 --- /dev/null +++ b/docs/resources/availabilities/user_availability_schedule.md @@ -0,0 +1,50 @@ +# User Availability Schedule Calendlyr::Availabilities::UserSchedule + +The availability schedule set by the user. + +Visit official [API Doc](https://developer.calendly.com/api-docs/008bd39518269-user-availability-schedule) + +## Client requests + +### Retrieve + +This will return the availability schedule of the given UUID.See [official API doc](https://developer.calendly.com/api-docs/3b1c2d5f97b5c-get-user-availability-schedule) + +```ruby +client.availabilities.retrieve_user_schedule(uuid: @uuid) +#=> #], wday="sunday", date="2022-12-31">], client=#, uuid="abc123"> +``` + +### List + +Return the availability schedules of the given user. See [official API doc](https://developer.calendly.com/api-docs/8098de44af94c-list-user-availability-schedules) + +```ruby +client.availabilities.list_user_schedules(user: @user) +#=> #], wday="sunday", date="2022-12-31">], client=#, uuid="abc123">, #], wday="monday">, #], wday="tuesday">, #, #], wday="thursday">, #], wday="friday">, #, #], date="2028-12-31">], client=#, uuid="abc456">], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +#### List on me + +Use `me` user + +```ruby +client.me.availability_schedules +#=> #], wday="sunday", date="2022-12-31">], client=#, uuid="abc123">, #], wday="monday">, #], wday="tuesday">, #, #], wday="thursday">, #], wday="friday">, #, #], date="2028-12-31">], client=#, uuid="abc456">], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated User + +```ruby +user_schedule.associated_user +#=> # +``` + +### Associated Rules + +```ruby +user_schedule.rules +#=> [#, ...] +``` diff --git a/docs/resources/availabilities/user_busy_time.md b/docs/resources/availabilities/user_busy_time.md new file mode 100644 index 0000000..c524585 --- /dev/null +++ b/docs/resources/availabilities/user_busy_time.md @@ -0,0 +1,28 @@ +# User Busy Time Calendlyr::Availabilities::UserBusyTime + +An internal or external scheduled event for a given user. + +Visit official [API Doc](https://developer.calendly.com/api-docs/acae53ca17454-user-busy-time) + +## Client requests + +### List + +Visit official [API Doc](https://developer.calendly.com/api-docs/5920076156501-list-user-busy-times) + +Date range can be no greater than 1 week (7 days). + +For the example bellow we will use only required parameters, but you can use any other parameter as well. +```ruby +client.availabilities.list_user_busy_times(user: `user_uri`, start_time: `start_time`, end_time: `end_time`) +#=> #, client=#, uuid=nil>, #, client=#, uuid=nil>, #, uuid=nil>], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Event + +```ruby +user_busy_time.associated_event +#=> # +``` diff --git a/docs/resources/availability/1_user_busy_time.md b/docs/resources/availability/1_user_busy_time.md deleted file mode 100644 index 7d57543..0000000 --- a/docs/resources/availability/1_user_busy_time.md +++ /dev/null @@ -1,18 +0,0 @@ -# User Busy Time - -User internal and external scheduled events within a specified date range. - -Date range can be no greater than 1 week (7 days). - -## List - -Visit official [API Doc](https://developer.calendly.com/api-docs/5920076156501-list-user-busy-times) to see [query parameters](https://developer.calendly.com/api-docs/5920076156501-list-user-busy-times) and [response body](https://developer.calendly.com/api-docs/5920076156501-list-user-busy-times#response-body) - -```ruby -client.user_busy_times.list(user_uri: `user_uri`, start_time: `start_time`, end_time: `end_time`) -#=> #, client=#, uuid=nil>, #, client=#, uuid=nil>, #, uuid=nil>], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> -``` - -## Next - -See [User Availability Schedule](/docs/resources/availability/2_user_availability_schedule.md) diff --git a/docs/resources/availability/2_user_availability_schedule.md b/docs/resources/availability/2_user_availability_schedule.md deleted file mode 100644 index ad24477..0000000 --- a/docs/resources/availability/2_user_availability_schedule.md +++ /dev/null @@ -1,32 +0,0 @@ -# User Availability Schedule - -## Retrieve - -This will return the availability schedule of the given UUID.See [official API doc](https://developer.calendly.com/api-docs/3b1c2d5f97b5c-get-user-availability-schedule) - -```ruby -client.user_availability_schedules.retrieve(uuid: @uuid) -#=> #], wday="sunday", date="2022-12-31">], client=#, uuid="abc123"> -``` - -## List - -Return the availability schedules of the given user. See [official API doc](https://developer.calendly.com/api-docs/8098de44af94c-list-user-availability-schedules) - -```ruby -client.user_availability_schedules.list(user_uri: @user_uri) -#=> #], wday="sunday", date="2022-12-31">], client=#, uuid="abc123">, #], wday="monday">, #], wday="tuesday">, #, #], wday="thursday">, #], wday="friday">, #, #], date="2028-12-31">], client=#, uuid="abc456">], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> -``` - -### List on me - -Use `me` user - -```ruby -client.me.availability_schedules -#=> #], wday="sunday", date="2022-12-31">], client=#, uuid="abc123">, #], wday="monday">, #], wday="tuesday">, #, #], wday="thursday">, #], wday="friday">, #, #], date="2028-12-31">], client=#, uuid="abc456">], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> -``` - -## Next - -See [Data Compliance](/docs/resources/2_data_compliance.md) diff --git a/docs/resources/2_data_compliance.md b/docs/resources/data_compliance.md similarity index 60% rename from docs/resources/2_data_compliance.md rename to docs/resources/data_compliance.md index 52b84c2..2232287 100644 --- a/docs/resources/2_data_compliance.md +++ b/docs/resources/data_compliance.md @@ -2,7 +2,8 @@ ## Delete Invitee Data -Remove invitee data from all previously booked events in your organization. Take a look on [official API doc](https://developer.calendly.com/api-docs/4cf896120a018-delete-invitee-data) for more information. +Remove invitee data from all previously booked events in your organization.. +Visit official [API Doc](https://developer.calendly.com/api-docs/4cf896120a018-delete-invitee-data) ```ruby client.data_compliance.delete_invitee_data(emails: %w[test@email.org test2@email.org]) @@ -10,7 +11,8 @@ client.data_compliance.delete_invitee_data(emails: %w[test@email.org test2@email ## Delete Scheduled Event Data -Remove scheduled events data within a time range for your organization. Take a look on [official API doc](https://developer.calendly.com/api-docs/fc9211ad9b551-delete-scheduled-event-data) for more information. +Remove scheduled events data within a time range for your organization. +Visit official [API Doc](https://developer.calendly.com/api-docs/fc9211ad9b551-delete-scheduled-event-data) ```ruby client.data_compliance.delete_scheduled_event_data(start_time: "2019-01-02T03:04:05.678123Z", end_time: "2021-01-01T02:04:05.678123Z") diff --git a/docs/resources/event_types/available_time.md b/docs/resources/event_types/available_time.md new file mode 100644 index 0000000..885831b --- /dev/null +++ b/docs/resources/event_types/available_time.md @@ -0,0 +1,21 @@ +# Available Time Calendlyr::EventTypes::AvailableTime + +An available meeting time slot for the given event type. + +Visit official [API Doc](https://developer.calendly.com/api-docs/2d8d322931358-event-type-available-time) + +## Client requests + +### List +Returns a list of available times for an event type within a specified date range. + +Date range can be no greater than 1 week (7 days). + +For the examples bellow we will use only required parameters, but you can use any other parameter as well. + +Visit official [API Doc](https://developer.calendly.com/api-docs/6a1be82aef359-list-event-type-available-times) + +```ruby +client.event_types.list_available_times(event_type, event_type, start_time: start_time, end_time: end_time) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/event_types/event_type.md b/docs/resources/event_types/event_type.md new file mode 100644 index 0000000..5379d16 --- /dev/null +++ b/docs/resources/event_types/event_type.md @@ -0,0 +1,55 @@ +# Event Type Calendlyr::EventType + +A configuration for an Event. + +Visit official [API Doc](https://developer.calendly.com/api-docs/f3185c91567db-event-type) + +## Client requests + +### Retrieve + +Returns information about a specified Event Type. + +Visit official [API Doc](https://developer.calendly.com/api-docs/c1f9db4a585da-get-event-type) + +```ruby +client.event_types.retrieve(uuid: @uuid) +#=> # +``` + +### List +Returns all Event Types associated with a specified User. + +Visit official [API Doc](https://developer.calendly.com/api-docs/25a4ece03c1bc-list-user-s-event-types) + +For the examples bellow we will use only required parameters, but you can use any other parameter as well. +```ruby +client.event_types.list(user: @user) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> + +client.event_types.list(organization: @organization) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Profile + +```ruby +event_type.associated_profile +#=> # +``` + +### Create Share + +```ruby +event_type.create_share +#=> # +``` + +### Available Times + +```ruby +event_type.available_times(start_time: @start_time, end_time: @end_time, ...) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/event_types/membership.md b/docs/resources/event_types/membership.md new file mode 100644 index 0000000..867b32a --- /dev/null +++ b/docs/resources/event_types/membership.md @@ -0,0 +1,29 @@ +# Membership (Host) Calendlyr::EventTypes::Membership + +## Client requests + +### List +Fetch list of event type hosts. + +Visit official [API Doc](https://developer.calendly.com/api-docs/9e27c9bd793da-list-event-type-hosts) + +```ruby +client.event_types.list_memberships(event_type, event_type) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Event Type + +```ruby +membership.associated_event_type +#=> # +``` + +### Associated Member + +```ruby +membership.associated_member +#=> [#, ...] +``` diff --git a/docs/resources/event_types/profile.md b/docs/resources/event_types/profile.md new file mode 100644 index 0000000..a549440 --- /dev/null +++ b/docs/resources/event_types/profile.md @@ -0,0 +1,13 @@ +# Profile Calendlyr::EventTypes::Profile + +Visit official [API Doc](https://developer.calendly.com/api-docs/c2NoOjU5MTM5NQ-profile) + +## Object methods + +### Associated Owner + +```ruby +profile.associated_owner +#=> [#, ...] +``` + diff --git a/docs/resources/events/cancellation.md b/docs/resources/events/cancellation.md new file mode 100644 index 0000000..7c38e4e --- /dev/null +++ b/docs/resources/events/cancellation.md @@ -0,0 +1,18 @@ +# Cancellation Calendlyr::Events::Cancellation + +Provides data pertaining to the cancellation of the Event or the Invitee. + +Visit official [API Doc](https://developer.calendly.com/api-docs/77497aba237ee-cancellation) + +## Client requests + +### Cancel event + +Cancels specified event. + +Visit official [API Doc](https://developer.calendly.com/api-docs/afb2e9fe3a0a0-cancel-event) + +```ruby +client.events.cancel(uuid: event_uuid, reason: "I'm bussy") +#=> # +``` diff --git a/docs/resources/events/event.md b/docs/resources/events/event.md new file mode 100644 index 0000000..cfa2237 --- /dev/null +++ b/docs/resources/events/event.md @@ -0,0 +1,62 @@ +# Event Calendlyr::Event + +Information about a scheduled meeting. + +Visit official [API Doc](https://developer.calendly.com/api-docs/504508461e486-event) + +## Client requests + +### Retrieve + +Returns information about a specified Event. + +Visit official [API Doc](https://developer.calendly.com/api-docs/e2f95ebd44914-get-event) + +```ruby +client.events.retrieve(uuid: uuid) +#=> # +``` + +### List + +Returns a list of Events. + +Visit official [API Doc](https://developer.calendly.com/api-docs/2d5ed9bbd2952-list-events) + +```ruby +client.events.list(organization: organization, user: user) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> + +client.events.list(organization: organization, group: group) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> + +client.events.list(user: user) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Cancel + +Cancels specified event. + +Visit official [API Doc](https://developer.calendly.com/api-docs/afb2e9fe3a0a0-cancel-event) + +```ruby +client.events.cancel(uuid: event_uuid, reason: "I'm bussy") +#=> # +``` + +## Object methods + +### Memberships + +```ruby +event.memberships +#=> [#, ...] +``` + +### Cancel + +```ruby +event.cancel(reason: "I'm bussy") +#=> # +``` diff --git a/docs/resources/events/guest.md b/docs/resources/events/guest.md new file mode 100644 index 0000000..16260bd --- /dev/null +++ b/docs/resources/events/guest.md @@ -0,0 +1,5 @@ +# Guest Calendlyr::Events::Guest + +An individual whom an invitee has invited to be a guest attendee to an event. + +Visit official [API Doc](https://developer.calendly.com/api-docs/7307270523502-guest) diff --git a/docs/resources/events/invitee.md b/docs/resources/events/invitee.md new file mode 100644 index 0000000..a45e8f4 --- /dev/null +++ b/docs/resources/events/invitee.md @@ -0,0 +1,28 @@ +# Invitee Calendlyr::Events::Invitee + +An individual who has been invited to meet with a Calendly member. + +Visit official [API Doc](https://developer.calendly.com/api-docs/decca36cf717f-invitee) + +## Client requests + +### Retrieve + +Returns information about a specified Invitee (person invited to an event). + +Visit official [API Doc](https://developer.calendly.com/api-docs/8305c0ccfac70-get-event-invitee) + +```ruby +client.events.retrieve_invitee(event_uuid: event_uuid, invitee_uuid: invitee_uuid) +#=> # +``` +### List + +Returns a list of Invitees for an event. + +Visit official [API Doc](https://developer.calendly.com/api-docs/eb8ee72701f99-list-event-invitees) + +```ruby +client.events.list_invitees(uuid: uuid) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/events/invitee_no_show.md b/docs/resources/events/invitee_no_show.md new file mode 100644 index 0000000..e1c6ecf --- /dev/null +++ b/docs/resources/events/invitee_no_show.md @@ -0,0 +1,49 @@ +# Invitee No Show Calendlyr::Events::InviteeNoShow + +Information about an invitees no show. + +Visit official [API Doc](https://developer.calendly.com/api-docs/753a78b938d75-invitee-no-show) + +## Client requests + +### Retrieve + +Returns information about a specified Invitee No Show. + +Visit official [API Doc](https://developer.calendly.com/api-docs/49cf0c87ee6f4-get-invitee-no-show) + +```ruby +client.events.retrieve_invitee_no_show(uuid: uuid) +#=> # +``` + +### Create + +Marks an Invitee as a No Show. + +Visit official [API Doc](https://developer.calendly.com/api-docs/cebd8c3170790-create-invitee-no-show) + +```ruby +client.events.create_invitee_no_show(invitee: invitee_uri) +#=> # +``` + +### Delete + +Undoes marking an Invitee as a No Show. + +Visit official [API Doc](https://developer.calendly.com/api-docs/eb599c64c95ea-delete-invitee-no-show) + +```ruby +client.events.delete_invitee_no_show(uuid: uuid) +#=> +``` + +## Object methods + +### Delete + +```ruby +invitee_no_show.delete +#=> +``` diff --git a/docs/resources/groups/group.md b/docs/resources/groups/group.md new file mode 100644 index 0000000..47e2f10 --- /dev/null +++ b/docs/resources/groups/group.md @@ -0,0 +1,56 @@ +# Group Calendlyr::Group + +The Group resource that was requested. Represents groupings of Users within an Organization. + +Visit official [API Doc](https://developer.calendly.com/api-docs/15c7951a86b40-group) + +## Client requests + +### Retrieve + +Returns information about a specified Group. + +Visit official [API Doc](https://developer.calendly.com/api-docs/beaf147a3bc34-get-group) + +```ruby +client.groups.retrieve(uuid: uuid) +#=> # +``` + +### List + +Returns a list of groups. + +Visit official [API Doc](https://developer.calendly.com/api-docs/6rb6dtdln74sy-list-groups) + +```ruby +client.groups.list(organization: organization_uri) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Organization + +```ruby +group.associated_organization +#=> # +``` + +### Events + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +group.events +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Group Relationships + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +group.group_relationships +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/groups/relationship.md b/docs/resources/groups/relationship.md new file mode 100644 index 0000000..2c1bd22 --- /dev/null +++ b/docs/resources/groups/relationship.md @@ -0,0 +1,54 @@ +# Group Relationship Calendlyr::Groups::Relationship + +A group relationship record for an individual. A given individual may have more than one admin relationship to multiple groups, but only one member relationship to a single group. + +Visit official [API Doc](https://developer.calendly.com/api-docs/a82d8ee79eb82-group-relationship) + +## Client requests + +### Retrieve + +Returns a group relationship by uuid. + +Visit official [API Doc](https://developer.calendly.com/api-docs/91925872af92a-get-group-relationship) + +```ruby +client.groups.retrieve_relationship(uuid: uuid) +#=> # +``` + +### List + +Returns a list of group relationships - a given owner can have one membership record, but multiple admin records. + +Visit official [API Doc](https://developer.calendly.com/api-docs/4674a12f55f82-list-group-relationships) + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +client.groups.list_relationships +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Organization + +```ruby +group_relationship.associated_organization +#=> # +``` + +### Associated Group + +```ruby +group_relationship.associated_group +#=> # +``` + +### Associated Owner + +```ruby +group_relationship.associated_owner +#=> # +``` diff --git a/docs/resources/organizations/invitation.md b/docs/resources/organizations/invitation.md new file mode 100644 index 0000000..02c0570 --- /dev/null +++ b/docs/resources/organizations/invitation.md @@ -0,0 +1,65 @@ +# Organization Invitation Calendlyr::Organizations::Invitation + +Organization Invitation object. + +Visit official [API Doc](https://developer.calendly.com/api-docs/736b3f42c9586-organization-invitation) + +## Client requests + +### Retrieve + +Returns an Organization Invitation that was sent to the organization's members. + +Visit official [API Doc](https://developer.calendly.com/api-docs/f3f0b6c2a95c7-get-organization-invitation) + +```ruby +client.organizations.retrieve_invitation(org_uuid: organization_uuid, uuid: invitation_uuid) +#=> # +``` + +### Invite + +Invites a user to an organization. + +Visit official [API Doc](https://developer.calendly.com/api-docs/094d15d2cd4ab-invite-user-to-organization) + +```ruby +client.organizations.invite(organization_uuid: organization_uuid, email: "email@example.com") +#=> # +``` + +### List + +Returns a list of Organization Invitations that were sent to the organization's members. + +Visit official [API Doc](https://developer.calendly.com/api-docs/3ad68ee2cc606-list-organization-invitations) + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +client.organizations.list_invitations(uuid: organization_uuid) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Organization + +```ruby +organization_invitation.associated_organization +#=> # +``` + +### Associated User + +```ruby +organization_invitation.associated_user +#=> # +``` + +### Revoke + +```ruby +organization_invitation.revoke +#=> +``` diff --git a/docs/resources/organizations/membership.md b/docs/resources/organizations/membership.md new file mode 100644 index 0000000..dc519e2 --- /dev/null +++ b/docs/resources/organizations/membership.md @@ -0,0 +1,58 @@ +# Organization Membership Calendlyr::Organizations::Membership + +Organization Membership object. + +Visit official [API Doc](https://developer.calendly.com/api-docs/ae30b41b52a54-organization-membership) + +## Client requests + +### Retrieve + +Returns information about a user's Organization Membership. + +Visit official [API Doc](https://developer.calendly.com/api-docs/8c3baa79a5883-get-organization-membership) + +```ruby +client.organizations.retrieve_membership(uuid: uuid) +#=> # +``` + +### List + +Use this to list the Organization Memberships for all users belonging to an organization. + +Visit official [API Doc](https://developer.calendly.com/api-docs/eaed2e61a6bc3-list-organization-memberships) + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +client.organizations.list_memberships(user: user) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> + +client.organizations.list_memberships(organization: organization) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Organization + +```ruby +organization_membership.associated_organization +#=> # +``` + +### Associated User + +```ruby +organization_membership.associated_user +#=> # +``` + +### Group Relationships +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization_membership.group_relationships +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/organizations/organization.md b/docs/resources/organizations/organization.md new file mode 100644 index 0000000..cb9a53a --- /dev/null +++ b/docs/resources/organizations/organization.md @@ -0,0 +1,149 @@ +# Organization Calendlyr::Organization + +Organization object. + +Visit official [API Doc](https://developer.calendly.com/api-docs/848e5e20591ee-organization) + +## Me + +We can access your organization information by calling `organization` method on the client object. + +```ruby +organization = client.organization +#=> # +``` + +## Object methods + +### Activity Logs + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.activity_logs +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Events + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.events +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Event Types + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.event_types +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Routing Forms + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.routing_forms +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Groups + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.groups +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Group Relationships + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.group_relationships +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Memberships + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.memberships +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Membership + +```ruby +organization.membership(uuid: uuid) +#=> # +``` + +### Webhooks + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +organization.webhooks(scope: scope) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Create a Webhook + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +organization.create_webhook(url:, url, events: events, scope: scope) +#=> # +``` + +### Sample Webhook Data + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +organization.sample_webhook_data(event: event, scope: scope) +#=> # +``` + +### Invite user + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +organization.invite_user(email: 'email@example.com') +#=> # +``` + +### Invitations + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +organization.invitations +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Invitation + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +organization.invitation(invitation_uuid: invitation_uuid) +#=> # +``` + +### Revoke an invitation + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +organization.revoke_invitation(invitation_uuid: invitation_uuid) +#=> +``` diff --git a/docs/resources/1_pagination.md b/docs/resources/pagination.md similarity index 87% rename from docs/resources/1_pagination.md rename to docs/resources/pagination.md index bcf8532..8361849 100644 --- a/docs/resources/1_pagination.md +++ b/docs/resources/pagination.md @@ -19,7 +19,3 @@ results.next_page_token client.me.events(count: 5, next_page_token: results.next_page_token) #=> Calendlyr::Collection ``` - -## Next - -See [UserBusyTime](/docs/resources/availability/1_user_busy_time.md) diff --git a/docs/resources/routing_forms/routing_form.md b/docs/resources/routing_forms/routing_form.md new file mode 100644 index 0000000..b6bd231 --- /dev/null +++ b/docs/resources/routing_forms/routing_form.md @@ -0,0 +1,48 @@ +# Routing Form Calendlyr::RoutingForm + +Information about a routing form. + +Visit official [API Doc](https://developer.calendly.com/api-docs/20e016678903c-routing-form) + +## Client requests + +### Retrieve + +Get a specified Routing Form. + +Visit official [API Doc](https://developer.calendly.com/api-docs/910a7e2f573e8-get-routing-form) + +```ruby +client.routing_forms.retrieve(uuid: form_uuid) +#=> # +``` + +### List + +Get a list of Routing Forms for a specified Organization. + +Visit official [API Doc](https://developer.calendly.com/api-docs/9fe7334bec6ad-list-routing-forms) + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +client.routing_forms.list(organization: organization_uri) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Organization + +```ruby +routing_form.associated_organization +#=> # +``` + +### Submissions +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +routing_form.submissions +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/routing_forms/submission.md b/docs/resources/routing_forms/submission.md new file mode 100644 index 0000000..83b5508 --- /dev/null +++ b/docs/resources/routing_forms/submission.md @@ -0,0 +1,40 @@ +# Routing Form Submission Calendlyr::RoutingForms::Submission + +Information about a Routing Form Submission. + +Visit official [API Doc](https://developer.calendly.com/api-docs/09b54c4d45b62-routing-form-submission) + +## Client requests + +### Retrieve + +Get a specified Routing Form Submission. + +Visit official [API Doc](https://developer.calendly.com/api-docs/f4ccebf48e5b5-get-routing-form-submission) + +```ruby +client.routing_forms.retrieve_submission(uuid: submission_uuid) +#=> # +``` + +### List + +Get a list of Routing Form Submissions for a specified Routing Form. + +Visit official [API Doc](https://developer.calendly.com/api-docs/17db5cb915a57-list-routing-form-submissions) + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +client.routing_forms.list_submissions(form: routing_form_uri) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +## Object methods + +### Associated Routing Form + +```ruby +routing_form_submission.associated_routing_form +#=> # +``` diff --git a/docs/resources/scheduling_link.md b/docs/resources/scheduling_link.md new file mode 100644 index 0000000..b4f1711 --- /dev/null +++ b/docs/resources/scheduling_link.md @@ -0,0 +1,26 @@ +# Scheduling Link Calendlyr::SchedulingLink + +Scheduling Link Object. + + +## Client requests + +### Create + +Creates a single-use scheduling link. + +Visit official [API Doc](https://developer.calendly.com/api-docs/4b8195084e287-create-single-use-scheduling-link) + +```ruby +client.scheduling_links.create(owner: event_type_uri, max_event_count: 1) +#=> # +``` + +## Object methods + +### Event Type + +```ruby +scheduling_link.event_type +#=> # +``` diff --git a/docs/resources/share.md b/docs/resources/share.md new file mode 100644 index 0000000..ea6d705 --- /dev/null +++ b/docs/resources/share.md @@ -0,0 +1,28 @@ +# Share Calendlyr::Schare + +Schare Object. + +Visit official [API Doc](https://developer.calendly.com/api-docs/0069948603238-share) + + +## Client requests + +### Create + +Endpoint for our Customize Once and Share feature. This allows you to customize events for a specific invitee without needing to make an entirely new event type. This feature is only available for one-on-one event types. Note: Any parameter which is not provided in the request body will be copied from the target event type. + +Visit official [API Doc](https://developer.calendly.com/api-docs/fdcac06abfc8c-create-share) + +```ruby +client.shares.create(create: event_type_uri, name: "15 minute meeting", duration: ...) +#=> # +``` + +## Object methods + +### Associated Scheduling Links + +```ruby +share.associated_scheduling_links +#=> [#] +``` diff --git a/docs/resources/user.md b/docs/resources/user.md index 9b5cc1c..f56e671 100644 --- a/docs/resources/user.md +++ b/docs/resources/user.md @@ -1,25 +1,34 @@ -# User +# User Calendlyr::User + +Information about the user. + +Visit official [API Doc](https://developer.calendly.com/api-docs/647961f90c0dd-user) + +## Client requests + +### Retrieve + +Returns information about a specified User. + +Visit official [API Doc](https://developer.calendly.com/api-docs/ff9832c5a6640-get-user) ```ruby -client.me -client.users.me -client.retrieve(user_uuid: "uuid") -#=> #, uuid="123abc"> +client.users.retrieve(uuid: user_uuid) +#=> # +``` -client.organization -#=> #, uuid="123abc"> +### Me -client.me.event_types -#=> #], deleted_at=nil, description_html=nil, description_plain=nil, duration=15, internal_note=nil, kind="solo", locations=[#], name="15 Minute Meeting", pooling_type=nil, position=0, profile=#, scheduling_url="https://calendly.com/john-doe/15min", secret=false, slug="15min", type="StandardEventType", updated_at="2022-01-10T17:24:53.767416Z", uri="https://api.calendly.com/event_types/abc123", client=#, uuid="abc123">]> +Returns basic information about your user account. -client.me.events -#=> #, created_at="2022-05-27T11:49:29.726091Z", end_time="2022-05-27T17:30:00.000000Z", event_guests=[], event_memberships=[#], event_type="https://api.calendly.com/event_types/abc123", invitees_counter=#, location=#, join_url=nil, status=nil, type="zoom">, meeting_notes_html=nil, meeting_notes_plain=nil, name="30 Minute Meeting", start_time="2022-05-27T17:00:00.000000Z", status="active", updated_at="2022-05-27T11:49:31.007529Z", uri="https://api.calendly.com/scheduled_events/abc123", client=#, uuid="abc123">]> +Visit official [API Doc](https://developer.calendly.com/api-docs/005832c83aeae-get-current-user) -client.me.memberships -#=> #, client=#, uuid="abc123">]> +```ruby +client.users.me +#=> # ``` -## Me +#### Easy access Probably you need to make many calls through `client.me`, so we decided to not make calls for every `client.me` reference by memoizing it the first time. @@ -28,7 +37,7 @@ client.me # makes a call and memoize the response client.me # no call, value memoized ``` -### Force reload +#### Force reload However, if you need to reload the content of `me` you can `force_relaod` to force a new call. @@ -36,5 +45,67 @@ However, if you need to reload the content of `me` you can `force_relaod` to for client.me(force_reload: true) # makes a new call and update memoized value ``` +## Object methods + +### Associated Organization + +```ruby +user.associated_organization +#=> # +``` + +### Availability Schedules + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +user.availability_schedules +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Memberships + +Based on your user organization + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +user.memberships +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Organization Membership + +Based on your user organization + +```ruby +user.membership(uuid: membership_uuid) +#=> # +``` + +### Event Types + +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +user.event_types +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Events -## Next +For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs. + +```ruby +user.events +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Busy Times + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +user.busy_times(start_time: start_time, end_time: end_time) +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` diff --git a/docs/resources/webhooks/invitee_payload.md b/docs/resources/webhooks/invitee_payload.md new file mode 100644 index 0000000..5e7d1c6 --- /dev/null +++ b/docs/resources/webhooks/invitee_payload.md @@ -0,0 +1,42 @@ +# Webhook Invitee Payload Calendlyr::Wehooks::InviteePayload + +The payload that is sent via Webhook when an invitee creates or schedules a meeting, and when an invitee cancels. + +Visit official [API Doc](https://developer.calendly.com/api-docs/b92768854bc06-invitee-payload) + +## Object methods + +### Associated Event + +```ruby +webhook_invitee_payload.associated_organization +#=> # +``` + +### Associated Routing Form Submission + +```ruby +webhook_invitee_payload.associated_routing_form_submission +#=> # +``` + +### Associated Invitee No Show + +```ruby +webhook_invitee_payload.associated_invitee_no_show +#=> # +``` + +### active? + +```ruby +webhook_subscription.active? +#=> true +``` + +### disabled? + +```ruby +webhook_subscription.disabled? +#=> false +``` diff --git a/docs/resources/webhooks/payload.md b/docs/resources/webhooks/payload.md new file mode 100644 index 0000000..5bad96a --- /dev/null +++ b/docs/resources/webhooks/payload.md @@ -0,0 +1,5 @@ +# Webhook Payload Calendlyr::Wehooks::Payload + +Webhook Payload Object + +Visit official [API Doc](https://developer.calendly.com/api-docs/69c58da556b61-webhook-payload) diff --git a/docs/resources/webhooks/subscription.md b/docs/resources/webhooks/subscription.md new file mode 100644 index 0000000..ae2b8b0 --- /dev/null +++ b/docs/resources/webhooks/subscription.md @@ -0,0 +1,96 @@ +# Webhook Subscription Calendlyr::Wehooks::Subscription + +Webhook Subscription Object. + +Visit official [API Doc](https://developer.calendly.com/api-docs/9950e4dff7351-webhook-subscription) + +## Client requests + +### Create + +Create a Webhook Subscription for an Organization or User. + +Visit official [API Doc](https://developer.calendly.com/api-docs/c1ddc06ce1f1b-create-webhook-subscription) + +```ruby +client.webhooks.create(url: 'https://example.com/webhook', events: ['invitee.created'], organization: organization_uri, scope: 'organization') +#=> # + +client.webhooks.create(url: 'https://example.com/webhook', events: ['invitee.created'], organization: organization_uri, user: user_uri, scope: 'user') +#=> # + +client.webhooks.create(url: 'https://example.com/webhook', events: ['invitee.created'], organization: organization_uri, group: group_uri, scope: 'group') +#=> # +``` + +### Retrieve + +Get a specified Webhook Subscription. + +Visit official [API Doc](https://developer.calendly.com/api-docs/4d800dc2cb119-get-webhook-subscription) + +```ruby +client.webhooks.retrieve(webhook_uuid: webhook_uuid) +#=> # +``` + +### List + +Get a list of Webhook Subscriptions for a specified Organization or User. + +Visit official [API Doc](https://developer.calendly.com/api-docs/faac832d7c57d-list-webhook-subscriptions) + +For the example bellow we will use only required parameters, but you can use any other parameter as well. + +```ruby +client.webhooks.list(organization: organization_uri, scope: 'organization') +#=> #, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#> +``` + +### Delete + +Delete a Webhook Subscription. + +Visit official [API Doc](https://developer.calendly.com/api-docs/565b97f62dafe-delete-webhook-subscription) + +```ruby +client.webhooks.delete(webhook_uuid: webhook_uuid) +#=> +``` + +## Object methods + +### Associated Organization + +```ruby +webhook_subscription.associated_organization +#=> # +``` + +### Associated User + +```ruby +webhook_subscription.associated_user +#=> # +``` + +### Associated Creator + +```ruby +webhook_subscription.associated_creator +#=> # +``` + +### active? + +```ruby +webhook_subscription.active? +#=> true +``` + +### disabled? + +```ruby +webhook_subscription.disabled? +#=> false +``` diff --git a/lib/calendlyr.rb b/lib/calendlyr.rb index b1d8249..f5d08be 100644 --- a/lib/calendlyr.rb +++ b/lib/calendlyr.rb @@ -3,44 +3,80 @@ module Calendlyr autoload :Client, "calendlyr/client" autoload :Collection, "calendlyr/collection" - autoload :Resource, "calendlyr/resource" autoload :Object, "calendlyr/object" + autoload :Resource, "calendlyr/resource" # Errors - autoload :ResponseErrorHandler, "calendlyr/error" - autoload :Error, "calendlyr/error" - autoload :PermissionDenied, "calendlyr/error" autoload :BadRequest, "calendlyr/error" - autoload :PaymentRequired, "calendlyr/error" - autoload :Unauthenticated, "calendlyr/error" - autoload :NotFound, "calendlyr/error" + autoload :Error, "calendlyr/error" autoload :ExternalCalendarEror, "calendlyr/error" autoload :InternalServerError, "calendlyr/error" + autoload :NotFound, "calendlyr/error" + autoload :PaymentRequired, "calendlyr/error" + autoload :PermissionDenied, "calendlyr/error" + autoload :ResponseErrorHandler, "calendlyr/error" + autoload :Unauthenticated, "calendlyr/error" # High-level categories of Calendly API calls - autoload :UserResource, "calendlyr/resources/users" - autoload :EventTypeResource, "calendlyr/resources/event_types" - autoload :OrganizationResource, "calendlyr/resources/organizations" - autoload :EventResource, "calendlyr/resources/events" - autoload :EventInviteeResource, "calendlyr/resources/event_invitees" - autoload :SchedulingLinkResource, "calendlyr/resources/scheduling_links" - autoload :WebhookResource, "calendlyr/resources/webhooks" + autoload :AvailabilityResource, "calendlyr/resources/availability" autoload :DataComplianceResource, "calendlyr/resources/data_compliance" - autoload :UserBusyTimeResource, "calendlyr/resources/user_busy_times" - autoload :UserAvailabilityScheduleResource, "calendlyr/resources/user_availability_schedules" + autoload :EventResource, "calendlyr/resources/event" + autoload :EventTypeResource, "calendlyr/resources/event_type" + autoload :GroupResource, "calendlyr/resources/group" + autoload :OrganizationResource, "calendlyr/resources/organization" + autoload :OutgoingCommunicationResource, "calendlyr/resources/outgoing_communication" + autoload :RoutingFormResource, "calendlyr/resources/routing_form" + autoload :SchedulingLinkResource, "calendlyr/resources/scheduling_link" + autoload :ShareResource, "calendlyr/resources/share" + autoload :UserResource, "calendlyr/resources/user" + autoload :WebhookResource, "calendlyr/resources/webhook" # Classes used to return a nicer object wrapping the response data - autoload :User, "calendlyr/objects/users" - autoload :EventType, "calendlyr/objects/event_types" - autoload :Event, "calendlyr/objects/event" - autoload :Organization, "calendlyr/objects/organizations" - autoload :Invitation, "calendlyr/objects/invitations" - autoload :EventInvitee, "calendlyr/objects/event_invitees" - autoload :SchedulingLink, "calendlyr/objects/scheduling_links" - autoload :Membership, "calendlyr/objects/memberships" - autoload :Webhook, "calendlyr/objects/webhooks" autoload :ActivityLog, "calendlyr/objects/activity_log" - autoload :AvailabilityRule, "calendlyr/objects/availability_rule" - autoload :UserAvailabilitySchedule, "calendlyr/objects/user_availability_schedule" - autoload :UserBusyTime, "calendlyr/objects/user_busy_time" + autoload :Event, "calendlyr/objects/event" + autoload :EventType, "calendlyr/objects/event_type" + autoload :Group, "calendlyr/objects/group" + autoload :Organization, "calendlyr/objects/organization" + autoload :RoutingForm, "calendlyr/objects/routing_form" + autoload :SchedulingLink, "calendlyr/objects/scheduling_link" + autoload :Share, "calendlyr/objects/share" + autoload :User, "calendlyr/objects/user" + + module Availabilities + autoload :Rule, "calendlyr/objects/availabilities/rule" + autoload :UserSchedule, "calendlyr/objects/availabilities/user_schedule" + autoload :UserBusyTime, "calendlyr/objects/availabilities/user_busy_time" + end + + module Events + autoload :Cancellation, "calendlyr/objects/events/cancellation" + autoload :Guest, "calendlyr/objects/events/guest" + autoload :Invitee, "calendlyr/objects/events/invitee" + autoload :InviteeNoShow, "calendlyr/objects/events/invitee_no_show" + end + + module EventTypes + autoload :AvailableTime, "calendlyr/objects/event_types/available_time" + autoload :Membership, "calendlyr/objects/event_types/membership" + autoload :Profile, "calendlyr/objects/event_types/profile" + end + + module Groups + autoload :Relationship, "calendlyr/objects/groups/relationship" + end + + module Organizations + autoload :Invitation, "calendlyr/objects/organizations/invitation" + autoload :Membership, "calendlyr/objects/organizations/membership" + end + + module RoutingForms + autoload :Submission, "calendlyr/objects/routing_forms/submission" + end + + module Webhooks + autoload :Subscription, "calendlyr/objects/webhooks/subscription" + autoload :InviteePayload, "calendlyr/objects/webhooks/invitee_payload" + autoload :Payload, "calendlyr/objects/webhooks/payload" + end end diff --git a/lib/calendlyr/client.rb b/lib/calendlyr/client.rb index aad1597..1745c7f 100644 --- a/lib/calendlyr/client.rb +++ b/lib/calendlyr/client.rb @@ -8,6 +8,10 @@ def initialize(token:) @token = token end + def availability + AvailabilityResource.new(self) + end + def me(force_reload: false) @me = nil if force_reload @me ||= users.me @@ -33,14 +37,26 @@ def events EventResource.new(self) end - def event_invitees - EventInviteeResource.new(self) + def groups + GroupResource.new(self) + end + + def outgoing_communications + OutgoingCommunicationResource.new(self) + end + + def routing_forms + RoutingFormResource.new(self) end def scheduling_links SchedulingLinkResource.new(self) end + def shares + ShareResource.new(self) + end + def webhooks WebhookResource.new(self) end @@ -49,14 +65,6 @@ def data_compliance DataComplianceResource.new(self) end - def user_busy_times - UserBusyTimeResource.new(self) - end - - def user_availability_schedules - UserAvailabilityScheduleResource.new(self) - end - # Avoid returning # def inspect "#" diff --git a/lib/calendlyr/object.rb b/lib/calendlyr/object.rb index d25e674..3063c81 100644 --- a/lib/calendlyr/object.rb +++ b/lib/calendlyr/object.rb @@ -2,6 +2,10 @@ module Calendlyr class Object < OpenStruct + def self.get_slug(path) + path.split("/").last + end + def initialize(attributes) super(to_ostruct(attributes.merge(uuid: extract_uuid(attributes)))) end @@ -21,7 +25,7 @@ def extract_uuid(attrs) end def get_slug(path) - path.split("/").last + Calendlyr::Object.get_slug(path) end end end diff --git a/lib/calendlyr/objects/activity_log.rb b/lib/calendlyr/objects/activity_log.rb index 967bcf4..212e857 100644 --- a/lib/calendlyr/objects/activity_log.rb +++ b/lib/calendlyr/objects/activity_log.rb @@ -1,7 +1,11 @@ module Calendlyr class ActivityLog < Object def associated_organization - @associated_organization ||= Organization.new({"uri" => organization}.merge(client: client)) + Organization.new({"uri" => organization}.merge(client: client)) + end + + def associated_actor + client.users.retrieve(uuid: get_slug(actor.uri)) end end end diff --git a/lib/calendlyr/objects/availabilities/rule.rb b/lib/calendlyr/objects/availabilities/rule.rb new file mode 100644 index 0000000..208d1a4 --- /dev/null +++ b/lib/calendlyr/objects/availabilities/rule.rb @@ -0,0 +1,4 @@ +module Calendlyr + class Availabilities::Rule < Object + end +end diff --git a/lib/calendlyr/objects/availabilities/user_busy_time.rb b/lib/calendlyr/objects/availabilities/user_busy_time.rb new file mode 100644 index 0000000..b55c56a --- /dev/null +++ b/lib/calendlyr/objects/availabilities/user_busy_time.rb @@ -0,0 +1,7 @@ +module Calendlyr + class Availabilities::UserBusyTime < Object + def associated_event + client.events.retrieve(uuid: get_slug(event.uri)) + end + end +end diff --git a/lib/calendlyr/objects/availabilities/user_schedule.rb b/lib/calendlyr/objects/availabilities/user_schedule.rb new file mode 100644 index 0000000..12c97e0 --- /dev/null +++ b/lib/calendlyr/objects/availabilities/user_schedule.rb @@ -0,0 +1,13 @@ +module Calendlyr + class Availabilities::UserSchedule < Object + def associated_user + client.users.retrieve(uuid: get_slug(user)) + end + + def availability_rules + rules.map do |rule| + Availabilities::Rule.new(rule.to_h.merge(client: client)) + end + end + end +end diff --git a/lib/calendlyr/objects/availability_rule.rb b/lib/calendlyr/objects/availability_rule.rb deleted file mode 100644 index 76c1ed6..0000000 --- a/lib/calendlyr/objects/availability_rule.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Calendlyr - class AvailabilityRule < Object - end -end diff --git a/lib/calendlyr/objects/event.rb b/lib/calendlyr/objects/event.rb index b22ad11..6b23516 100644 --- a/lib/calendlyr/objects/event.rb +++ b/lib/calendlyr/objects/event.rb @@ -1,4 +1,11 @@ module Calendlyr class Event < Object + def memberships + event_memberships.map { |membership| client.users.retrieve(uuid: get_slug(membership.user)) } + end + + def cancel(reason: nil) + client.events.cancel(uuid: uuid, reason: reason) + end end end diff --git a/lib/calendlyr/objects/event_invitees.rb b/lib/calendlyr/objects/event_invitees.rb deleted file mode 100644 index b8aaa85..0000000 --- a/lib/calendlyr/objects/event_invitees.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Calendlyr - class EventInvitee < Object - end -end diff --git a/lib/calendlyr/objects/event_type.rb b/lib/calendlyr/objects/event_type.rb new file mode 100644 index 0000000..685bc2c --- /dev/null +++ b/lib/calendlyr/objects/event_type.rb @@ -0,0 +1,15 @@ +module Calendlyr + class EventType < Object + def associated_profile + EventTypes::Profile.new(profile.to_h.merge(client: client)) + end + + def create_share(**params) + client.shares.create(**params.merge(event_type: uri)) + end + + def available_times(start_time:, end_time:, **params) + client.event_types.list_available_times(**params.merge(event_type: uri, start_time: start_time, end_time: end_time)) + end + end +end diff --git a/lib/calendlyr/objects/event_types.rb b/lib/calendlyr/objects/event_types.rb deleted file mode 100644 index 71bed3a..0000000 --- a/lib/calendlyr/objects/event_types.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Calendlyr - class EventType < Object - end -end diff --git a/lib/calendlyr/objects/event_types/available_time.rb b/lib/calendlyr/objects/event_types/available_time.rb new file mode 100644 index 0000000..4b76a3c --- /dev/null +++ b/lib/calendlyr/objects/event_types/available_time.rb @@ -0,0 +1,4 @@ +module Calendlyr + class EventTypes::AvailableTime < Object + end +end diff --git a/lib/calendlyr/objects/event_types/membership.rb b/lib/calendlyr/objects/event_types/membership.rb new file mode 100644 index 0000000..aa23f23 --- /dev/null +++ b/lib/calendlyr/objects/event_types/membership.rb @@ -0,0 +1,11 @@ +module Calendlyr + class EventTypes::Membership < Object + def associated_event_type + client.event_types.retrieve(uuid: get_slug(event_type.uri)) + end + + def associated_member + client.users.retrieve(uuid: get_slug(member.uri)) + end + end +end diff --git a/lib/calendlyr/objects/event_types/profile.rb b/lib/calendlyr/objects/event_types/profile.rb new file mode 100644 index 0000000..cd52fde --- /dev/null +++ b/lib/calendlyr/objects/event_types/profile.rb @@ -0,0 +1,7 @@ +module Calendlyr + class EventTypes::Profile < Object + def associated_owner + client.users.retrieve(uuid: get_slug(owner)) + end + end +end diff --git a/lib/calendlyr/objects/events/cancellation.rb b/lib/calendlyr/objects/events/cancellation.rb new file mode 100644 index 0000000..6059fd3 --- /dev/null +++ b/lib/calendlyr/objects/events/cancellation.rb @@ -0,0 +1,4 @@ +module Calendlyr + class Events::Cancellation < Object + end +end diff --git a/lib/calendlyr/objects/events/guest.rb b/lib/calendlyr/objects/events/guest.rb new file mode 100644 index 0000000..476acd8 --- /dev/null +++ b/lib/calendlyr/objects/events/guest.rb @@ -0,0 +1,4 @@ +module Calendlyr + class Events::Guest < Object + end +end diff --git a/lib/calendlyr/objects/events/invitee.rb b/lib/calendlyr/objects/events/invitee.rb new file mode 100644 index 0000000..081dcd2 --- /dev/null +++ b/lib/calendlyr/objects/events/invitee.rb @@ -0,0 +1,11 @@ +module Calendlyr + class Events::Invitee < Object + def cancel(reason: nil) + client.events.cancel(uuid: uuid, reason: reason) + end + + def create_no_shows + client.events.create_invitee_no_show(invitee: uri) + end + end +end diff --git a/lib/calendlyr/objects/events/invitee_no_show.rb b/lib/calendlyr/objects/events/invitee_no_show.rb new file mode 100644 index 0000000..1471cd4 --- /dev/null +++ b/lib/calendlyr/objects/events/invitee_no_show.rb @@ -0,0 +1,7 @@ +module Calendlyr + class Events::InviteeNoShow < Object + def delete + client.events.delete_invitee_no_show(uuid: uuid) + end + end +end diff --git a/lib/calendlyr/objects/group.rb b/lib/calendlyr/objects/group.rb new file mode 100644 index 0000000..145c9a4 --- /dev/null +++ b/lib/calendlyr/objects/group.rb @@ -0,0 +1,15 @@ +module Calendlyr + class Group < Object + def associated_organization + Organization.new({"uri" => organization}.merge(client: client)) + end + + def events(**params) + client.events.list(**params.merge(group: uri)) + end + + def group_relationships(**params) + client.groups.list_relationships(**params.merge(group: uri)) + end + end +end diff --git a/lib/calendlyr/objects/groups/relationship.rb b/lib/calendlyr/objects/groups/relationship.rb new file mode 100644 index 0000000..82bc885 --- /dev/null +++ b/lib/calendlyr/objects/groups/relationship.rb @@ -0,0 +1,15 @@ +module Calendlyr + class Groups::Relationship < Object + def associated_organization + Organization.new({"uri" => organization}.merge(client: client)) + end + + def associated_group + client.groups.retrieve(uuid: get_slug(group)) + end + + def associated_owner + client.organizations.retrieve_membership(uuid: get_slug(owner.uri)) + end + end +end diff --git a/lib/calendlyr/objects/invitations.rb b/lib/calendlyr/objects/invitations.rb deleted file mode 100644 index d87694b..0000000 --- a/lib/calendlyr/objects/invitations.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Calendlyr - class Invitation < Object - def associated_organization - @associated_organization ||= Organization.new({"uri" => organization}.merge(client: client)) - end - - def revoke - associated_organization.revoke_invitation invitation_uuid: uuid - end - end -end diff --git a/lib/calendlyr/objects/memberships.rb b/lib/calendlyr/objects/memberships.rb deleted file mode 100644 index e9d9bae..0000000 --- a/lib/calendlyr/objects/memberships.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Calendlyr - class Membership < Object - def associated_user - client.users.retrieve user_uuid: get_slug(user.uri) - end - end -end diff --git a/lib/calendlyr/objects/organization.rb b/lib/calendlyr/objects/organization.rb new file mode 100644 index 0000000..22f37a8 --- /dev/null +++ b/lib/calendlyr/objects/organization.rb @@ -0,0 +1,67 @@ +module Calendlyr + class Organization < Object + def activity_logs(**params) + client.organizations.activity_log(**params.merge(organization: uri)) + end + + def events(**params) + client.events.list(**params.merge(organization: uri)) + end + + def event_types(**params) + client.event_types.list(**params.merge(organization: uri)) + end + + def routing_forms(**params) + client.routing_forms.list(**params.merge(organization: uri)) + end + + # Groups + def groups(**params) + client.groups.list(**params.merge(organization: uri)) + end + + def group_relationships(**params) + client.groups.list_relationships(**params.merge(organization: uri)) + end + + # Memberships + def memberships(**params) + client.organizations.list_memberships(**params.merge(organization: uri)) + end + + def membership(uuid:) + client.organizations.retrieve_membership(uuid: uuid) + end + + # Webhooks + def webhooks(scope:, **params) + client.webhooks.list(**params.merge(organization: uri, scope: scope)) + end + + def create_webhook(url:, events:, scope:, **params) + client.webhooks.create(**params.merge(organization: uri, url: url, events: events, scope: scope)) + end + + def sample_webhook_data(event:, scope:, **params) + client.webhooks.sample_webhook_data(event: event, scope: scope, organization: uri, **params) + end + + # Invitations + def invite_user(email:, **params) + client.organizations.invite(**params.merge(organization_uuid: uuid, email: email)) + end + + def invitations(**params) + client.organizations.list_invitations(**params.merge(uuid: uuid)) + end + + def invitation(invitation_uuid:) + client.organizations.retrieve_invitation(org_uuid: uuid, uuid: invitation_uuid) + end + + def revoke_invitation(invitation_uuid:) + client.organizations.revoke_invitation(org_uuid: uuid, uuid: invitation_uuid) + end + end +end diff --git a/lib/calendlyr/objects/organizations.rb b/lib/calendlyr/objects/organizations.rb deleted file mode 100644 index fdca451..0000000 --- a/lib/calendlyr/objects/organizations.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Calendlyr - class Organization < Object - def invite_user(email:) - client.organizations.invite organization_uuid: uuid, email: email - end - - def list_invitations(**params) - client.organizations.list_invitations organization_uuid: uuid, **params - end - - def list_webhooks(**params) - client.webhooks.list(organization_uri: uri, **params) - end - - def create_webhook(**params) - client.webhooks.create(organization_uri: uri, **params) - end - - def revoke_invitation(invitation_uuid:) - client.organizations.revoke_invitation(organization_uuid: uuid, invitation_uuid: invitation_uuid) - end - - def invitation(invitation_uuid:) - client.organizations.retrieve_invitation(organization_uuid: uuid, invitation_uuid: invitation_uuid) - end - - def events(user_uri: nil, **params) - client.events.list user_uri: user_uri, organization_uri: uri, **params - end - - def memberships(user_uri: nil, **params) - client.organizations.list_memberships user_uri: user_uri, organization_uri: uri, **params - end - - def activity_log(**params) - client.organizations.activity_log organization_uri: uri, **params - end - end -end diff --git a/lib/calendlyr/objects/organizations/invitation.rb b/lib/calendlyr/objects/organizations/invitation.rb new file mode 100644 index 0000000..d6f71f8 --- /dev/null +++ b/lib/calendlyr/objects/organizations/invitation.rb @@ -0,0 +1,15 @@ +module Calendlyr + class Organizations::Invitation < Object + def associated_organization + Organization.new({"uri" => organization}.merge(client: client)) + end + + def associated_user + client.users.retrieve(uuid: get_slug(user)) + end + + def revoke + associated_organization.revoke_invitation(invitation_uuid: uuid) + end + end +end diff --git a/lib/calendlyr/objects/organizations/membership.rb b/lib/calendlyr/objects/organizations/membership.rb new file mode 100644 index 0000000..931181e --- /dev/null +++ b/lib/calendlyr/objects/organizations/membership.rb @@ -0,0 +1,15 @@ +module Calendlyr + class Organizations::Membership < Object + def associated_organization + Organization.new({"uri" => organization}.merge(client: client)) + end + + def associated_user + client.users.retrieve(uuid: get_slug(user.uri)) + end + + def group_relationships(**params) + client.groups.list_relationships(**params.merge(owner: uri)) + end + end +end diff --git a/lib/calendlyr/objects/routing_form.rb b/lib/calendlyr/objects/routing_form.rb new file mode 100644 index 0000000..8154aa2 --- /dev/null +++ b/lib/calendlyr/objects/routing_form.rb @@ -0,0 +1,11 @@ +module Calendlyr + class RoutingForm < Object + def associated_organization + Organization.new({"uri" => organization}.merge(client: client)) + end + + def submissions(**params) + client.routing_forms.list_submissions(**params.merge(form: uri)) + end + end +end diff --git a/lib/calendlyr/objects/routing_forms/submission.rb b/lib/calendlyr/objects/routing_forms/submission.rb new file mode 100644 index 0000000..96bec11 --- /dev/null +++ b/lib/calendlyr/objects/routing_forms/submission.rb @@ -0,0 +1,7 @@ +module Calendlyr + class RoutingForms::Submission < Object + def associated_routing_form + client.routing_forms.retrieve(uuid: get_slug(routing_form)) + end + end +end diff --git a/lib/calendlyr/objects/scheduling_link.rb b/lib/calendlyr/objects/scheduling_link.rb new file mode 100644 index 0000000..a799a01 --- /dev/null +++ b/lib/calendlyr/objects/scheduling_link.rb @@ -0,0 +1,9 @@ +module Calendlyr + class SchedulingLink < Object + def event_type + return unless owner_type == "EventType" + + client.event_types.retrieve(uuid: get_slug(owner)) + end + end +end diff --git a/lib/calendlyr/objects/scheduling_links.rb b/lib/calendlyr/objects/scheduling_links.rb deleted file mode 100644 index 1915096..0000000 --- a/lib/calendlyr/objects/scheduling_links.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Calendlyr - class SchedulingLink < Object - end -end diff --git a/lib/calendlyr/objects/share.rb b/lib/calendlyr/objects/share.rb new file mode 100644 index 0000000..744c93d --- /dev/null +++ b/lib/calendlyr/objects/share.rb @@ -0,0 +1,9 @@ +module Calendlyr + class Share < Object + def associated_scheduling_links + scheduling_links.map do |scheduling_link| + SchedulingLink.new(scheduling_link.to_h.merge(client: client)) + end + end + end +end diff --git a/lib/calendlyr/objects/user.rb b/lib/calendlyr/objects/user.rb new file mode 100644 index 0000000..63781b8 --- /dev/null +++ b/lib/calendlyr/objects/user.rb @@ -0,0 +1,31 @@ +module Calendlyr + class User < Object + def organization + Organization.new({"uri" => current_organization}.merge(client: client)) + end + + def availability_schedules(**params) + client.availability.list_user_schedules(**params.merge(user: uri)) + end + + def event_types(**params) + client.event_types.list(**params.merge(user: uri)) + end + + def events(**params) + client.events.list(**params.merge(user: uri, organization: current_organization)) + end + + def membership(uuid:) + organization.membership(uuid: uuid) + end + + def memberships(**params) + organization.memberships(**params.merge(user: uri)) + end + + def busy_times(start_time:, end_time:, **params) + client.availability.list_user_busy_times(**params.merge(user: uri, start_time: start_time, end_time: end_time)) + end + end +end diff --git a/lib/calendlyr/objects/user_availability_schedule.rb b/lib/calendlyr/objects/user_availability_schedule.rb deleted file mode 100644 index aa215d4..0000000 --- a/lib/calendlyr/objects/user_availability_schedule.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Calendlyr - class UserAvailabilitySchedule < Object - def associated_user - client.users.retrieve user_uuid: get_slug(user) - end - - def availability_rules - rules.map do |rule| - AvailabilityRule.new(rule.to_h) - end - end - end -end diff --git a/lib/calendlyr/objects/user_busy_time.rb b/lib/calendlyr/objects/user_busy_time.rb deleted file mode 100644 index d200d15..0000000 --- a/lib/calendlyr/objects/user_busy_time.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Calendlyr - class UserBusyTime < Object - def associated_event - client.events.retrieve event_uuid: get_slug(event.uri) - end - end -end diff --git a/lib/calendlyr/objects/users.rb b/lib/calendlyr/objects/users.rb deleted file mode 100644 index 9c0dc45..0000000 --- a/lib/calendlyr/objects/users.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Calendlyr - class User < Object - def organization - @organization ||= Organization.new({"uri" => current_organization}.merge(client: client)) - end - - def event_types(**params) - client.event_types.list user_uri: uri, organization_uri: current_organization, **params - end - - def events(**params) - client.events.list user_uri: uri, organization_uri: current_organization, **params - end - - def memberships(organization_uri: nil, **params) - client.organizations.list_memberships user_uri: uri, organization_uri: organization_uri, **params - end - - def busy_times(start_time:, end_time:, **params) - client.user_busy_times.list(user_uri: uri, start_time: start_time, end_time: end_time, **params) - end - - def availability_schedules - client.user_availability_schedules.list(user_uri: uri) - end - end -end diff --git a/lib/calendlyr/objects/webhooks.rb b/lib/calendlyr/objects/webhooks.rb deleted file mode 100644 index 698ab20..0000000 --- a/lib/calendlyr/objects/webhooks.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Calendlyr - class Webhook < Object - def associated_user - client.users.retrieve(user_uuid: get_slug(user)) - end - - def associated_organization - @associated_organization ||= Organization.new({"uri" => organization}.merge(client: client)) - end - - def active? - state == "active" - end - - def disabled? - state == "disabled" - end - end -end diff --git a/lib/calendlyr/objects/webhooks/invitee_payload.rb b/lib/calendlyr/objects/webhooks/invitee_payload.rb new file mode 100644 index 0000000..4062dc3 --- /dev/null +++ b/lib/calendlyr/objects/webhooks/invitee_payload.rb @@ -0,0 +1,15 @@ +module Calendlyr + class Webhooks::InviteePayload < Object + def associated_event + client.events.retrieve(uuid: get_slug(event)) + end + + def associated_routing_form_submission + client.routing_forms.retrieve_submission(uuid: get_slug(routing_form_submission)) + end + + def associated_invitee_no_show + client.events.retrieve_invitee_no_show(uuid: get_slug(no_show.uri)) + end + end +end diff --git a/lib/calendlyr/objects/webhooks/payload.rb b/lib/calendlyr/objects/webhooks/payload.rb new file mode 100644 index 0000000..342ce5c --- /dev/null +++ b/lib/calendlyr/objects/webhooks/payload.rb @@ -0,0 +1,4 @@ +module Calendlyr + class Webhooks::Payload < Object + end +end diff --git a/lib/calendlyr/objects/webhooks/subscription.rb b/lib/calendlyr/objects/webhooks/subscription.rb new file mode 100644 index 0000000..607ff75 --- /dev/null +++ b/lib/calendlyr/objects/webhooks/subscription.rb @@ -0,0 +1,23 @@ +module Calendlyr + class Webhooks::Subscription < Object + def associated_organization + Organization.new({"uri" => organization}.merge(client: client)) + end + + def associated_user + client.users.retrieve(uuid: get_slug(user)) + end + + def associated_creator + client.users.retrieve(uuid: get_slug(creator)) + end + + def active? + state == "active" + end + + def disabled? + state == "disabled" + end + end +end diff --git a/lib/calendlyr/resources/availability.rb b/lib/calendlyr/resources/availability.rb new file mode 100644 index 0000000..fffbda3 --- /dev/null +++ b/lib/calendlyr/resources/availability.rb @@ -0,0 +1,19 @@ +module Calendlyr + class AvailabilityResource < Resource + # User Busy Time + def list_user_busy_times(user:, start_time:, end_time:, **params) + response = get_request("user_busy_times", params: {user: user, start_time: start_time, end_time: end_time}.merge(params).compact) + Collection.from_response(response, type: Availabilities::UserBusyTime, client: client) + end + + # User Schedule + def list_user_schedules(user:, **params) + response = get_request("user_availability_schedules", params: {user: user}.merge(params).compact) + Collection.from_response(response, type: Availabilities::UserSchedule, client: client) + end + + def retrieve_user_schedule(uuid:) + Availabilities::UserSchedule.new get_request("user_availability_schedules/#{uuid}").dig("resource").merge(client: client) + end + end +end diff --git a/lib/calendlyr/resources/event.rb b/lib/calendlyr/resources/event.rb new file mode 100644 index 0000000..1f29ff0 --- /dev/null +++ b/lib/calendlyr/resources/event.rb @@ -0,0 +1,40 @@ +module Calendlyr + class EventResource < Resource + def list(**params) + response = get_request("scheduled_events", params: params) + Collection.from_response(response, type: Event, client: client) + end + + def retrieve(uuid:) + Event.new get_request("scheduled_events/#{uuid}").dig("resource").merge(client: client) + end + + def cancel(uuid:, reason: nil) + Events::Cancellation.new post_request("scheduled_events/#{uuid}/cancellation", body: {reason: reason}).dig("resource").merge(client: client) + end + + # Invitee + def list_invitees(uuid:, **params) + response = get_request("scheduled_events/#{uuid}/invitees", params: params) + Collection.from_response(response, type: Events::Invitee, client: client) + end + + def retrieve_invitee(event_uuid:, invitee_uuid:) + Events::Invitee.new get_request("scheduled_events/#{event_uuid}/invitees/#{invitee_uuid}").dig("resource").merge(client: client) + end + + # Invitee No Show + def retrieve_invitee_no_show(uuid:) + Events::InviteeNoShow.new get_request("invitee_no_shows/#{uuid}").dig("resource").merge(client: client) + end + + def create_invitee_no_show(invitee:) + body = {invitee: invitee} + Events::InviteeNoShow.new post_request("invitee_no_shows", body: body).dig("resource").merge(client: client) + end + + def delete_invitee_no_show(uuid:) + delete_request("invitee_no_shows/#{uuid}") + end + end +end diff --git a/lib/calendlyr/resources/event_invitees.rb b/lib/calendlyr/resources/event_invitees.rb deleted file mode 100644 index d9598dd..0000000 --- a/lib/calendlyr/resources/event_invitees.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Calendlyr - class EventInviteeResource < Resource - def list(event_uuid:, **params) - response = get_request("scheduled_events/#{event_uuid}/invitees", params: params.compact) - Collection.from_response(response, type: EventInvitee, client: client) - end - - def retrieve(event_uuid:, invitee_uuid:) - EventInvitee.new get_request("scheduled_events/#{event_uuid}/invitees/#{invitee_uuid}").dig("resource").merge(client: client) - end - end -end diff --git a/lib/calendlyr/resources/event_type.rb b/lib/calendlyr/resources/event_type.rb new file mode 100644 index 0000000..4b6c2b9 --- /dev/null +++ b/lib/calendlyr/resources/event_type.rb @@ -0,0 +1,28 @@ +module Calendlyr + class EventTypeResource < Resource + def list(**params) + response = get_request("event_types", params: params) + Collection.from_response(response, type: EventType, client: client) + end + + def retrieve(uuid:) + EventType.new get_request("event_types/#{uuid}").dig("resource").merge(client: client) + end + + def create_one_off(name:, host:, duration:, date_setting:, location:, **params) + body = {name: name, host: host, duration: duration, date_setting: date_setting, location: location}.merge(params) + EventType.new post_request("one_off_event_types", body: body).dig("resource").merge(client: client) + end + + def list_memberships(event_type:, **params) + response = get_request("event_type_memberships", params: {event_type: event_type}.merge(params)) + Collection.from_response(response, type: EventTypes::Membership, client: client) + end + + # Available Times + def list_available_times(event_type:, start_time:, end_time:, **params) + response = get_request("event_type_available_times", params: {event_type: event_type, start_time: start_time, end_time: end_time}.merge(params)) + Collection.from_response(response, type: EventTypes::AvailableTime, client: client) + end + end +end diff --git a/lib/calendlyr/resources/event_types.rb b/lib/calendlyr/resources/event_types.rb deleted file mode 100644 index f59fe60..0000000 --- a/lib/calendlyr/resources/event_types.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Calendlyr - class EventTypeResource < Resource - def list(user_uri:, organization_uri:, **params) - response = get_request("event_types", params: {user: user_uri, organization: organization_uri}.merge(params)) - Collection.from_response(response, type: EventType, client: client) - end - - def retrieve(event_type_uuid:) - EventType.new get_request("event_types/#{event_type_uuid}").dig("resource").merge(client: client) - end - end -end diff --git a/lib/calendlyr/resources/events.rb b/lib/calendlyr/resources/events.rb deleted file mode 100644 index fae516a..0000000 --- a/lib/calendlyr/resources/events.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Calendlyr - class EventResource < Resource - def list(user_uri:, organization_uri:, **params) - response = get_request("scheduled_events", params: {user: user_uri, organization: organization_uri}.merge(params).compact) - Collection.from_response(response, type: Event, client: client) - end - - def retrieve(event_uuid:) - Event.new get_request("scheduled_events/#{event_uuid}").dig("resource").merge(client: client) - end - end -end diff --git a/lib/calendlyr/resources/group.rb b/lib/calendlyr/resources/group.rb new file mode 100644 index 0000000..6d71dbd --- /dev/null +++ b/lib/calendlyr/resources/group.rb @@ -0,0 +1,22 @@ +module Calendlyr + class GroupResource < Resource + def list(organization:, **params) + response = get_request("groups", params: params.merge(organization: organization)) + Collection.from_response(response, type: Group, client: client) + end + + def retrieve(uuid:) + Group.new get_request("groups/#{uuid}").dig("resource").merge(client: client) + end + + # Relationships + def list_relationships(**params) + response = get_request("group_relationships", params: params) + Collection.from_response(response, type: Groups::Relationship, client: client) + end + + def retrieve_relationship(uuid:) + Groups::Relationship.new get_request("group_relationships/#{uuid}").dig("resource").merge(client: client) + end + end +end diff --git a/lib/calendlyr/resources/organization.rb b/lib/calendlyr/resources/organization.rb new file mode 100644 index 0000000..9ba64be --- /dev/null +++ b/lib/calendlyr/resources/organization.rb @@ -0,0 +1,40 @@ +module Calendlyr + class OrganizationResource < Resource + def activity_log(organization: nil, **params) + response = get_request("activity_log_entries", params: {organization: organization}.merge(params).compact) + Collection.from_response(response, type: ActivityLog, client: client) + end + + # Memberships + def list_memberships(**params) + response = get_request("organization_memberships", params: params) + Collection.from_response(response, type: Organizations::Membership, client: client) + end + + def retrieve_membership(uuid:) + Organizations::Membership.new(get_request("organization_memberships/#{uuid}").dig("resource").merge(client: client)) + end + + def remove_user(uuid:) + delete_request("organization_memberships/#{uuid}") + end + + # Invitations + def list_invitations(uuid:, **params) + response = get_request("organizations/#{uuid}/invitations", params: params) + Collection.from_response(response, type: Organizations::Invitation, client: client) + end + + def retrieve_invitation(org_uuid:, uuid:) + Organizations::Invitation.new get_request("organizations/#{org_uuid}/invitations/#{uuid}").dig("resource").merge(client: client) + end + + def invite(organization_uuid:, email:) + Organizations::Invitation.new post_request("organizations/#{organization_uuid}/invitations", body: {email: email}).dig("resource").merge(client: client) + end + + def revoke_invitation(org_uuid:, uuid:) + delete_request("organizations/#{org_uuid}/invitations/#{uuid}") + end + end +end diff --git a/lib/calendlyr/resources/organizations.rb b/lib/calendlyr/resources/organizations.rb deleted file mode 100644 index ba030f6..0000000 --- a/lib/calendlyr/resources/organizations.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Calendlyr - class OrganizationResource < Resource - def invite(organization_uuid:, email:) - Invitation.new post_request("organizations/#{organization_uuid}/invitations", body: {email: email}).dig("resource").merge(client: client) - end - - def list_invitations(organization_uuid:, **params) - response = get_request("organizations/#{organization_uuid}/invitations", params: params) - Collection.from_response(response, type: Invitation, client: client) - end - - def list_memberships(user_uri: nil, organization_uri: nil, **params) - response = get_request("organization_memberships", params: {user: user_uri, organization: organization_uri}.merge(params).compact) - Collection.from_response(response, type: Membership, client: client) - end - - def activity_log(organization_uri: nil, **params) - response = get_request("activity_log_entries", params: {organization: organization_uri}.merge(params).compact) - Collection.from_response(response, type: ActivityLog, client: client) - end - - def retrieve_invitation(organization_uuid:, invitation_uuid:) - Invitation.new get_request("organizations/#{organization_uuid}/invitations/#{invitation_uuid}").dig("resource").merge(client: client) - end - - def retrieve_membership(membership_uuid:) - Membership.new get_request("organization_memberships/#{membership_uuid}").dig("resource").merge(client: client) - end - - def revoke_invitation(organization_uuid:, invitation_uuid:) - delete_request("organizations/#{organization_uuid}/invitations/#{invitation_uuid}") - end - - def remove_user(membership_uuid:) - delete_request("organization_memberships/#{membership_uuid}") - end - end -end diff --git a/lib/calendlyr/resources/outgoing_communication.rb b/lib/calendlyr/resources/outgoing_communication.rb new file mode 100644 index 0000000..279f16f --- /dev/null +++ b/lib/calendlyr/resources/outgoing_communication.rb @@ -0,0 +1,8 @@ +module Calendlyr + class OutgoingCommunicationResource < Resource + def list(**params) + response = get_request("outgoing_communications", params: params) + Collection.from_response(response, type: Object, client: client) + end + end +end diff --git a/lib/calendlyr/resources/routing_form.rb b/lib/calendlyr/resources/routing_form.rb new file mode 100644 index 0000000..57c3a42 --- /dev/null +++ b/lib/calendlyr/resources/routing_form.rb @@ -0,0 +1,22 @@ +module Calendlyr + class RoutingFormResource < Resource + def list(organization:, **params) + response = get_request("routing_forms", params: {organization: organization}.merge(params)) + Collection.from_response(response, type: RoutingForm, client: client) + end + + def retrieve(uuid:) + RoutingForm.new(get_request("routing_forms/#{uuid}").dig("resource").merge(client: client)) + end + + # Routing Form Submission + def list_submissions(form:, **params) + response = get_request("routing_form_submissions", params: {form: form}.merge(params)) + Collection.from_response(response, type: RoutingForms::Submission, client: client) + end + + def retrieve_submission(uuid:) + RoutingForms::Submission.new get_request("routing_form_submissions/#{uuid}").dig("resource").merge(client: client) + end + end +end diff --git a/lib/calendlyr/resources/scheduling_links.rb b/lib/calendlyr/resources/scheduling_link.rb similarity index 53% rename from lib/calendlyr/resources/scheduling_links.rb rename to lib/calendlyr/resources/scheduling_link.rb index 6a4a67d..716762e 100644 --- a/lib/calendlyr/resources/scheduling_links.rb +++ b/lib/calendlyr/resources/scheduling_link.rb @@ -1,7 +1,7 @@ module Calendlyr class SchedulingLinkResource < Resource - def create(owner_uri:, max_event_count:, owner_type: "EventType") - body = {owner: owner_uri, max_event_count: max_event_count, owner_type: owner_type} + def create(owner:, max_event_count:, owner_type: "EventType") + body = {owner: owner, max_event_count: max_event_count, owner_type: owner_type} SchedulingLink.new post_request("scheduling_links", body: body).dig("resource").merge(client: client) end end diff --git a/lib/calendlyr/resources/share.rb b/lib/calendlyr/resources/share.rb new file mode 100644 index 0000000..0c45812 --- /dev/null +++ b/lib/calendlyr/resources/share.rb @@ -0,0 +1,8 @@ +module Calendlyr + class ShareResource < Resource + def create(event_type:, **params) + body = {event_type: event_type}.merge(params) + Share.new post_request("shares", body: body).dig("resource").merge(client: client) + end + end +end diff --git a/lib/calendlyr/resources/user.rb b/lib/calendlyr/resources/user.rb new file mode 100644 index 0000000..75ebf60 --- /dev/null +++ b/lib/calendlyr/resources/user.rb @@ -0,0 +1,11 @@ +module Calendlyr + class UserResource < Resource + def me + retrieve(uuid: "me") + end + + def retrieve(uuid:) + User.new get_request("users/#{uuid}").dig("resource").merge(client: client) + end + end +end diff --git a/lib/calendlyr/resources/user_availability_schedules.rb b/lib/calendlyr/resources/user_availability_schedules.rb deleted file mode 100644 index 3497682..0000000 --- a/lib/calendlyr/resources/user_availability_schedules.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Calendlyr - class UserAvailabilityScheduleResource < Resource - def list(user_uri:, **params) - response = get_request("user_availability_schedules", params: {user: user_uri}.merge(params).compact) - Collection.from_response(response, type: UserAvailabilitySchedule, client: client) - end - - def retrieve(uuid:) - UserAvailabilitySchedule.new get_request("user_availability_schedules/#{uuid}").dig("resource").merge(client: client) - end - end -end diff --git a/lib/calendlyr/resources/user_busy_times.rb b/lib/calendlyr/resources/user_busy_times.rb deleted file mode 100644 index 2fe9b56..0000000 --- a/lib/calendlyr/resources/user_busy_times.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Calendlyr - class UserBusyTimeResource < Resource - def list(user_uri:, start_time:, end_time:, **params) - response = get_request("user_busy_times", params: {user: user_uri, start_time: start_time, end_time: end_time}.merge(params).compact) - Collection.from_response(response, type: UserBusyTime, client: client) - end - end -end diff --git a/lib/calendlyr/resources/users.rb b/lib/calendlyr/resources/users.rb deleted file mode 100644 index 9b57255..0000000 --- a/lib/calendlyr/resources/users.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Calendlyr - class UserResource < Resource - def me - retrieve(user_uuid: "me") - end - - def retrieve(user_uuid:) - User.new get_request("users/#{user_uuid}").dig("resource").merge(client: client) - end - end -end diff --git a/lib/calendlyr/resources/webhook.rb b/lib/calendlyr/resources/webhook.rb new file mode 100644 index 0000000..115802e --- /dev/null +++ b/lib/calendlyr/resources/webhook.rb @@ -0,0 +1,25 @@ +module Calendlyr + class WebhookResource < Resource + def list(organization:, scope:, **params) + response = get_request("webhook_subscriptions", params: params.merge(organization: organization, scope: scope).compact) + Collection.from_response(response, type: Webhooks::Subscription, client: client) + end + + def create(url:, events:, organization:, scope:, **params) + body = params.merge(url: url, events: events, organization: organization, scope: scope) + Webhooks::Subscription.new post_request("webhook_subscriptions", body: body).dig("resource").merge(client: client) + end + + def retrieve(webhook_uuid:) + Webhooks::Subscription.new get_request("webhook_subscriptions/#{webhook_uuid}").dig("resource").merge(client: client) + end + + def delete(webhook_uuid:) + delete_request("webhook_subscriptions/#{webhook_uuid}") + end + + def sample_webhook_data(event:, organization:, scope:, **params) + Object.new get_request("sample_webhook_data", params: params.merge(event: event, organization: organization, scope: scope)).merge(client: client) + end + end +end diff --git a/lib/calendlyr/resources/webhooks.rb b/lib/calendlyr/resources/webhooks.rb deleted file mode 100644 index 035e5d8..0000000 --- a/lib/calendlyr/resources/webhooks.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Calendlyr - class WebhookResource < Resource - def list(organization_uri:, scope:, **params) - response = get_request("webhook_subscriptions", params: {organization: organization_uri, scope: scope}.merge(params).compact) - Collection.from_response(response, type: Webhook, client: client) - end - - def create(url:, events:, organization_uri:, scope:, signing_key: nil, user_uri: nil) - body = {url: url, events: events, organization: organization_uri, user: user_uri, scope: scope, signing_key: signing_key}.compact - Webhook.new post_request("webhook_subscriptions", body: body).dig("resource").merge(client: client) - end - - def retrieve(webhook_uuid:) - Webhook.new get_request("webhook_subscriptions/#{webhook_uuid}").dig("resource").merge(client: client) - end - - def delete(webhook_uuid:) - delete_request("webhook_subscriptions/#{webhook_uuid}") - end - end -end diff --git a/test/calendlyr/objects/activity_log_test.rb b/test/calendlyr/objects/activity_log_test.rb new file mode 100644 index 0000000..5ce7a07 --- /dev/null +++ b/test/calendlyr/objects/activity_log_test.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "test_helper" + +class ActivityLogObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/activity_log")).merge(client: client) + @activity_log = Calendlyr::ActivityLog.new(json) + + user_uuid = "SDLKJENFJKD123" + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{user_uuid}", response: response) + end + + def test_associated_organization + organization = @activity_log.associated_organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_associated_actor + user = @activity_log.associated_actor + + assert_equal "John Doe", user.name + end +end diff --git a/test/calendlyr/objects/availabilities/rule_test.rb b/test/calendlyr/objects/availabilities/rule_test.rb new file mode 100644 index 0000000..c5494a9 --- /dev/null +++ b/test/calendlyr/objects/availabilities/rule_test.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require "test_helper" + +module Availabilities + class RuleObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/availabilities/rule")).merge(client: client) + @rule = Calendlyr::Availabilities::Rule.new(json) + end + + def test_type + assert_equal "wday", @rule.type + end + + def test_intervals + assert_equal 1, @rule.intervals.size + end + + def test_wday + assert_equal "sunday", @rule.wday + end + end +end diff --git a/test/calendlyr/objects/availabilities/user_busy_time_test.rb b/test/calendlyr/objects/availabilities/user_busy_time_test.rb new file mode 100644 index 0000000..b2c98a5 --- /dev/null +++ b/test/calendlyr/objects/availabilities/user_busy_time_test.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require "test_helper" +module Availabilities + class UserBusyTimeObjectTest < Minitest::Test + def setup + response = {body: fixture_file("events/retrieve"), status: 200} + stub(path: "scheduled_events/abc123", response: response) + json = JSON.parse(fixture_file("objects/availabilities/user_busy_time")).merge(client: client) + @user_busy_time = Calendlyr::Availabilities::UserBusyTime.new(json) + end + + def test_associated_event + assert_equal Calendlyr::Event, @user_busy_time.associated_event.class + end + + def test_type + assert_equal "calendly", @user_busy_time.type + end + end +end diff --git a/test/calendlyr/objects/availabilities/user_schedule_test.rb b/test/calendlyr/objects/availabilities/user_schedule_test.rb new file mode 100644 index 0000000..55ba052 --- /dev/null +++ b/test/calendlyr/objects/availabilities/user_schedule_test.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "test_helper" + +module Availabilities + class UserScheduleObjectTest < Minitest::Test + def setup + stub(path: "users/abc123", response: {body: fixture_file("users/retrieve"), status: 200}) + json = JSON.parse(fixture_file("objects/availabilities/user_schedule")).merge(client: client) + @user_availability_schedule = Calendlyr::Availabilities::UserSchedule.new(json) + end + + def test_associated_user + assert_equal Calendlyr::User, @user_availability_schedule.associated_user.class + end + + def test_availability_schedule + assert_equal "America\\/New_York", @user_availability_schedule.timezone + end + + def test_availability_rules + assert_equal 7, @user_availability_schedule.availability_rules.count + assert_equal Calendlyr::Availabilities::Rule, @user_availability_schedule.availability_rules.first.class + end + end +end diff --git a/test/calendlyr/objects/availability_rule_test.rb b/test/calendlyr/objects/availability_rule_test.rb deleted file mode 100644 index b755f32..0000000 --- a/test/calendlyr/objects/availability_rule_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class AvailabilityRuleObjectTest < Minitest::Test - def test_associated_user - json = JSON.parse(fixture_file("objects/availability_rule")).merge(client: client) - availability_rule = Calendlyr::UserAvailabilitySchedule.new(json) - - assert_equal "wday", availability_rule.type - assert_equal "sunday", availability_rule.wday - assert_equal 1, availability_rule.intervals.count - end -end diff --git a/test/calendlyr/objects/event_test.rb b/test/calendlyr/objects/event_test.rb new file mode 100644 index 0000000..fb56c00 --- /dev/null +++ b/test/calendlyr/objects/event_test.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require "test_helper" + +class EventObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/event")).merge(client: client) + @event = Calendlyr::Event.new(json) + + user_uuid = "GBGBDCAADAEDCRZ2" + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{user_uuid}", response: response) + end + + def test_memberships + memberships = @event.memberships + + assert_equal 1, memberships.count + assert_equal "John Doe", memberships.first.name + assert_instance_of Calendlyr::User, memberships.first + end + + def test_cancel + response = {body: fixture_file("events/cancel_invitee"), status: 201} + stub(method: :post, path: "scheduled_events/#{@event.uuid}/cancellation", response: response) + + cancellation = @event.cancel(reason: "I'm busy") + + assert_instance_of Calendlyr::Events::Cancellation, cancellation + assert_equal "string", cancellation.reason + end +end diff --git a/test/calendlyr/objects/event_type_test.rb b/test/calendlyr/objects/event_type_test.rb new file mode 100644 index 0000000..906dce4 --- /dev/null +++ b/test/calendlyr/objects/event_type_test.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require "test_helper" + +class EventTypeObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/event_type")).merge(client: client) + @event_type = Calendlyr::EventType.new(json) + + event_type_uri = "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA" + @start_time = "2020-01-02T20:00:00.000000Z" + @end_time = "2020-01-07T24:00:00.000000Z" + + response = {body: fixture_file("event_type_available_times/list"), status: 200} + stub(path: "event_type_available_times?event_type=#{event_type_uri}&start_time=#{@start_time}&end_time=#{@end_time}", response: response) + + event_type_uri = "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA" + response = {body: fixture_file("shares/create"), status: 201} + stub(method: :post, path: "shares", body: {event_type: event_type_uri}, response: response) + end + + def test_associated_profile + profile = @event_type.associated_profile + + assert_equal Calendlyr::EventTypes::Profile, profile.class + assert_equal "Tamara Jones", profile.name + end + + def test_create_share + share = @event_type.create_share + + assert_instance_of Calendlyr::Share, share + assert_equal 1, share.scheduling_links.size + end + + def test_available_times + available_times = @event_type.available_times(start_time: @start_time, end_time: @end_time) + + assert 3, available_times.data.size + assert "available", available_times.data.first.status + assert_instance_of Calendlyr::EventTypes::AvailableTime, available_times.data.first + end +end diff --git a/test/calendlyr/objects/event_types/available_time_test.rb b/test/calendlyr/objects/event_types/available_time_test.rb new file mode 100644 index 0000000..d340c00 --- /dev/null +++ b/test/calendlyr/objects/event_types/available_time_test.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "test_helper" + +module EventTypes + class AvailableTimeObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/event_types/available_time")).merge(client: client) + @available_time = Calendlyr::EventTypes::AvailableTime.new(json) + end + + def test_status + assert_equal "available", @available_time.status + end + + def test_invitees_remaining + assert_equal 2, @available_time.invitees_remaining + end + end +end diff --git a/test/calendlyr/objects/event_types/membership_test.rb b/test/calendlyr/objects/event_types/membership_test.rb new file mode 100644 index 0000000..b4d7e4e --- /dev/null +++ b/test/calendlyr/objects/event_types/membership_test.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require "test_helper" + +module EventTypes + class MembershipObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/event_types/membership")).merge(client: client) + @membership = Calendlyr::EventTypes::Membership.new(json) + + event_type_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("event_types/retrieve"), status: 200} + stub(path: "event_types/#{event_type_uuid}", response: response) + + user_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{user_uuid}", response: response) + end + + def test_associated_event_type + event_type = @membership.associated_event_type + + assert_equal "15 Minute Meeting", event_type.name + end + + def test_associated_member + member = @membership.associated_member + + assert_equal "John Doe", member.name + end + end +end diff --git a/test/calendlyr/objects/event_types/profile_test.rb b/test/calendlyr/objects/event_types/profile_test.rb new file mode 100644 index 0000000..5ec2c13 --- /dev/null +++ b/test/calendlyr/objects/event_types/profile_test.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "test_helper" + +module EventTypes + class ProfileObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/event_types/profile")).merge(client: client) + @profile = Calendlyr::EventTypes::Profile.new(json) + + owner_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{owner_uuid}", response: response) + end + + def test_associated_owner + owner = @profile.associated_owner + + assert_equal "John Doe", owner.name + assert_equal Calendlyr::User, owner.class + end + end +end diff --git a/test/calendlyr/objects/events/cancellation_test.rb b/test/calendlyr/objects/events/cancellation_test.rb new file mode 100644 index 0000000..6d47bb4 --- /dev/null +++ b/test/calendlyr/objects/events/cancellation_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "test_helper" + +module Events + class CancellationObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/events/cancellation")).merge(client: client) + @cancellation = Calendlyr::Events::Cancellation.new(json) + end + + def test_canceled_by + assert "string", @cancellation.canceled_by + end + end +end diff --git a/test/calendlyr/objects/events/guest_test.rb b/test/calendlyr/objects/events/guest_test.rb new file mode 100644 index 0000000..a94bc44 --- /dev/null +++ b/test/calendlyr/objects/events/guest_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "test_helper" + +module Events + class GuestObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/events/guest")).merge(client: client) + @guest = Calendlyr::Events::Guest.new(json) + end + + def test_email + assert "user@example.com", @guest.email + end + end +end diff --git a/test/calendlyr/objects/events/invitee_no_show_test.rb b/test/calendlyr/objects/events/invitee_no_show_test.rb new file mode 100644 index 0000000..3379599 --- /dev/null +++ b/test/calendlyr/objects/events/invitee_no_show_test.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "test_helper" + +module Events + class InviteeNoShowObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/events/invitee_no_show")).merge(client: client) + @invitee_no_show = Calendlyr::Events::InviteeNoShow.new(json) + end + + def test_created_at + assert "2019-01-02T03:04:05.678123Z", @invitee_no_show.created_at + end + + def test_delete + response = {body: fixture_file("events/delete_invitee_no_show"), status: 204} + stub(method: :delete, path: "invitee_no_shows/#{@invitee_no_show.uuid}", response: response) + + assert @invitee_no_show.delete + end + end +end diff --git a/test/calendlyr/objects/events/invitee_test.rb b/test/calendlyr/objects/events/invitee_test.rb new file mode 100644 index 0000000..c349808 --- /dev/null +++ b/test/calendlyr/objects/events/invitee_test.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require "test_helper" + +module Events + class InviteeObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/events/invitee")).merge(client: client) + @invitee = Calendlyr::Events::Invitee.new(json) + end + + def test_email + assert "user@example.com", @invitee.email + end + + def test_cancel + response = {body: fixture_file("events/cancel_invitee"), status: 201} + stub(method: :post, path: "scheduled_events/#{@invitee.uuid}/cancellation", response: response) + + cancellation = @invitee.cancel(reason: "I'm busy") + + assert_instance_of Calendlyr::Events::Cancellation, cancellation + assert_equal "host", cancellation.canceler_type + end + + def test_create_no_shows + response = {body: fixture_file("events/create_invitee_no_show"), status: 201} + stub(method: :post, path: "invitee_no_shows", body: {invitee: @invitee.uri}, response: response) + + no_show = @invitee.create_no_shows + + assert_instance_of Calendlyr::Events::InviteeNoShow, no_show + end + end +end diff --git a/test/calendlyr/objects/group_test.rb b/test/calendlyr/objects/group_test.rb new file mode 100644 index 0000000..49bf542 --- /dev/null +++ b/test/calendlyr/objects/group_test.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require "test_helper" + +class GroupObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/group")).merge(client: client) + @group = Calendlyr::Group.new(json) + + @start_time = "2020-01-02T20:00:00.000000Z" + @end_time = "2020-01-07T24:00:00.000000Z" + + group_uri = "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA" + response = {body: fixture_file("events/list"), status: 200} + stub(path: "scheduled_events?group=#{group_uri}", response: response) + + response = {body: fixture_file("group_relationships/list"), status: 200} + stub(path: "group_relationships?group=#{group_uri}", response: response) + end + + def test_associated_organization + organization = @group.associated_organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_events + events = @group.events + + assert_equal 1, events.data.size + assert_equal Calendlyr::Event, events.data.first.class + end + + def test_group_relationships + group_relationships = @group.group_relationships + + assert_equal 3, group_relationships.data.size + assert_equal Calendlyr::Groups::Relationship, group_relationships.data.first.class + end +end diff --git a/test/calendlyr/objects/groups/relationship_test.rb b/test/calendlyr/objects/groups/relationship_test.rb new file mode 100644 index 0000000..a03fd31 --- /dev/null +++ b/test/calendlyr/objects/groups/relationship_test.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require "test_helper" + +module Groups + class RelationshipObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/groups/relationship")).merge(client: client) + @relationship = Calendlyr::Groups::Relationship.new(json) + + group_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("groups/retrieve"), status: 200} + stub(path: "groups/#{group_uuid}", response: response) + end + + def test_associated_organization + organization = @relationship.associated_organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_associated_group + group = @relationship.associated_group + + assert_equal "Sales Team", group.name + end + + def test_associated_owner + organization_membership_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("organization_memberships/retrieve"), status: 200} + stub(path: "organization_memberships/#{organization_membership_uuid}", response: response) + + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/AAAAAAAAAAAAAAAA", response: response) + + owner = @relationship.associated_owner + + assert_equal Calendlyr::Organizations::Membership, owner.class + assert_equal Calendlyr::User, owner.associated_user.class + assert_equal "John Doe", owner.associated_user.name + end + end +end diff --git a/test/calendlyr/objects/organization_test.rb b/test/calendlyr/objects/organization_test.rb new file mode 100644 index 0000000..cd2af4c --- /dev/null +++ b/test/calendlyr/objects/organization_test.rb @@ -0,0 +1,157 @@ +# frozen_string_literal: true + +require "test_helper" + +class OrganizatonObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/organization")).merge(client: client) + @organization = Calendlyr::Organization.new(json) + + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/AAAAAAAAAAAAAAAA", response: response) + end + + def test_activity_logs + response = {body: fixture_file("activity_log/list"), status: 200} + stub(path: "activity_log_entries?organization=#{@organization.uri}", response: response) + + activity_logs = @organization.activity_logs + + assert_equal 1, activity_logs.data.size + assert_instance_of Calendlyr::ActivityLog, activity_logs.data.first + end + + def test_events + response = {body: fixture_file("events/list"), status: 200} + stub(path: "scheduled_events?organization=#{@organization.uri}", response: response) + + events = @organization.events + + assert_equal 1, events.data.size + assert_instance_of Calendlyr::Event, events.data.first + end + + def test_event_types + response = {body: fixture_file("event_types/list"), status: 200} + stub(path: "event_types?organization=#{@organization.uri}", response: response) + + event_types = @organization.event_types + + assert_equal 1, event_types.data.size + assert_instance_of Calendlyr::EventType, event_types.data.first + end + + def test_routing_forms + response = {body: fixture_file("routing_forms/list"), status: 200} + stub(path: "routing_forms?organization=#{@organization.uri}", response: response) + + routing_forms = @organization.routing_forms + + assert_equal 1, routing_forms.data.size + assert_instance_of Calendlyr::RoutingForm, routing_forms.data.first + end + + def test_groups + response = {body: fixture_file("groups/list"), status: 200} + stub(path: "groups?organization=#{@organization.uri}", response: response) + + groups = @organization.groups + + assert_equal 1, groups.data.size + assert_instance_of Calendlyr::Group, groups.data.first + end + + def test_group_relationships + response = {body: fixture_file("group_relationships/list"), status: 200} + stub(path: "group_relationships?organization=#{@organization.uri}", response: response) + + group_relationships = @organization.group_relationships + + assert_equal 3, group_relationships.data.size + assert_instance_of Calendlyr::Groups::Relationship, group_relationships.data.first + end + + def test_memberships + response = {body: fixture_file("organization_memberships/list"), status: 200} + stub(path: "organization_memberships?organization=#{@organization.uri}", response: response) + + memberships = @organization.memberships + + assert_equal 1, memberships.data.size + assert_instance_of Calendlyr::Organizations::Membership, memberships.data.first + end + + def test_membership + response = {body: fixture_file("organization_memberships/retrieve"), status: 200} + stub(path: "organization_memberships/AAAAAAAAAAAAAAAA", response: response) + + membership = @organization.membership(uuid: "AAAAAAAAAAAAAAAA") + + assert_instance_of Calendlyr::User, membership.associated_user + assert_instance_of Calendlyr::Organizations::Membership, membership + end + + def test_webhooks + scope = "user" + response = {body: fixture_file("webhooks/list"), status: 200} + stub(path: "webhook_subscriptions?organization=#{@organization.uri}&scope=#{scope}", response: response) + webhooks = @organization.webhooks(scope: scope) + + assert_instance_of Calendlyr::Collection, webhooks + assert_instance_of Calendlyr::Webhooks::Subscription, webhooks.data.first + assert_equal 1, webhooks.data.count + assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", webhooks.next_page_token + end + + def test_create_webhook + user_uri = "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" + body = {url: "https://blah.foo/bar", events: ["invitee.created"], scope: "user", user: user_uri} + stub(method: :post, path: "webhook_subscriptions", body: body.merge(organization: @organization.uri), response: {body: fixture_file("webhooks/create"), status: 201}) + + assert @organization.create_webhook(**body) + end + + def test_sample_webhook_data + 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}) + webhook_data = @organization.sample_webhook_data(event: "invitee.created", scope: "organization") + + assert_instance_of Calendlyr::Object, webhook_data + assert_equal "invitee.created", webhook_data.event + end + + def test_invite_user + email = "email@example.com" + response = {body: fixture_file("organizations/invite"), status: 201} + stub(method: :post, path: "organizations/#{@organization.uuid}/invitations", body: {email: email}, response: response) + invitation = @organization.invite_user(email: email) + + assert_instance_of Calendlyr::Organizations::Invitation, invitation + assert_equal email, invitation.email + end + + def test_invitations + response = {body: fixture_file("organizations/list_invitations"), status: 200} + stub(path: "organizations/#{@organization.uuid}/invitations", response: response) + invitations = @organization.invitations + + assert_instance_of Calendlyr::Collection, invitations + assert_instance_of Calendlyr::Organizations::Invitation, invitations.data.first + assert_equal 1, invitations.count + assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", invitations.next_page_token + end + + def test_organization_invitation + response = {body: fixture_file("organizations/retrieve_invitation"), status: 200} + stub(path: "organizations/#{@organization.uuid}/invitations/abc123", response: response) + invitation = @organization.invitation(invitation_uuid: "abc123") + + assert_instance_of Calendlyr::Organizations::Invitation, invitation + assert_equal "test@example.com", invitation.email + end + + def test_revoke_invitation + response = {body: fixture_file("organizations/revoke_invitation"), status: 200} + stub(method: :delete, path: "organizations/#{@organization.uuid}/invitations/abc123", response: response) + assert @organization.revoke_invitation(invitation_uuid: "abc123") + end +end diff --git a/test/calendlyr/objects/organizations/invitation_test.rb b/test/calendlyr/objects/organizations/invitation_test.rb new file mode 100644 index 0000000..e84c31e --- /dev/null +++ b/test/calendlyr/objects/organizations/invitation_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require "test_helper" + +module Organizations + class InvitationObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/organizations/invitation")).merge(client: client) + @invitation = Calendlyr::Organizations::Invitation.new(json) + + response = {body: fixture_file("organizations/revoke_invitation"), status: 204} + stub(method: :delete, path: "organizations/#{@invitation.associated_organization.uuid}/invitations/#{@invitation.uuid}", response: response) + + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{Calendlyr::Object.get_slug(@invitation.user)}", response: response) + end + + def test_associated_organization + organization = @invitation.associated_organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_associated_user + user = @invitation.associated_user + + assert_equal "John Doe", user.name + end + + def test_revoke + assert @invitation.revoke + end + end +end diff --git a/test/calendlyr/objects/organizations/membership_test.rb b/test/calendlyr/objects/organizations/membership_test.rb new file mode 100644 index 0000000..6c54e96 --- /dev/null +++ b/test/calendlyr/objects/organizations/membership_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require "test_helper" + +module Organizations + class MembershipObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/organizations/membership")).merge(client: client) + @membership = Calendlyr::Organizations::Membership.new(json) + + owner_uri = "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA" + response = {body: fixture_file("group_relationships/list"), status: 200} + stub(path: "group_relationships?owner=#{owner_uri}", response: response) + + user_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{user_uuid}", response: response) + end + + def test_associated_organization + organization = @membership.associated_organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_associated_user + user = @membership.associated_user + + assert_equal "John Doe", user.name + end + + def test_group_relationships + group_relationships = @membership.group_relationships + + assert_equal Calendlyr::Groups::Relationship, group_relationships.data.first.class + end + end +end diff --git a/test/calendlyr/objects/routing_form_test.rb b/test/calendlyr/objects/routing_form_test.rb new file mode 100644 index 0000000..cb43bb8 --- /dev/null +++ b/test/calendlyr/objects/routing_form_test.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "test_helper" + +class RoutingFormObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/routing_form")).merge(client: client) + @routing_form = Calendlyr::RoutingForm.new(json) + end + + def test_associated_organization + organization = @routing_form.associated_organization + + assert_instance_of Calendlyr::Organization, organization + end + + def test_submissions + response = {body: fixture_file("routing_forms/list_routing_form_submission"), status: 200} + stub(path: "routing_form_submissions?form=#{@routing_form.uri}", response: response) + + submissions = @routing_form.submissions + + assert_equal 1, submissions.data.size + assert_instance_of Calendlyr::RoutingForms::Submission, submissions.data.first + end +end diff --git a/test/calendlyr/objects/routing_forms/submission_test.rb b/test/calendlyr/objects/routing_forms/submission_test.rb new file mode 100644 index 0000000..c1c50b7 --- /dev/null +++ b/test/calendlyr/objects/routing_forms/submission_test.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "test_helper" + +module RoutingForms + class SubmissionObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/routing_forms/submission")).merge(client: client) + @submission = Calendlyr::RoutingForms::Submission.new(json) + end + + def test_associated_routing_form + uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("routing_forms/retrieve"), status: 200} + stub(path: "routing_forms/#{uuid}", response: response) + + routing_form = @submission.associated_routing_form + + assert_equal Calendlyr::RoutingForm, routing_form.class + end + end +end diff --git a/test/calendlyr/objects/scheduling_link_test.rb b/test/calendlyr/objects/scheduling_link_test.rb new file mode 100644 index 0000000..d9594ea --- /dev/null +++ b/test/calendlyr/objects/scheduling_link_test.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require "test_helper" + +class ScheduleLinkObjectTest < Minitest::Test + def test_event_type + json = JSON.parse(fixture_file("objects/scheduling_links/event_type")).merge(client: client) + @scheduling_link = Calendlyr::SchedulingLink.new(json) + + response = {body: fixture_file("event_types/retrieve"), status: 200} + stub(path: "event_types/GBGBDCAADAEDCRZ2", response: response) + + event_type = @scheduling_link.event_type + + assert_equal Calendlyr::EventType, event_type.class + end +end diff --git a/test/calendlyr/objects/share_test.rb b/test/calendlyr/objects/share_test.rb new file mode 100644 index 0000000..a7859d7 --- /dev/null +++ b/test/calendlyr/objects/share_test.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "test_helper" + +class ShareObjectTest < Minitest::Test + def test_associated_scheduling_links + json = JSON.parse(fixture_file("objects/share")).merge(client: client) + @share = Calendlyr::Share.new(json) + + response = {body: fixture_file("event_types/retrieve"), status: 200} + stub(path: "event_types/AAAAAAAAAAAAAAAA", response: response) + + scheculing_links = @share.associated_scheduling_links + + assert_equal 1, scheculing_links.size + assert_equal Calendlyr::SchedulingLink, scheculing_links.first.class + assert_equal Calendlyr::EventType, scheculing_links.first.event_type.class + end +end diff --git a/test/calendlyr/objects/user_availability_schedule_test.rb b/test/calendlyr/objects/user_availability_schedule_test.rb deleted file mode 100644 index 5fe2033..0000000 --- a/test/calendlyr/objects/user_availability_schedule_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class UserAvailabilityObjectTest < Minitest::Test - def setup - stub(path: "users/abc123", response: {body: fixture_file("users/retrieve"), status: 200}) - json = JSON.parse(fixture_file("objects/user_availability_schedule")).merge(client: client) - @user_availability_schedule = Calendlyr::UserAvailabilitySchedule.new(json) - end - - def test_associated_user - assert_equal Calendlyr::User, @user_availability_schedule.associated_user.class - end - - def test_availability_schedule - assert_equal "America\\/New_York", @user_availability_schedule.timezone - end - - def test_availability_rules - assert_equal 7, @user_availability_schedule.availability_rules.count - assert_equal Calendlyr::AvailabilityRule, @user_availability_schedule.availability_rules.first.class - end -end diff --git a/test/calendlyr/objects/user_busy_time_test.rb b/test/calendlyr/objects/user_busy_time_test.rb deleted file mode 100644 index d2e7e99..0000000 --- a/test/calendlyr/objects/user_busy_time_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class UserBusyTimeObjectTest < Minitest::Test - def setup - response = {body: fixture_file("events/retrieve"), status: 200} - stub(path: "scheduled_events/abc123", response: response) - json = JSON.parse(fixture_file("objects/user_busy_time")).merge(client: client) - @user_busy_time = Calendlyr::UserBusyTime.new(json) - end - - def test_associated_user - assert_equal Calendlyr::Event, @user_busy_time.associated_event.class - end - - def test_type - assert_equal "calendly", @user_busy_time.type - end -end diff --git a/test/calendlyr/objects/user_test.rb b/test/calendlyr/objects/user_test.rb new file mode 100644 index 0000000..262c5ed --- /dev/null +++ b/test/calendlyr/objects/user_test.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +require "test_helper" + +class UserObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/user")).merge(client: client) + @user = Calendlyr::User.new(json) + + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{@user.uuid}", response: response) + end + + def test_organization + organization = @user.organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_availability_schedules + response = {body: fixture_file("availabilities/user_schedules_list"), status: 200} + stub(path: "user_availability_schedules?user=#{@user.uri}", response: response) + + availability_schedules = @user.availability_schedules + + assert_equal 2, availability_schedules.data.size + assert_equal Calendlyr::Availabilities::UserSchedule, availability_schedules.data.first.class + end + + def test_event_types + response = {body: fixture_file("event_types/list"), status: 200} + stub(path: "event_types?user=#{@user.uri}", response: response) + + event_types = @user.event_types + + assert_equal 1, event_types.data.size + assert_equal Calendlyr::EventType, event_types.data.first.class + end + + def test_events + response = {body: fixture_file("events/list"), status: 200} + stub(path: "scheduled_events?user=#{@user.uri}&organization=#{@user.current_organization}", response: response) + + events = @user.events + + assert_equal 1, events.data.size + assert_equal Calendlyr::Event, events.data.first.class + end + + def test_memberships + response = {body: fixture_file("organization_memberships/list"), status: 200} + stub(path: "organization_memberships?user=#{@user.uri}&organization=#{@user.organization.uri}", response: response) + + memberships = @user.memberships + + assert_equal 1, memberships.data.size + assert_equal Calendlyr::Organizations::Membership, memberships.data.first.class + end + + def test_membership + response = {body: fixture_file("organization_memberships/retrieve"), status: 200} + stub(path: "organization_memberships/AAAAAAAAAAAAAAAA", response: response) + + membership = @user.membership(uuid: "AAAAAAAAAAAAAAAA") + + assert_equal Calendlyr::User, membership.associated_user.class + assert_equal Calendlyr::Organizations::Membership, membership.class + end + + def test_busy_times + start_time = "2020-01-02T20:00:00.000000Z" + end_time = "2020-01-07T24:00:00.000000Z" + response = {body: fixture_file("availabilities/user_busy_times_list"), status: 200} + stub(path: "user_busy_times?user=#{@user.uri}&start_time=#{start_time}&end_time=#{end_time}", response: response) + + busy_times = @user.busy_times(start_time: start_time, end_time: end_time) + + assert_equal 5, busy_times.data.size + assert_equal Calendlyr::Availabilities::UserBusyTime, busy_times.data.first.class + end +end diff --git a/test/calendlyr/objects/webhooks/invite_payload_test.rb b/test/calendlyr/objects/webhooks/invite_payload_test.rb new file mode 100644 index 0000000..4f6ca49 --- /dev/null +++ b/test/calendlyr/objects/webhooks/invite_payload_test.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "test_helper" + +module Webhooks + class InviteePayloadObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/webhooks/invite_payload")).merge(client: client) + @invite_payload = Calendlyr::Webhooks::InviteePayload.new(json) + + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/AAAAAAAAAAAAAAAA", response: response) + end + + def test_associated_event + response = {body: fixture_file("events/retrieve"), status: 200} + stub(path: "scheduled_events/AAAAAAAAAAAAAAAA", response: response) + + event = @invite_payload.associated_event + + assert_equal Calendlyr::Event, event.class + end + + def test_associated_routing_form_submission + response = {body: fixture_file("routing_forms/retrieve_routing_form_submission"), status: 200} + stub(path: "routing_form_submissions/AAAAAAAAAAAAAAAA", response: response) + + routing_form = @invite_payload.associated_routing_form_submission + + assert_equal Calendlyr::RoutingForms::Submission, routing_form.class + end + + def test_associated_invitee_no_show + response = {body: fixture_file("events/retrieve_invitee_no_show"), status: 200} + stub(path: "invitee_no_shows/6ee96ed4-83a3-4966-a278-cd19b3c02e09", response: response) + + invitee_no_show = @invite_payload.associated_invitee_no_show + + assert_equal Calendlyr::Events::InviteeNoShow, invitee_no_show.class + end + end +end diff --git a/test/calendlyr/objects/webhooks/payload_test.rb b/test/calendlyr/objects/webhooks/payload_test.rb new file mode 100644 index 0000000..b11f0c2 --- /dev/null +++ b/test/calendlyr/objects/webhooks/payload_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "test_helper" + +module Webhooks + class PayloadObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/webhooks/payload")).merge(client: client) + @payload = Calendlyr::Webhooks::Payload.new(json) + end + + def test_event + assert_equal "invitee.created", @payload.event + end + end +end diff --git a/test/calendlyr/objects/webhooks/subscription_test.rb b/test/calendlyr/objects/webhooks/subscription_test.rb new file mode 100644 index 0000000..47fc0fb --- /dev/null +++ b/test/calendlyr/objects/webhooks/subscription_test.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "test_helper" + +module Webhooks + class SubscriptionObjectTest < Minitest::Test + def setup + json = JSON.parse(fixture_file("objects/webhooks/subscription")).merge(client: client) + @subscription = Calendlyr::Webhooks::Subscription.new(json) + + user_uuid = "AAAAAAAAAAAAAAAA" + response = {body: fixture_file("users/retrieve"), status: 200} + stub(path: "users/#{user_uuid}", response: response) + end + + def test_associated_organization + organization = @subscription.associated_organization + + assert_equal Calendlyr::Organization, organization.class + end + + def test_associated_user + user = @subscription.associated_user + + assert_equal Calendlyr::User, user.class + end + + def test_associated_creator + creator = @subscription.associated_creator + + assert_equal Calendlyr::User, creator.class + end + + def test_active? + assert @subscription.active? + end + + def test_disabled? + refute @subscription.disabled? + end + end +end diff --git a/test/calendlyr/resources/availabilities/user_busy_times_test.rb b/test/calendlyr/resources/availabilities/user_busy_times_test.rb new file mode 100644 index 0000000..5ddc23e --- /dev/null +++ b/test/calendlyr/resources/availabilities/user_busy_times_test.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require "test_helper" + +module Availabilities + class UserBusyTimeTest < Minitest::Test + def setup + @user_uri = "https://api.calendly.com/users/abc123" + @start_time = "2020-01-02T20:00:00.000000Z" + @end_time = "2020-01-02T20:30:00.000000Z" + response = {body: fixture_file("user_busy_times/list"), status: 200} + stub(path: "user_busy_times?user=#{@user_uri}&start_time=#{@start_time}&end_time=#{@end_time}", response: response) + end + + def test_list + user_busy_times = client.availability.list_user_busy_times(user: @user_uri, start_time: @start_time, end_time: @end_time) + + assert_equal Calendlyr::Collection, user_busy_times.class + assert_equal Calendlyr::Availabilities::UserBusyTime, user_busy_times.data.first.class + assert_equal 5, user_busy_times.data.count + end + + def test_list_from_user + user_busy_times = client.me.busy_times(start_time: @start_time, end_time: @end_time) + + assert_equal Calendlyr::Collection, user_busy_times.class + assert_equal Calendlyr::Availabilities::UserBusyTime, user_busy_times.data.first.class + assert_equal 5, user_busy_times.data.count + end + end +end diff --git a/test/calendlyr/resources/availabilities/user_schedules_test.rb b/test/calendlyr/resources/availabilities/user_schedules_test.rb new file mode 100644 index 0000000..971220a --- /dev/null +++ b/test/calendlyr/resources/availabilities/user_schedules_test.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require "test_helper" + +module Availabilities + class UserScheduleTest < Minitest::Test + def setup + @user_uri = "https://api.calendly.com/users/abc123" + @uuid = "abc123" + stub(path: "users/abc123", response: {body: fixture_file("users/retrieve"), status: 200}) + stub(path: "user_availability_schedules?user=#{@user_uri}", response: {body: fixture_file("user_availability_schedules/list"), status: 200}) + stub(path: "user_availability_schedules/#{@uuid}", response: {body: fixture_file("user_availability_schedules/retrieve"), status: 200}) + end + + def test_list + user_availability_schedules = client.availability.list_user_schedules(user: @user_uri) + + assert_equal 2, user_availability_schedules.data.count + assert_equal Calendlyr::Collection, user_availability_schedules.class + assert_equal Calendlyr::Availabilities::UserSchedule, user_availability_schedules.data.first.class + end + + def test_list_from_user + availability_schedules = client.me.availability_schedules + + assert_equal Calendlyr::Collection, availability_schedules.class + assert_equal Calendlyr::Availabilities::UserSchedule, availability_schedules.data.first.class + assert_equal 2, availability_schedules.data.count + end + + def test_retrieve + user_availability_schedule = client.availability.retrieve_user_schedule(uuid: @uuid) + + assert_equal Calendlyr::Availabilities::UserSchedule, user_availability_schedule.class + end + end +end diff --git a/test/calendlyr/resources/event_invitees_test.rb b/test/calendlyr/resources/event_invitees_test.rb deleted file mode 100644 index 679a921..0000000 --- a/test/calendlyr/resources/event_invitees_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class EventInviteesResourceTest < Minitest::Test - def test_list - event_uuid = "ABCDABCDABCDABCD" - response = {body: fixture_file("event_invitees/list"), status: 200} - stub(path: "scheduled_events/#{event_uuid}/invitees", response: response) - event_invitees = client.event_invitees.list(event_uuid: event_uuid) - - assert_equal Calendlyr::Collection, event_invitees.class - assert_equal Calendlyr::EventInvitee, event_invitees.data.first.class - assert_equal 1, event_invitees.data.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", event_invitees.next_page_token - end - - def test_retrieve - event_uuid = "abc123" - invitee_uuid = "abc123" - response = {body: fixture_file("event_invitees/retrieve"), status: 200} - stub(path: "scheduled_events/#{event_uuid}/invitees/#{invitee_uuid}", response: response) - event_invitee = client.event_invitees.retrieve(event_uuid: event_uuid, invitee_uuid: invitee_uuid) - - assert_equal Calendlyr::EventInvitee, event_invitee.class - assert_equal "https://api.calendly.com/api/v2/scheduled_events/ABCDABCDABCDABCD/invitees/ABCDABCDABCDABCD", event_invitee.uri - assert_equal "John Doe", event_invitee.name - end -end diff --git a/test/calendlyr/resources/event_types/membership_test.rb b/test/calendlyr/resources/event_types/membership_test.rb new file mode 100644 index 0000000..d573da3 --- /dev/null +++ b/test/calendlyr/resources/event_types/membership_test.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "test_helper" + +module EventTypes + class MembershipTest < Minitest::Test + def setup + @event_type_uri = "https://api.calendly.com/event_types/abc123" + response = {body: fixture_file("event_type_hosts/list"), status: 200} + stub(path: "event_type_memberships?event_type=#{@event_type_uri}", response: response) + end + + def test_list + event_type_hosts = client.event_types.list_memberships(event_type: @event_type_uri) + + assert_equal Calendlyr::Collection, event_type_hosts.class + assert_equal Calendlyr::EventTypes::Membership, event_type_hosts.data.first.class + assert_equal 1, event_type_hosts.data.count + assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", event_type_hosts.next_page_token + end + end +end diff --git a/test/calendlyr/resources/event_types_test.rb b/test/calendlyr/resources/event_types_test.rb index 3895fe3..8ecb867 100644 --- a/test/calendlyr/resources/event_types_test.rb +++ b/test/calendlyr/resources/event_types_test.rb @@ -6,15 +6,17 @@ class EventTypesResourceTest < Minitest::Test def setup @user_uri = "https://api.calendly.com/users/abc123" @organization_uri = "https://api.calendly.com/organizations/abc123" - @event_type_uuid = "abc123" + @event_type_uuid = "AAAAAAAAAAAAAAAA" list_response = {body: fixture_file("event_types/list"), status: 200} stub(path: "event_types?user=#{@user_uri}&organization=#{@organization_uri}", response: list_response) + stub(path: "event_types?organization=#{@organization_uri}", response: list_response) + stub(path: "event_types?user=#{@user_uri}", response: list_response) retrieve_response = {body: fixture_file("event_types/retrieve"), status: 200} stub(path: "event_types/#{@event_type_uuid}", response: retrieve_response) end def test_list - event_types = client.event_types.list(user_uri: @user_uri, organization_uri: @organization_uri) + event_types = client.event_types.list(user: @user_uri, organization: @organization_uri) assert_equal Calendlyr::Collection, event_types.class assert_equal Calendlyr::EventType, event_types.data.first.class @@ -32,10 +34,41 @@ def test_list_from_user end def test_retrieve - event_type = client.event_types.retrieve(event_type_uuid: @event_type_uuid) + event_type = client.event_types.retrieve(uuid: @event_type_uuid) assert_equal Calendlyr::EventType, event_type.class - assert_equal "https://api.calendly.com/event_types/abc123", event_type.uri + assert_equal "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", event_type.uri + assert_equal "15 Minute Meeting", event_type.name + assert_equal "acmesales", event_type.slug + assert_equal 30, event_type.duration + end + + def test_create_one_off + body = { + name: "My Meeting", + host: "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + co_hosts: [ + "https://api.calendly.com/users/BBBBBBBBBBBBBBBB", + "https://api.calendly.com/users/CCCCCCCCCCCCCCCC" + ], + duration: 30, + timezone: "string", + date_setting: { + type: "date_range", + start_date: "2020-01-07", + end_date: "2020-01-09" + }, + location: { + kind: "physical", + location: "Main Office", + additonal_info: "string" + } + } + stub(method: :post, path: "one_off_event_types", response: {body: fixture_file("event_types/create_one_off"), status: 201}) + event_type = client.event_types.create_one_off(**body) + + assert_equal Calendlyr::EventType, event_type.class + assert_equal "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", event_type.uri assert_equal "15 Minute Meeting", event_type.name assert_equal "acmesales", event_type.slug assert_equal 30, event_type.duration diff --git a/test/calendlyr/resources/events/invitee_test.rb b/test/calendlyr/resources/events/invitee_test.rb new file mode 100644 index 0000000..62d6d20 --- /dev/null +++ b/test/calendlyr/resources/events/invitee_test.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require "test_helper" + +module Events + class InviteeTest < Minitest::Test + def test_list + event_uuid = "ABCDABCDABCDABCD" + response = {body: fixture_file("event_invitees/list"), status: 200} + stub(path: "scheduled_events/#{event_uuid}/invitees", response: response) + event_invitees = client.events.list_invitees(uuid: event_uuid) + + assert_equal Calendlyr::Collection, event_invitees.class + assert_equal Calendlyr::Events::Invitee, event_invitees.data.first.class + assert_equal 1, event_invitees.data.count + assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", event_invitees.next_page_token + end + + def test_retrieve + event_uuid = "abc123" + invitee_uuid = "abc123" + response = {body: fixture_file("event_invitees/retrieve"), status: 200} + stub(path: "scheduled_events/#{event_uuid}/invitees/#{invitee_uuid}", response: response) + event_invitee = client.events.retrieve_invitee(event_uuid: event_uuid, invitee_uuid: invitee_uuid) + + assert_equal Calendlyr::Events::Invitee, event_invitee.class + assert_equal "https://api.calendly.com/api/v2/scheduled_events/ABCDABCDABCDABCD/invitees/ABCDABCDABCDABCD", event_invitee.uri + assert_equal "John Doe", event_invitee.name + end + end +end diff --git a/test/calendlyr/resources/events_test.rb b/test/calendlyr/resources/events_test.rb index bcdf6c3..80215cf 100644 --- a/test/calendlyr/resources/events_test.rb +++ b/test/calendlyr/resources/events_test.rb @@ -14,7 +14,7 @@ def setup end def test_list - events = client.events.list(user_uri: @user_uri, organization_uri: @organization_uri) + events = client.events.list(user: @user_uri, organization: @organization_uri) assert_equal Calendlyr::Collection, events.class assert_equal Calendlyr::Event, events.data.first.class @@ -23,7 +23,7 @@ def test_list end def test_list_from_user - events = client.me.events(user_uri: @user_uri, organization_uri: @organization_uri) + events = client.me.events assert_equal Calendlyr::Collection, events.class assert_equal Calendlyr::Event, events.data.first.class @@ -32,7 +32,7 @@ def test_list_from_user end def test_retrieve - event = client.events.retrieve(event_uuid: @event_uuid) + event = client.events.retrieve(uuid: @event_uuid) assert_equal Calendlyr::Event, event.class assert_equal "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2", event.uri diff --git a/test/calendlyr/resources/groups_test.rb b/test/calendlyr/resources/groups_test.rb new file mode 100644 index 0000000..704ec72 --- /dev/null +++ b/test/calendlyr/resources/groups_test.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "test_helper" + +class GroupsResourceTest < Minitest::Test + def test_list + organization = "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA" + response = {body: fixture_file("groups/list"), status: 200} + stub(path: "groups?organization=#{organization}", response: response) + + groups = client.groups.list(organization: organization) + + assert_equal 1, groups.data.size + assert_instance_of Calendlyr::Group, groups.data.first + end + + def test_retrieve + uuid = "abc123" + response = {body: fixture_file("group_relationships/retrieve"), status: 200} + stub(path: "group_relationships/#{uuid}", response: response) + relationship = client.groups.retrieve_relationship(uuid: uuid) + + assert_instance_of Calendlyr::Groups::Relationship, relationship + assert_equal "member", relationship.role + end +end diff --git a/test/calendlyr/resources/organizations_test.rb b/test/calendlyr/resources/organizations_test.rb index 2ab7859..a1334e1 100644 --- a/test/calendlyr/resources/organizations_test.rb +++ b/test/calendlyr/resources/organizations_test.rb @@ -11,7 +11,7 @@ def test_invite invitation = client.organizations.invite(organization_uuid: organization_uuid, email: email) - assert_equal Calendlyr::Invitation, invitation.class + assert_equal Calendlyr::Organizations::Invitation, invitation.class assert_equal email, invitation.email end @@ -19,52 +19,19 @@ def test_list_invitations organization_uuid = "abc123" response = {body: fixture_file("organizations/list_invitations"), status: 200} stub(path: "organizations/#{organization_uuid}/invitations", response: response) - invitations = client.organizations.list_invitations(organization_uuid: organization_uuid) + invitations = client.organizations.list_invitations(uuid: organization_uuid) assert_equal Calendlyr::Collection, invitations.class - assert_equal Calendlyr::Invitation, invitations.data.first.class + assert_equal Calendlyr::Organizations::Invitation, invitations.data.first.class assert_equal 1, invitations.count assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", invitations.next_page_token end - def test_list_memberships - user_uri = "abc123" - organization_uri = "abc123" - response = {body: fixture_file("organizations/list_memberships"), status: 200} - stub(path: "organization_memberships?user=#{user_uri}&organization=#{organization_uri}", response: response) - memberships = client.organizations.list_memberships(user_uri: user_uri, organization_uri: organization_uri) - - assert_equal Calendlyr::Collection, memberships.class - assert_equal Calendlyr::Membership, memberships.data.first.class - assert_equal 1, memberships.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token - end - - def test_list_webhooks - stub(path: "webhook_subscriptions?organization=#{client.organization.uri}&scope=user", response: {body: fixture_file("webhooks/list"), status: 200}) - webhooks = client.organization.list_webhooks(scope: "user") - - assert_equal Calendlyr::Collection, webhooks.class - assert_equal Calendlyr::Webhook, webhooks.data.first.class - assert_equal 1, webhooks.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", webhooks.next_page_token - end - - def test_activity_log - stub(path: "activity_log_entries?organization=#{client.organization.uri}", response: {body: fixture_file("activity_log/list"), status: 200}) - activity_log = client.organization.activity_log - - assert_equal Calendlyr::Collection, activity_log.class - assert_equal Calendlyr::ActivityLog, activity_log.data.first.class - assert_equal 20, activity_log.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", activity_log.next_page_token - end - def test_create_webhook body = {url: "https://blah.foo/bar", events: ["invitee.created"], organization: client.organization.uri, scope: "user", user: client.me.uri} stub(method: :post, path: "webhook_subscriptions", body: body, response: {body: fixture_file("webhooks/create"), status: 201}) - assert client.webhooks.create(url: body[:url], events: body[:events], organization_uri: body[:organization], scope: body[:scope], user_uri: body[:user]) + assert client.webhooks.create(**body) end def test_retrieve_invitation @@ -72,94 +39,53 @@ def test_retrieve_invitation stub(path: "organizations/#{client.organization.uuid}/invitations/#{invitation_uuid}", response: {body: fixture_file("organizations/retrieve_invitation"), status: 200}) stub(method: :delete, path: "organizations/#{client.organization.uuid}/invitations/#{invitation_uuid}", response: {body: fixture_file("organizations/revoke_invitation")}) - invitation = client.organizations.retrieve_invitation(organization_uuid: client.organization.uuid, invitation_uuid: invitation_uuid) + invitation = client.organizations.retrieve_invitation(org_uuid: client.organization.uuid, uuid: invitation_uuid) - assert_equal Calendlyr::Invitation, invitation.class + assert_equal Calendlyr::Organizations::Invitation, invitation.class assert_equal "test@example.com", invitation.email assert invitation.associated_organization assert invitation.revoke end - def test_retrieve_membership - membership_uuid = "abc123" - response = {body: fixture_file("organizations/retrieve_membership"), status: 200} - stub(path: "organization_memberships/#{membership_uuid}", response: response) - stub(path: "users/#{membership_uuid}", response: {body: fixture_file("users/retrieve"), status: 200}) - membership = client.organizations.retrieve_membership(membership_uuid: membership_uuid) - - assert_equal Calendlyr::Membership, membership.class - assert_equal "test@example.com", membership.user.email - assert_equal membership.associated_user, client.users.retrieve(user_uuid: membership_uuid) - end - def test_revoke_invitation organization_uuid = "abc123" invitation_uuid = "abc123" response = {body: fixture_file("organizations/revoke_invitation")} stub(method: :delete, path: "organizations/#{organization_uuid}/invitations/#{invitation_uuid}", response: response) - assert client.organizations.revoke_invitation(organization_uuid: organization_uuid, invitation_uuid: invitation_uuid) + assert client.organizations.revoke_invitation(org_uuid: organization_uuid, uuid: invitation_uuid) end - def test_remove_user - membership_uuid = "abc123" - response = {body: fixture_file("organizations/remove_user")} - stub(method: :delete, path: "organization_memberships/#{membership_uuid}", response: response) - assert client.organizations.remove_user(membership_uuid: membership_uuid) - end - - def test_organization_invite_user - email = "email@example.com" - response = {body: fixture_file("organizations/invite"), status: 201} - stub(method: :post, path: "organizations/#{client.organization.uuid}/invitations", body: {email: email}, response: response) - - invitation = client.organization.invite_user(email: email) - - assert_equal Calendlyr::Invitation, invitation.class - assert_equal email, invitation.email - end - - def test_organization_list_invitations - stub(path: "organizations/#{client.organization.uuid}/invitations", response: {body: fixture_file("organizations/list_invitations"), status: 200}) - invitations = client.organization.list_invitations - - assert_equal Calendlyr::Collection, invitations.class - assert_equal Calendlyr::Invitation, invitations.data.first.class - assert_equal 1, invitations.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", invitations.next_page_token - end - - def test_organization_revoke_invitation - stub(method: :delete, path: "organizations/#{client.organization.uuid}/invitations/abc123", response: {body: fixture_file("organizations/revoke_invitation")}) - assert client.organization.revoke_invitation(invitation_uuid: "abc123") - end - - def test_organization_invitation - response = {body: fixture_file("organizations/retrieve_invitation"), status: 200} - stub(path: "organizations/#{client.organization.uuid}/invitations/abc123", response: response) - invitation = client.organization.invitation(invitation_uuid: "abc123") + # Memberships + def test_list_memberships + user_uri = "abc123" + organization_uri = "abc123" + response = {body: fixture_file("organizations/list_memberships"), status: 200} + stub(path: "organization_memberships?user=#{user_uri}&organization=#{organization_uri}", response: response) + memberships = client.organizations.list_memberships(user: user_uri, organization: organization_uri) - assert_equal Calendlyr::Invitation, invitation.class - assert_equal "test@example.com", invitation.email + assert_equal Calendlyr::Collection, memberships.class + assert_equal Calendlyr::Organizations::Membership, memberships.data.first.class + assert_equal 1, memberships.data.count + assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token end - def test_organization_events - stub(path: "scheduled_events?organization=#{client.organization.uri}", response: {body: fixture_file("events/list"), status: 200}) - events = client.organization.events + def test_retrieve_membership + membership_uuid = "abc123" + response = {body: fixture_file("organizations/retrieve_membership"), status: 200} + stub(path: "organization_memberships/#{membership_uuid}", response: response) + stub(path: "users/#{membership_uuid}", response: {body: fixture_file("users/retrieve"), status: 200}) + membership = client.organizations.retrieve_membership(uuid: membership_uuid) - assert_equal Calendlyr::Collection, events.class - assert_equal Calendlyr::Event, events.data.first.class - assert_equal 1, events.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", events.next_page_token + assert_equal Calendlyr::Organizations::Membership, membership.class + assert_equal "test@example.com", membership.user.email + assert_equal membership.associated_user, client.users.retrieve(uuid: membership_uuid) end - def test_organization_memberships - stub(path: "organization_memberships?organization=#{client.organization.uri}", response: {body: fixture_file("organizations/list_memberships"), status: 200}) - memberships = client.organization.memberships - - assert_equal Calendlyr::Collection, memberships.class - assert_equal Calendlyr::Membership, memberships.data.first.class - assert_equal 1, memberships.count - assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token + def test_remove_user + membership_uuid = "abc123" + response = {body: fixture_file("organizations/remove_user")} + stub(method: :delete, path: "organization_memberships/#{membership_uuid}", response: response) + assert client.organizations.remove_user(uuid: membership_uuid) end end diff --git a/test/calendlyr/resources/outgoing_communications_test.rb b/test/calendlyr/resources/outgoing_communications_test.rb new file mode 100644 index 0000000..93fe613 --- /dev/null +++ b/test/calendlyr/resources/outgoing_communications_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "test_helper" + +class OutgoingCommunicationsResourceTest < Minitest::Test + def test_list + response = {body: fixture_file("outgoing_communications/list"), status: 200} + stub(path: "outgoing_communications", response: response) + outgoing_communications = client.outgoing_communications.list + + assert_equal Calendlyr::Collection, outgoing_communications.class + assert_equal Calendlyr::Object, outgoing_communications.data.first.class + assert_equal 1, outgoing_communications.data.count + assert_equal "sms", outgoing_communications.data.first.type + end +end diff --git a/test/calendlyr/resources/scheduling_links_test.rb b/test/calendlyr/resources/scheduling_links_test.rb index 4ce014d..8c887f8 100644 --- a/test/calendlyr/resources/scheduling_links_test.rb +++ b/test/calendlyr/resources/scheduling_links_test.rb @@ -10,6 +10,6 @@ def test_create response = {body: fixture_file("scheduling_links/create"), status: 201} stub(method: :post, path: "scheduling_links", body: {owner: owner_uri, max_event_count: max_event_count, owner_type: owner_type}, response: response) - assert client.scheduling_links.create(owner_uri: owner_uri, max_event_count: max_event_count, owner_type: owner_type) + assert client.scheduling_links.create(owner: owner_uri, max_event_count: max_event_count, owner_type: owner_type) end end diff --git a/test/calendlyr/resources/user_availability_schedules_test.rb b/test/calendlyr/resources/user_availability_schedules_test.rb deleted file mode 100644 index 92464f4..0000000 --- a/test/calendlyr/resources/user_availability_schedules_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class UserAvailabilityResourceTest < Minitest::Test - def setup - @user_uri = "https://api.calendly.com/users/abc123" - @uuid = "abc123" - stub(path: "users/abc123", response: {body: fixture_file("users/retrieve"), status: 200}) - stub(path: "user_availability_schedules?user=#{@user_uri}", response: {body: fixture_file("user_availability_schedules/list"), status: 200}) - stub(path: "user_availability_schedules/#{@uuid}", response: {body: fixture_file("user_availability_schedules/retrieve"), status: 200}) - end - - def test_list - user_availability_schedules = client.user_availability_schedules.list(user_uri: @user_uri) - - assert_equal 2, user_availability_schedules.data.count - assert_equal Calendlyr::Collection, user_availability_schedules.class - assert_equal Calendlyr::UserAvailabilitySchedule, user_availability_schedules.data.first.class - end - - def test_list_from_user - availability_schedules = client.me.availability_schedules - - assert_equal Calendlyr::Collection, availability_schedules.class - assert_equal Calendlyr::UserAvailabilitySchedule, availability_schedules.data.first.class - assert_equal 2, availability_schedules.data.count - end - - def test_retrieve - user_availability_schedule = client.user_availability_schedules.retrieve(uuid: @uuid) - - assert_equal Calendlyr::UserAvailabilitySchedule, user_availability_schedule.class - end -end diff --git a/test/calendlyr/resources/user_busy_times_test.rb b/test/calendlyr/resources/user_busy_times_test.rb deleted file mode 100644 index 97b70fa..0000000 --- a/test/calendlyr/resources/user_busy_times_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class UserBusyTimeTest < Minitest::Test - def setup - @user_uri = "https://api.calendly.com/users/abc123" - @start_time = "2020-01-02T20:00:00.000000Z" - @end_time = "2020-01-02T20:30:00.000000Z" - response = {body: fixture_file("user_busy_times/list"), status: 200} - stub(path: "user_busy_times?user=#{@user_uri}&start_time=#{@start_time}&end_time=#{@end_time}", response: response) - end - - def test_list - user_busy_times = client.user_busy_times.list(user_uri: @user_uri, start_time: @start_time, end_time: @end_time) - - assert_equal Calendlyr::Collection, user_busy_times.class - assert_equal Calendlyr::UserBusyTime, user_busy_times.data.first.class - assert_equal 3, user_busy_times.data.count - end - - def test_list_from_user - user_busy_times = client.me.busy_times(start_time: @start_time, end_time: @end_time) - - puts user_busy_times.inspect - assert_equal Calendlyr::Collection, user_busy_times.class - assert_equal Calendlyr::UserBusyTime, user_busy_times.data.first.class - assert_equal 3, user_busy_times.data.count - end -end diff --git a/test/calendlyr/resources/users_test.rb b/test/calendlyr/resources/users_test.rb index 3803921..6af257a 100644 --- a/test/calendlyr/resources/users_test.rb +++ b/test/calendlyr/resources/users_test.rb @@ -7,7 +7,7 @@ def test_retrieve user_uuid = "abc123" response = {body: fixture_file("users/retrieve"), status: 200} stub(path: "users/#{user_uuid}", response: response) - user = client.users.retrieve(user_uuid: user_uuid) + user = client.users.retrieve(uuid: user_uuid) assert_equal Calendlyr::User, user.class assert_equal "https://api.calendly.com/users/abc123", user.uri @@ -57,10 +57,10 @@ def test_memberships me = client.me stub(path: "organization_memberships?user=#{me.uri}&organization=#{me.organization.uri}", response: {body: fixture_file("organizations/list_memberships"), status: 200}) - memberships = client.me.memberships(organization_uri: me.organization.uri) + memberships = client.me.memberships(organization: me.organization.uri) assert_equal Calendlyr::Collection, memberships.class - assert_equal Calendlyr::Membership, memberships.data.first.class + assert_equal Calendlyr::Organizations::Membership, memberships.data.first.class assert_equal 1, memberships.data.count assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token end diff --git a/test/calendlyr/resources/webhooks_test.rb b/test/calendlyr/resources/webhooks_test.rb index 5d66d30..ac596e0 100644 --- a/test/calendlyr/resources/webhooks_test.rb +++ b/test/calendlyr/resources/webhooks_test.rb @@ -8,10 +8,10 @@ def test_list scope = "user" response = {body: fixture_file("webhooks/list"), status: 200} stub(path: "webhook_subscriptions?organization=#{organization_uri}&scope=#{scope}", response: response) - webhooks = client.webhooks.list(organization_uri: organization_uri, scope: scope) + webhooks = client.webhooks.list(organization: organization_uri, scope: scope) assert_equal Calendlyr::Collection, webhooks.class - assert_equal Calendlyr::Webhook, webhooks.data.first.class + assert_equal Calendlyr::Webhooks::Subscription, webhooks.data.first.class assert_equal 1, webhooks.data.count assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", webhooks.next_page_token end @@ -20,8 +20,8 @@ def test_create body = {url: "https://blah.foo/bar", events: ["invitee.created"], organization: "https://api.calendly.com/organizations/abc123", scope: "user", user: "https://api.calendly.com/users/abc123"} stub(method: :post, path: "webhook_subscriptions", body: body, response: {body: fixture_file("webhooks/create"), status: 201}) - assert client.webhooks.create(url: body[:url], events: body[:events], organization_uri: body[:organization], scope: body[:scope], user_uri: body[:user]) - assert client.organization.create_webhook(url: body[:url], events: body[:events], scope: body[:scope], user_uri: body[:user]) + assert client.webhooks.create(**body) + assert client.organization.create_webhook(**body) end def test_retrieve @@ -30,10 +30,10 @@ def test_retrieve stub(path: "users/abc123", response: {body: fixture_file("users/retrieve"), status: 200}) webhook = client.webhooks.retrieve(webhook_uuid: webhook_uuid) - assert_equal Calendlyr::Webhook, webhook.class + assert_equal Calendlyr::Webhooks::Subscription, webhook.class assert_equal "user", webhook.scope - assert_equal webhook.associated_user, client.users.retrieve(user_uuid: "abc123") - assert_equal webhook.associated_organization, client.users.retrieve(user_uuid: "abc123").organization + assert_equal webhook.associated_user, client.users.retrieve(uuid: "abc123") + assert_equal webhook.associated_organization, client.users.retrieve(uuid: "abc123").organization assert_equal webhook.active?, true end @@ -43,4 +43,12 @@ def test_delete stub(method: :delete, path: "webhook_subscriptions/#{webhook_uuid}", response: response) assert client.webhooks.delete(webhook_uuid: webhook_uuid) end + + def test_sample_webhook_data + stub(path: "sample_webhook_data?event=invitee.created&scope=organization&organization=https://api.calendly.com/organizations/abc123", response: {body: fixture_file("webhooks/sample"), status: 200}) + webhook_data = client.webhooks.sample_webhook_data(event: "invitee.created", scope: "organization", organization: "https://api.calendly.com/organizations/abc123") + + assert_equal Calendlyr::Object, webhook_data.class + assert_equal "invitee.created", webhook_data.event + end end diff --git a/test/fixtures/activity_log/list.json b/test/fixtures/activity_log/list.json index ddc7511..cffd0b8 100644 --- a/test/fixtures/activity_log/list.json +++ b/test/fixtures/activity_log/list.json @@ -22,7 +22,7 @@ }, "fully_qualified_name": "User.Add", "details": {}, - "organization": "https://api.calendly.com/organizations/abc123" + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAA" } ], "pagination": { diff --git a/test/fixtures/availabilities/user_busy_times_list.json b/test/fixtures/availabilities/user_busy_times_list.json new file mode 100644 index 0000000..3c7363e --- /dev/null +++ b/test/fixtures/availabilities/user_busy_times_list.json @@ -0,0 +1,39 @@ +{ + "collection": [ + { + "type": "calendly", + "start_time": "2020-01-02T20:00:00.000000Z", + "end_time": "2020-01-02T20:30:00.000000Z", + "buffered_start_time": "2020-01-02T19:30:00.000000Z", + "buffered_end_time": "2020-01-02T21:00:00.000000Z", + "event": { + "uri": "https://api.calendly.com/scheduled_events/abc123" + } + }, + { + "type": "calendly", + "start_time": "2020-01-05T20:00:00.000000Z", + "end_time": "2020-01-05T20:30:00.000000Z", + "buffered_start_time": "2020-01-05T19:30:00.000000Z", + "buffered_end_time": "2020-01-05T21:00:00.000000Z", + "event": { + "uri": "https://api.calendly.com/scheduled_events/abc12345" + } + }, + { + "type": "reserved", + "start_time": "2020-01-07T17:00:00.000000Z", + "end_time": "2020-01-07T17:30:00.000000Z" + }, + { + "type": "reserved", + "start_time": "2020-01-07T18:00:00.000000Z", + "end_time": "2020-01-07T18:30:00.000000Z" + }, + { + "type": "external", + "start_time": "2020-01-07T20:00:00.000000Z", + "end_time": "2020-01-07T20:30:00.000000Z" + } + ] +} diff --git a/test/fixtures/availabilities/user_schedules_list.json b/test/fixtures/availabilities/user_schedules_list.json new file mode 100644 index 0000000..19453b0 --- /dev/null +++ b/test/fixtures/availabilities/user_schedules_list.json @@ -0,0 +1,93 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/user_availability_schedule/abc123", + "default": true, + "name": "Working Hours", + "user": "https://api.calendly.com/users/abc123", + "timezone": "America/New_York", + "rules": [ + { + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "09:30" + } + ], + "wday": "sunday", + "date": "2022-12-31" + } + ] + }, + { + "uri": "https://api.calendly.com/user_availability_schedule/abc456", + "default": false, + "name": "Evening Hours", + "user": "https://api.calendly.com/users/abc123", + "timezone": "America/New_York", + "rules": [ + { + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "17:00" + } + ], + "wday": "monday" + }, + { + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "17:00" + } + ], + "wday": "tuesday" + }, + { + "type": "wday", + "intervals": [], + "wday": "wednesday" + }, + { + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "17:00" + } + ], + "wday": "thursday" + }, + { + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "17:00" + } + ], + "wday": "friday" + }, + { + "type": "wday", + "intervals": [], + "wday": "saturday" + }, + { + "type": "date", + "intervals": [ + { + "from": "08:30", + "to": "09:30" + } + ], + "date": "2028-12-31" + } + ] + } + ] +} diff --git a/test/fixtures/availabilities/user_schedules_retrieve.json b/test/fixtures/availabilities/user_schedules_retrieve.json new file mode 100644 index 0000000..9ce0463 --- /dev/null +++ b/test/fixtures/availabilities/user_schedules_retrieve.json @@ -0,0 +1,22 @@ +{ + "resource": { + "uri": "https://api.calendly.com/user_availability_schedule/abc123", + "default": true, + "name": "Working Hours", + "user": "https://api.calendly.com/users/abc123", + "timezone": "America/New_York", + "rules": [ + { + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "09:30" + } + ], + "wday": "sunday", + "date": "2022-12-31" + } + ] + } +} diff --git a/test/fixtures/event_type_available_times/list.json b/test/fixtures/event_type_available_times/list.json new file mode 100644 index 0000000..0e2bea9 --- /dev/null +++ b/test/fixtures/event_type_available_times/list.json @@ -0,0 +1,22 @@ +{ + "collection": [ + { + "status": "available", + "invitees_remaining": 2, + "start_time": "2020-01-02T20:00:00.000000Z", + "scheduling_url": "https://calendly.com/acmesales/discovery-call/2020-01-02T20:00:00Z?month=2020-01&date=2020-01-02" + }, + { + "status": "available", + "invitees_remaining": 1, + "start_time": "2020-01-03T15:00:00.000000Z", + "scheduling_url": "https://calendly.com/acmesales/discovery-call/2020-01-03T15:00:00Z?month=2020-01&date=2020-01-03" + }, + { + "status": "available", + "invitees_remaining": 3, + "start_time": "2020-01-07T23:00:00.000000Z", + "scheduling_url": "https://calendly.com/acmesales/discovery-call/2020-01-07T23:00:00Z?month=2020-01&date=2020-01-07" + } + ] +} diff --git a/test/fixtures/event_type_hosts/list.json b/test/fixtures/event_type_hosts/list.json new file mode 100644 index 0000000..e51be1a --- /dev/null +++ b/test/fixtures/event_type_hosts/list.json @@ -0,0 +1,76 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/event_type_memberships/AAAAAAAAAAAAAAAA", + "event_type": { + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "name": "15 Minute Meeting", + "active": true, + "slug": "acmesales", + "scheduling_url": "https://calendly.com/acmesales", + "duration": 30, + "kind": "solo", + "pooling_type": "round_robin", + "type": "StandardEventType", + "color": "#fff200", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "internal_note": "Internal note", + "description_plain": "15 Minute Meeting", + "description_html": "

15 Minute Meeting

", + "profile": { + "type": "User", + "name": "Tamara Jones", + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" + }, + "secret": true, + "booking_method": "poll", + "custom_questions": [ + { + "name": "string", + "type": "string", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": [ + "string" + ], + "include_other": true + } + ], + "deleted_at": "2019-01-02T03:04:05.678123Z", + "admin_managed": true, + "locations": [ + { + "kind": "inbound_call", + "phone_number": 380934567654, + "additional_info": "Additional information about location" + } + ], + "position": 0 + }, + "member": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "resource_type": "User" + }, + "updated_at": "2019-01-02T03:04:05.678123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/event_types?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/event_types?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + } +} diff --git a/test/fixtures/event_types/create_one_off.json b/test/fixtures/event_types/create_one_off.json new file mode 100644 index 0000000..a45dc63 --- /dev/null +++ b/test/fixtures/event_types/create_one_off.json @@ -0,0 +1,45 @@ +{ + "resource": { + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "name": "15 Minute Meeting", + "active": true, + "slug": "acmesales", + "scheduling_url": "https://calendly.com/acmesales", + "duration": 30, + "kind": "solo", + "pooling_type": "round_robin", + "type": "StandardEventType", + "color": "#fff200", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "internal_note": "Internal note", + "description_plain": "15 Minute Meeting", + "description_html": "

15 Minute Meeting

", + "profile": { + "type": "User", + "name": "Tamara Jones", + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" + }, + "secret": true, + "booking_method": "poll", + "custom_questions": [ + { + "name": "string", + "type": "string", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": [ + "string" + ], + "include_other": true + } + ], + "deleted_at": "2019-01-02T03:04:05.678123Z", + "admin_managed": true, + "locations": [ + {} + ], + "position": 0 + } +} diff --git a/test/fixtures/event_types/list.json b/test/fixtures/event_types/list.json index b3308ca..767df80 100644 --- a/test/fixtures/event_types/list.json +++ b/test/fixtures/event_types/list.json @@ -1,9 +1,10 @@ { "collection": [ { - "uri": "https://api.calendly.com/event_types/abc123", + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", "name": "15 Minute Meeting", "active": true, + "booking_method": "instant", "slug": "acmesales", "scheduling_url": "https://calendly.com/acmesales", "duration": 30, @@ -11,17 +12,27 @@ "pooling_type": "round_robin", "type": "StandardEventType", "color": "#fff200", - "created_at": "2019-01-02T03:04:05.678Z", - "updated_at": "2019-08-07T06:05:04.321Z", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", "internal_note": "Internal note", "description_plain": "15 Minute Meeting", "description_html": "

15 Minute Meeting

", "profile": { "type": "User", "name": "Tamara Jones", - "owner": "https://api.calendly.com/users/abc123" + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" }, "secret": true, + "deleted_at": null, + "admin_managed": false, + "locations": [ + { + "kind": "inbound_call", + "phone_number": 380934567654, + "additional_info": "Additional information about location" + } + ], + "position": 0, "custom_questions": [ { "name": "Company Name", @@ -82,7 +93,10 @@ } ], "pagination": { - "count": 1, - "next_page": "https://api.calendly.com/event_types?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi" + "count": 20, + "next_page": "https://api.calendly.com/event_types?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/event_types?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" } } diff --git a/test/fixtures/event_types/retrieve.json b/test/fixtures/event_types/retrieve.json index 3f0eae0..6df88c1 100644 --- a/test/fixtures/event_types/retrieve.json +++ b/test/fixtures/event_types/retrieve.json @@ -1,8 +1,9 @@ { "resource": { - "uri": "https://api.calendly.com/event_types/abc123", + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", "name": "15 Minute Meeting", "active": true, + "booking_method": "instant", "slug": "acmesales", "scheduling_url": "https://calendly.com/acmesales", "duration": 30, @@ -10,17 +11,27 @@ "pooling_type": "round_robin", "type": "StandardEventType", "color": "#fff200", - "created_at": "2019-01-02T03:04:05.678Z", - "updated_at": "2019-08-07T06:05:04.321Z", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", "internal_note": "Internal note", "description_plain": "15 Minute Meeting", "description_html": "

15 Minute Meeting

", "profile": { "type": "User", "name": "Tamara Jones", - "owner": "https://api.calendly.com/users/abc123" + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" }, "secret": true, + "deleted_at": null, + "admin_managed": false, + "locations": [ + { + "kind": "inbound_call", + "phone_number": 380934567654, + "additional_info": "Additional information about location" + } + ], + "position": 0, "custom_questions": [ { "name": "Company Name", diff --git a/test/fixtures/events/cancel_invitee.json b/test/fixtures/events/cancel_invitee.json new file mode 100644 index 0000000..73aa2d7 --- /dev/null +++ b/test/fixtures/events/cancel_invitee.json @@ -0,0 +1,8 @@ +{ + "resource": { + "canceled_by": "string", + "reason": "string", + "canceler_type": "host", + "created_at": "2019-01-02T03:04:05.678123Z" + } +} diff --git a/test/fixtures/events/create_invitee_no_show.json b/test/fixtures/events/create_invitee_no_show.json new file mode 100644 index 0000000..f26172a --- /dev/null +++ b/test/fixtures/events/create_invitee_no_show.json @@ -0,0 +1,7 @@ +{ + "resource": { + "uri": "https://api.calendly.com/invitee_no_shows/639fa667-4c1b-4b20-93b5-1b1969d67dc6", + "invitee": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2/invitees/7c1dbe46-bd84-42e2-9b97-05e2fb379bfe", + "created_at": "2019-01-02T03:04:05.678123Z" + } +} diff --git a/test/fixtures/events/delete_invitee_no_show.json b/test/fixtures/events/delete_invitee_no_show.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/fixtures/events/delete_invitee_no_show.json @@ -0,0 +1 @@ +{} diff --git a/test/fixtures/events/retrieve_invitee_no_show.json b/test/fixtures/events/retrieve_invitee_no_show.json new file mode 100644 index 0000000..f26172a --- /dev/null +++ b/test/fixtures/events/retrieve_invitee_no_show.json @@ -0,0 +1,7 @@ +{ + "resource": { + "uri": "https://api.calendly.com/invitee_no_shows/639fa667-4c1b-4b20-93b5-1b1969d67dc6", + "invitee": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2/invitees/7c1dbe46-bd84-42e2-9b97-05e2fb379bfe", + "created_at": "2019-01-02T03:04:05.678123Z" + } +} diff --git a/test/fixtures/group_relationships/list.json b/test/fixtures/group_relationships/list.json new file mode 100644 index 0000000..5eb44ae --- /dev/null +++ b/test/fixtures/group_relationships/list.json @@ -0,0 +1,83 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/group_relationships/AAAAAAAAAAAAAAAA", + "role": "member", + "owner": { + "type": "OrganizationMembership", + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "user", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "group": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + { + "uri": "https://api.calendly.com/group_relationships/AAAAAAAAAAAAAAAA", + "role": "admin", + "owner": { + "type": "OrganizationMembership", + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "user", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "group": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + { + "uri": "https://api.calendly.com/group_relationships/AAAAAAAAAAAAAAAA", + "role": "member", + "owner": { + "type": "OrganizationInvitation", + "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "email": "test@example.com", + "status": "pending", + "created_at": "2019-08-07T06:05:04.321123Z", + "updated_at": "2019-01-02T03:04:05.678123Z", + "last_sent_at": "2019-01-02T03:04:05.678123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "group": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/group_relationships?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/group_relationships?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + } +} diff --git a/test/fixtures/group_relationships/retrieve.json b/test/fixtures/group_relationships/retrieve.json new file mode 100644 index 0000000..11088ae --- /dev/null +++ b/test/fixtures/group_relationships/retrieve.json @@ -0,0 +1,29 @@ +{ + "resource": { + "uri": "https://api.calendly.com/group_relationships/AAAAAAAAAAAAAAAA", + "role": "member", + "owner": { + "type": "OrganizationMembership", + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "user", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "group": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + } +} diff --git a/test/fixtures/groups/list.json b/test/fixtures/groups/list.json new file mode 100644 index 0000000..c7f28eb --- /dev/null +++ b/test/fixtures/groups/list.json @@ -0,0 +1,19 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "name": "Sales Team", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "member_count": 0 + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/event_types?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/event_types?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + } +} diff --git a/test/fixtures/groups/retrieve.json b/test/fixtures/groups/retrieve.json new file mode 100644 index 0000000..075490a --- /dev/null +++ b/test/fixtures/groups/retrieve.json @@ -0,0 +1,9 @@ +{ + "resource": { + "uri": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "name": "Sales Team", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + } +} diff --git a/test/fixtures/objects/activity_log.json b/test/fixtures/objects/activity_log.json new file mode 100644 index 0000000..2bc7ed8 --- /dev/null +++ b/test/fixtures/objects/activity_log.json @@ -0,0 +1,24 @@ +{ + "occurred_at": "2020-01-02T03:04:05.678Z", + "uri": "https://api.calendly.com/activity_log_entries/ALFKJELNCLKSJDLKFJGELKJ", + "namespace": "User", + "action": "Add", + "actor": { + "uri": "https://api.calendly.com/users/SDLKJENFJKD123", + "type": "User", + "organization": { + "uri": "https://api.calendly.com/organizations/LKJENFLKE293847", + "role": "Owner" + }, + "group": { + "uri": "https://api.calendly.com/groups/123987DJLKJEF", + "name": "Development", + "role": "Admin" + }, + "display_name": "Test User", + "alternative_identifier": "testuser@example.com" + }, + "fully_qualified_name": "User.Add", + "details": {}, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAA" +} diff --git a/test/fixtures/objects/availabilities/rule.json b/test/fixtures/objects/availabilities/rule.json new file mode 100644 index 0000000..3b4c121 --- /dev/null +++ b/test/fixtures/objects/availabilities/rule.json @@ -0,0 +1,10 @@ +{ + "type": "wday", + "intervals": [ + { + "from": "08:30", + "to": "09:30" + } + ], + "wday": "sunday" +} diff --git a/test/fixtures/objects/user_busy_time.json b/test/fixtures/objects/availabilities/user_busy_time.json similarity index 100% rename from test/fixtures/objects/user_busy_time.json rename to test/fixtures/objects/availabilities/user_busy_time.json diff --git a/test/fixtures/objects/user_availability_schedule.json b/test/fixtures/objects/availabilities/user_schedule.json similarity index 100% rename from test/fixtures/objects/user_availability_schedule.json rename to test/fixtures/objects/availabilities/user_schedule.json diff --git a/test/fixtures/objects/event_type.json b/test/fixtures/objects/event_type.json new file mode 100644 index 0000000..4018e05 --- /dev/null +++ b/test/fixtures/objects/event_type.json @@ -0,0 +1,91 @@ +{ + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "name": "15 Minute Meeting", + "active": true, + "booking_method": "instant", + "slug": "acmesales", + "scheduling_url": "https://calendly.com/acmesales", + "duration": 30, + "kind": "solo", + "pooling_type": "round_robin", + "type": "StandardEventType", + "color": "#fff200", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "internal_note": "Event type note", + "description_plain": "Event type description", + "description_html": "

Event type description

", + "profile": { + "type": "User", + "name": "Tamara Jones", + "owner": "https://api.calendly.com/users/ABC123" + }, + "secret": true, + "deleted_at": null, + "admin_managed": false, + "locations": [ + { + "kind": "inbound_call", + "phone_number": 380934567654, + "additional_info": "Additional information about location" + } + ], + "position": 0, + "custom_questions": [ + { + "name": "Company Name", + "type": "string", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": null, + "include_other": false + }, + { + "name": "What would you like to discuss?", + "type": "text", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": null, + "include_other": false + }, + { + "name": "Number of employees", + "answer_choices": [ + "1", + "2-10", + "11-20", + "20+" + ], + "enabled": true, + "include_other": true, + "position": 2, + "required": false, + "type": "single_select" + }, + { + "name": "Multi-Select Question", + "answer_choices": [ + "Answer 1", + "Answer 2", + "Answer 3", + "Answer 4" + ], + "enabled": true, + "include_other": true, + "position": 2, + "required": false, + "type": "multi_select" + }, + { + "name": "Phone Number", + "type": "phone_number", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": null, + "include_other": false + } + ] +} diff --git a/test/fixtures/objects/event_type_host.json b/test/fixtures/objects/event_type_host.json new file mode 100644 index 0000000..734697f --- /dev/null +++ b/test/fixtures/objects/event_type_host.json @@ -0,0 +1,65 @@ +{ + "uri": "https://api.calendly.com/event_type_memberships/AAAAAAAAAAAAAAAA", + "event_type": { + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "name": "15 Minute Meeting", + "active": true, + "slug": "acmesales", + "scheduling_url": "https://calendly.com/acmesales", + "duration": 30, + "kind": "solo", + "pooling_type": "round_robin", + "type": "StandardEventType", + "color": "#fff200", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "internal_note": "Internal note", + "description_plain": "15 Minute Meeting", + "description_html": "

15 Minute Meeting

", + "profile": { + "type": "User", + "name": "Tamara Jones", + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" + }, + "secret": true, + "booking_method": "poll", + "custom_questions": [ + { + "name": "string", + "type": "string", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": [ + "string" + ], + "include_other": true + } + ], + "deleted_at": "2019-01-02T03:04:05.678123Z", + "admin_managed": true, + "locations": [ + { + "kind": "inbound_call", + "phone_number": 380934567654, + "additional_info": "Additional information about location" + } + ], + "position": 0 + }, + "member": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "resource_type": "User" + }, + "updated_at": "2019-01-02T03:04:05.678123Z", + "created_at": "2019-01-02T03:04:05.678123Z" +} diff --git a/test/fixtures/objects/event_types/available_time.json b/test/fixtures/objects/event_types/available_time.json new file mode 100644 index 0000000..af09b72 --- /dev/null +++ b/test/fixtures/objects/event_types/available_time.json @@ -0,0 +1,6 @@ +{ + "status": "available", + "invitees_remaining": 2, + "start_time": "2020-01-02T20:00:00.000000Z", + "scheduling_url": "https://calendly.com/acmesales/discovery-call/2020-01-02T20:00:00Z?month=2020-01&date=2020-01-02" +} diff --git a/test/fixtures/objects/event_types/membership.json b/test/fixtures/objects/event_types/membership.json new file mode 100644 index 0000000..734697f --- /dev/null +++ b/test/fixtures/objects/event_types/membership.json @@ -0,0 +1,65 @@ +{ + "uri": "https://api.calendly.com/event_type_memberships/AAAAAAAAAAAAAAAA", + "event_type": { + "uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "name": "15 Minute Meeting", + "active": true, + "slug": "acmesales", + "scheduling_url": "https://calendly.com/acmesales", + "duration": 30, + "kind": "solo", + "pooling_type": "round_robin", + "type": "StandardEventType", + "color": "#fff200", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "internal_note": "Internal note", + "description_plain": "15 Minute Meeting", + "description_html": "

15 Minute Meeting

", + "profile": { + "type": "User", + "name": "Tamara Jones", + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" + }, + "secret": true, + "booking_method": "poll", + "custom_questions": [ + { + "name": "string", + "type": "string", + "position": 0, + "enabled": true, + "required": true, + "answer_choices": [ + "string" + ], + "include_other": true + } + ], + "deleted_at": "2019-01-02T03:04:05.678123Z", + "admin_managed": true, + "locations": [ + { + "kind": "inbound_call", + "phone_number": 380934567654, + "additional_info": "Additional information about location" + } + ], + "position": 0 + }, + "member": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "resource_type": "User" + }, + "updated_at": "2019-01-02T03:04:05.678123Z", + "created_at": "2019-01-02T03:04:05.678123Z" +} diff --git a/test/fixtures/objects/event_types/profile.json b/test/fixtures/objects/event_types/profile.json new file mode 100644 index 0000000..5b46b90 --- /dev/null +++ b/test/fixtures/objects/event_types/profile.json @@ -0,0 +1,5 @@ +{ + "type": "User", + "name": "Tamara Jones", + "owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" +} diff --git a/test/fixtures/objects/events/cancellation.json b/test/fixtures/objects/events/cancellation.json new file mode 100644 index 0000000..0c878fa --- /dev/null +++ b/test/fixtures/objects/events/cancellation.json @@ -0,0 +1,6 @@ +{ + "canceled_by": "string", + "reason": "string", + "canceler_type": "host", + "created_at": "2019-01-02T03:04:05.678123Z" +} diff --git a/test/fixtures/objects/events/guest.json b/test/fixtures/objects/events/guest.json new file mode 100644 index 0000000..c7a3c15 --- /dev/null +++ b/test/fixtures/objects/events/guest.json @@ -0,0 +1,5 @@ +{ + "email": "user@example.com", + "created_at": "2019-08-24T14:15:22.123456Z", + "updated_at": "2019-08-24T14:15:22.123456Z" +} diff --git a/test/fixtures/objects/events/invitee.json b/test/fixtures/objects/events/invitee.json new file mode 100644 index 0000000..316f0c2 --- /dev/null +++ b/test/fixtures/objects/events/invitee.json @@ -0,0 +1,46 @@ +{ + "cancel_url": "https://calendly.com/cancellations/AAAAAAAAAAAAAAAA", + "created_at": "2020-11-23T17:51:18.327602Z", + "email": "test@example.com", + "event": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA", + "first_name": "John", + "last_name": "Doe", + "name": "John Doe", + "new_invitee": null, + "old_invitee": null, + "questions_and_answers": [], + "reschedule_url": "https://calendly.com/reschedulings/AAAAAAAAAAAAAAAA", + "rescheduled": false, + "status": "active", + "text_reminder_number": null, + "timezone": "America/New_York", + "tracking": { + "utm_campaign": null, + "utm_source": null, + "utm_medium": null, + "utm_content": null, + "utm_term": null, + "salesforce_uuid": null + }, + "updated_at": "2020-11-23T17:51:18.341657Z", + "uri": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "routing_form_submission": "https://api.calendly.com/routing_form_submissions/AAAAAAAAAAAAAAAA", + "payment": { + "external_id": "ch_AAAAAAAAAAAAAAAAAAAAAAAA", + "provider": "stripe", + "amount": 1234.56, + "currency": "USD", + "terms": "sample terms of payment (up to 1,024 characters)", + "successful": true + }, + "no_show": { + "uri": "https://api.calendly.com/invitee_no_shows/6ee96ed4-83a3-4966-a278-cd19b3c02e09", + "created_at": "2020-11-23T17:51:18.341657Z" + }, + "reconfirmation": { + "created_at": "2020-11-23T17:51:18.341657Z", + "confirmed_at": "2020-11-23T20:01:18.341657Z" + }, + "scheduling_method": null, + "invitee_scheduled_by": null +} diff --git a/test/fixtures/objects/events/invitee_no_show.json b/test/fixtures/objects/events/invitee_no_show.json new file mode 100644 index 0000000..92bfd61 --- /dev/null +++ b/test/fixtures/objects/events/invitee_no_show.json @@ -0,0 +1,5 @@ +{ + "uri": "https://api.calendly.com/no_shows/40a3cb54-e45c-4f34-b100-bd346220a5bb", + "invitee": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2/invitees/7c1dbe46-bd84-42e2-9b97-05e2fb379bfe", + "created_at": "2019-01-02T03:04:05.678123Z" +} diff --git a/test/fixtures/objects/group.json b/test/fixtures/objects/group.json new file mode 100644 index 0000000..d9a9c47 --- /dev/null +++ b/test/fixtures/objects/group.json @@ -0,0 +1,7 @@ +{ + "uri": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "name": "Sales Team", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" +} diff --git a/test/fixtures/objects/groups/relationship.json b/test/fixtures/objects/groups/relationship.json new file mode 100644 index 0000000..5268a95 --- /dev/null +++ b/test/fixtures/objects/groups/relationship.json @@ -0,0 +1,27 @@ +{ + "uri": "https://api.calendly.com/group_relationships/AAAAAAAAAAAAAAAA", + "role": "member", + "owner": { + "type": "OrganizationMembership", + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "admin", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "group": "https://api.calendly.com/groups/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" +} diff --git a/test/fixtures/objects/organization.json b/test/fixtures/objects/organization.json new file mode 100644 index 0000000..1bcb15f --- /dev/null +++ b/test/fixtures/objects/organization.json @@ -0,0 +1,8 @@ +{ + "uri": "https://api.calendly.com/organizations/012345678901234567890", + "name": "Sales Team", + "plan": "basic", + "stage": "trial", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" +} diff --git a/test/fixtures/objects/organizations/invitation.json b/test/fixtures/objects/organizations/invitation.json new file mode 100644 index 0000000..2c91764 --- /dev/null +++ b/test/fixtures/objects/organizations/invitation.json @@ -0,0 +1,10 @@ +{ + "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "email": "test@example.com", + "status": "accepted", + "created_at": "2019-08-07T06:05:04.321123Z", + "updated_at": "2019-01-02T03:04:05.678123Z", + "last_sent_at": "2019-01-02T03:04:05.678123Z", + "user": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" +} diff --git a/test/fixtures/objects/organizations/membership.json b/test/fixtures/objects/organizations/membership.json new file mode 100644 index 0000000..0868654 --- /dev/null +++ b/test/fixtures/objects/organizations/membership.json @@ -0,0 +1,18 @@ +{ + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "admin", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" +} diff --git a/test/fixtures/objects/routing_form.json b/test/fixtures/objects/routing_form.json new file mode 100644 index 0000000..3df7526 --- /dev/null +++ b/test/fixtures/objects/routing_form.json @@ -0,0 +1,28 @@ +{ + "uri": "https://api.calendly.com/routing_forms/AAAAAAAAAAAAAAAA", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "name": "ACME Routing Form", + "status": "published", + "questions": [ + { + "uuid": "123e4567-e89b-12d3-a456-426614174000", + "name": "What is your industry?", + "type": "select", + "required": true, + "answer_choices": [ + "IT & Software", + "Financial Services", + "Entertainment" + ] + }, + { + "uuid": "1213f8f1-57fd-45ee-88e9-1978d35b5cad", + "name": "Email", + "type": "email", + "required": true, + "answer_choices": null + } + ], + "created_at": "2022-05-15T03:04:05.678Z", + "updated_at": "2022-05-15T06:05:04.321Z" +} diff --git a/test/fixtures/objects/routing_forms/submission.json b/test/fixtures/objects/routing_forms/submission.json new file mode 100644 index 0000000..610ebcb --- /dev/null +++ b/test/fixtures/objects/routing_forms/submission.json @@ -0,0 +1,27 @@ +{ + "uri": "https://api.calendly.com/routing_form_submissions/AAAAAAAAAAAAAAAA", + "routing_form": "https://api.calendly.com/routing_forms/AAAAAAAAAAAAAAAA", + "questions_and_answers": [ + { + "question_uuid": "123e4567-e89b-12d3-a456-426614174000", + "question": "What is your industry?", + "answer": "IT & Software" + } + ], + "tracking": { + "utm_campaign": null, + "utm_source": null, + "utm_medium": null, + "utm_content": null, + "utm_term": null, + "salesforce_uuid": null + }, + "result": { + "type": "event_type", + "value": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2" + }, + "submitter": "https://calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "submitter_type": "Invitee", + "created_at": "2022-05-15T03:04:05.678Z", + "updated_at": "2022-05-15T06:05:04.321Z" +} diff --git a/test/fixtures/objects/scheduling_links/event_type.json b/test/fixtures/objects/scheduling_links/event_type.json new file mode 100644 index 0000000..b93a0c8 --- /dev/null +++ b/test/fixtures/objects/scheduling_links/event_type.json @@ -0,0 +1,5 @@ +{ + "booking_url": "https://calendly.com/d/abcd-brv8/15-minute-meeting", + "owner": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2", + "owner_type": "EventType" +} diff --git a/test/fixtures/objects/share.json b/test/fixtures/objects/share.json new file mode 100644 index 0000000..83f3e9d --- /dev/null +++ b/test/fixtures/objects/share.json @@ -0,0 +1,43 @@ +{ + "scheduling_links": [ + { + "booking_url": "https://calendly.com/d/abcd-brv8/15-minute-meeting", + "owner": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "owner_type": "EventType" + } + ], + "share_override": { + "name": "15 Minute Meeting", + "duration": 60, + "period_type": "available_moving", + "start_date": "2019-01-02", + "end_date": "2019-01-03", + "max_booking_time": 300, + "hide_location": true, + "location_configurations": [ + { + "location": "123 Abc St.", + "additional_info": "Example additional info", + "phone_number": "+1 888-888-8888", + "position": 0, + "kind": "physical" + } + ], + "availability_rule": { + "rules": [ + { + "type": "wday", + "wday": "sunday", + "date": "2019-01-02", + "intervals": [ + { + "from": "07:00", + "to": "11:00" + } + ] + } + ], + "timezone": "America/New_York" + } + } +} diff --git a/test/fixtures/objects/user.json b/test/fixtures/objects/user.json new file mode 100644 index 0000000..41bf795 --- /dev/null +++ b/test/fixtures/objects/user.json @@ -0,0 +1,13 @@ +{ + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "resource_type": "User" +} diff --git a/test/fixtures/objects/webhooks/invite_payload.json b/test/fixtures/objects/webhooks/invite_payload.json new file mode 100644 index 0000000..3007f9f --- /dev/null +++ b/test/fixtures/objects/webhooks/invite_payload.json @@ -0,0 +1,83 @@ +{ + "cancel_url": "https://calendly.com/cancellations/AAAAAAAAAAAAAAAA", + "created_at": "2020-11-23T17:51:18.327602Z", + "email": "test@example.com", + "event": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA", + "first_name": "John", + "last_name": "Doe", + "name": "John Doe", + "new_invitee": null, + "old_invitee": null, + "questions_and_answers": [], + "reschedule_url": "https://calendly.com/reschedulings/AAAAAAAAAAAAAAAA", + "rescheduled": false, + "status": "active", + "text_reminder_number": null, + "timezone": "America/New_York", + "tracking": { + "utm_campaign": null, + "utm_source": null, + "utm_medium": null, + "utm_content": null, + "utm_term": null, + "salesforce_uuid": null + }, + "updated_at": "2020-11-23T17:51:18.341657Z", + "uri": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "canceled": false, + "routing_form_submission": "https://api.calendly.com/routing_form_submissions/AAAAAAAAAAAAAAAA", + "payment": { + "external_id": "ch_AAAAAAAAAAAAAAAAAAAAAAAA", + "provider": "stripe", + "amount": 1234.56, + "currency": "USD", + "terms": "sample terms of payment (up to 1,024 characters)", + "successful": true + }, + "no_show": { + "uri": "https://api.calendly.com/invitee_no_shows/6ee96ed4-83a3-4966-a278-cd19b3c02e09", + "created_at": "2020-11-23T17:51:18.341657Z" + }, + "reconfirmation": { + "created_at": "2020-11-23T17:51:18.341657Z", + "confirmed_at": "2020-11-23T20:01:18.341657Z" + }, + "scheduling_method": null, + "invitee_scheduled_by": null, + "scheduled_event": { + "uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2", + "name": "15 Minute Meeting", + "meeting_notes_plain": "Internal meeting notes", + "meeting_notes_html": "

Internal meeting notes

", + "status": "active", + "start_time": "2019-08-24T14:15:22.123456Z", + "end_time": "2019-08-24T14:15:22.123456Z", + "event_type": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2", + "location": { + "type": "physical", + "location": "string", + "additional_info": "string" + }, + "invitees_counter": { + "total": 0, + "active": 0, + "limit": 0 + }, + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-01-02T03:04:05.678123Z", + "event_memberships": [ + { + "user": "https://api.calendly.com/users/GBGBDCAADAEDCRZ2", + "user_email": "user@example.com", + "user_name": "John Smith" + } + ], + "event_guests": [ + { + "email": "user@example.com", + "created_at": "2019-08-24T14:15:22.123456Z", + "updated_at": "2019-08-24T14:15:22.123456Z" + } + ] + } +} diff --git a/test/fixtures/objects/webhooks/payload.json b/test/fixtures/objects/webhooks/payload.json new file mode 100644 index 0000000..f2a209c --- /dev/null +++ b/test/fixtures/objects/webhooks/payload.json @@ -0,0 +1,66 @@ +{ + "created_at": "2020-11-23T17:51:19.000000Z", + "created_by": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "event": "invitee.created", + "payload": { + "cancel_url": "https://calendly.com/cancellations/AAAAAAAAAAAAAAAA", + "created_at": "2020-11-23T17:51:18.327602Z", + "email": "test@example.com", + "event": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "new_invitee": null, + "old_invitee": null, + "questions_and_answers": [], + "reschedule_url": "https://calendly.com/reschedulings/AAAAAAAAAAAAAAAA", + "rescheduled": false, + "status": "active", + "text_reminder_number": null, + "timezone": "America/New_York", + "tracking": { + "utm_campaign": null, + "utm_source": null, + "utm_medium": null, + "utm_content": null, + "utm_term": null, + "salesforce_uuid": null + }, + "updated_at": "2020-11-23T17:51:18.341657Z", + "uri": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "scheduled_event": { + "uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2", + "name": "15 Minute Meeting", + "meeting_notes_plain": "Internal meeting notes", + "meeting_notes_html": "

Internal meeting notes

", + "status": "active", + "start_time": "2019-08-24T14:15:22.123456Z", + "end_time": "2019-08-24T14:15:22.123456Z", + "event_type": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2", + "location": { + "type": "physical", + "location": "string", + "additional_info": "string" + }, + "invitees_counter": { + "total": 0, + "active": 0, + "limit": 0 + }, + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-01-02T03:04:05.678123Z", + "event_memberships": [ + { + "user": "https://api.calendly.com/users/GBGBDCAADAEDCRZ2", + "user_email": "user@example.com", + "user_name": "John Smith" + } + ], + "event_guests": [ + { + "email": "user@example.com", + "created_at": "2019-08-24T14:15:22.123456Z", + "updated_at": "2019-08-24T14:15:22.123456Z" + } + ] + } + } +} diff --git a/test/fixtures/objects/webhooks/subscription.json b/test/fixtures/objects/webhooks/subscription.json new file mode 100644 index 0000000..5cd8b57 --- /dev/null +++ b/test/fixtures/objects/webhooks/subscription.json @@ -0,0 +1,15 @@ +{ + "uri": "https://api.calendly.com/webhook_subscriptions/AAAAAAAAAAAAAAAA", + "callback_url": "https://blah.foo/bar", + "created_at": "2019-08-24T14:15:22.123456Z", + "updated_at": "2019-08-24T14:15:22.123456Z", + "retry_started_at": "2019-08-24T14:15:22.123456Z", + "state": "active", + "events": [ + "invitee.created" + ], + "scope": "user", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "user": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "creator": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA" +} diff --git a/test/fixtures/organization_memberships/list.json b/test/fixtures/organization_memberships/list.json new file mode 100644 index 0000000..6c3cab2 --- /dev/null +++ b/test/fixtures/organization_memberships/list.json @@ -0,0 +1,29 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "admin", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + } +} diff --git a/test/fixtures/organization_memberships/retrieve.json b/test/fixtures/organization_memberships/retrieve.json new file mode 100644 index 0000000..fc3f257 --- /dev/null +++ b/test/fixtures/organization_memberships/retrieve.json @@ -0,0 +1,20 @@ +{ + "resource": { + "uri": "https://api.calendly.com/organization_memberships/AAAAAAAAAAAAAAAA", + "role": "admin", + "user": { + "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "name": "John Doe", + "slug": "acmesales", + "email": "test@example.com", + "scheduling_url": "https://calendly.com/acmesales", + "timezone": "America/New York", + "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" + }, + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" + } +} diff --git a/test/fixtures/organizations/list_memberships.json b/test/fixtures/organizations/list_memberships.json index 30e2bf1..8eb7da3 100644 --- a/test/fixtures/organizations/list_memberships.json +++ b/test/fixtures/organizations/list_memberships.json @@ -11,16 +11,19 @@ "scheduling_url": "https://calendly.com/acmesales", "timezone": "America/New York", "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png", - "created_at": "2019-01-02T03:04:05.678Z", - "updated_at": "2019-08-07T06:05:04.321Z" + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z" }, "organization": "https://api.calendly.com/organizations/abc123", - "updated_at": "2019-08-07T06:05:04.321Z", - "created_at": "2019-01-02T03:04:05.678Z" + "updated_at": "2019-08-07T06:05:04.321123Z", + "created_at": "2019-01-02T03:04:05.678123Z" } ], "pagination": { - "count": 1, - "next_page": "https://api.calendly.com/organization_memberships/abc123?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi" + "count": 20, + "next_page": "https://api.calendly.com/organization_memberships/abc123?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/organization_memberships/abc123?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" } } diff --git a/test/fixtures/outgoing_communications/list.json b/test/fixtures/outgoing_communications/list.json new file mode 100644 index 0000000..fb46577 --- /dev/null +++ b/test/fixtures/outgoing_communications/list.json @@ -0,0 +1,26 @@ +{ + "collection": [ + { + "type": "sms", + "to": "+14047549876", + "from": "+14042916667", + "subject": "", + "body": "Your scheduled event is coming up.", + "sender_uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "sender_email": "user@example.com", + "event_type_uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "event_uri": "https://api.calendly.com/scheduled_events/ABCDABCDABCDABCD", + "sent_at": "2023-09-24T11:12:13.145Z", + "created_at": "2023-09-24T11:12:13.145Z", + "scheduling_url": "https://calendly.com/event/name" + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/event_types?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page": "https://api.calendly.com/event_types?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + }, + "total_count": 0 +} diff --git a/test/fixtures/routing_forms/list.json b/test/fixtures/routing_forms/list.json new file mode 100644 index 0000000..c1fbced --- /dev/null +++ b/test/fixtures/routing_forms/list.json @@ -0,0 +1,39 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/routing_forms/AAAAAAAAAAAAAAAA", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "name": "ACME Demo", + "status": "published", + "questions": [ + { + "uuid": "123e4567-e89b-12d3-a456-426614174000", + "name": "What is your industry?", + "type": "select", + "required": true, + "answer_choices": [ + "IT & Software", + "Financial Services", + "Entertainment" + ] + }, + { + "uuid": "1213f8f1-57fd-45ee-88e9-1978d35b5cad", + "name": "Email", + "type": "email", + "required": true, + "answer_choices": null + } + ], + "created_at": "2022-05-15T03:04:05.678Z", + "updated_at": "2022-05-15T06:05:04.321Z" + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/routing_forms?count=1&page_token=d8T0LKQ1XsC2utmPlI7TFPpHX4SSfoGl", + "previous_page": "https://api.calendly.com/routing_forms?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "d8T0LKQ1XsC2utmPlI7TFPpHX4SSfoGl", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + } +} diff --git a/test/fixtures/routing_forms/list_routing_form_submission.json b/test/fixtures/routing_forms/list_routing_form_submission.json new file mode 100644 index 0000000..9a4983f --- /dev/null +++ b/test/fixtures/routing_forms/list_routing_form_submission.json @@ -0,0 +1,38 @@ +{ + "collection": [ + { + "uri": "https://api.calendly.com/routing_form_submissions/AAAAAAAAAAAAAAAA", + "routing_form": "https://api.calendly.com/routing_forms/AAAAAAAAAAAAAAAA", + "questions_and_answers": [ + { + "question_uuid": "123e4567-e89b-12d3-a456-426614174000", + "question": "What is your industry?", + "answer": "IT & Software" + } + ], + "tracking": { + "utm_campaign": null, + "utm_source": null, + "utm_medium": null, + "utm_content": null, + "utm_term": null, + "salesforce_uuid": null + }, + "result": { + "type": "event_type", + "value": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2" + }, + "submitter": "https://calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "submitter_type": "Invitee", + "created_at": "2022-05-15T03:04:05.678Z", + "updated_at": "2022-05-15T06:05:04.321Z" + } + ], + "pagination": { + "count": 20, + "next_page": "https://api.calendly.com/routing_form_submissions?count=1&page_token=d8T0LKQ1XsC2utmPlI7TFPpHX4SSfoGl", + "previous_page": "https://api.calendly.com/routing_form_submissions?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H", + "next_page_token": "d8T0LKQ1XsC2utmPlI7TFPpHX4SSfoGl", + "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H" + } +} diff --git a/test/fixtures/routing_forms/retrieve.json b/test/fixtures/routing_forms/retrieve.json new file mode 100644 index 0000000..0645ab7 --- /dev/null +++ b/test/fixtures/routing_forms/retrieve.json @@ -0,0 +1,30 @@ +{ + "resource": { + "uri": "https://api.calendly.com/routing_forms/AAAAAAAAAAAAAAAA", + "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", + "name": "ACME Demo", + "status": "published", + "questions": [ + { + "uuid": "123e4567-e89b-12d3-a456-426614174000", + "name": "What is your industry?", + "type": "select", + "required": true, + "answer_choices": [ + "IT & Software", + "Financial Services", + "Entertainment" + ] + }, + { + "uuid": "1213f8f1-57fd-45ee-88e9-1978d35b5cad", + "name": "Email", + "type": "email", + "required": true, + "answer_choices": null + } + ], + "created_at": "2022-05-15T03:04:05.678Z", + "updated_at": "2022-05-15T06:05:04.321Z" + } +} diff --git a/test/fixtures/routing_forms/retrieve_routing_form_submission.json b/test/fixtures/routing_forms/retrieve_routing_form_submission.json new file mode 100644 index 0000000..0dcd3f9 --- /dev/null +++ b/test/fixtures/routing_forms/retrieve_routing_form_submission.json @@ -0,0 +1,29 @@ +{ + "resource": { + "uri": "https://api.calendly.com/routing_form_submissions/AAAAAAAAAAAAAAAA", + "routing_form": "https://api.calendly.com/routing_forms/AAAAAAAAAAAAAAAA", + "questions_and_answers": [ + { + "question_uuid": "123e4567-e89b-12d3-a456-426614174000", + "question": "What is your industry?", + "answer": "IT & Software" + } + ], + "tracking": { + "utm_campaign": null, + "utm_source": null, + "utm_medium": null, + "utm_content": null, + "utm_term": null, + "salesforce_uuid": null + }, + "result": { + "type": "event_type", + "value": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2" + }, + "submitter": "https://calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "submitter_type": "Invitee", + "created_at": "2022-05-15T03:04:05.678Z", + "updated_at": "2022-05-15T06:05:04.321Z" + } +} diff --git a/test/fixtures/shares/create.json b/test/fixtures/shares/create.json new file mode 100644 index 0000000..354d233 --- /dev/null +++ b/test/fixtures/shares/create.json @@ -0,0 +1,45 @@ +{ + "resource": { + "scheduling_links": [ + { + "booking_url": "https://calendly.com/d/abcd-brv8/15-minute-meeting", + "owner": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", + "owner_type": "EventType" + } + ], + "share_override": { + "name": "15 Minute Meeting", + "duration": 60, + "period_type": "fixed", + "start_date": "2019-01-02", + "end_date": "2019-01-03", + "max_booking_time": 300, + "hide_location": true, + "location_configurations": [ + { + "location": "123 Abc St.", + "additional_info": "Example additional info", + "phone_number": "+1 888-888-8888", + "position": 0, + "kind": "physical" + } + ], + "availability_rule": { + "rules": [ + { + "type": "wday", + "wday": "friday", + "date": "2019-01-02", + "intervals": [ + { + "from": "07:00", + "to": "11:00" + } + ] + } + ], + "timezone": "America/New_York" + } + } + } +} diff --git a/test/fixtures/user_busy_times/list.json b/test/fixtures/user_busy_times/list.json index 042e1b0..3c7363e 100644 --- a/test/fixtures/user_busy_times/list.json +++ b/test/fixtures/user_busy_times/list.json @@ -20,6 +20,16 @@ "uri": "https://api.calendly.com/scheduled_events/abc12345" } }, + { + "type": "reserved", + "start_time": "2020-01-07T17:00:00.000000Z", + "end_time": "2020-01-07T17:30:00.000000Z" + }, + { + "type": "reserved", + "start_time": "2020-01-07T18:00:00.000000Z", + "end_time": "2020-01-07T18:30:00.000000Z" + }, { "type": "external", "start_time": "2020-01-07T20:00:00.000000Z", diff --git a/test/fixtures/webhooks/sample.json b/test/fixtures/webhooks/sample.json new file mode 100644 index 0000000..6a42df9 --- /dev/null +++ b/test/fixtures/webhooks/sample.json @@ -0,0 +1,105 @@ +{ + "event": "invitee.created", + "created_at": "2019-08-24T14:15:22Z", + "created_by": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", + "payload": { + "uri": "https://calendly.com/scheduled_events/AAAAAAAAAAAAAAAA/invitees/AAAAAAAAAAAAAAAA", + "email": "test@example.com", + "first_name": "John", + "last_name": "Doe", + "name": "John Doe", + "status": "active", + "questions_and_answers": [ + { + "question": "string", + "answer": "string", + "position": 0 + } + ], + "timezone": "string", + "event": "https://api.calendly.com/scheduled_events/AAAAAAAAAAAAAAAA", + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-08-07T06:05:04.321123Z", + "tracking": { + "utm_campaign": "string", + "utm_source": "string", + "utm_medium": "string", + "utm_content": "string", + "utm_term": "string", + "salesforce_uuid": "string" + }, + "text_reminder_number": "+1 404-555-1234", + "rescheduled": true, + "old_invitee": "http://example.com", + "new_invitee": "http://example.com", + "cancel_url": "http://example.com", + "reschedule_url": "http://example.com", + "routing_form_submission": "https://api.calendly.com/routing_form_submissions/AAAAAAAAAAAAAAAA", + "cancellation": { + "canceled_by": "string", + "reason": "string", + "canceler_type": "host", + "created_at": "2019-01-02T03:04:05.678123Z" + }, + "payment": { + "external_id": "string", + "provider": "stripe", + "amount": 0, + "currency": "AUD", + "terms": "sample terms of payment (up to 1,024 characters)", + "successful": true + }, + "no_show": { + "uri": "string", + "created_at": "2019-01-02T03:04:05.678123Z" + }, + "reconfirmation": { + "created_at": "2020-11-23T17:51:18.341657Z", + "confirmed_at": "2020-11-23T17:51:18.341657Z" + }, + "scheduling_method": "instant_book", + "invitee_scheduled_by": "http://example.com", + "scheduled_event": { + "uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2", + "name": "15 Minute Meeting", + "meeting_notes_plain": "15 Minute Meeting", + "meeting_notes_html": "

15 Minute Meeting

", + "status": "active", + "start_time": "2019-08-24T14:15:22Z", + "end_time": "2019-08-24T14:15:22Z", + "event_type": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2", + "location": { + "type": "physical", + "location": "Calendly Office", + "additional_info": "Please check in at the main lobby." + }, + "invitees_counter": { + "total": 0, + "active": 0, + "limit": 0 + }, + "created_at": "2019-01-02T03:04:05.678123Z", + "updated_at": "2019-01-02T03:04:05.678123Z", + "event_memberships": [ + { + "user": "https://api.calendly.com/users/GBGBDCAADAEDCRZ2", + "user_email": "user@example.com", + "user_name": "John Smith" + } + ], + "event_guests": [ + { + "email": "user@example.com", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z" + } + ], + "cancellation": { + "canceled_by": "string", + "reason": "string", + "canceler_type": "host", + "created_at": "2019-01-02T03:04:05.678123Z" + } + } + } +}