calendly 0.5.2 → 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.
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'calendly/models/model_utils'
4
+
5
+ module Calendly
6
+ # Calendly's custom question model.
7
+ class EventTypeCustomQuestion
8
+ include ModelUtils
9
+
10
+ # @return [String]
11
+ # The custom question that the host created for the event type.
12
+ attr_accessor :name
13
+
14
+ # @return [String]
15
+ # The type of response that the invitee provides to the custom question;
16
+ # can be one or multiple lines of text, a phone number, or single- or multiple-select.
17
+ attr_accessor :type
18
+
19
+ # @return [Integer]
20
+ # The numerical position of the question on the event booking page after the name and email address fields.
21
+ attr_accessor :position
22
+
23
+ # @return [Boolean]
24
+ # true if the question created by the host is turned ON and visible on the event booking page;
25
+ # false if turned OFF and invisible on the event booking page.
26
+ attr_accessor :enabled
27
+
28
+ # @return [Boolean]
29
+ # true if a response to the question created by the host is required for invitees to book the event type;
30
+ # false if not required.
31
+ attr_accessor :required
32
+
33
+ # @return [Array<String>]
34
+ # The invitee’s option(s) for single_select or multi_select type of responses.
35
+ attr_accessor :answer_choices
36
+
37
+ # @return [Boolean]
38
+ # true if the custom question lets invitees record a written response in addition to single-select or multiple-select type of responses;
39
+ # false if it doesn’t.
40
+ attr_accessor :include_other
41
+
42
+ private
43
+
44
+ def inspect_attributes
45
+ super + %i[enabled position]
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'calendly/models/model_utils'
4
+
5
+ module Calendly
6
+ # Calendly's event type profile model.
7
+ class EventTypeProfile
8
+ include ModelUtils
9
+
10
+ # @return [String]
11
+ # Indicates if the profile belongs to a "user" (individual) or "team"
12
+ attr_accessor :type
13
+
14
+ # @return [String]
15
+ # Human-readable name for the profile of the user that's associated with the event type
16
+ attr_accessor :name
17
+
18
+ # @return [String]
19
+ # The unique reference to the user associated with the profile
20
+ attr_accessor :owner
21
+
22
+ # @return [User]
23
+ # The owner user if the profile belongs to a "user" (individual).
24
+ attr_accessor :owner_user
25
+
26
+ # @return [Team]
27
+ # The owner team if the profile belongs to a "team".
28
+ attr_accessor :owner_team
29
+
30
+ # whether type is user or not.
31
+ # @return [Boolean]
32
+ # @since 0.6.0
33
+ def type_user?
34
+ type&.downcase == 'user'
35
+ end
36
+
37
+ # whether type is team or not.
38
+ # @return [Boolean]
39
+ # @since 0.6.0
40
+ def type_team?
41
+ type&.downcase == 'team'
42
+ end
43
+
44
+ private
45
+
46
+ def after_set_attributes(attrs)
47
+ super attrs
48
+ if owner # rubocop:disable Style/GuardClause
49
+ @owner_user = User.new({uri: owner}, @client) if type_user?
50
+ @owner_team = Team.new({uri: owner}, @client) if type_team?
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'calendly/models/model_utils'
4
+
5
+ module Calendly
6
+ # Calendly's guest model.
7
+ # Additional people added to an event by an invitee.
8
+ class Guest
9
+ include ModelUtils
10
+ TIME_FIELDS = %i[created_at updated_at].freeze
11
+
12
+ # @return [String]
13
+ attr_accessor :email
14
+
15
+ # @return [Time]
16
+ attr_accessor :created_at
17
+
18
+ # @return [Time]
19
+ attr_accessor :updated_at
20
+ end
21
+ end
@@ -3,60 +3,99 @@
3
3
  require 'calendly/client'
4
4
  require 'calendly/models/model_utils'
5
5
  require 'calendly/models/event'
6
+ require 'calendly/models/invitee_cancellation'
7
+ require 'calendly/models/invitee_payment'
8
+ require 'calendly/models/invitee_question_and_answer'
9
+ require 'calendly/models/invitee_tracking'
6
10
 
7
11
  module Calendly
8
- # Calendly's Invitee model.
12
+ # Calendly's invitee model.
9
13
  # An individual who has been invited to meet with a Calendly member.
10
14
  class Invitee
11
15
  include ModelUtils
12
16
  UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/\w+/invitees/(\w+)\z}.freeze
13
17
  TIME_FIELDS = %i[created_at updated_at].freeze
14
- ASSOCIATION = {event: Event}.freeze
18
+ ASSOCIATION = {
19
+ event: Event,
20
+ cancellation: InviteeCancellation,
21
+ payment: InviteePayment,
22
+ questions_and_answers: InviteeQuestionAndAnswer,
23
+ tracking: InviteeTracking
24
+ }.freeze
15
25
 
16
26
  # @return [String]
17
27
  # unique id of the Invitee object.
18
28
  attr_accessor :uuid
29
+
19
30
  # @return [String]
20
31
  # Canonical resource reference.
21
32
  attr_accessor :uri
33
+
22
34
  # @return [String]
23
35
  # The invitee's email address.
24
36
  attr_accessor :email
37
+
25
38
  # @return [String]
26
39
  # The invitee's human-readable name.
27
40
  attr_accessor :name
41
+
42
+ # @return [String]
43
+ # The first name of the invitee who booked the event when the event type is configured to use separate fields for
44
+ # first name and last name. Null when event type is configured to use a single field for name.
45
+ attr_accessor :first_name
46
+
47
+ # @return [String]
48
+ # The last name of the invitee who booked the event when the event type is configured to use separate fields
49
+ # for first name and last name. Null when event type is configured to use a single field for name.
50
+ attr_accessor :last_name
51
+
28
52
  # @return [String]
29
53
  # Whether the invitee has canceled or is still active.
30
54
  attr_accessor :status
55
+
31
56
  # @return [String]
32
57
  # Timezone offest to use when presenting time information to invitee.
33
58
  attr_accessor :timezone
59
+
34
60
  # @return [String]
35
61
  # Text (SMS) reminder phone number.
36
62
  attr_accessor :text_reminder_number
63
+
37
64
  # @return [Boolean]
38
65
  # Indicates if this invitee has rescheduled.
39
66
  # If true, a reference to the new Invitee instance is provided in the new_invitee field.
40
67
  attr_accessor :rescheduled
68
+
41
69
  # @return [String, nil]
42
70
  # Reference to old Invitee instance that got rescheduled.
43
71
  attr_accessor :old_invitee
72
+
44
73
  # @return [String, nil]
45
74
  # Link to new invitee, after reschedule.
46
75
  attr_accessor :new_invitee
76
+
47
77
  # @return [String]
48
78
  # Link to cancelling the event for the invitee.
49
79
  attr_accessor :cancel_url
80
+
50
81
  # @return [String]
51
82
  # Link to rescheduling the event for the invitee.
52
83
  attr_accessor :reschedule_url
84
+
53
85
  # @return [Time]
54
86
  # Moment when user record was first created.
55
87
  attr_accessor :created_at
88
+
56
89
  # @return [Time]
57
90
  # Moment when user record was last updated.
58
91
  attr_accessor :updated_at
59
92
 
93
+ # @return [InviteeCancellation] Provides data pertaining to the cancellation of the Invitee.
94
+ attr_accessor :cancellation
95
+
96
+ # @return [InviteePayment] Invitee payment.
97
+ attr_accessor :payment
98
+
60
99
  # @return [Event]
61
100
  # Reference to Event associated with this invitee.
62
101
  attr_accessor :event
@@ -80,16 +119,5 @@ module Calendly
80
119
  ev_uuid = event.uuid if event
81
120
  client.event_invitee ev_uuid, uuid
82
121
  end
83
-
84
- private
85
-
86
- def after_set_attributes(attrs)
87
- super attrs
88
- answers = attrs[:questions_and_answers]
89
- @questions_and_answers = answers.map { |ans| InviteeQuestionAndAnswer.new ans } if answers&.is_a? Array
90
-
91
- trac_attrs = attrs[:tracking]
92
- @tracking = InviteeTracking.new trac_attrs if trac_attrs&.is_a? Hash
93
- end
94
122
  end
95
123
  end
@@ -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 InviteeQuestionAndAnswer model.
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 InviteeTracking model.
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
- # alias of uuid.
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
- description = "uuid:#{uuid}" if respond_to? :uuid
42
- "\#<#{self.class}:#{object_id} #{description}>"
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 all
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
- associated_attrs = value.is_a?(Hash) ? value : {uri: value}
74
- value = self.class::ASSOCIATION[key].new associated_attrs, @client
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