Skip to content

Commit

Permalink
✨ Extending support for Data Compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
araluce committed Mar 7, 2024
1 parent 53e3d1a commit 14df74e
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 10 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/1_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Or install it yourself as:

## Next

See [Usage](2_usage.md)
See [Usage](/docs/2_usage.md)
2 changes: 1 addition & 1 deletion docs/2_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion docs/3_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion docs/resources/1_pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 17 additions & 0 deletions docs/resources/2_data_compliance.md
Original file line number Diff line number Diff line change
@@ -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[[email protected] [email protected]])
```

## 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")
```
2 changes: 1 addition & 1 deletion docs/resources/availabily/1_user_busy_time.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion docs/resources/availabily/2_user_availability_schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
40 changes: 40 additions & 0 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# User

```ruby
client.me
client.users.me
client.retrieve(user_uuid: "uuid")
#=> #<Calendlyr::User avatar_url=nil, created_at="2021-01-20T15:46:27.251298Z", current_organization="https://api.calendly.com/organizations/123abc", email="[email protected]", name="John Doe", resource_type="User", scheduling_url="https://calendly.com/john-doe", slug="john-doe", timezone="Europe/Berlin", updated_at="2024-01-21T11:39:27.889254Z", uri="https://api.calendly.com/users/123abc", client=#<Calendlyr::Client>, uuid="123abc">

client.organization
#=> #<Calendlyr::Organization uri="https://api.calendly.com/organizations/123abc", client=#<Calendlyr::Client>, uuid="123abc">

client.me.event_types
#=> #<Calendlyr::Collection @data=[#<Calendlyr::EventType active=true, admin_managed=false, booking_method="instant", color="#f8e436", created_at="2021-12-02T07:43:57.994910Z", custom_questions=[#<OpenStruct answer_choices=[], enabled=true, include_other=false, name="Please share anything that will help prepare for our meeting.", position=0, required=false, type="text">], deleted_at=nil, description_html=nil, description_plain=nil, duration=15, internal_note=nil, kind="solo", locations=[#<OpenStruct kind="zoom_conference">], name="15 Minute Meeting", pooling_type=nil, position=0, profile=#<OpenStruct name="John Doe", owner="https://api.calendly.com/users/abc123", type="User">, 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=#<Calendlyr::Client>, uuid="abc123">]>

client.me.events
#=> #<Calendlyr::Collection @data=[#<Calendlyr::Event calendar_event=#<OpenStruct external_id="abc123", kind="google">, created_at="2022-05-27T11:49:29.726091Z", end_time="2022-05-27T17:30:00.000000Z", event_guests=[], event_memberships=[#<OpenStruct user="https://api.calendly.com/users/abc123", user_email="[email protected]", user_name="John Doe">], event_type="https://api.calendly.com/event_types/abc123", invitees_counter=#<OpenStruct active=1, limit=1, total=1>, location=#<OpenStruct data=#<OpenStruct>, 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=#<Calendlyr::Client>, uuid="abc123">]>

client.me.memberships
#=> #<Calendlyr::Collection @data=[#<Calendlyr::Membership created_at="2021-12-02T07:43:56.752548Z", organization="https://api.calendly.com/organizations/abc123", role="owner", updated_at="2022-01-10T14:52:50.966271Z", uri="https://api.calendly.com/organization_memberships/abc123", user=#<OpenStruct avatar_url=nil, created_at="2021-01-20T15:46:27.251298Z", email="[email protected]", name="John Doe", timezone="Europe/Berlin", updated_at="2024-01-21T11:39:27.889254Z", uri="https://api.calendly.com/users/abc123", scheduling_url="https://calendly.com/john-doe", slug="john-doe">, client=#<Calendlyr::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
4 changes: 4 additions & 0 deletions lib/calendlyr/resources/data_compliance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions test/calendlyr/resources/data_compliance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 14df74e

Please sign in to comment.