calendlyr 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +7 -8
  3. data/CHANGELOG.md +2 -2
  4. data/README.md +46 -127
  5. data/calendlyr.gemspec +0 -1
  6. data/docs/resources/activity_log/list_activity_log_entries.md +34 -0
  7. data/docs/resources/availabilities/availability_rule.md +5 -0
  8. data/docs/resources/availabilities/user_availability_schedule.md +50 -0
  9. data/docs/resources/availabilities/user_busy_time.md +28 -0
  10. data/docs/resources/data_compliance.md +19 -0
  11. data/docs/resources/event_types/available_time.md +21 -0
  12. data/docs/resources/event_types/event_type.md +55 -0
  13. data/docs/resources/event_types/membership.md +29 -0
  14. data/docs/resources/event_types/profile.md +13 -0
  15. data/docs/resources/events/cancellation.md +18 -0
  16. data/docs/resources/events/event.md +62 -0
  17. data/docs/resources/events/guest.md +5 -0
  18. data/docs/resources/events/invitee.md +28 -0
  19. data/docs/resources/events/invitee_no_show.md +49 -0
  20. data/docs/resources/groups/group.md +56 -0
  21. data/docs/resources/groups/relationship.md +54 -0
  22. data/docs/resources/organizations/invitation.md +65 -0
  23. data/docs/resources/organizations/membership.md +58 -0
  24. data/docs/resources/organizations/organization.md +149 -0
  25. data/docs/resources/pagination.md +21 -0
  26. data/docs/resources/routing_forms/routing_form.md +48 -0
  27. data/docs/resources/routing_forms/submission.md +40 -0
  28. data/docs/resources/scheduling_link.md +26 -0
  29. data/docs/resources/share.md +28 -0
  30. data/docs/resources/user.md +111 -0
  31. data/docs/resources/webhooks/invitee_payload.md +42 -0
  32. data/docs/resources/webhooks/payload.md +5 -0
  33. data/docs/resources/webhooks/subscription.md +96 -0
  34. data/lib/calendlyr/client.rb +18 -2
  35. data/lib/calendlyr/collection.rb +2 -2
  36. data/lib/calendlyr/error.rb +42 -1
  37. data/lib/calendlyr/object.rb +6 -2
  38. data/lib/calendlyr/objects/activity_log.rb +11 -0
  39. data/lib/calendlyr/objects/availabilities/rule.rb +4 -0
  40. data/lib/calendlyr/objects/availabilities/user_busy_time.rb +7 -0
  41. data/lib/calendlyr/objects/availabilities/user_schedule.rb +13 -0
  42. data/lib/calendlyr/objects/event.rb +11 -0
  43. data/lib/calendlyr/objects/event_type.rb +15 -0
  44. data/lib/calendlyr/objects/event_types/available_time.rb +4 -0
  45. data/lib/calendlyr/objects/event_types/membership.rb +11 -0
  46. data/lib/calendlyr/objects/event_types/profile.rb +7 -0
  47. data/lib/calendlyr/objects/events/cancellation.rb +4 -0
  48. data/lib/calendlyr/objects/events/guest.rb +4 -0
  49. data/lib/calendlyr/objects/events/invitee.rb +11 -0
  50. data/lib/calendlyr/objects/events/invitee_no_show.rb +7 -0
  51. data/lib/calendlyr/objects/group.rb +15 -0
  52. data/lib/calendlyr/objects/groups/relationship.rb +15 -0
  53. data/lib/calendlyr/objects/organization.rb +67 -0
  54. data/lib/calendlyr/objects/organizations/invitation.rb +15 -0
  55. data/lib/calendlyr/objects/organizations/membership.rb +15 -0
  56. data/lib/calendlyr/objects/routing_form.rb +11 -0
  57. data/lib/calendlyr/objects/routing_forms/submission.rb +7 -0
  58. data/lib/calendlyr/objects/scheduling_link.rb +9 -0
  59. data/lib/calendlyr/objects/share.rb +9 -0
  60. data/lib/calendlyr/objects/user.rb +31 -0
  61. data/lib/calendlyr/objects/webhooks/invitee_payload.rb +15 -0
  62. data/lib/calendlyr/objects/webhooks/payload.rb +4 -0
  63. data/lib/calendlyr/objects/webhooks/subscription.rb +23 -0
  64. data/lib/calendlyr/resource.rb +2 -2
  65. data/lib/calendlyr/resources/availability.rb +19 -0
  66. data/lib/calendlyr/resources/data_compliance.rb +4 -0
  67. data/lib/calendlyr/resources/event.rb +40 -0
  68. data/lib/calendlyr/resources/event_type.rb +28 -0
  69. data/lib/calendlyr/resources/group.rb +22 -0
  70. data/lib/calendlyr/resources/organization.rb +40 -0
  71. data/lib/calendlyr/resources/outgoing_communication.rb +8 -0
  72. data/lib/calendlyr/resources/routing_form.rb +22 -0
  73. data/lib/calendlyr/resources/{scheduling_links.rb → scheduling_link.rb} +2 -2
  74. data/lib/calendlyr/resources/share.rb +8 -0
  75. data/lib/calendlyr/resources/user.rb +11 -0
  76. data/lib/calendlyr/resources/webhook.rb +25 -0
  77. data/lib/calendlyr/version.rb +1 -1
  78. data/lib/calendlyr.rb +70 -18
  79. data/test/calendlyr/objects/activity_log_test.rb +26 -0
  80. data/test/calendlyr/objects/availabilities/rule_test.rb +24 -0
  81. data/test/calendlyr/objects/availabilities/user_busy_time_test.rb +21 -0
  82. data/test/calendlyr/objects/availabilities/user_schedule_test.rb +26 -0
  83. data/test/calendlyr/objects/event_test.rb +32 -0
  84. data/test/calendlyr/objects/event_type_test.rb +43 -0
  85. data/test/calendlyr/objects/event_types/available_time_test.rb +20 -0
  86. data/test/calendlyr/objects/event_types/membership_test.rb +32 -0
  87. data/test/calendlyr/objects/event_types/profile_test.rb +23 -0
  88. data/test/calendlyr/objects/events/cancellation_test.rb +16 -0
  89. data/test/calendlyr/objects/events/guest_test.rb +16 -0
  90. data/test/calendlyr/objects/events/invitee_no_show_test.rb +23 -0
  91. data/test/calendlyr/objects/events/invitee_test.rb +35 -0
  92. data/test/calendlyr/objects/group_test.rb +40 -0
  93. data/test/calendlyr/objects/groups/relationship_test.rb +43 -0
  94. data/test/calendlyr/objects/organization_test.rb +157 -0
  95. data/test/calendlyr/objects/organizations/invitation_test.rb +34 -0
  96. data/test/calendlyr/objects/organizations/membership_test.rb +38 -0
  97. data/test/calendlyr/objects/routing_form_test.rb +26 -0
  98. data/test/calendlyr/objects/routing_forms/submission_test.rb +22 -0
  99. data/test/calendlyr/objects/scheduling_link_test.rb +17 -0
  100. data/test/calendlyr/objects/share_test.rb +19 -0
  101. data/test/calendlyr/objects/user_test.rb +81 -0
  102. data/test/calendlyr/objects/webhooks/invite_payload_test.rb +42 -0
  103. data/test/calendlyr/objects/webhooks/payload_test.rb +16 -0
  104. data/test/calendlyr/objects/webhooks/subscription_test.rb +42 -0
  105. data/test/calendlyr/resource_test.rb +12 -3
  106. data/test/calendlyr/resources/availabilities/user_busy_times_test.rb +31 -0
  107. data/test/calendlyr/resources/availabilities/user_schedules_test.rb +37 -0
  108. data/test/calendlyr/resources/data_compliance_test.rb +11 -0
  109. data/test/calendlyr/resources/event_types/membership_test.rb +22 -0
  110. data/test/calendlyr/resources/event_types_test.rb +55 -10
  111. data/test/calendlyr/resources/events/invitee_test.rb +31 -0
  112. data/test/calendlyr/resources/events_test.rb +22 -10
  113. data/test/calendlyr/resources/groups_test.rb +26 -0
  114. data/test/calendlyr/resources/organizations_test.rb +36 -100
  115. data/test/calendlyr/resources/outgoing_communications_test.rb +16 -0
  116. data/test/calendlyr/resources/scheduling_links_test.rb +1 -1
  117. data/test/calendlyr/resources/users_test.rb +9 -33
  118. data/test/calendlyr/resources/webhooks_test.rb +22 -13
  119. data/test/fixtures/activity_log/list.json +38 -0
  120. data/test/fixtures/availabilities/user_busy_times_list.json +39 -0
  121. data/test/fixtures/availabilities/user_schedules_list.json +93 -0
  122. data/test/fixtures/availabilities/user_schedules_retrieve.json +22 -0
  123. data/test/fixtures/data_compliance/delete_scheduled_event_data.json +1 -0
  124. data/test/fixtures/event_invitees/list.json +6 -6
  125. data/test/fixtures/event_invitees/retrieve.json +3 -3
  126. data/test/fixtures/event_type_available_times/list.json +22 -0
  127. data/test/fixtures/event_type_hosts/list.json +76 -0
  128. data/test/fixtures/event_types/create_one_off.json +45 -0
  129. data/test/fixtures/event_types/list.json +18 -4
  130. data/test/fixtures/event_types/retrieve.json +13 -2
  131. data/test/fixtures/events/cancel_invitee.json +8 -0
  132. data/test/fixtures/events/create_invitee_no_show.json +7 -0
  133. data/test/fixtures/events/delete_invitee_no_show.json +1 -0
  134. data/test/fixtures/events/retrieve_invitee_no_show.json +7 -0
  135. data/test/fixtures/group_relationships/list.json +83 -0
  136. data/test/fixtures/group_relationships/retrieve.json +29 -0
  137. data/test/fixtures/groups/list.json +19 -0
  138. data/test/fixtures/groups/retrieve.json +9 -0
  139. data/test/fixtures/objects/activity_log.json +24 -0
  140. data/test/fixtures/objects/availabilities/rule.json +10 -0
  141. data/test/fixtures/objects/availabilities/user_busy_time.json +10 -0
  142. data/test/fixtures/objects/availabilities/user_schedule.json +69 -0
  143. data/test/fixtures/objects/availability_rule.json +10 -0
  144. data/test/fixtures/objects/event.json +36 -0
  145. data/test/fixtures/objects/event_type.json +91 -0
  146. data/test/fixtures/objects/event_type_host.json +65 -0
  147. data/test/fixtures/objects/event_types/available_time.json +6 -0
  148. data/test/fixtures/objects/event_types/membership.json +65 -0
  149. data/test/fixtures/objects/event_types/profile.json +5 -0
  150. data/test/fixtures/objects/events/cancellation.json +6 -0
  151. data/test/fixtures/objects/events/guest.json +5 -0
  152. data/test/fixtures/objects/events/invitee.json +46 -0
  153. data/test/fixtures/objects/events/invitee_no_show.json +5 -0
  154. data/test/fixtures/objects/group.json +7 -0
  155. data/test/fixtures/objects/groups/relationship.json +27 -0
  156. data/test/fixtures/objects/organization.json +8 -0
  157. data/test/fixtures/objects/organizations/invitation.json +10 -0
  158. data/test/fixtures/objects/organizations/membership.json +18 -0
  159. data/test/fixtures/objects/routing_form.json +28 -0
  160. data/test/fixtures/objects/routing_forms/submission.json +27 -0
  161. data/test/fixtures/objects/scheduling_links/event_type.json +5 -0
  162. data/test/fixtures/objects/share.json +43 -0
  163. data/test/fixtures/objects/user.json +13 -0
  164. data/test/fixtures/objects/webhooks/invite_payload.json +83 -0
  165. data/test/fixtures/objects/webhooks/payload.json +66 -0
  166. data/test/fixtures/objects/webhooks/subscription.json +15 -0
  167. data/test/fixtures/organization_memberships/list.json +29 -0
  168. data/test/fixtures/organization_memberships/retrieve.json +20 -0
  169. data/test/fixtures/organizations/list_invitations.json +4 -4
  170. data/test/fixtures/organizations/list_memberships.json +12 -9
  171. data/test/fixtures/organizations/retrieve_invitation.json +3 -3
  172. data/test/fixtures/organizations/retrieve_membership.json +3 -3
  173. data/test/fixtures/outgoing_communications/list.json +26 -0
  174. data/test/fixtures/resources/401.json +2 -2
  175. data/test/fixtures/resources/403.json +1 -1
  176. data/test/fixtures/resources/403_payment_required.json +4 -0
  177. data/test/fixtures/resources/424.json +4 -0
  178. data/test/fixtures/routing_forms/list.json +39 -0
  179. data/test/fixtures/routing_forms/list_routing_form_submission.json +38 -0
  180. data/test/fixtures/routing_forms/retrieve.json +30 -0
  181. data/test/fixtures/routing_forms/retrieve_routing_form_submission.json +29 -0
  182. data/test/fixtures/shares/create.json +45 -0
  183. data/test/fixtures/user_availability_schedules/list.json +93 -0
  184. data/test/fixtures/user_availability_schedules/retrieve.json +22 -0
  185. data/test/fixtures/user_busy_times/list.json +39 -0
  186. data/test/fixtures/users/reload.json +5 -4
  187. data/test/fixtures/users/retrieve.json +5 -4
  188. data/test/fixtures/webhooks/create.json +4 -4
  189. data/test/fixtures/webhooks/list.json +4 -4
  190. data/test/fixtures/webhooks/retrieve.json +4 -4
  191. data/test/fixtures/webhooks/sample.json +105 -0
  192. metadata +159 -62
  193. data/lib/calendlyr/objects/event_invitees.rb +0 -4
  194. data/lib/calendlyr/objects/event_types.rb +0 -4
  195. data/lib/calendlyr/objects/events.rb +0 -4
  196. data/lib/calendlyr/objects/invitations.rb +0 -11
  197. data/lib/calendlyr/objects/memberships.rb +0 -7
  198. data/lib/calendlyr/objects/organizations.rb +0 -35
  199. data/lib/calendlyr/objects/scheduling_links.rb +0 -4
  200. data/lib/calendlyr/objects/users.rb +0 -19
  201. data/lib/calendlyr/objects/webhooks.rb +0 -11
  202. data/lib/calendlyr/resources/event_invitees.rb +0 -12
  203. data/lib/calendlyr/resources/event_types.rb +0 -12
  204. data/lib/calendlyr/resources/events.rb +0 -12
  205. data/lib/calendlyr/resources/organizations.rb +0 -33
  206. data/lib/calendlyr/resources/users.rb +0 -11
  207. data/lib/calendlyr/resources/webhooks.rb +0 -21
  208. data/test/calendlyr/resources/event_invitees_test.rb +0 -29
  209. data/test/fixtures/resources/409.json +0 -4
@@ -0,0 +1,111 @@
1
+ # User Calendlyr::User
2
+
3
+ Information about the user.
4
+
5
+ Visit official [API Doc](https://developer.calendly.com/api-docs/647961f90c0dd-user)
6
+
7
+ ## Client requests
8
+
9
+ ### Retrieve
10
+
11
+ Returns information about a specified User.
12
+
13
+ Visit official [API Doc](https://developer.calendly.com/api-docs/ff9832c5a6640-get-user)
14
+
15
+ ```ruby
16
+ client.users.retrieve(uuid: user_uuid)
17
+ #=> #<Calendlyr::User>
18
+ ```
19
+
20
+ ### Me
21
+
22
+ Returns basic information about your user account.
23
+
24
+ Visit official [API Doc](https://developer.calendly.com/api-docs/005832c83aeae-get-current-user)
25
+
26
+ ```ruby
27
+ client.users.me
28
+ #=> #<Calendlyr::User>
29
+ ```
30
+
31
+ #### Easy access
32
+
33
+ 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.
34
+
35
+ ```ruby
36
+ client.me # makes a call and memoize the response
37
+ client.me # no call, value memoized
38
+ ```
39
+
40
+ #### Force reload
41
+
42
+ However, if you need to reload the content of `me` you can `force_relaod` to force a new call.
43
+
44
+ ```ruby
45
+ client.me(force_reload: true) # makes a new call and update memoized value
46
+ ```
47
+
48
+ ## Object methods
49
+
50
+ ### Associated Organization
51
+
52
+ ```ruby
53
+ user.associated_organization
54
+ #=> #<Calendlyr::Organization>
55
+ ```
56
+
57
+ ### Availability Schedules
58
+
59
+ For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs.
60
+
61
+ ```ruby
62
+ user.availability_schedules
63
+ #=> #<Calendlyr::Collection @data=[#<Calendlyr::Availabilities::UserSchedule>, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#<Calendlyr::Client>>
64
+ ```
65
+
66
+ ### Memberships
67
+
68
+ Based on your user organization
69
+
70
+ For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs.
71
+
72
+ ```ruby
73
+ user.memberships
74
+ #=> #<Calendlyr::Collection @data=[#<Calendlyr::Organizations::Membership>, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#<Calendlyr::Client>>
75
+ ```
76
+
77
+ ### Organization Membership
78
+
79
+ Based on your user organization
80
+
81
+ ```ruby
82
+ user.membership(uuid: membership_uuid)
83
+ #=> #<Calendlyr::Organizations::Membership>
84
+ ```
85
+
86
+ ### Event Types
87
+
88
+ For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs.
89
+
90
+ ```ruby
91
+ user.event_types
92
+ #=> #<Calendlyr::Collection @data=[#<Calendlyr::EventType>, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#<Calendlyr::Client>>
93
+ ```
94
+
95
+ ### Events
96
+
97
+ For the example bellow we will use not parameters, but you can use the allowed parameters in Calendly docs.
98
+
99
+ ```ruby
100
+ user.events
101
+ #=> #<Calendlyr::Collection @data=[#<Calendlyr::Event>, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#<Calendlyr::Client>>
102
+ ```
103
+
104
+ ### Busy Times
105
+
106
+ For the example bellow we will use only required parameters, but you can use any other parameter as well.
107
+
108
+ ```ruby
109
+ user.busy_times(start_time: start_time, end_time: end_time)
110
+ #=> #<Calendlyr::Collection @data=[#<Calendlyr::Availabilities::UserBusyTime>, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#<Calendlyr::Client>>
111
+ ```
@@ -0,0 +1,42 @@
1
+ # Webhook Invitee Payload Calendlyr::Wehooks::InviteePayload
2
+
3
+ The payload that is sent via Webhook when an invitee creates or schedules a meeting, and when an invitee cancels.
4
+
5
+ Visit official [API Doc](https://developer.calendly.com/api-docs/b92768854bc06-invitee-payload)
6
+
7
+ ## Object methods
8
+
9
+ ### Associated Event
10
+
11
+ ```ruby
12
+ webhook_invitee_payload.associated_organization
13
+ #=> #<Calendlyr::Event>
14
+ ```
15
+
16
+ ### Associated Routing Form Submission
17
+
18
+ ```ruby
19
+ webhook_invitee_payload.associated_routing_form_submission
20
+ #=> #<Calendlyr::RoutingForms::Submission>
21
+ ```
22
+
23
+ ### Associated Invitee No Show
24
+
25
+ ```ruby
26
+ webhook_invitee_payload.associated_invitee_no_show
27
+ #=> #<Calendlyr::Events::InviteeNoShow>
28
+ ```
29
+
30
+ ### active?
31
+
32
+ ```ruby
33
+ webhook_subscription.active?
34
+ #=> true
35
+ ```
36
+
37
+ ### disabled?
38
+
39
+ ```ruby
40
+ webhook_subscription.disabled?
41
+ #=> false
42
+ ```
@@ -0,0 +1,5 @@
1
+ # Webhook Payload Calendlyr::Wehooks::Payload
2
+
3
+ Webhook Payload Object
4
+
5
+ Visit official [API Doc](https://developer.calendly.com/api-docs/69c58da556b61-webhook-payload)
@@ -0,0 +1,96 @@
1
+ # Webhook Subscription Calendlyr::Wehooks::Subscription
2
+
3
+ Webhook Subscription Object.
4
+
5
+ Visit official [API Doc](https://developer.calendly.com/api-docs/9950e4dff7351-webhook-subscription)
6
+
7
+ ## Client requests
8
+
9
+ ### Create
10
+
11
+ Create a Webhook Subscription for an Organization or User.
12
+
13
+ Visit official [API Doc](https://developer.calendly.com/api-docs/c1ddc06ce1f1b-create-webhook-subscription)
14
+
15
+ ```ruby
16
+ client.webhooks.create(url: 'https://example.com/webhook', events: ['invitee.created'], organization: organization_uri, scope: 'organization')
17
+ #=> #<Calendlyr::Webhooks::Subscription>
18
+
19
+ client.webhooks.create(url: 'https://example.com/webhook', events: ['invitee.created'], organization: organization_uri, user: user_uri, scope: 'user')
20
+ #=> #<Calendlyr::Webhooks::Subscription>
21
+
22
+ client.webhooks.create(url: 'https://example.com/webhook', events: ['invitee.created'], organization: organization_uri, group: group_uri, scope: 'group')
23
+ #=> #<Calendlyr::Webhooks::Subscription>
24
+ ```
25
+
26
+ ### Retrieve
27
+
28
+ Get a specified Webhook Subscription.
29
+
30
+ Visit official [API Doc](https://developer.calendly.com/api-docs/4d800dc2cb119-get-webhook-subscription)
31
+
32
+ ```ruby
33
+ client.webhooks.retrieve(webhook_uuid: webhook_uuid)
34
+ #=> #<Calendlyr::Webhooks::Subscription>
35
+ ```
36
+
37
+ ### List
38
+
39
+ Get a list of Webhook Subscriptions for a specified Organization or User.
40
+
41
+ Visit official [API Doc](https://developer.calendly.com/api-docs/faac832d7c57d-list-webhook-subscriptions)
42
+
43
+ For the example bellow we will use only required parameters, but you can use any other parameter as well.
44
+
45
+ ```ruby
46
+ client.webhooks.list(organization: organization_uri, scope: 'organization')
47
+ #=> #<Calendlyr::Collection @data=[#<Calendlyr::Webhooks::Subscription>, ...], @count=nil, @next_page=nil, @next_page_token=nil, @client=#<Calendlyr::Client>>
48
+ ```
49
+
50
+ ### Delete
51
+
52
+ Delete a Webhook Subscription.
53
+
54
+ Visit official [API Doc](https://developer.calendly.com/api-docs/565b97f62dafe-delete-webhook-subscription)
55
+
56
+ ```ruby
57
+ client.webhooks.delete(webhook_uuid: webhook_uuid)
58
+ #=>
59
+ ```
60
+
61
+ ## Object methods
62
+
63
+ ### Associated Organization
64
+
65
+ ```ruby
66
+ webhook_subscription.associated_organization
67
+ #=> #<Calendlyr::Organization>
68
+ ```
69
+
70
+ ### Associated User
71
+
72
+ ```ruby
73
+ webhook_subscription.associated_user
74
+ #=> #<Calendlyr::User>
75
+ ```
76
+
77
+ ### Associated Creator
78
+
79
+ ```ruby
80
+ webhook_subscription.associated_creator
81
+ #=> #<Calendlyr::User>
82
+ ```
83
+
84
+ ### active?
85
+
86
+ ```ruby
87
+ webhook_subscription.active?
88
+ #=> true
89
+ ```
90
+
91
+ ### disabled?
92
+
93
+ ```ruby
94
+ webhook_subscription.disabled?
95
+ #=> false
96
+ ```
@@ -8,6 +8,10 @@ module Calendlyr
8
8
  @token = token
9
9
  end
10
10
 
11
+ def availability
12
+ AvailabilityResource.new(self)
13
+ end
14
+
11
15
  def me(force_reload: false)
12
16
  @me = nil if force_reload
13
17
  @me ||= users.me
@@ -33,14 +37,26 @@ module Calendlyr
33
37
  EventResource.new(self)
34
38
  end
35
39
 
36
- def event_invitees
37
- EventInviteeResource.new(self)
40
+ def groups
41
+ GroupResource.new(self)
42
+ end
43
+
44
+ def outgoing_communications
45
+ OutgoingCommunicationResource.new(self)
46
+ end
47
+
48
+ def routing_forms
49
+ RoutingFormResource.new(self)
38
50
  end
39
51
 
40
52
  def scheduling_links
41
53
  SchedulingLinkResource.new(self)
42
54
  end
43
55
 
56
+ def shares
57
+ ShareResource.new(self)
58
+ end
59
+
44
60
  def webhooks
45
61
  WebhookResource.new(self)
46
62
  end
@@ -5,9 +5,9 @@ module Calendlyr
5
5
  class Collection
6
6
  attr_reader :data, :count, :next_page, :next_page_token, :client
7
7
 
8
- def self.from_response(response, key:, type:, client:)
8
+ def self.from_response(response, type:, client:)
9
9
  new(
10
- data: response[key].map { |attrs| type.new(attrs.merge(client: client)) },
10
+ data: response["collection"].map { |attrs| type.new(attrs.merge(client: client)) },
11
11
  count: response.dig("pagination", "count"),
12
12
  next_page: response.dig("pagination", "next_page"),
13
13
  client: client
@@ -1,4 +1,45 @@
1
1
  module Calendlyr
2
- class Error < StandardError
2
+ class Error < StandardError; end
3
+
4
+ class PermissionDenied < StandardError; end
5
+
6
+ class BadRequest < StandardError; end
7
+
8
+ class PaymentRequired < StandardError; end
9
+
10
+ class Unauthenticated < StandardError; end
11
+
12
+ class NotFound < StandardError; end
13
+
14
+ class ExternalCalendarEror < StandardError; end
15
+
16
+ class InternalServerError < StandardError; end
17
+
18
+ class ResponseErrorHandler
19
+ ERROR_TYPES = {
20
+ "400" => BadRequest,
21
+ "401" => Unauthenticated,
22
+ "403" => PermissionDenied,
23
+ "404" => NotFound,
24
+ "424" => ExternalCalendarEror,
25
+ "500" => InternalServerError
26
+ }
27
+
28
+ def initialize(code, body)
29
+ @code = code
30
+ @body = body
31
+ end
32
+
33
+ def error
34
+ error_type.new("[Error #{@code}] #{@body["title"]}. #{@body["message"]}")
35
+ end
36
+
37
+ private
38
+
39
+ def error_type
40
+ return PaymentRequired if @code == "403" && @body["message"].include?("upgrade")
41
+
42
+ ERROR_TYPES[@code]
43
+ end
3
44
  end
4
45
  end
@@ -2,8 +2,12 @@ require "ostruct"
2
2
 
3
3
  module Calendlyr
4
4
  class Object < OpenStruct
5
+ def self.get_slug(path)
6
+ path.split("/").last
7
+ end
8
+
5
9
  def initialize(attributes)
6
- super to_ostruct(attributes.merge(uuid: extract_uuid(attributes)))
10
+ super(to_ostruct(attributes.merge(uuid: extract_uuid(attributes))))
7
11
  end
8
12
 
9
13
  def to_ostruct(obj)
@@ -21,7 +25,7 @@ module Calendlyr
21
25
  end
22
26
 
23
27
  def get_slug(path)
24
- path.split("/").last
28
+ Calendlyr::Object.get_slug(path)
25
29
  end
26
30
  end
27
31
  end
@@ -0,0 +1,11 @@
1
+ module Calendlyr
2
+ class ActivityLog < Object
3
+ def associated_organization
4
+ Organization.new({"uri" => organization}.merge(client: client))
5
+ end
6
+
7
+ def associated_actor
8
+ client.users.retrieve(uuid: get_slug(actor.uri))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module Calendlyr
2
+ class Availabilities::Rule < Object
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Calendlyr
2
+ class Availabilities::UserBusyTime < Object
3
+ def associated_event
4
+ client.events.retrieve(uuid: get_slug(event.uri))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module Calendlyr
2
+ class Availabilities::UserSchedule < Object
3
+ def associated_user
4
+ client.users.retrieve(uuid: get_slug(user))
5
+ end
6
+
7
+ def availability_rules
8
+ rules.map do |rule|
9
+ Availabilities::Rule.new(rule.to_h.merge(client: client))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Calendlyr
2
+ class Event < Object
3
+ def memberships
4
+ event_memberships.map { |membership| client.users.retrieve(uuid: get_slug(membership.user)) }
5
+ end
6
+
7
+ def cancel(reason: nil)
8
+ client.events.cancel(uuid: uuid, reason: reason)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Calendlyr
2
+ class EventType < Object
3
+ def associated_profile
4
+ EventTypes::Profile.new(profile.to_h.merge(client: client))
5
+ end
6
+
7
+ def create_share(**params)
8
+ client.shares.create(**params.merge(event_type: uri))
9
+ end
10
+
11
+ def available_times(start_time:, end_time:, **params)
12
+ client.event_types.list_available_times(**params.merge(event_type: uri, start_time: start_time, end_time: end_time))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ module Calendlyr
2
+ class EventTypes::AvailableTime < Object
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module Calendlyr
2
+ class EventTypes::Membership < Object
3
+ def associated_event_type
4
+ client.event_types.retrieve(uuid: get_slug(event_type.uri))
5
+ end
6
+
7
+ def associated_member
8
+ client.users.retrieve(uuid: get_slug(member.uri))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Calendlyr
2
+ class EventTypes::Profile < Object
3
+ def associated_owner
4
+ client.users.retrieve(uuid: get_slug(owner))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Calendlyr
2
+ class Events::Cancellation < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Calendlyr
2
+ class Events::Guest < Object
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module Calendlyr
2
+ class Events::Invitee < Object
3
+ def cancel(reason: nil)
4
+ client.events.cancel(uuid: uuid, reason: reason)
5
+ end
6
+
7
+ def create_no_shows
8
+ client.events.create_invitee_no_show(invitee: uri)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Calendlyr
2
+ class Events::InviteeNoShow < Object
3
+ def delete
4
+ client.events.delete_invitee_no_show(uuid: uuid)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Calendlyr
2
+ class Group < Object
3
+ def associated_organization
4
+ Organization.new({"uri" => organization}.merge(client: client))
5
+ end
6
+
7
+ def events(**params)
8
+ client.events.list(**params.merge(group: uri))
9
+ end
10
+
11
+ def group_relationships(**params)
12
+ client.groups.list_relationships(**params.merge(group: uri))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Calendlyr
2
+ class Groups::Relationship < Object
3
+ def associated_organization
4
+ Organization.new({"uri" => organization}.merge(client: client))
5
+ end
6
+
7
+ def associated_group
8
+ client.groups.retrieve(uuid: get_slug(group))
9
+ end
10
+
11
+ def associated_owner
12
+ client.organizations.retrieve_membership(uuid: get_slug(owner.uri))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,67 @@
1
+ module Calendlyr
2
+ class Organization < Object
3
+ def activity_logs(**params)
4
+ client.organizations.activity_log(**params.merge(organization: uri))
5
+ end
6
+
7
+ def events(**params)
8
+ client.events.list(**params.merge(organization: uri))
9
+ end
10
+
11
+ def event_types(**params)
12
+ client.event_types.list(**params.merge(organization: uri))
13
+ end
14
+
15
+ def routing_forms(**params)
16
+ client.routing_forms.list(**params.merge(organization: uri))
17
+ end
18
+
19
+ # Groups
20
+ def groups(**params)
21
+ client.groups.list(**params.merge(organization: uri))
22
+ end
23
+
24
+ def group_relationships(**params)
25
+ client.groups.list_relationships(**params.merge(organization: uri))
26
+ end
27
+
28
+ # Memberships
29
+ def memberships(**params)
30
+ client.organizations.list_memberships(**params.merge(organization: uri))
31
+ end
32
+
33
+ def membership(uuid:)
34
+ client.organizations.retrieve_membership(uuid: uuid)
35
+ end
36
+
37
+ # Webhooks
38
+ def webhooks(scope:, **params)
39
+ client.webhooks.list(**params.merge(organization: uri, scope: scope))
40
+ end
41
+
42
+ def create_webhook(url:, events:, scope:, **params)
43
+ client.webhooks.create(**params.merge(organization: uri, url: url, events: events, scope: scope))
44
+ end
45
+
46
+ def sample_webhook_data(event:, scope:, **params)
47
+ client.webhooks.sample_webhook_data(event: event, scope: scope, organization: uri, **params)
48
+ end
49
+
50
+ # Invitations
51
+ def invite_user(email:, **params)
52
+ client.organizations.invite(**params.merge(organization_uuid: uuid, email: email))
53
+ end
54
+
55
+ def invitations(**params)
56
+ client.organizations.list_invitations(**params.merge(uuid: uuid))
57
+ end
58
+
59
+ def invitation(invitation_uuid:)
60
+ client.organizations.retrieve_invitation(org_uuid: uuid, uuid: invitation_uuid)
61
+ end
62
+
63
+ def revoke_invitation(invitation_uuid:)
64
+ client.organizations.revoke_invitation(org_uuid: uuid, uuid: invitation_uuid)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,15 @@
1
+ module Calendlyr
2
+ class Organizations::Invitation < Object
3
+ def associated_organization
4
+ Organization.new({"uri" => organization}.merge(client: client))
5
+ end
6
+
7
+ def associated_user
8
+ client.users.retrieve(uuid: get_slug(user))
9
+ end
10
+
11
+ def revoke
12
+ associated_organization.revoke_invitation(invitation_uuid: uuid)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Calendlyr
2
+ class Organizations::Membership < Object
3
+ def associated_organization
4
+ Organization.new({"uri" => organization}.merge(client: client))
5
+ end
6
+
7
+ def associated_user
8
+ client.users.retrieve(uuid: get_slug(user.uri))
9
+ end
10
+
11
+ def group_relationships(**params)
12
+ client.groups.list_relationships(**params.merge(owner: uri))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Calendlyr
2
+ class RoutingForm < Object
3
+ def associated_organization
4
+ Organization.new({"uri" => organization}.merge(client: client))
5
+ end
6
+
7
+ def submissions(**params)
8
+ client.routing_forms.list_submissions(**params.merge(form: uri))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Calendlyr
2
+ class RoutingForms::Submission < Object
3
+ def associated_routing_form
4
+ client.routing_forms.retrieve(uuid: get_slug(routing_form))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Calendlyr
2
+ class SchedulingLink < Object
3
+ def event_type
4
+ return unless owner_type == "EventType"
5
+
6
+ client.event_types.retrieve(uuid: get_slug(owner))
7
+ end
8
+ end
9
+ end