Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Support either UUIDs or URIs in client#65

Open
shalvah-gs wants to merge 1 commit intokoshilife:masterfrom
nxt-insurance:uuids_or_uris
Open

Support either UUIDs or URIs in client#65
shalvah-gs wants to merge 1 commit intokoshilife:masterfrom
nxt-insurance:uuids_or_uris

Conversation

@shalvah-gs
Copy link

@shalvah-gs shalvah-gs commented Sep 7, 2023

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant