youcanbookme 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/gem-push.yml +37 -0
  3. data/.github/workflows/test.yml +21 -0
  4. data/.gitignore +10 -0
  5. data/.rubocom.yml +69 -0
  6. data/CHANGELOG.md +7 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +6 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +119 -0
  11. data/Rakefile +12 -0
  12. data/bin/console +7 -0
  13. data/bin/setup +6 -0
  14. data/lib/youcanbookme.rb +22 -0
  15. data/lib/youcanbookme/client.rb +85 -0
  16. data/lib/youcanbookme/common_module.rb +32 -0
  17. data/lib/youcanbookme/configuration.rb +20 -0
  18. data/lib/youcanbookme/error.rb +15 -0
  19. data/lib/youcanbookme/http_command.rb +94 -0
  20. data/lib/youcanbookme/models/account.rb +125 -0
  21. data/lib/youcanbookme/models/action.rb +91 -0
  22. data/lib/youcanbookme/models/answer.rb +19 -0
  23. data/lib/youcanbookme/models/appointment_type.rb +7 -0
  24. data/lib/youcanbookme/models/booking.rb +167 -0
  25. data/lib/youcanbookme/models/booking_lobby.rb +13 -0
  26. data/lib/youcanbookme/models/calendar.rb +67 -0
  27. data/lib/youcanbookme/models/caligraph_calendar.rb +29 -0
  28. data/lib/youcanbookme/models/caligraph_event.rb +8 -0
  29. data/lib/youcanbookme/models/caligraph_link.rb +17 -0
  30. data/lib/youcanbookme/models/caligraph_local_account.rb +47 -0
  31. data/lib/youcanbookme/models/caligraph_permission.rb +32 -0
  32. data/lib/youcanbookme/models/caligraph_remote_account.rb +23 -0
  33. data/lib/youcanbookme/models/caligraph_safe_local_account.rb +13 -0
  34. data/lib/youcanbookme/models/card.rb +25 -0
  35. data/lib/youcanbookme/models/event.rb +98 -0
  36. data/lib/youcanbookme/models/instant.rb +9 -0
  37. data/lib/youcanbookme/models/link.rb +17 -0
  38. data/lib/youcanbookme/models/local_account.rb +180 -0
  39. data/lib/youcanbookme/models/model_utils.rb +88 -0
  40. data/lib/youcanbookme/models/name_and_address.rb +25 -0
  41. data/lib/youcanbookme/models/participant.rb +25 -0
  42. data/lib/youcanbookme/models/permission.rb +39 -0
  43. data/lib/youcanbookme/models/profile.rb +114 -0
  44. data/lib/youcanbookme/models/profile_afterwards.rb +34 -0
  45. data/lib/youcanbookme/models/profile_appointment_type.rb +23 -0
  46. data/lib/youcanbookme/models/profile_appointment_types.rb +27 -0
  47. data/lib/youcanbookme/models/profile_calendar.rb +21 -0
  48. data/lib/youcanbookme/models/profile_calendars.rb +19 -0
  49. data/lib/youcanbookme/models/profile_cancel_or_reschedule.rb +21 -0
  50. data/lib/youcanbookme/models/profile_display.rb +55 -0
  51. data/lib/youcanbookme/models/profile_local_account.rb +19 -0
  52. data/lib/youcanbookme/models/profile_payments.rb +23 -0
  53. data/lib/youcanbookme/models/profile_remote_account.rb +25 -0
  54. data/lib/youcanbookme/models/profile_remote_reminder.rb +15 -0
  55. data/lib/youcanbookme/models/profile_team_member.rb +33 -0
  56. data/lib/youcanbookme/models/profile_team_members.rb +29 -0
  57. data/lib/youcanbookme/models/profile_tentative.rb +16 -0
  58. data/lib/youcanbookme/models/profile_times.rb +79 -0
  59. data/lib/youcanbookme/models/profile_vouchers.rb +17 -0
  60. data/lib/youcanbookme/models/provider.rb +17 -0
  61. data/lib/youcanbookme/models/purchase.rb +126 -0
  62. data/lib/youcanbookme/models/purchases_sync_changes.rb +19 -0
  63. data/lib/youcanbookme/models/query.rb +8 -0
  64. data/lib/youcanbookme/models/question.rb +24 -0
  65. data/lib/youcanbookme/models/reminder.rb +21 -0
  66. data/lib/youcanbookme/models/remote_account.rb +63 -0
  67. data/lib/youcanbookme/models/team_member.rb +8 -0
  68. data/lib/youcanbookme/models/template_event.rb +17 -0
  69. data/lib/youcanbookme/models/transaction.rb +42 -0
  70. data/lib/youcanbookme/models/warning.rb +27 -0
  71. data/lib/youcanbookme/version.rb +5 -0
  72. data/youcanbookme.gemspec +41 -0
  73. metadata +244 -0
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module YouCanBookMe
6
+ # YouCanBook.me model utility.
7
+ module ModelUtils
8
+ # @param [Hash] attrs the attributes of the model.
9
+ # @param [YouCanBookMe::Client] the api client.
10
+ def initialize(attrs = nil, client = nil)
11
+ @client = client
12
+ set_attributes attrs
13
+ end
14
+
15
+ def inspect
16
+ "\#<#{self.class}:#{object_id}>"
17
+ end
18
+
19
+ module ClassMethods
20
+ # @param [String] prefix
21
+ # @return [Array<String>]
22
+ def fields(prefix = nil)
23
+ instance = new
24
+ ret_fields = []
25
+ instance.methods.each do |m|
26
+ next if %i[=== == !=].include? m
27
+ next unless m.to_s.end_with? '='
28
+
29
+ field = m.to_s.split('=')[0]
30
+ ret_fields << (prefix ? "#{prefix}.#{field}" : field)
31
+ end
32
+ ret_fields
33
+ end
34
+
35
+ # @param [String] prefix
36
+ # @param [Integer] max_depth
37
+ # @return [Array<String>]
38
+ def deep_fields(prefix = nil, max_depth: 3)
39
+ ret_fields = []
40
+ fields(prefix).each do |field_with_prefix|
41
+ ret_fields << field_with_prefix
42
+ depth = field_with_prefix.split('.').length
43
+ field = field_with_prefix.split('.')[-1].to_sym
44
+ next unless defined? self::ASSOCIATION
45
+ next unless self::ASSOCIATION.key? field
46
+
47
+ child_klass = self::ASSOCIATION[field]
48
+ child_fields = if (self == child_klass) || depth >= max_depth
49
+ c_klass.fields(field_with_prefix)
50
+ else
51
+ c_klass.deep_fields(field_with_prefix, max_depth: max_depth)
52
+ end
53
+ child_fields.each { |c_field| ret_fields << c_field }
54
+ end
55
+ ret_fields
56
+ end
57
+ end
58
+
59
+ def self.included(base)
60
+ base.extend ClassMethods
61
+ end
62
+
63
+ private
64
+
65
+ def set_attributes(attrs)
66
+ return if attrs.nil?
67
+ return unless attrs.is_a? Hash
68
+ return if attrs.empty?
69
+
70
+ attrs.each do |key, value|
71
+ next unless respond_to? "#{key}=".to_sym
72
+
73
+ if defined?(self.class::ASSOCIATION) && self.class::ASSOCIATION.key?(key)
74
+ klass = self.class::ASSOCIATION[key]
75
+ if value.is_a? Array
76
+ value = value.map { |item| klass.new item, @client }
77
+ elsif value.is_a? Hash
78
+ value = klass.new value, @client
79
+ end
80
+ end
81
+ instance_variable_set "@#{key}", value
82
+ end
83
+ after_set_attributes(attrs)
84
+ end
85
+
86
+ def after_set_attributes(attrs); end
87
+ end
88
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's NameAndAddress model.
5
+ class NameAndAddress
6
+ include ModelUtils
7
+
8
+ # @return [String]
9
+ attr_accessor :address
10
+ # @return [String]
11
+ attr_accessor :city
12
+ # @return [String]
13
+ attr_accessor :country
14
+ # @return [String]
15
+ attr_accessor :familyName
16
+ # @return [String]
17
+ attr_accessor :givenName
18
+ # @return [String]
19
+ attr_accessor :organizationName
20
+ # @return [String]
21
+ attr_accessor :postalCode
22
+ # @return [String]
23
+ attr_accessor :region
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's Participant model.
5
+ class Participant
6
+ include ModelUtils
7
+
8
+ ASSOCIATION = {
9
+ links: Link
10
+ }.freeze
11
+
12
+ # @return [String]
13
+ attr_accessor :email
14
+ # @return [String]
15
+ attr_accessor :id
16
+ # @return [Array<YouCanBookMe::Link>]
17
+ attr_accessor :links
18
+ # @return [Boolean]
19
+ attr_accessor :required
20
+ # @return [String]
21
+ attr_accessor :role
22
+ # @return [String]
23
+ attr_accessor :status
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's Permission model.
5
+ class Permission
6
+ include ModelUtils
7
+
8
+ ASSOCIATION = {
9
+ databaseVersion: Permission,
10
+ fromLocalAccount: LocalAccount,
11
+ toLocalAccount: LocalAccount
12
+ }.freeze
13
+
14
+ # @return [String]
15
+ attr_accessor :createdAt
16
+ # @return [YouCanBookMe::Permission]
17
+ attr_accessor :databaseVersion
18
+ # @return [String]
19
+ attr_accessor :expiresAt
20
+ # @return [YouCanBookMe::LocalAccount]
21
+ attr_accessor :fromLocalAccount
22
+ # @return [String]
23
+ attr_accessor :id
24
+ # @return [String]
25
+ attr_accessor :requestedAction
26
+ # @return [String]
27
+ attr_accessor :resource
28
+ # @return [String]
29
+ attr_accessor :status
30
+ # @return [Integer]
31
+ attr_accessor :statusHibernate
32
+ # @return [YouCanBookMe::LocalAccount]
33
+ attr_accessor :toLocalAccount
34
+ # @return [String]
35
+ attr_accessor :type
36
+ # @return [String]
37
+ attr_accessor :updatedAt
38
+ end
39
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's Profile model.
5
+ class Profile
6
+ include ModelUtils
7
+
8
+ ASSOCIATION = {
9
+ actions: Action,
10
+ afterwards: ProfileAfterwards,
11
+ appointmentTypes: ProfileAppointmentTypes,
12
+ availableAccounts: ProfileLocalAccount,
13
+ calendars: ProfileCalendars,
14
+ cancelOrReschedule: ProfileCancelOrReschedule,
15
+ databaseVersion: Profile,
16
+ display: ProfileDisplay,
17
+ payments: ProfilePayments,
18
+ questions: Question,
19
+ remoteReminders: ProfileRemoteReminder,
20
+ services: ProfileAppointmentTypes,
21
+ teamMembers: ProfileTeamMembers,
22
+ tentative: ProfileTentative,
23
+ times: ProfileTimes,
24
+ vouchers: ProfileVouchers
25
+ }.freeze
26
+
27
+ # @return [String]
28
+ attr_accessor :accessCode
29
+ # @return [Boolean]
30
+ attr_accessor :accountCanAccessRestrictedFeatures
31
+ # @return [String]
32
+ attr_accessor :accountEmail
33
+ # @return [String]
34
+ attr_accessor :accountId
35
+ # @return [String]
36
+ attr_accessor :accountLocale
37
+ # @return [String]
38
+ attr_accessor :accountMobile
39
+ # @return [String]
40
+ attr_accessor :accountTimeZone
41
+ # @return [Array<YouCanBookMe::Action>]
42
+ attr_accessor :actions
43
+ # @return [YouCanBookMe::ProfileAfterwards]
44
+ attr_accessor :afterwards
45
+ # @return [YouCanBookMe::ProfileAppointmentTypes]
46
+ attr_accessor :appointmentTypes
47
+ # @return [Array<YouCanBookMe::ProfileLocalAccount>]
48
+ attr_accessor :availableAccounts
49
+ # @return [Array<YouCanBookMe::ProfileCalendars>]
50
+ attr_accessor :calendars
51
+ # @return [YouCanBookMe::ProfileCancelOrReschedule]
52
+ attr_accessor :cancelOrReschedule
53
+ # @return [Boolean]
54
+ attr_accessor :captchaActive
55
+ # @return [String]
56
+ attr_accessor :createdAt
57
+ # @return [YouCanBookMe::Profile]
58
+ attr_accessor :databaseVersion
59
+ # @return [String]
60
+ attr_accessor :datesPattern
61
+ # @return [String]
62
+ attr_accessor :description
63
+ # @return [YouCanBookMe::ProfileDisplay]
64
+ attr_accessor :display
65
+ # @return [Boolean]
66
+ attr_accessor :htmlAllowed
67
+ # @return [String]
68
+ attr_accessor :id
69
+ # @return [String]
70
+ attr_accessor :locale
71
+ # @return [String]
72
+ attr_accessor :logo
73
+ # @return [String]
74
+ attr_accessor :parentId
75
+ # @return [String]
76
+ attr_accessor :password
77
+ # @return [YouCanBookMe::ProfilePayments]
78
+ attr_accessor :payments
79
+ # @return [Boolean]
80
+ attr_accessor :protectedByAccessCode
81
+ # @return [Array<YouCanBookMe::Question>]
82
+ attr_accessor :questions
83
+ # @return [String]
84
+ attr_accessor :realtimeTopic
85
+ # @return [Array<YouCanBookMe::ProfileRemoteReminder>]
86
+ attr_accessor :remoteReminders
87
+ # @return [String]
88
+ attr_accessor :requestedAction
89
+ # @return [YouCanBookMe::ProfileAppointmentTypes]
90
+ attr_accessor :services
91
+ # @return [String]
92
+ attr_accessor :status
93
+ # @return [String]
94
+ attr_accessor :subdomain
95
+ # @return [YouCanBookMe::ProfileTeamMembers]
96
+ attr_accessor :teamMembers
97
+ # @return [YouCanBookMe::ProfileTentative]
98
+ attr_accessor :tentative
99
+ # @return [String]
100
+ attr_accessor :timeZone
101
+ # @return [Boolean]
102
+ attr_accessor :timeZoneOverride
103
+ # @return [YouCanBookMe::ProfileTimes]
104
+ attr_accessor :times
105
+ # @return [String]
106
+ attr_accessor :timesPattern
107
+ # @return [String]
108
+ attr_accessor :title
109
+ # @return [String]
110
+ attr_accessor :updatedAt
111
+ # @return [YouCanBookMe::ProfileVouchers]
112
+ attr_accessor :vouchers
113
+ end
114
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's ProfileAfterwards model.
5
+ class ProfileAfterwards
6
+ include ModelUtils
7
+
8
+ ASSOCIATION = {
9
+ bookerEvent: TemplateEvent,
10
+ ownerEvent: TemplateEvent
11
+ }.freeze
12
+
13
+ # @return [YouCanBookMe::TemplateEvent]
14
+ attr_accessor :bookerEvent
15
+ # @return [String]
16
+ attr_accessor :bookingDescription
17
+ # @return [String]
18
+ attr_accessor :bookingLocation
19
+ # @return [String]
20
+ attr_accessor :bookingTitle
21
+ # @return [Boolean]
22
+ attr_accessor :isUrl
23
+ # @return [YouCanBookMe::TemplateEvent]
24
+ attr_accessor :ownerEvent
25
+ # @return [Boolean]
26
+ attr_accessor :scrollToTop
27
+ # @return [String]
28
+ attr_accessor :text
29
+ # @return [Boolean]
30
+ attr_accessor :updateWholeBrowserWindow
31
+ # @return [String]
32
+ attr_accessor :url
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's ProfileAppointmentType model.
5
+ class ProfileAppointmentType
6
+ include ModelUtils
7
+
8
+ # @return [String]
9
+ attr_accessor :description
10
+ # @return [String]
11
+ attr_accessor :id
12
+ # @return [String]
13
+ attr_accessor :name
14
+ # @return [Integer]
15
+ attr_accessor :numberOfSlots
16
+ # @return [String]
17
+ attr_accessor :pic
18
+ # @return [Integer]
19
+ attr_accessor :price
20
+ # @return [Integer]
21
+ attr_accessor :slotLengthMinutes
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's ProfileAppointmentTypes model.
5
+ class ProfileAppointmentTypes
6
+ include ModelUtils
7
+
8
+ ASSOCIATION = {
9
+ items: ProfileAppointmentType
10
+ }.freeze
11
+
12
+ # @return [Boolean]
13
+ attr_accessor :active
14
+ # @return [Boolean]
15
+ attr_accessor :combinable
16
+ # @return [String]
17
+ attr_accessor :description
18
+ # @return [Boolean]
19
+ attr_accessor :groupsActive
20
+ # @return [String]
21
+ attr_accessor :groupsDivider
22
+ # @return [Array<ProfileAppointmentType>]
23
+ attr_accessor :items
24
+ # @return [Boolean]
25
+ attr_accessor :randomizable
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's ProfileCalendar model.
5
+ class ProfileCalendar
6
+ include ModelUtils
7
+
8
+ # @return [String]
9
+ attr_accessor :id
10
+ # @return [String]
11
+ attr_accessor :timeZone
12
+ # @return [String]
13
+ attr_accessor :title
14
+ # @return [String]
15
+ attr_accessor :url
16
+ # @return [String]
17
+ attr_accessor :userName
18
+ # @return [Boolean]
19
+ attr_accessor :writeable
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's ProfileCalendars model.
5
+ class ProfileCalendars
6
+ include ModelUtils
7
+
8
+ ASSOCIATION = {
9
+ targetCalendar: ProfileCalendar
10
+ }.freeze
11
+
12
+ # @return [Array<String>]
13
+ attr_accessor :calendarIds
14
+ # @return [YouCanBookMe::ProfileCalendar]
15
+ attr_accessor :targetCalendar
16
+ # @return [String]
17
+ attr_accessor :targetCalendarId
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouCanBookMe
4
+ # YouCanBookMe's ProfileCancelOrReschedule model.
5
+ class ProfileCancelOrReschedule
6
+ include ModelUtils
7
+
8
+ # @return [Boolean]
9
+ attr_accessor :allowed
10
+ # @return [String]
11
+ attr_accessor :cancellationInstructions
12
+ # @return [String]
13
+ attr_accessor :limitMessage
14
+ # @return [Integer]
15
+ attr_accessor :limitMinutes
16
+ # @return [Boolean]
17
+ attr_accessor :reasonRequired
18
+ # @return [Boolean]
19
+ attr_accessor :showReasonTextBox
20
+ end
21
+ end