From 14df74e2940b53a67a69f88fed4030a2f07d4e1a Mon Sep 17 00:00:00 2001 From: araluce Date: Thu, 7 Mar 2024 20:52:19 +0100 Subject: [PATCH] :sparkles: Extending support for Data Compliance --- README.md | 9 +++-- docs/1_installation.md | 2 +- docs/2_usage.md | 2 +- docs/3_resources.md | 2 +- docs/resources/1_pagination.md | 2 +- docs/resources/2_data_compliance.md | 17 ++++++++ docs/resources/availabily/1_user_busy_time.md | 2 +- .../2_user_availability_schedule.md | 2 +- docs/resources/user.md | 40 +++++++++++++++++++ lib/calendlyr/resources/data_compliance.rb | 4 ++ .../resources/data_compliance_test.rb | 11 +++++ .../delete_scheduled_event_data.json | 1 + 12 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 docs/resources/2_data_compliance.md create mode 100644 docs/resources/user.md create mode 100644 test/fixtures/data_compliance/delete_scheduled_event_data.json diff --git a/README.md b/README.md index c69b07f..5d61ad1 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,12 @@ We know about the importance of not add dependencies that you don't want. * [Installation](docs/1_installation.md) * [Usage](docs/2_usage.md) * **Resources** + * [Pagination](/docs/resources/1_pagination.md) * **Availability** - * [UserBusyTime](docs/resources/availabily/1_user_busy_time.md) - * [UserAvailabilitySchedule](docs/resources/availabily/2_user_availability_schedule.md) - * [Pagination](docs/resources/1_pagination.md) - * [User](docs/resources/2_user.md) + * [UserBusyTime](/docs/resources/availabily/1_user_busy_time.md) + * [UserAvailabilitySchedule](/docs/resources/availabily/2_user_availability_schedule.md) + * [Data Compliance](/docs/resources/2_data_compliance.md) + * [User](/docs/resources/user.md) ### Event Types ````ruby diff --git a/docs/1_installation.md b/docs/1_installation.md index dcb010d..3346f6c 100644 --- a/docs/1_installation.md +++ b/docs/1_installation.md @@ -18,4 +18,4 @@ Or install it yourself as: ## Next -See [Usage](2_usage.md) +See [Usage](/docs/2_usage.md) diff --git a/docs/2_usage.md b/docs/2_usage.md index 77f751f..76f2ed9 100644 --- a/docs/2_usage.md +++ b/docs/2_usage.md @@ -10,4 +10,4 @@ The client then gives you access to each of the resources. ## Next -See [Resources](3_resources.md) +See [Resources](/docs/3_resources.md) diff --git a/docs/3_resources.md b/docs/3_resources.md index d1fec34..d18024f 100644 --- a/docs/3_resources.md +++ b/docs/3_resources.md @@ -6,4 +6,4 @@ Responses are created as objects like `Calendlyr::Event`. Having types like `Cal ## Next -See [Pagination](resources/1_pagination.md) +See [Pagination](/docs/resources/1_pagination.md) diff --git a/docs/resources/1_pagination.md b/docs/resources/1_pagination.md index 067600e..2b152e5 100644 --- a/docs/resources/1_pagination.md +++ b/docs/resources/1_pagination.md @@ -22,4 +22,4 @@ client.me.events(count: 5, next_page_token: results.next_page_token) ## Next -See [User](2_user.md) +See [Data Compliance](/docs/resources/2_data_compliance.md) diff --git a/docs/resources/2_data_compliance.md b/docs/resources/2_data_compliance.md new file mode 100644 index 0000000..52b84c2 --- /dev/null +++ b/docs/resources/2_data_compliance.md @@ -0,0 +1,17 @@ +# Data Compliance + +## 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. + +```ruby +client.data_compliance.delete_invitee_data(emails: %w[test@email.org test2@email.org]) +``` + +## 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. + +```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/availabily/1_user_busy_time.md b/docs/resources/availabily/1_user_busy_time.md index 75ba34e..32e23a8 100644 --- a/docs/resources/availabily/1_user_busy_time.md +++ b/docs/resources/availabily/1_user_busy_time.md @@ -15,4 +15,4 @@ client.user_busy_times.list(user_uri: `user_uri`, start_time: `start_time`, end_ ## Next -[User Availability Schedule](2_user_availability_schedule.md) +[User Availability Schedule](/docs/resources/availability/2_user_availability_schedule.md) diff --git a/docs/resources/availabily/2_user_availability_schedule.md b/docs/resources/availabily/2_user_availability_schedule.md index 6f6128a..366aa93 100644 --- a/docs/resources/availabily/2_user_availability_schedule.md +++ b/docs/resources/availabily/2_user_availability_schedule.md @@ -29,4 +29,4 @@ client.me.availability_schedules ## Next -[User Availability Schedule](2_user_availability_schedule.md) +[User Availability Schedule](/docs/resources/2_data_compliance.md) diff --git a/docs/resources/user.md b/docs/resources/user.md new file mode 100644 index 0000000..9b5cc1c --- /dev/null +++ b/docs/resources/user.md @@ -0,0 +1,40 @@ +# User + +```ruby +client.me +client.users.me +client.retrieve(user_uuid: "uuid") +#=> #, uuid="123abc"> + +client.organization +#=> #, uuid="123abc"> + +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">]> + +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">]> + +client.me.memberships +#=> #, client=#, uuid="abc123">]> +``` + +## Me + +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. + +```ruby +client.me # makes a call and memoize the response +client.me # no call, value memoized +``` + +### Force reload + +However, if you need to reload the content of `me` you can `force_relaod` to force a new call. + +```ruby +client.me(force_reload: true) # makes a new call and update memoized value +``` + + +## Next diff --git a/lib/calendlyr/resources/data_compliance.rb b/lib/calendlyr/resources/data_compliance.rb index 18515cc..07c7917 100644 --- a/lib/calendlyr/resources/data_compliance.rb +++ b/lib/calendlyr/resources/data_compliance.rb @@ -3,5 +3,9 @@ class DataComplianceResource < Resource def delete_invitee_data(emails:) post_request("data_compliance/deletion/invitees", body: {emails: emails}) end + + def delete_scheduled_event_data(start_time:, end_time:) + post_request("data_compliance/deletion/events", body: {start_time: start_time, end_time: end_time}) + end end end diff --git a/test/calendlyr/resources/data_compliance_test.rb b/test/calendlyr/resources/data_compliance_test.rb index a883fa4..ea5d0cb 100644 --- a/test/calendlyr/resources/data_compliance_test.rb +++ b/test/calendlyr/resources/data_compliance_test.rb @@ -10,4 +10,15 @@ def test_delete_invitee_data assert client.data_compliance.delete_invitee_data(**body) end + + def test_delete_scheduled_event_data + body = { + start_time: "2019-01-02T03:04:05.678123Z", + end_time: "2021-01-01T02:04:05.678123Z" + } + response = {body: fixture_file("data_compliance/delete_scheduled_event_data"), status: 202} + stub(method: :post, path: "data_compliance/deletion/events", body: body, response: response) + + assert client.data_compliance.delete_scheduled_event_data(**body) + end end diff --git a/test/fixtures/data_compliance/delete_scheduled_event_data.json b/test/fixtures/data_compliance/delete_scheduled_event_data.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/fixtures/data_compliance/delete_scheduled_event_data.json @@ -0,0 +1 @@ +{}