calendly 0.4.1 → 0.6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +78 -16
- data/README.md +40 -29
- data/lib/calendly/api_error.rb +3 -0
- data/lib/calendly/client.rb +102 -12
- data/lib/calendly/configuration.rb +6 -1
- data/lib/calendly/models/event.rb +35 -22
- data/lib/calendly/models/event_type.rb +76 -21
- data/lib/calendly/models/event_type_custom_question.rb +48 -0
- data/lib/calendly/models/event_type_profile.rb +54 -0
- data/lib/calendly/models/guest.rb +21 -0
- data/lib/calendly/models/invitee.rb +57 -13
- data/lib/calendly/models/invitee_cancellation.rb +17 -0
- data/lib/calendly/models/invitee_payment.rb +28 -0
- data/lib/calendly/models/invitee_question_and_answer.rb +9 -1
- data/lib/calendly/models/invitee_tracking.rb +12 -1
- data/lib/calendly/models/invitees_counter.rb +19 -0
- data/lib/calendly/models/location.rb +10 -0
- data/lib/calendly/models/model_utils.rb +32 -6
- data/lib/calendly/models/organization.rb +58 -3
- data/lib/calendly/models/organization_invitation.rb +6 -0
- data/lib/calendly/models/organization_membership.rb +20 -11
- data/lib/calendly/models/team.rb +20 -0
- data/lib/calendly/models/user.rb +64 -5
- data/lib/calendly/models/webhook_subscription.rb +17 -0
- data/lib/calendly/version.rb +1 -1
- metadata +11 -4
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/models/model_utils'
|
4
|
+
|
5
|
+
module Calendly
|
6
|
+
# Calendly's invitee cancellation model.
|
7
|
+
# Provides data pertaining to the cancellation of the Invitee.
|
8
|
+
class InviteeCancellation
|
9
|
+
include ModelUtils
|
10
|
+
|
11
|
+
# @return [String] Name of the person whom canceled.
|
12
|
+
attr_accessor :canceled_by
|
13
|
+
|
14
|
+
# @return [String] Reason that the cancellation occurred.
|
15
|
+
attr_accessor :reason
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/models/model_utils'
|
4
|
+
|
5
|
+
module Calendly
|
6
|
+
# Calendly's invitee payment model.
|
7
|
+
class InviteePayment
|
8
|
+
include ModelUtils
|
9
|
+
|
10
|
+
# @return [String] Unique identifier for the payment.
|
11
|
+
attr_accessor :external_id
|
12
|
+
|
13
|
+
# @return [String] Payment provider.
|
14
|
+
attr_accessor :provider
|
15
|
+
|
16
|
+
# @return[Float] The amount of the payment.
|
17
|
+
attr_accessor :amount
|
18
|
+
|
19
|
+
# @return [String] The currency format that the payment is in.
|
20
|
+
attr_accessor :currency
|
21
|
+
|
22
|
+
# @return [String] Terms of the payment.
|
23
|
+
attr_accessor :terms
|
24
|
+
|
25
|
+
# @return [Boolean] Indicates whether the payment was successfully processed.
|
26
|
+
attr_accessor :successful
|
27
|
+
end
|
28
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'calendly/models/model_utils'
|
4
4
|
|
5
5
|
module Calendly
|
6
|
-
# Calendly's
|
6
|
+
# Calendly's question and answer model.
|
7
7
|
# An individual form question and response.
|
8
8
|
class InviteeQuestionAndAnswer
|
9
9
|
include ModelUtils
|
@@ -11,11 +11,19 @@ module Calendly
|
|
11
11
|
# @return [String]
|
12
12
|
# The question from the event booking confirmation form.
|
13
13
|
attr_accessor :question
|
14
|
+
|
14
15
|
# @return [String]
|
15
16
|
# The answer supplied by the invitee to this question.
|
16
17
|
attr_accessor :answer
|
18
|
+
|
17
19
|
# @return [Integer]
|
18
20
|
# The position of this question in the event booking confirmation form.
|
19
21
|
attr_accessor :position
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def inspect_attributes
|
26
|
+
super + %i[position question]
|
27
|
+
end
|
20
28
|
end
|
21
29
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'calendly/models/model_utils'
|
4
4
|
|
5
5
|
module Calendly
|
6
|
-
# Calendly's
|
6
|
+
# Calendly's invitee tracking model.
|
7
7
|
# Object that represents UTM and Salesforce tracking parameters associated with the invitee.
|
8
8
|
class InviteeTracking
|
9
9
|
include ModelUtils
|
@@ -11,20 +11,31 @@ module Calendly
|
|
11
11
|
# @return [String]
|
12
12
|
# UTM campaign tracking parameter.
|
13
13
|
attr_accessor :utm_campaign
|
14
|
+
|
14
15
|
# @return [String]
|
15
16
|
# UTM source tracking parameter.
|
16
17
|
attr_accessor :utm_source
|
18
|
+
|
17
19
|
# @return [String]
|
18
20
|
# UTM medium tracking parameter.
|
19
21
|
attr_accessor :utm_medium
|
22
|
+
|
20
23
|
# @return [String]
|
21
24
|
# UTM content tracking parameter.
|
22
25
|
attr_accessor :utm_content
|
26
|
+
|
23
27
|
# @return [String]
|
24
28
|
# UTM term tracking parameter.
|
25
29
|
attr_accessor :utm_term
|
30
|
+
|
26
31
|
# @return [String]
|
27
32
|
# Salesforce Record ID.
|
28
33
|
attr_accessor :salesforce_uuid
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def inspect_attributes
|
38
|
+
super + %i[utm_source utm_medium utm_campaign]
|
39
|
+
end
|
29
40
|
end
|
30
41
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/models/model_utils'
|
4
|
+
|
5
|
+
module Calendly
|
6
|
+
# Calendly's invitees counter model.
|
7
|
+
class InviteesCounter
|
8
|
+
include ModelUtils
|
9
|
+
|
10
|
+
# @return [Integer] number of total invitees in this event.
|
11
|
+
attr_accessor :total
|
12
|
+
|
13
|
+
# @return [Integer] number of active invitees in this event.
|
14
|
+
attr_accessor :active
|
15
|
+
|
16
|
+
# @return [Integer] max invitees in this event.
|
17
|
+
attr_accessor :limit
|
18
|
+
end
|
19
|
+
end
|
@@ -59,13 +59,23 @@ module Calendly
|
|
59
59
|
|
60
60
|
# @return [String]
|
61
61
|
attr_accessor :type
|
62
|
+
|
62
63
|
# @return [String]
|
63
64
|
attr_accessor :location
|
65
|
+
|
64
66
|
# @return [String]
|
65
67
|
attr_accessor :status
|
68
|
+
|
66
69
|
# @return [String]
|
67
70
|
attr_accessor :join_url
|
71
|
+
|
68
72
|
# @return [Hash]
|
69
73
|
attr_accessor :data
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def inspect_attributes
|
78
|
+
super + %i[location]
|
79
|
+
end
|
70
80
|
end
|
71
81
|
end
|
@@ -26,7 +26,7 @@ module Calendly
|
|
26
26
|
end
|
27
27
|
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# Alias of uuid.
|
30
30
|
#
|
31
31
|
# @return [String]
|
32
32
|
# @raise [Calendly::Error] if uuid is not defined.
|
@@ -37,9 +37,20 @@ module Calendly
|
|
37
37
|
uuid
|
38
38
|
end
|
39
39
|
|
40
|
+
#
|
41
|
+
# Self object description human readable in CLI.
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
# @since 0.0.1
|
40
45
|
def inspect
|
41
|
-
|
42
|
-
|
46
|
+
att_info = []
|
47
|
+
inspect_attributes.each do |att|
|
48
|
+
next unless respond_to? att
|
49
|
+
|
50
|
+
att_info << "#{att}=#{send(att).inspect}"
|
51
|
+
end
|
52
|
+
att_info << '..'
|
53
|
+
"\#<#{self.class}:#{object_id} #{att_info.join(', ')}>"
|
43
54
|
end
|
44
55
|
|
45
56
|
module ClassMethods
|
@@ -61,7 +72,7 @@ module Calendly
|
|
61
72
|
|
62
73
|
private
|
63
74
|
|
64
|
-
def set_attributes(attrs) # rubocop:disable
|
75
|
+
def set_attributes(attrs) # rubocop:disable Naming/AccessorMethodName, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
65
76
|
return if attrs.nil?
|
66
77
|
return unless attrs.is_a? Hash
|
67
78
|
return if attrs.empty?
|
@@ -70,8 +81,14 @@ module Calendly
|
|
70
81
|
next unless respond_to? "#{key}=".to_sym
|
71
82
|
|
72
83
|
if value && defined?(self.class::ASSOCIATION) && self.class::ASSOCIATION.key?(key)
|
73
|
-
|
74
|
-
value
|
84
|
+
klass = self.class::ASSOCIATION[key]
|
85
|
+
if value.is_a? String # rubocop:disable Style/CaseLikeIf
|
86
|
+
value = klass.new({uri: value}, @client)
|
87
|
+
elsif value.is_a? Hash
|
88
|
+
value = klass.new(value, @client)
|
89
|
+
elsif value.is_a? Array
|
90
|
+
value = value.map { |v| klass.new(v, @client) }
|
91
|
+
end
|
75
92
|
elsif value && defined?(self.class::TIME_FIELDS) && self.class::TIME_FIELDS.include?(key)
|
76
93
|
value = Time.parse value
|
77
94
|
end
|
@@ -102,5 +119,14 @@ module Calendly
|
|
102
119
|
end
|
103
120
|
items
|
104
121
|
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# Basic attributes used by inspect method.
|
125
|
+
#
|
126
|
+
# @return [Array<Symbol>]
|
127
|
+
# @since 0.6.0
|
128
|
+
def inspect_attributes
|
129
|
+
%i[uuid name type slug status email]
|
130
|
+
end
|
105
131
|
end
|
106
132
|
end
|
@@ -12,6 +12,7 @@ module Calendly
|
|
12
12
|
# @return [String]
|
13
13
|
# unique id of the Organization object.
|
14
14
|
attr_accessor :uuid
|
15
|
+
|
15
16
|
# @return [String]
|
16
17
|
# Canonical resource reference.
|
17
18
|
attr_accessor :uri
|
@@ -28,7 +29,7 @@ module Calendly
|
|
28
29
|
# @raise [Calendly::ApiError] if the api returns error code.
|
29
30
|
# @since 0.1.0
|
30
31
|
def memberships(opts = {})
|
31
|
-
return @cached_memberships if @cached_memberships
|
32
|
+
return @cached_memberships if defined?(@cached_memberships) && @cached_memberships
|
32
33
|
|
33
34
|
request_proc = proc { |options| client.memberships uri, options }
|
34
35
|
@cached_memberships = auto_pagination request_proc, opts
|
@@ -55,7 +56,7 @@ module Calendly
|
|
55
56
|
# @raise [Calendly::ApiError] if the api returns error code.
|
56
57
|
# @since 0.1.0
|
57
58
|
def invitations(opts = {})
|
58
|
-
return @cached_invitations if @cached_invitations
|
59
|
+
return @cached_invitations if defined?(@cached_invitations) && @cached_invitations
|
59
60
|
|
60
61
|
request_proc = proc { |options| client.invitations uuid, options }
|
61
62
|
@cached_invitations = auto_pagination request_proc, opts
|
@@ -80,6 +81,60 @@ module Calendly
|
|
80
81
|
client.create_invitation uuid, email
|
81
82
|
end
|
82
83
|
|
84
|
+
#
|
85
|
+
# Returns all Event Types associated with self.
|
86
|
+
#
|
87
|
+
# @param [Hash] opts the optional request parameters.
|
88
|
+
# @option opts [Integer] :count Number of rows to return.
|
89
|
+
# @option opts [String] :page_token Pass this to get the next portion of collection.
|
90
|
+
# @option opts [String] :sort Order results by the specified field and direction.
|
91
|
+
# Accepts comma-separated list of {field}:{direction} values.
|
92
|
+
# @return [Array<Calendly::EventType>]
|
93
|
+
# @raise [Calendly::Error] if the uri is empty.
|
94
|
+
# @raise [Calendly::ApiError] if the api returns error code.
|
95
|
+
# @since 0.6.0
|
96
|
+
def event_types(opts = {})
|
97
|
+
return @cached_event_types if defined?(@cached_event_types) && @cached_event_types
|
98
|
+
|
99
|
+
request_proc = proc { |options| client.event_types uri, options }
|
100
|
+
@cached_event_types = auto_pagination request_proc, opts
|
101
|
+
end
|
102
|
+
|
103
|
+
# @since 0.6.0
|
104
|
+
def event_types!(opts = {})
|
105
|
+
@cached_event_types = nil
|
106
|
+
event_types opts
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Returns all Scheduled Events associated with self.
|
111
|
+
#
|
112
|
+
# @param [Hash] opts the optional request parameters.
|
113
|
+
# @option opts [Integer] :count Number of rows to return.
|
114
|
+
# @option opts [String] :invitee_email Return events scheduled with the specified invitee email
|
115
|
+
# @option opts [String] :max_start_timeUpper bound (inclusive) for an event's start time to filter by.
|
116
|
+
# @option opts [String] :min_start_time Lower bound (inclusive) for an event's start time to filter by.
|
117
|
+
# @option opts [String] :page_token Pass this to get the next portion of collection.
|
118
|
+
# @option opts [String] :sort Order results by the specified field and directin.
|
119
|
+
# Accepts comma-separated list of {field}:{direction} values.
|
120
|
+
# @option opts [String] :status Whether the scheduled event is active or canceled
|
121
|
+
# @return [Array<Calendly::Event>]
|
122
|
+
# @raise [Calendly::Error] if the uri is empty.
|
123
|
+
# @raise [Calendly::ApiError] if the api returns error code.
|
124
|
+
# @since 0.5.0
|
125
|
+
def scheduled_events(opts = {})
|
126
|
+
return @cached_scheduled_events if defined?(@cached_scheduled_events) && @cached_scheduled_events
|
127
|
+
|
128
|
+
request_proc = proc { |options| client.scheduled_events uri, options }
|
129
|
+
@cached_scheduled_events = auto_pagination request_proc, opts
|
130
|
+
end
|
131
|
+
|
132
|
+
# @since 0.5.0
|
133
|
+
def scheduled_events!(opts = {})
|
134
|
+
@cached_scheduled_events = nil
|
135
|
+
scheduled_events opts
|
136
|
+
end
|
137
|
+
|
83
138
|
#
|
84
139
|
# Get List of organization scope Webhooks associated with self.
|
85
140
|
#
|
@@ -93,7 +148,7 @@ module Calendly
|
|
93
148
|
# @raise [Calendly::ApiError] if the api returns error code.
|
94
149
|
# @since 0.1.3
|
95
150
|
def webhooks(opts = {})
|
96
|
-
return @cached_webhooks if @cached_webhooks
|
151
|
+
return @cached_webhooks if defined?(@cached_webhooks) && @cached_webhooks
|
97
152
|
|
98
153
|
request_proc = proc { |options| client.webhooks uri, options }
|
99
154
|
@cached_webhooks = auto_pagination request_proc, opts
|
@@ -16,21 +16,27 @@ module Calendly
|
|
16
16
|
# @return [String]
|
17
17
|
# unique id of the OrganizationInvitation object.
|
18
18
|
attr_accessor :uuid
|
19
|
+
|
19
20
|
# @return [String]
|
20
21
|
# Canonical resource reference.
|
21
22
|
attr_accessor :uri
|
23
|
+
|
22
24
|
# @return [String]
|
23
25
|
# Invited person's email.
|
24
26
|
attr_accessor :email
|
27
|
+
|
25
28
|
# @return [String]
|
26
29
|
# Invitation status.
|
27
30
|
attr_accessor :status
|
31
|
+
|
28
32
|
# @return [Time]
|
29
33
|
# Moment when user record was first created.
|
30
34
|
attr_accessor :created_at
|
35
|
+
|
31
36
|
# @return [Time]
|
32
37
|
# Moment when user record was last updated.
|
33
38
|
attr_accessor :updated_at
|
39
|
+
|
34
40
|
# @return [Time]
|
35
41
|
# Moment when the last invitation was sent.
|
36
42
|
attr_accessor :last_sent_at
|
@@ -16,15 +16,19 @@ module Calendly
|
|
16
16
|
# @return [String]
|
17
17
|
# unique id of the OrganizationMembership object.
|
18
18
|
attr_accessor :uuid
|
19
|
+
|
19
20
|
# @return [String]
|
20
21
|
# Canonical resource reference.
|
21
22
|
attr_accessor :uri
|
23
|
+
|
22
24
|
# @return [String]
|
23
25
|
# User's role within the organization
|
24
26
|
attr_accessor :role
|
27
|
+
|
25
28
|
# @return [Time]
|
26
29
|
# Moment when user record was first created.
|
27
30
|
attr_accessor :created_at
|
31
|
+
|
28
32
|
# @return [Time]
|
29
33
|
# Moment when user record was last updated.
|
30
34
|
attr_accessor :updated_at
|
@@ -72,18 +76,12 @@ module Calendly
|
|
72
76
|
# @raise [Calendly::ApiError] if the api returns error code.
|
73
77
|
# @since 0.1.3
|
74
78
|
def user_scope_webhooks(opts = {})
|
75
|
-
|
76
|
-
|
77
|
-
org_uri = organization.uri if organization
|
78
|
-
user_uri = user.uri if user
|
79
|
-
request_proc = proc { |options| client.user_scope_webhooks org_uri, user_uri, options }
|
80
|
-
@cached_user_scope_webhooks = auto_pagination request_proc, opts
|
79
|
+
user.webhooks(opts)
|
81
80
|
end
|
82
81
|
|
83
82
|
# @since 0.2.0
|
84
83
|
def user_scope_webhooks!(opts = {})
|
85
|
-
|
86
|
-
user_scope_webhooks opts
|
84
|
+
user.webhooks!(opts)
|
87
85
|
end
|
88
86
|
|
89
87
|
#
|
@@ -98,9 +96,20 @@ module Calendly
|
|
98
96
|
# @raise [Calendly::ApiError] if the api returns error code.
|
99
97
|
# @since 0.1.3
|
100
98
|
def create_user_scope_webhook(url, events)
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
user.create_webhook url, events
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def after_set_attributes(attrs)
|
105
|
+
super attrs
|
106
|
+
if user.is_a?(User) && user.current_organization.nil? && organization.is_a?(Organization) # rubocop:disable Style/GuardClause
|
107
|
+
user.current_organization = organization
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def inspect_attributes
|
112
|
+
super + %i[role]
|
104
113
|
end
|
105
114
|
end
|
106
115
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/client'
|
4
|
+
require 'calendly/models/model_utils'
|
5
|
+
|
6
|
+
module Calendly
|
7
|
+
# Calendly's team model.
|
8
|
+
class Team
|
9
|
+
include ModelUtils
|
10
|
+
UUID_RE = %r{\A#{Client::API_HOST}/teams/(\w+)\z}.freeze
|
11
|
+
|
12
|
+
# @return [String]
|
13
|
+
# unique id of the Team object.
|
14
|
+
attr_accessor :uuid
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
# Canonical resource reference.
|
18
|
+
attr_accessor :uri
|
19
|
+
end
|
20
|
+
end
|