calendlyr 0.3.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/CHANGELOG.md +3 -27
  4. data/Gemfile +1 -5
  5. data/README.md +47 -20
  6. data/bin/console +3 -3
  7. data/{calendly.gemspec → calendlyr.gemspec} +3 -3
  8. data/lib/{calendly → calendlyr}/client.rb +9 -9
  9. data/lib/{calendly → calendlyr}/collection.rb +4 -1
  10. data/lib/{calendly → calendlyr}/error.rb +1 -1
  11. data/lib/{calendly → calendlyr}/object.rb +1 -1
  12. data/lib/{calendly → calendlyr}/objects/event_invitees.rb +1 -1
  13. data/lib/{calendly → calendlyr}/objects/event_types.rb +1 -1
  14. data/lib/{calendly → calendlyr}/objects/events.rb +1 -1
  15. data/lib/{calendly → calendlyr}/objects/invitations.rb +1 -1
  16. data/lib/{calendly → calendlyr}/objects/memberships.rb +1 -1
  17. data/lib/{calendly → calendlyr}/objects/organizations.rb +9 -1
  18. data/lib/{calendly → calendlyr}/objects/scheduling_links.rb +1 -1
  19. data/lib/{calendly → calendlyr}/objects/users.rb +1 -1
  20. data/lib/{calendly → calendlyr}/objects/webhooks.rb +1 -1
  21. data/lib/{calendly → calendlyr}/resource.rb +13 -25
  22. data/lib/{calendly → calendlyr}/resources/data_compliance.rb +1 -1
  23. data/lib/{calendly → calendlyr}/resources/event_invitees.rb +1 -1
  24. data/lib/{calendly → calendlyr}/resources/event_types.rb +1 -1
  25. data/lib/{calendly → calendlyr}/resources/events.rb +1 -1
  26. data/lib/{calendly → calendlyr}/resources/organizations.rb +2 -2
  27. data/lib/{calendly → calendlyr}/resources/scheduling_links.rb +1 -1
  28. data/lib/{calendly → calendlyr}/resources/users.rb +1 -1
  29. data/lib/{calendly → calendlyr}/resources/webhooks.rb +1 -1
  30. data/lib/calendlyr/version.rb +3 -0
  31. data/lib/calendlyr.rb +30 -0
  32. data/test/calendlyr/client_test.rb +11 -0
  33. data/test/calendlyr/object_test.rb +21 -0
  34. data/test/calendlyr/resource_test.rb +14 -0
  35. data/test/{calendly/resources/data_compliance.rb → calendlyr/resources/data_compliance_test.rb} +0 -0
  36. data/test/{calendly → calendlyr}/resources/event_invitees_test.rb +3 -3
  37. data/test/{calendly → calendlyr}/resources/event_types_test.rb +3 -3
  38. data/test/{calendly → calendlyr}/resources/events_test.rb +3 -3
  39. data/test/{calendly → calendlyr}/resources/organizations_test.rb +41 -26
  40. data/test/calendlyr/resources/scheduling_links_test.rb +15 -0
  41. data/test/{calendly → calendlyr}/resources/users_test.rb +24 -12
  42. data/test/{calendly → calendlyr}/resources/webhooks_test.rb +8 -5
  43. data/test/{calendly_test.rb → calendlyr_test.rb} +2 -2
  44. data/test/fixtures/organizations/invite.json +9 -7
  45. data/test/fixtures/organizations/list_invitations.json +1 -1
  46. data/test/fixtures/organizations/retrieve_invitation.json +1 -1
  47. data/test/fixtures/resources/400.json +10 -0
  48. data/test/fixtures/resources/401.json +10 -0
  49. data/test/fixtures/resources/403.json +10 -0
  50. data/test/fixtures/resources/404.json +10 -0
  51. data/test/fixtures/resources/409.json +4 -0
  52. data/test/fixtures/resources/500.json +10 -0
  53. data/test/fixtures/users/reload.json +14 -0
  54. data/test/test_helper.rb +9 -3
  55. metadata +67 -51
  56. data/lib/calendly/version.rb +0 -3
  57. data/lib/calendly.rb +0 -35
  58. data/test/calendly/client_test.rb +0 -8
  59. data/test/calendly/object_test.rb +0 -21
  60. data/test/calendly/resources/scheduling_links.rb +0 -12
@@ -10,8 +10,8 @@ class EventTypesResourceTest < Minitest::Test
10
10
  stub(path: "event_types?user=#{user_uri}&organization=#{organization_uri}", response: response)
11
11
  event_types = client.event_types.list(user_uri: user_uri, organization_uri: organization_uri)
12
12
 
13
- assert_equal Calendly::Collection, event_types.class
14
- assert_equal Calendly::EventType, event_types.data.first.class
13
+ assert_equal Calendlyr::Collection, event_types.class
14
+ assert_equal Calendlyr::EventType, event_types.data.first.class
15
15
  assert_equal 1, event_types.count
16
16
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", event_types.next_page_token
17
17
  end
@@ -22,7 +22,7 @@ class EventTypesResourceTest < Minitest::Test
22
22
  stub(path: "event_types/#{event_type_uuid}", response: response)
23
23
  event_type = client.event_types.retrieve(event_type_uuid: event_type_uuid)
24
24
 
25
- assert_equal Calendly::EventType, event_type.class
25
+ assert_equal Calendlyr::EventType, event_type.class
26
26
  assert_equal "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA", event_type.uri
27
27
  assert_equal "15 Minute Meeting", event_type.name
28
28
  assert_equal "acmesales", event_type.slug
@@ -10,8 +10,8 @@ class EventsResourceTest < Minitest::Test
10
10
  stub(path: "scheduled_events?user=#{user_uri}&organization=#{organization_uri}", response: response)
11
11
  events = client.events.list(user_uri: user_uri, organization_uri: organization_uri)
12
12
 
13
- assert_equal Calendly::Collection, events.class
14
- assert_equal Calendly::Event, events.data.first.class
13
+ assert_equal Calendlyr::Collection, events.class
14
+ assert_equal Calendlyr::Event, events.data.first.class
15
15
  assert_equal 1, events.count
16
16
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", events.next_page_token
17
17
  end
@@ -22,7 +22,7 @@ class EventsResourceTest < Minitest::Test
22
22
  stub(path: "scheduled_events/#{event_uuid}", response: response)
23
23
  event = client.events.retrieve(event_uuid: event_uuid)
24
24
 
25
- assert_equal Calendly::Event, event.class
25
+ assert_equal Calendlyr::Event, event.class
26
26
  assert_equal "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2", event.uri
27
27
  assert_equal "15 Minute Meeting", event.name
28
28
  end
@@ -11,7 +11,7 @@ class OrganizationsResourceTest < Minitest::Test
11
11
 
12
12
  invitation = client.organizations.invite(organization_uuid: organization_uuid, email: email)
13
13
 
14
- assert_equal Calendly::Invitation, invitation.class
14
+ assert_equal Calendlyr::Invitation, invitation.class
15
15
  assert_equal email, invitation.email
16
16
  end
17
17
 
@@ -21,8 +21,8 @@ class OrganizationsResourceTest < Minitest::Test
21
21
  stub(path: "organizations/#{organization_uuid}/invitations", response: response)
22
22
  invitations = client.organizations.list_invitations(organization_uuid: organization_uuid)
23
23
 
24
- assert_equal Calendly::Collection, invitations.class
25
- assert_equal Calendly::Invitation, invitations.data.first.class
24
+ assert_equal Calendlyr::Collection, invitations.class
25
+ assert_equal Calendlyr::Invitation, invitations.data.first.class
26
26
  assert_equal 1, invitations.count
27
27
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", invitations.next_page_token
28
28
  end
@@ -34,31 +34,53 @@ class OrganizationsResourceTest < Minitest::Test
34
34
  stub(path: "organization_memberships?user=#{user_uri}&organization=#{organization_uri}", response: response)
35
35
  memberships = client.organizations.list_memberships(user_uri: user_uri, organization_uri: organization_uri)
36
36
 
37
- assert_equal Calendly::Collection, memberships.class
38
- assert_equal Calendly::Membership, memberships.data.first.class
37
+ assert_equal Calendlyr::Collection, memberships.class
38
+ assert_equal Calendlyr::Membership, memberships.data.first.class
39
39
  assert_equal 1, memberships.count
40
40
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token
41
41
  end
42
42
 
43
+ def test_list_webhooks
44
+ stub(path: "webhook_subscriptions?organization=#{client.organization.uri}&scope=user", response: {body: fixture_file("webhooks/list"), status: 200})
45
+ webhooks = client.organization.list_webhooks(scope: "user")
46
+
47
+ assert_equal Calendlyr::Collection, webhooks.class
48
+ assert_equal Calendlyr::Webhook, webhooks.data.first.class
49
+ assert_equal 1, webhooks.count
50
+ assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", webhooks.next_page_token
51
+ end
52
+
53
+ def test_create_webhook
54
+ body = {url: "https://blah.foo/bar", events: ["invitee.created"], organization: client.organization.uri, scope: "user", user: client.me.uri}
55
+ stub(method: :post, path: "webhook_subscriptions", body: body, response: {body: fixture_file("webhooks/create"), status: 201})
56
+
57
+ assert client.webhooks.create(url: body[:url], events: body[:events], organization_uri: body[:organization], scope: body[:scope], user_uri: body[:user])
58
+ end
59
+
43
60
  def test_retrieve_invitation
44
- organization_uuid = "AAAAAAAAAAAAAAAA"
45
61
  invitation_uuid = "AAAAAAAAAAAAAAAA"
46
- response = {body: fixture_file("organizations/retrieve_invitation"), status: 200}
47
- stub(path: "organizations/#{organization_uuid}/invitations/#{invitation_uuid}", response: response)
48
- invitation = client.organizations.retrieve_invitation(organization_uuid: organization_uuid, invitation_uuid: invitation_uuid)
49
62
 
50
- assert_equal Calendly::Invitation, invitation.class
63
+ stub(path: "organizations/#{client.organization.uuid}/invitations/#{invitation_uuid}", response: {body: fixture_file("organizations/retrieve_invitation"), status: 200})
64
+ stub(method: :delete, path: "organizations/#{client.organization.uuid}/invitations/#{invitation_uuid}", response: {body: fixture_file("organizations/revoke_invitation")})
65
+ invitation = client.organizations.retrieve_invitation(organization_uuid: client.organization.uuid, invitation_uuid: invitation_uuid)
66
+
67
+ assert_equal Calendlyr::Invitation, invitation.class
51
68
  assert_equal "test@example.com", invitation.email
69
+
70
+ assert invitation.associated_organization
71
+ assert invitation.revoke
52
72
  end
53
73
 
54
74
  def test_retrieve_membership
55
75
  membership_uuid = "AAAAAAAAAAAAAAAA"
56
76
  response = {body: fixture_file("organizations/retrieve_membership"), status: 200}
57
77
  stub(path: "organization_memberships/#{membership_uuid}", response: response)
78
+ stub(path: "users/#{membership_uuid}", response: {body: fixture_file("users/retrieve"), status: 200})
58
79
  membership = client.organizations.retrieve_membership(membership_uuid: membership_uuid)
59
80
 
60
- assert_equal Calendly::Membership, membership.class
81
+ assert_equal Calendlyr::Membership, membership.class
61
82
  assert_equal "test@example.com", membership.user.email
83
+ assert_equal membership.associated_user, client.users.retrieve(user_uuid: membership_uuid)
62
84
  end
63
85
 
64
86
  def test_revoke_invitation
@@ -77,63 +99,56 @@ class OrganizationsResourceTest < Minitest::Test
77
99
  end
78
100
 
79
101
  def test_organization_invite_user
80
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
81
-
82
102
  email = "email@example.com"
83
103
  response = {body: fixture_file("organizations/invite"), status: 201}
84
104
  stub(method: :post, path: "organizations/#{client.organization.uuid}/invitations", body: {email: email}, response: response)
85
105
 
86
106
  invitation = client.organization.invite_user(email: email)
87
107
 
88
- assert_equal Calendly::Invitation, invitation.class
108
+ assert_equal Calendlyr::Invitation, invitation.class
89
109
  assert_equal email, invitation.email
90
110
  end
91
111
 
92
112
  def test_organization_list_invitations
93
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
94
113
  stub(path: "organizations/#{client.organization.uuid}/invitations", response: {body: fixture_file("organizations/list_invitations"), status: 200})
95
114
  invitations = client.organization.list_invitations
96
115
 
97
- assert_equal Calendly::Collection, invitations.class
98
- assert_equal Calendly::Invitation, invitations.data.first.class
116
+ assert_equal Calendlyr::Collection, invitations.class
117
+ assert_equal Calendlyr::Invitation, invitations.data.first.class
99
118
  assert_equal 1, invitations.count
100
119
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", invitations.next_page_token
101
120
  end
102
121
 
103
122
  def test_organization_revoke_invitation
104
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
105
123
  stub(method: :delete, path: "organizations/#{client.organization.uuid}/invitations/AAAAAAAAAAAAAAAA", response: {body: fixture_file("organizations/revoke_invitation")})
106
124
  assert client.organization.revoke_invitation(invitation_uuid: "AAAAAAAAAAAAAAAA")
107
125
  end
108
126
 
109
127
  def test_organization_invitation
110
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
111
128
  response = {body: fixture_file("organizations/retrieve_invitation"), status: 200}
112
129
  stub(path: "organizations/#{client.organization.uuid}/invitations/AAAAAAAAAAAAAAAA", response: response)
113
130
  invitation = client.organization.invitation(invitation_uuid: "AAAAAAAAAAAAAAAA")
114
131
 
115
- assert_equal Calendly::Invitation, invitation.class
132
+ assert_equal Calendlyr::Invitation, invitation.class
116
133
  assert_equal "test@example.com", invitation.email
117
134
  end
118
135
 
119
136
  def test_organization_events
120
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
121
137
  stub(path: "scheduled_events?organization=#{client.organization.uri}", response: {body: fixture_file("events/list"), status: 200})
122
138
  events = client.organization.events
123
139
 
124
- assert_equal Calendly::Collection, events.class
125
- assert_equal Calendly::Event, events.data.first.class
140
+ assert_equal Calendlyr::Collection, events.class
141
+ assert_equal Calendlyr::Event, events.data.first.class
126
142
  assert_equal 1, events.count
127
143
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", events.next_page_token
128
144
  end
129
145
 
130
146
  def test_organization_memberships
131
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
132
147
  stub(path: "organization_memberships?organization=#{client.organization.uri}", response: {body: fixture_file("organizations/list_memberships"), status: 200})
133
148
  memberships = client.organization.memberships
134
149
 
135
- assert_equal Calendly::Collection, memberships.class
136
- assert_equal Calendly::Membership, memberships.data.first.class
150
+ assert_equal Calendlyr::Collection, memberships.class
151
+ assert_equal Calendlyr::Membership, memberships.data.first.class
137
152
  assert_equal 1, memberships.count
138
153
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token
139
154
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SchedulingLinksResourceTest < Minitest::Test
6
+ def test_create
7
+ owner_uri = "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2"
8
+ max_event_count = 20
9
+ owner_type = "EventType"
10
+ response = {body: fixture_file("scheduling_links/create"), status: 201}
11
+ stub(method: :post, path: "scheduling_links", body: {owner: owner_uri, max_event_count: max_event_count, owner_type: owner_type}, response: response)
12
+
13
+ assert client.scheduling_links.create(owner_uri: owner_uri, max_event_count: max_event_count, owner_type: owner_type)
14
+ end
15
+ end
@@ -9,7 +9,7 @@ class UsersResourceTest < Minitest::Test
9
9
  stub(path: "users/#{user_uuid}", response: response)
10
10
  user = client.users.retrieve(user_uuid: user_uuid)
11
11
 
12
- assert_equal Calendly::User, user.class
12
+ assert_equal Calendlyr::User, user.class
13
13
  assert_equal "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", user.uri
14
14
  assert_equal "John Doe", user.name
15
15
  assert_equal "acmesales", user.slug
@@ -21,58 +21,70 @@ class UsersResourceTest < Minitest::Test
21
21
  stub(path: "users/me", response: response)
22
22
  me = client.me
23
23
 
24
- assert_equal Calendly::User, me.class
24
+ assert_equal Calendlyr::User, me.class
25
25
  assert_equal "https://api.calendly.com/users/AAAAAAAAAAAAAAAA", me.uri
26
26
  assert_equal "John Doe", me.name
27
27
  assert_equal "acmesales", me.slug
28
28
  assert_equal "test@example.com", me.email
29
29
  end
30
30
 
31
+ def test_me_caching
32
+ response = {body: fixture_file("users/retrieve"), status: 200}
33
+ stub = stub(path: "users/me", response: response)
34
+ me = client.me
35
+ remove_request_stub(stub)
36
+ assert_equal client.me, me
37
+ end
38
+
39
+ def test_me_caching_reload
40
+ me = client.me
41
+ stub(path: "users/me", response: {body: fixture_file("users/reload"), status: 200})
42
+ reloaded_me = client.me(force_reload: true)
43
+ assert me.name != reloaded_me.name
44
+ end
45
+
31
46
  def test_organization
32
47
  response = {body: fixture_file("users/retrieve"), status: 200}
33
48
  stub(path: "users/me", response: response)
34
49
  organization = client.organization
35
50
 
36
- assert_equal Calendly::Organization, organization.class
51
+ assert_equal Calendlyr::Organization, organization.class
37
52
  assert_equal "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA", organization.uri
38
53
  assert_equal "AAAAAAAAAAAAAAAA", organization.uuid
39
54
  end
40
55
 
41
56
  def test_event_types
42
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
43
57
  me = client.me
44
58
 
45
59
  stub(path: "event_types?user=#{me.uri}&organization=#{me.organization.uri}", response: {body: fixture_file("event_types/list"), status: 200})
46
60
  event_types = client.me.event_types
47
61
 
48
- assert_equal Calendly::Collection, event_types.class
49
- assert_equal Calendly::EventType, event_types.data.first.class
62
+ assert_equal Calendlyr::Collection, event_types.class
63
+ assert_equal Calendlyr::EventType, event_types.data.first.class
50
64
  assert_equal 1, event_types.count
51
65
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", event_types.next_page_token
52
66
  end
53
67
 
54
68
  def test_events
55
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
56
69
  me = client.me
57
70
 
58
71
  stub(path: "scheduled_events?user=#{me.uri}&organization=#{me.organization.uri}", response: {body: fixture_file("events/list"), status: 200})
59
72
  events = client.me.events
60
73
 
61
- assert_equal Calendly::Collection, events.class
62
- assert_equal Calendly::Event, events.data.first.class
74
+ assert_equal Calendlyr::Collection, events.class
75
+ assert_equal Calendlyr::Event, events.data.first.class
63
76
  assert_equal 1, events.count
64
77
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", events.next_page_token
65
78
  end
66
79
 
67
80
  def test_memberships
68
- stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
69
81
  me = client.me
70
82
 
71
83
  stub(path: "organization_memberships?user=#{me.uri}&organization=#{me.organization.uri}", response: {body: fixture_file("organizations/list_memberships"), status: 200})
72
84
  memberships = client.me.memberships(organization_uri: me.organization.uri)
73
85
 
74
- assert_equal Calendly::Collection, memberships.class
75
- assert_equal Calendly::Membership, memberships.data.first.class
86
+ assert_equal Calendlyr::Collection, memberships.class
87
+ assert_equal Calendlyr::Membership, memberships.data.first.class
76
88
  assert_equal 1, memberships.count
77
89
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", memberships.next_page_token
78
90
  end
@@ -10,8 +10,8 @@ class WebhooksResourceTest < Minitest::Test
10
10
  stub(path: "webhook_subscriptions?organization=#{organization_uri}&scope=#{scope}", response: response)
11
11
  webhooks = client.webhooks.list(organization_uri: organization_uri, scope: scope)
12
12
 
13
- assert_equal Calendly::Collection, webhooks.class
14
- assert_equal Calendly::Webhook, webhooks.data.first.class
13
+ assert_equal Calendlyr::Collection, webhooks.class
14
+ assert_equal Calendlyr::Webhook, webhooks.data.first.class
15
15
  assert_equal 1, webhooks.count
16
16
  assert_equal "sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi", webhooks.next_page_token
17
17
  end
@@ -21,16 +21,19 @@ class WebhooksResourceTest < Minitest::Test
21
21
  stub(method: :post, path: "webhook_subscriptions", body: body, response: {body: fixture_file("webhooks/create"), status: 201})
22
22
 
23
23
  assert client.webhooks.create(url: body[:url], events: body[:events], organization_uri: body[:organization], scope: body[:scope], user_uri: body[:user])
24
+ assert client.organization.create_webhook(url: body[:url], events: body[:events], scope: body[:scope], user_uri: body[:user])
24
25
  end
25
26
 
26
27
  def test_retrieve
27
28
  webhook_uuid = "AAAAAAAAAAAAAAAA"
28
- response = {body: fixture_file("webhooks/retrieve"), status: 200}
29
- stub(path: "webhook_subscriptions/#{webhook_uuid}", response: response)
29
+ stub(path: "webhook_subscriptions/#{webhook_uuid}", response: {body: fixture_file("webhooks/retrieve"), status: 200})
30
+ stub(path: "users/AAAAAAAAAAAAAAAA", response: {body: fixture_file("users/retrieve"), status: 200})
30
31
  webhook = client.webhooks.retrieve(webhook_uuid: webhook_uuid)
31
32
 
32
- assert_equal Calendly::Webhook, webhook.class
33
+ assert_equal Calendlyr::Webhook, webhook.class
33
34
  assert_equal "user", webhook.scope
35
+ assert_equal webhook.associated_user, client.users.retrieve(user_uuid: "AAAAAAAAAAAAAAAA")
36
+ assert_equal webhook.associated_organization, client.users.retrieve(user_uuid: "AAAAAAAAAAAAAAAA").organization
34
37
  end
35
38
 
36
39
  def test_delete
@@ -1,7 +1,7 @@
1
1
  require "test_helper"
2
2
 
3
- class CalendlyTest < Minitest::Test
3
+ class CalendlyrTest < Minitest::Test
4
4
  def test_that_it_has_a_version_number
5
- refute_nil ::Calendly::VERSION
5
+ refute_nil ::Calendlyr::VERSION
6
6
  end
7
7
  end
@@ -1,9 +1,11 @@
1
1
  {
2
- "created_at": "2020-01-01T20:30:00Z",
3
- "email": "email@example.com",
4
- "last_sent_at": "2020-01-01T20:30:00Z",
5
- "organization": "https://api.calendly.com/organizations/ABCDABCDABCDABCD",
6
- "status": "pending",
7
- "updated_at": "2020-01-01T20:30:00Z",
8
- "uri": "https://api.calendly.com/organizations/ABCDABCDABCDABCD/invitations/DCBADCBADCBADCBA"
2
+ "resource": {
3
+ "created_at": "2020-01-01T20:30:00Z",
4
+ "email": "email@example.com",
5
+ "last_sent_at": "2020-01-01T20:30:00Z",
6
+ "organization": "https://api.calendly.com/organizations/ABCDABCDABCDABCD",
7
+ "status": "pending",
8
+ "updated_at": "2020-01-01T20:30:00Z",
9
+ "uri": "https://api.calendly.com/organizations/ABCDABCDABCDABCD/invitations/DCBADCBADCBADCBA"
10
+ }
9
11
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "collection": [
3
3
  {
4
- "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations",
4
+ "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/AAAAAAAAAAAAAAAA",
5
5
  "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
6
6
  "email": "test@example.com",
7
7
  "status": "accepted",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "resource": {
3
- "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations",
3
+ "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/AAAAAAAAAAAAAAAA",
4
4
  "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
5
5
  "email": "test@example.com",
6
6
  "status": "accepted",
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Unauthenticated",
3
+ "message": "The access token is invalid",
4
+ "details": [
5
+ {
6
+ "parameter": "string",
7
+ "message": "string"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Invalid Argument",
3
+ "message": "The supplied parameters are invalid.",
4
+ "details": [
5
+ {
6
+ "parameter": "string",
7
+ "message": "string"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Permission Denied",
3
+ "message": "This user is not in your organization",
4
+ "details": [
5
+ {
6
+ "parameter": "string",
7
+ "message": "string"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Resource Not Found",
3
+ "message": "The server could not find the requested resource.",
4
+ "details": [
5
+ {
6
+ "parameter": "string",
7
+ "message": "string"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "title": "Already Exists",
3
+ "message": "Hook with this url already exists"
4
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Internal Server Error",
3
+ "message": "The server encountered an unexpected condition that prevented it from fulfilling the request.",
4
+ "details": [
5
+ {
6
+ "parameter": "string",
7
+ "message": "string"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "resource": {
3
+ "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
4
+ "name": "John Doe Reloaded",
5
+ "slug": "acmesales",
6
+ "email": "test@example.com",
7
+ "scheduling_url": "https://calendly.com/acmesales",
8
+ "timezone": "America/New York",
9
+ "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png",
10
+ "created_at": "2019-01-02T03:04:05.678Z",
11
+ "updated_at": "2019-08-07T06:05:04.321Z",
12
+ "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA"
13
+ }
14
+ }
data/test/test_helper.rb CHANGED
@@ -6,13 +6,18 @@ if ENV["CI"] == "true"
6
6
  require "codecov"
7
7
  SimpleCov.formatter = SimpleCov::Formatter::Codecov
8
8
  end
9
- require "calendly"
9
+ require "calendlyr"
10
10
  require "minitest/autorun"
11
11
  require "webmock/minitest"
12
12
 
13
13
  class Minitest::Test
14
+ def initialize(name)
15
+ stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
16
+ super
17
+ end
18
+
14
19
  def client
15
- Calendly::Client.new(api_key: "fake")
20
+ @client ||= Calendlyr::Client.new(token: "fake")
16
21
  end
17
22
 
18
23
  def fixture_file(fixture)
@@ -20,8 +25,9 @@ class Minitest::Test
20
25
  end
21
26
 
22
27
  def stub(path:, method: :get, body: {}, response: {})
23
- stub_req = stub_request(method, "#{Calendly::Client::BASE_URL}/#{path}")
28
+ stub_req = stub_request(method, "#{Calendlyr::Client::BASE_URL}/#{path}")
24
29
  stub_req.with(body: body) if [:post, :put, :patch].include?(method)
25
30
  stub_req.to_return(**response)
31
+ stub_req
26
32
  end
27
33
  end