Skip to content

Commit

Permalink
Merge pull request #39 from koshilife/#38_support_new_uuid_format
Browse files Browse the repository at this point in the history
support new UUID format
  • Loading branch information
koshilife committed Oct 20, 2021
2 parents 191d930 + cbb5683 commit a3745e9
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 36 deletions.
50 changes: 27 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## 0.8.0
## 0.8.1 - 2021-10-20

- support new UUID format like 'bbc4f475-6125-435a-b713-2d1634651e10'. (#38, thanks to jameswilliamiii)

## 0.8.0 - 2021-06-03

- used keyword arguments for optional parameters, to be friendly for programmer.
- changed methods are followings:
Expand Down Expand Up @@ -41,12 +45,12 @@
- webhooks
- webhooks!

## 0.7.0
## 0.7.0 - 2021-06-03

- supported a signing key parameter when creating webhooks. (#33)
- supported a signing key parameter when creating webhooks. (#33, thanks to ismael-texidor)
- changed `user_uri` argument to keyword argument on Client#create_webhook.

## 0.6.0
## 0.6.0 - 2021-05-30

- supported new features until April 2021. (#29)
- Client
Expand Down Expand Up @@ -84,16 +88,16 @@
- fixed debug log encoding error. (#30)
- improved inspect method to be more readable in CLI.

## 0.5.2
## 0.5.2 - 2020-12-13

- started to support a API
- `POST /scheduling_links`

## 0.5.1
## 0.5.1 - 2020-12-13

- added method EventType#fetch

## 0.5.0
## 0.5.0 - 2020-12-13

- changed Calendly::Client#scheduled_events behavior (refs #21)
- previous version:
Expand All @@ -102,7 +106,7 @@
- getting all events belonging to a specific ORGANIZATION
- added Calendly::Client#scheduled_events_by_user method instead_of the before behavior

## 0.4.2
## 0.4.2 - 2020-11-26

- added new following fields to Invitee model (refs #21)
- :rescheduled
Expand All @@ -111,59 +115,59 @@
- :cancel_url
- :reschedule_url

## 0.4.1
## 0.4.1 - 2020-11-22

- started to support a API
- `GET /event_types/{uuid}`

## 0.4.0
## 0.4.0 - 2020-11-21

- fixed a changes for Location fields such as `kind` to `type`. (refs #18)

## 0.3.0
## 0.3.0 - 2020-11-18

- removed zeitwerk dependency. (refs #16)

## 0.2.0
## 0.2.0 - 2020-09-18

- added caching features in object when fetching data. (refs #14)

## 0.1.3
## 0.1.3 - 2020-09-17

- support webhook APIs (refs #9)
- `GET /webhook_subscriptions`
- `GET /webhook_subscriptions/{webhook_uuid}`
- `POST /webhook_subscriptions`
- `DELETE /webhook_subscriptions/{webhook_uuid}`

## 0.1.2
## 0.1.2 - 2020-09-03

- fixed rubocop warnings.

## 0.1.1
## 0.1.1 - 2020-08-27

- added tests to make coverage 100%.

## 0.1.0
## 0.1.0 - 2020-08-25

- defined methods to access associated resources with each model.
- renamed methods:
- `Calendly::Client#events` to `Calendly::Client#scheduled_events`

## 0.0.7.alpha
## 0.0.7.alpha - 2020-08-23

- started to support APIs
- `POST /organizations/{uuid}/invitations`
- `DELETE /organizations/{org_uuid}/invitations/{invitation_uuid}`
- `DELETE /organization_memberships/{uuid}`

## 0.0.6.alpha
## 0.0.6.alpha - 2020-08-22

- started to support APIs
- `GET /organizations/{uuid}/invitations`
- `GET /organizations/{organization_uuid}/invitations/{invitation_uuid}`

## 0.0.5.alpha
## 0.0.5.alpha - 2020-08-22

- started to support APIs
- `GET /organization_memberships`
Expand All @@ -172,24 +176,24 @@
- Invitee#event to Invitee#event_uri
- Event#event_type to Event#event_type_uri

## 0.0.4.alpha
## 0.0.4.alpha - 2020-08-22

- started to support APIs
- `GET /scheduled_events/{event_uuid}/invitees`
- `GET /scheduled_events/{event_uuid}/invitees/{invitee_uuid}`

## 0.0.3.alpha
## 0.0.3.alpha - 2020-08-19

- started to support APIs
- `GET /scheduled_events`
- `GET /scheduled_events/{uuid}`

## 0.0.2.alpha
## 0.0.2.alpha - 2020-08-12

- started to support APIs
- `GET /event_types`

## 0.0.1.alpha
## 0.0.1.alpha - 2020-08-09

- Initial release
- started to support a API
Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Calendly
# A meeting that has been scheduled.
class Event
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[start_time end_time created_at updated_at].freeze
ASSOCIATION = {
event_type: EventType,
Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/event_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Calendly
# A configuration for a schedulable event.
class EventType
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/event_types/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/event_types/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[created_at updated_at].freeze
ASSOCIATION = {profile: EventTypeProfile, custom_questions: EventTypeCustomQuestion}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/invitee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Calendly
# An individual who has been invited to meet with a Calendly member.
class Invitee
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/\w+/invitees/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/#{UUID_FORMAT}/invitees/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[created_at updated_at].freeze
ASSOCIATION = {
event: Event,
Expand Down
4 changes: 4 additions & 0 deletions lib/calendly/models/model_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
module Calendly
# Calendly model utility.
module ModelUtils
# UUID's format is ASCII.
# refs to official release note of October 2021.
UUID_FORMAT = '[[:ascii:]]+'

# @param [Hash] attrs the attributes of the model.
# @param [Calendly::Client] the api client.
def initialize(attrs = nil, client = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Calendly
# Calendly's organization model.
class Organization
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/organizations/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/organizations/(#{UUID_FORMAT})\z}.freeze

# @return [String]
# unique id of the Organization object.
Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/organization_invitation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Calendly
# Calendly's organization invitation model.
class OrganizationInvitation
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/organizations/\w+/invitations/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/organizations/#{UUID_FORMAT}/invitations/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[created_at updated_at last_sent_at].freeze
ASSOCIATION = {user: User, organization: Organization}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/organization_membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Calendly
# Calendly's organization membership model.
class OrganizationMembership
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/organization_memberships/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/organization_memberships/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[created_at updated_at].freeze
ASSOCIATION = {user: User, organization: Organization}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Calendly
# Calendly's team model.
class Team
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/teams/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/teams/(#{UUID_FORMAT})\z}.freeze

# @return [String]
# unique id of the Team object.
Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Calendly
# Primary account details of a specific user.
class User
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/users/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/users/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[created_at updated_at].freeze
ASSOCIATION = {current_organization: Organization}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/models/webhook_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Calendly
# Calendly's webhook model.
class WebhookSubscription
include ModelUtils
UUID_RE = %r{\A#{Client::API_HOST}/webhook_subscriptions/(\w+)\z}.freeze
UUID_RE = %r{\A#{Client::API_HOST}/webhook_subscriptions/(#{UUID_FORMAT})\z}.freeze
TIME_FIELDS = %i[created_at updated_at retry_started_at].freeze
ASSOCIATION = {organization: Organization, user: User, creator: User}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/calendly/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Calendly
VERSION = '0.8.0'
VERSION = '0.8.1'
end
6 changes: 6 additions & 0 deletions test/models/event_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@ def test_that_it_returns_event_invitees_across_pages
assert_event201_invitee002 invs[1]
assert_event201_invitee001 invs[2]
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = '8c7f1091-37b9-42fb-bb25-760cfc5c3ad3'
uri = "#{HOST}/scheduled_events/#{uuid}"
assert_equal(uuid, Event.extract_uuid(uri))
end
end
end
6 changes: 6 additions & 0 deletions test/models/event_type_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ def test_that_it_creates_schedule_link
add_stub_request :post, url, req_body: req_body, res_body: res_body, res_status: 201
assert_schedule_link_001 @event_type.create_schedule_link(max_event_count: 3)
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = 'ff200bd6-af4b-4fd4-a110-e35b2bb5e7ab'
uri = "#{HOST}/event_types/#{uuid}"
assert_equal(uuid, EventType.extract_uuid(uri))
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setup

@inv_uuid = 'INV001'
@inv_uri = "#{event_uri}/invitees/#{@inv_uuid}"
attrs = { uri: @inv_uri, event: event_uri }
attrs = {uri: @inv_uri, event: event_uri}
@invitee = Invitee.new attrs, @client
@invitee_no_client = Invitee.new attrs
end
Expand All @@ -33,5 +33,12 @@ def test_that_it_returns_an_associated_invitee
add_stub_request :get, @inv_uri, res_body: res_body
assert_event301_invitee001 @invitee.fetch
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
ev_uuid = '71785b54-c482-4b2f-8dbd-45d7635a9d19'
uuid = '2da7f0a5-f79c-4a85-a55a-3b028ad14b94'
uri = "#{HOST}/scheduled_events/#{ev_uuid}/invitees/#{uuid}"
assert_equal(uuid, Invitee.extract_uuid(uri))
end
end
end
9 changes: 8 additions & 1 deletion test/models/organization_invitation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setup
org_uri = "#{HOST}/organizations/#{org_uuid}"
@inv_uuid = 'INV001'
@inv_uri = "#{org_uri}/invitations/#{@inv_uuid}"
attrs = { uri: @inv_uri, organization: org_uri }
attrs = {uri: @inv_uri, organization: org_uri}
@inv = OrganizationInvitation.new attrs, @client
@inv_no_client = OrganizationInvitation.new attrs
end
Expand All @@ -38,5 +38,12 @@ def test_that_it_deletes_self
result = @inv.delete
assert_equal true, result
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
org_uuid = '6dc5fbc7-fd4f-4680-af7d-2b4ec6f25748'
uuid = '495cdb33-7357-47ef-b69f-0f70a521f72d'
uri = "#{HOST}/organizations/#{org_uuid}/invitations/#{uuid}"
assert_equal(uuid, OrganizationInvitation.extract_uuid(uri))
end
end
end
6 changes: 6 additions & 0 deletions test/models/organization_membership_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,11 @@ def test_that_it_creates_user_scope_webhook_with_signing_key

assert_user_webhook_001 @mem.create_user_scope_webhook webhook_url, events, signing_key: signing_key
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = '7276e6ef-2282-4834-92ff-5eae3d5758a1'
uri = "#{HOST}/organization_memberships/#{uuid}"
assert_equal(uuid, OrganizationMembership.extract_uuid(uri))
end
end
end
6 changes: 6 additions & 0 deletions test/models/organization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,11 @@ def test_that_it_creates_webhook_with_signing_key

assert_org_webhook_001 @org.create_webhook webhook_url, events, signing_key: signing_key
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = '1624634d-0798-49df-80d6-d24b6718a5c6'
uri = "#{HOST}/organizations/#{uuid}"
assert_equal(uuid, Organization.extract_uuid(uri))
end
end
end
8 changes: 7 additions & 1 deletion test/models/team_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TeamTest < BaseTest
def setup
super
@team_uuid = 'T001'
@team_uri = "#{HOST}/users/#{@team_uuid}"
@team_uri = "#{HOST}/teams/#{@team_uuid}"
attrs = {uri: @team_uri}
@team = Team.new attrs, @client
@team_no_client = Team.new attrs
Expand All @@ -17,5 +17,11 @@ def setup
def test_it_returns_inspect_string
assert @team.inspect.start_with? '#<Calendly::Team:'
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = '4b0b25ba-2078-409a-ba27-a419c257c811'
uri = "#{HOST}/teams/#{uuid}"
assert_equal(uuid, Team.extract_uuid(uri))
end
end
end
6 changes: 6 additions & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,11 @@ def test_that_it_creates_user_scope_webhook_with_signing_key

assert_user_webhook_001 @user.create_webhook webhook_url, events, signing_key: signing_key
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = 'fff1e21e-05fb-4070-ad35-f8e1234177c4'
uri = "#{HOST}/users/#{uuid}"
assert_equal(uuid, User.extract_uuid(uri))
end
end
end
6 changes: 6 additions & 0 deletions test/models/webhook_subscription_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ def test_that_it_deletes_self
result = @webhook.delete
assert_equal true, result
end

def test_that_it_parses_uuid_be_formatted_ascii_from_uri
uuid = '64190761-e851-410f-9e0a-25cbeebfa550'
uri = "#{HOST}/webhook_subscriptions/#{uuid}"
assert_equal(uuid, WebhookSubscription.extract_uuid(uri))
end
end
end

0 comments on commit a3745e9

Please sign in to comment.