Skip to content

Support either UUIDs or URIs in client#2

Merged
shalvah-gs merged 1 commit intoimprovementsfrom
uuids_or_uris
Sep 7, 2023
Merged

Support either UUIDs or URIs in client#2
shalvah-gs merged 1 commit intoimprovementsfrom
uuids_or_uris

Conversation

@shalvah-gs
Copy link

Port of koshilife#65

In many places in the Calendly API and webhook payloads, a URI to a resource is returned. However, the client in this gem always expects a UUID, which forces users to either parse the URI and extract the relevant UUID parts, or use the model objects (an API which involves more boilerplate).

# Supposing, you have a Calendly invitee object; the old_invitee field is a URI

invitee_uri = invitee.old_invitee

# To fetch the old invitee, you can't do this:

Calendly::Client.new.event_invitee(invitee_uri) # <= doesn't work

# You can either write a regex to extract the UUIDs from the URI
event_uuid, invitee_uuid = /https:\/\/api\.calendly\.com\/scheduled_events\/(.+)\/invitees\/(.+)/.match(invitee_uri)
Calendly::Client.new.event_invitee(event_uuid, invitee_uuid)


# or (unnecessary boilerplate, must remember to `#fetch`)

Calendly::Invitee.new({ uri: invitee_uri }, Calendly::Client.new).fetch

This PR makes most of the client methods also accept URIs, while keeping backwards compatibility.

@shalvah-gs shalvah-gs merged commit fd7c5bd into improvements Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant