stbaldricks 1.5.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/lib/stbaldricks.rb +2 -0
  4. data/lib/stbaldricks/api.rb +7 -0
  5. data/lib/stbaldricks/api_connector.rb +47 -0
  6. data/lib/stbaldricks/client.rb +7 -0
  7. data/lib/stbaldricks/configuration.rb +47 -0
  8. data/lib/stbaldricks/default_logger.rb +24 -0
  9. data/lib/stbaldricks/endpoints/communicate.rb +67 -0
  10. data/lib/stbaldricks/endpoints/config.rb +18 -0
  11. data/lib/stbaldricks/endpoints/contact.rb +12 -0
  12. data/lib/stbaldricks/endpoints/event.rb +39 -0
  13. data/lib/stbaldricks/endpoints/event_application.rb +32 -0
  14. data/lib/stbaldricks/endpoints/fund.rb +24 -0
  15. data/lib/stbaldricks/endpoints/kid.rb +24 -0
  16. data/lib/stbaldricks/endpoints/kid_honor.rb +17 -0
  17. data/lib/stbaldricks/endpoints/lib/entity.rb +247 -0
  18. data/lib/stbaldricks/endpoints/message.rb +27 -0
  19. data/lib/stbaldricks/endpoints/newsletter_recipient.rb +41 -0
  20. data/lib/stbaldricks/endpoints/participant.rb +66 -0
  21. data/lib/stbaldricks/endpoints/photo.rb +51 -0
  22. data/lib/stbaldricks/endpoints/recurring_gift.rb +18 -0
  23. data/lib/stbaldricks/endpoints/search.rb +63 -0
  24. data/lib/stbaldricks/endpoints/shave_schedule.rb +28 -0
  25. data/lib/stbaldricks/endpoints/user.rb +106 -0
  26. data/lib/stbaldricks/entities/batch.rb +29 -0
  27. data/lib/stbaldricks/entities/campaign.rb +37 -0
  28. data/lib/stbaldricks/entities/communicate.rb +20 -0
  29. data/lib/stbaldricks/entities/config.rb +41 -0
  30. data/lib/stbaldricks/entities/contact.rb +40 -0
  31. data/lib/stbaldricks/entities/contact_group.rb +29 -0
  32. data/lib/stbaldricks/entities/document_library.rb +19 -0
  33. data/lib/stbaldricks/entities/document_library_category.rb +14 -0
  34. data/lib/stbaldricks/entities/donation.rb +372 -0
  35. data/lib/stbaldricks/entities/donation/donor_type.rb +13 -0
  36. data/lib/stbaldricks/entities/donation/how_created.rb +22 -0
  37. data/lib/stbaldricks/entities/donation/payment_type.rb +17 -0
  38. data/lib/stbaldricks/entities/donation/promo_code.rb +22 -0
  39. data/lib/stbaldricks/entities/donation/recipient_type.rb +17 -0
  40. data/lib/stbaldricks/entities/donation/special_donation_type.rb +78 -0
  41. data/lib/stbaldricks/entities/donation/status.rb +12 -0
  42. data/lib/stbaldricks/entities/donation/submitter_type.rb +13 -0
  43. data/lib/stbaldricks/entities/donor.rb +15 -0
  44. data/lib/stbaldricks/entities/event.rb +173 -0
  45. data/lib/stbaldricks/entities/event/fund_relationship_type.rb +15 -0
  46. data/lib/stbaldricks/entities/event/how_created.rb +14 -0
  47. data/lib/stbaldricks/entities/event/promo_code.rb +11 -0
  48. data/lib/stbaldricks/entities/event/status.rb +13 -0
  49. data/lib/stbaldricks/entities/event/sub_type.rb +16 -0
  50. data/lib/stbaldricks/entities/event/type.rb +12 -0
  51. data/lib/stbaldricks/entities/event_application.rb +135 -0
  52. data/lib/stbaldricks/entities/event_application/model_type.rb +15 -0
  53. data/lib/stbaldricks/entities/event_application/status.rb +23 -0
  54. data/lib/stbaldricks/entities/event_donation_summary.rb +18 -0
  55. data/lib/stbaldricks/entities/event_participant_summary.rb +17 -0
  56. data/lib/stbaldricks/entities/event_supporter.rb +24 -0
  57. data/lib/stbaldricks/entities/fund.rb +98 -0
  58. data/lib/stbaldricks/entities/fundraiser.rb +124 -0
  59. data/lib/stbaldricks/entities/international_partner.rb +58 -0
  60. data/lib/stbaldricks/entities/kid.rb +190 -0
  61. data/lib/stbaldricks/entities/kid_honor.rb +123 -0
  62. data/lib/stbaldricks/entities/lib/address.rb +25 -0
  63. data/lib/stbaldricks/entities/lib/base.rb +505 -0
  64. data/lib/stbaldricks/entities/lib/cacheable.rb +43 -0
  65. data/lib/stbaldricks/entities/lib/default_cacheable.rb +17 -0
  66. data/lib/stbaldricks/entities/lib/email_address.rb +15 -0
  67. data/lib/stbaldricks/entities/lib/error.rb +38 -0
  68. data/lib/stbaldricks/entities/lib/fundraising_page.rb +20 -0
  69. data/lib/stbaldricks/entities/lib/geo_location.rb +9 -0
  70. data/lib/stbaldricks/entities/lib/location.rb +27 -0
  71. data/lib/stbaldricks/entities/lib/name.rb +17 -0
  72. data/lib/stbaldricks/entities/lib/not_implemented_object.rb +32 -0
  73. data/lib/stbaldricks/entities/lib/opt_out_settings.rb +21 -0
  74. data/lib/stbaldricks/entities/lib/payment.rb +86 -0
  75. data/lib/stbaldricks/entities/lib/permissions.rb +33 -0
  76. data/lib/stbaldricks/entities/lib/phone.rb +29 -0
  77. data/lib/stbaldricks/entities/lib/third_party_media.rb +20 -0
  78. data/lib/stbaldricks/entities/lib/top_level.rb +99 -0
  79. data/lib/stbaldricks/entities/lib/venue.rb +18 -0
  80. data/lib/stbaldricks/entities/memorial.rb +61 -0
  81. data/lib/stbaldricks/entities/message.rb +65 -0
  82. data/lib/stbaldricks/entities/newsletter_recipient.rb +17 -0
  83. data/lib/stbaldricks/entities/organization.rb +90 -0
  84. data/lib/stbaldricks/entities/page.rb +49 -0
  85. data/lib/stbaldricks/entities/participant.rb +216 -0
  86. data/lib/stbaldricks/entities/person.rb +403 -0
  87. data/lib/stbaldricks/entities/photo.rb +260 -0
  88. data/lib/stbaldricks/entities/recurring_gift.rb +215 -0
  89. data/lib/stbaldricks/entities/response.rb +37 -0
  90. data/lib/stbaldricks/entities/search.rb +223 -0
  91. data/lib/stbaldricks/entities/section.rb +15 -0
  92. data/lib/stbaldricks/entities/shave_schedule.rb +69 -0
  93. data/lib/stbaldricks/entities/summary.rb +32 -0
  94. data/lib/stbaldricks/entities/team.rb +95 -0
  95. data/lib/stbaldricks/entities/user.rb +76 -0
  96. data/lib/stbaldricks/enums/country.rb +223 -0
  97. data/lib/stbaldricks/enums/feature.rb +29 -0
  98. data/lib/stbaldricks/enums/league_status.rb +16 -0
  99. data/lib/stbaldricks/enums/model_type.rb +39 -0
  100. data/lib/stbaldricks/enums/permission.rb +223 -0
  101. data/lib/stbaldricks/enums/permission_model_type.rb +21 -0
  102. data/lib/stbaldricks/enums/province.rb +39 -0
  103. data/lib/stbaldricks/enums/state.rb +137 -0
  104. data/lib/stbaldricks/enums/top_level_category_type.rb +25 -0
  105. data/lib/stbaldricks/errors.rb +18 -0
  106. data/lib/stbaldricks/log.rb +16 -0
  107. data/lib/stbaldricks/patches/array.rb +6 -0
  108. data/lib/stbaldricks/patches/boolean.rb +25 -0
  109. data/lib/stbaldricks/patches/class.rb +13 -0
  110. data/lib/stbaldricks/patches/float.rb +9 -0
  111. data/lib/stbaldricks/patches/hash.rb +16 -0
  112. data/lib/stbaldricks/patches/integer.rb +9 -0
  113. data/lib/stbaldricks/patches/nil.rb +25 -0
  114. data/lib/stbaldricks/patches/string.rb +54 -0
  115. data/lib/stbaldricks/request.rb +146 -0
  116. data/lib/stbaldricks/version.rb +5 -0
  117. metadata +215 -0
@@ -0,0 +1,43 @@
1
+ module SBF
2
+ module Client
3
+ module Entities
4
+ module Cacheable
5
+ class CacheableNotImplementedError < StandardError; end
6
+ class CacheableInvalidDataError < StandardError; end
7
+
8
+ def self.included(base)
9
+ base.extend(ClassMethods)
10
+ end
11
+
12
+ def cache_id
13
+ raise CacheableNotImplementedError
14
+ end
15
+
16
+ module ClassMethods
17
+ def cache_id(proc)
18
+ define_method(:cache_id) do
19
+ instance_exec(&proc)
20
+ end
21
+ end
22
+
23
+ def cache_id_from_hash(proc_or_hash)
24
+ return cache_id_from_hash_func(proc_or_hash) if proc_or_hash.is_a?(Proc)
25
+ raise CacheableNotImplementedError unless @cache_id_proc || superclass.respond_to?(:cache_id_from_hash)
26
+
27
+ id = @cache_id_proc.call(proc_or_hash || {}) if @cache_id_proc
28
+ id ||= superclass.cache_id_from_hash(proc_or_hash || {}) if superclass.respond_to?(:cache_id_from_hash)
29
+ raise CacheableInvalidDataError, "Data missing id. Data: #{proc_or_hash.to_json}" unless id
30
+ id
31
+ end
32
+
33
+ private
34
+
35
+ def cache_id_from_hash_func(proc)
36
+ raise ArgumentError, "Unable to re-set cache_id_from_hash on #{name}" if @cache_id_proc
37
+ @cache_id_proc = proc
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ require 'stbaldricks/entities/lib/cacheable'
2
+
3
+ module SBF
4
+ module Client
5
+ module Entities
6
+ module DefaultCacheable
7
+ def self.included(klass)
8
+ klass.class_eval do
9
+ include Cacheable
10
+ cache_id_from_hash ->(h) { [h[:id]] }
11
+ cache_id -> { [id] }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class EmailAddress < SBF::Client::BaseEntity
6
+ module Type
7
+ PERSONAL = 'personal'
8
+ BUSINESS = 'business'
9
+ end
10
+
11
+ attr_accessor :type
12
+ attr_accessor :email_address
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ require 'stbaldricks/errors'
2
+
3
+ module SBF
4
+ module Client
5
+ class ErrorEntity
6
+ BAD_INPUT = 5007
7
+
8
+ attr_reader :code, :type, :details, :fields
9
+
10
+ def initialize(data = {})
11
+ super()
12
+
13
+ # In case null was explicitly passed in
14
+ data ||= {}
15
+
16
+ # Set all attributes
17
+ @code = data[:code].freeze
18
+ @type = data[:type].freeze
19
+ @details = data[:details].freeze
20
+ @fields = Set.new(data[:errors].empty? ? [] : data[:errors]).freeze
21
+ end
22
+
23
+ def to_hash
24
+ {code: @code, type: @type, details: @details, fields: @fields.to_a}
25
+ end
26
+
27
+ def to_json(*a)
28
+ to_hash.to_json(*a)
29
+ end
30
+
31
+ def to_s
32
+ error_message = "#{@code} - [#{@type}] #{@details}"
33
+ error_message << " details: #{@fields.to_a.join(', ')}" unless @fields.empty?
34
+ error_message
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class FundraisingPage < SBF::Client::BaseEntity
6
+ attr_accessor :is_enabled
7
+ attr_accessor :custom_url_segment
8
+ attr_reader :url
9
+
10
+ HTTP_REGEX = %r{^https?://}
11
+
12
+ def url_with_scheme
13
+ url.insert(0, 'https:') unless url.empty? || HTTP_REGEX.match(url)
14
+ url
15
+ end
16
+ end
17
+
18
+ class WebPage < SBF::Client::FundraisingPage; end
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class GeoLocation < SBF::Client::BaseEntity
6
+ attr_accessor :lat, :lon
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+ require 'stbaldricks/entities/lib/address'
3
+
4
+ module SBF
5
+ module Client
6
+ class Location < SBF::Client::BaseEntity
7
+ module Type
8
+ RESTAURANT = 'restaurant'
9
+ SCHOOL = 'school'
10
+ BUSINESS = 'business'
11
+ PRIVATE_RESIDENCE = 'private_residence'
12
+ HOSPITAL = 'hospital'
13
+ MUNICIPALITY = 'municipality'
14
+ OTHER = 'other'
15
+ LEGACY = 'legacy'
16
+ end
17
+
18
+ attr_accessor :type
19
+ attr_accessor :name
20
+ entity_attr_accessor :address, 'SBF::Client::Address'
21
+
22
+ def name
23
+ HTMLEntities.new.decode(@name)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class NamePieces < SBF::Client::BaseEntity
6
+ attr_accessor :prefix, :first_name, :middle_initial, :last_name, :suffix
7
+
8
+ def combined_name
9
+ name = ''
10
+ name += @first_name + ' ' unless @first_name.nil?
11
+ name += @middle_initial + '. ' unless @middle_initial.nil?
12
+ name += @last_name unless @last_name.nil?
13
+ name.strip
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ # - JUST CODED THIS SO IT WILL RESPOND WITH DOT NOTATION ex, thing.id instead of thing['id']
4
+ module SBF
5
+ module Client
6
+ class NotImplementedObject < SBF::Client::BaseEntity
7
+ attr_accessor :props
8
+
9
+ def initialize(attributes = {})
10
+ @props = {}.tap { |hsh|
11
+ attributes.each { |k, v|
12
+ hsh[k.to_sym] = v
13
+ }
14
+ }
15
+
16
+ super
17
+ end
18
+
19
+ def method_missing(name)
20
+ return @props[name.to_sym] if @props.key?(name.to_sym)
21
+ super.method_missing(name)
22
+ end
23
+
24
+ def to_hash
25
+ {}.tap do |hsh|
26
+ props.each { |k, v| hsh[k] = v }
27
+ self.class.attributes.each { |name| hsh[name] = send(name.to_sym) unless hsh.key?(name.to_sym) || name.to_sym == :props }
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class OptOutSettings < SBF::Client::BaseEntity
6
+ attr_reader :email_activity, :email_members_communication, :email_mass_online, :email_mass_print, :email_reply, :email_contact_us
7
+
8
+ # Setting Types
9
+ NOTIFICATION_TYPE = 1
10
+ EMAIL_TYPE = 2
11
+
12
+ # Settings
13
+ WEBSITE_ACTIVITY = 1
14
+ CONTACT_US = 20
15
+ ONLINE_MASS_MAIL = 23
16
+ PRINT_MASS_MAIL = 24
17
+ REPLY = 26
18
+ MEMBERS_COMMUNICATION = 28
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,86 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class Payment
6
+ module Type
7
+ UNKNOWN = 'unknown'
8
+ CREDIT_CARD = 'credit_card'
9
+ CHECK = 'check'
10
+ CASH = 'cash'
11
+ MONEY_ORDER = 'money_order'
12
+ NONCE = 'nonce'
13
+ WIRE_TRANSFER = 'wire_transfer'
14
+ RECURRING_GIFTS = 'recurring'
15
+ end
16
+
17
+ class Details < SBF::Client::BaseEntity
18
+ attr_reader :type
19
+
20
+ def type
21
+ SBF::Client::Payment::Type::UNKNOWN
22
+ end
23
+ end
24
+
25
+ class CreditCardDetails < SBF::Client::Payment::Details
26
+ attr_accessor :authorization_id, :cardholder_name, :card_type, :expiration_date, :card_number
27
+
28
+ def type
29
+ SBF::Client::Payment::Type::CREDIT_CARD
30
+ end
31
+ end
32
+
33
+ class BraintreeSubscriptionDetails < SBF::Client::Payment::Details
34
+ attr_accessor :subscription_id, :customer_id, :cardholder_name, :card_type, :expiration_date, :card_number
35
+
36
+ def type
37
+ SBF::Client::Payment::Type::RECURRING_GIFTS
38
+ end
39
+ end
40
+
41
+ class CheckDetails < SBF::Client::Payment::Details
42
+ attr_accessor :number
43
+
44
+ def type
45
+ SBF::Client::Payment::Type::CHECK
46
+ end
47
+ end
48
+
49
+ class MoneyOrderDetails < SBF::Client::Payment::Details
50
+ attr_accessor :number
51
+
52
+ def type
53
+ SBF::Client::Payment::Type::MONEY_ORDER
54
+ end
55
+ end
56
+
57
+ class WireTransferDetails < SBF::Client::Payment::Details
58
+ attr_accessor :number
59
+
60
+ def type
61
+ SBF::Client::Payment::Type::WIRE_TRANSFER
62
+ end
63
+ end
64
+
65
+ class CashDetails < SBF::Client::Payment::Details
66
+ def type
67
+ SBF::Client::Payment::Type::CASH
68
+ end
69
+ end
70
+
71
+ class UnknownDetails < SBF::Client::Payment::Details
72
+ def type
73
+ SBF::Client::Payment::Type::UNKNOWN
74
+ end
75
+ end
76
+
77
+ class NonceDetails < SBF::Client::Payment::Details
78
+ attr_accessor :nonce, :device_data
79
+
80
+ def type
81
+ SBF::Client::Payment::Type::NONCE
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,33 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+ require 'stbaldricks/enums/permission'
3
+ require 'set'
4
+
5
+ module SBF
6
+ module Client
7
+ class Permissions < SBF::Client::BaseEntity
8
+ attr_accessor :is_owner
9
+ attr_accessor :permission_ids
10
+
11
+ def method_missing(method, *arguments, &block)
12
+ # If the method starts with 'can', assume they are trying to determine if the user has the permission
13
+ # in their list of permission ids and return the result
14
+ if method.to_s.start_with?('can_')
15
+ const_name = method.to_s.split('can_').last.upcase.to_sym
16
+
17
+ if SBF::Client::Permission.constants(false).include?(const_name)
18
+ permission_id = SBF::Client::Permission.const_get(const_name, false)
19
+ return permission_ids.include?(permission_id)
20
+
21
+ end
22
+ end
23
+
24
+ super
25
+ end
26
+ end
27
+
28
+ class PermissionsAtEvent < SBF::Client::BaseEntity
29
+ attr_accessor :granted
30
+ attr_accessor :inherited_from_roles
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+
3
+ module SBF
4
+ module Client
5
+ class Phone < SBF::Client::BaseEntity
6
+ module Type
7
+ HOME = 'home'
8
+ BUSINESS = 'business'
9
+ MOBILE = 'mobile'
10
+ end
11
+
12
+ attr_accessor :type
13
+ attr_accessor :number, :extension
14
+
15
+ # (402)555-5555 --> tel:4025555555
16
+ def format_href
17
+ return 'tel:' + number.gsub(/\D/, '') unless number.nil?
18
+ number
19
+ end
20
+
21
+ # This kinda handles extensions, at least? We never actually populate :extension, do we?
22
+ # (402)555-5555 ext. 5555 --> 402.555.555 x5555
23
+ def format_number
24
+ return number.gsub(/\D/, '').gsub(/(\d{3})(\d{3})(\d{4})(\d*)/, '\1.\2.\3 x\4').gsub(/x$/, '').rstrip unless number.nil?
25
+ number
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+ require 'stbaldricks/entities/lib/cacheable'
3
+ require 'stbaldricks/entities/lib/default_cacheable'
4
+
5
+ module SBF
6
+ module Client
7
+ class ThirdPartyMedia < SBF::Client::BaseEntity
8
+ include Entities::DefaultCacheable
9
+
10
+ module Type
11
+ YOUTUBE = 'youtube'
12
+ VIMEO = 'vimeo'
13
+ end
14
+
15
+ attr_accessor :id
16
+ attr_accessor :type
17
+ attr_accessor :identifier
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,99 @@
1
+ require 'stbaldricks/entities/lib/base'
2
+ require 'stbaldricks/endpoints/lib/entity'
3
+ require 'stbaldricks/entities/lib/cacheable'
4
+
5
+ module SBF
6
+ module Client
7
+ class TopLevelEntity < SBF::Client::BaseEntity
8
+ include Entities::Cacheable
9
+
10
+ DEFAULT_ENDPOINT = SBF::Client::EntityEndpoint
11
+ DEFAULT_INSTANCE_ACTIONS = [:save, :create, :update, :delete]
12
+ DEFAULT_CLASS_ACTIONS = [:get, :find, :find_first, :aggregate, :update, :delete]
13
+ DEFAULT_CRUD_ACTIONS = DEFAULT_INSTANCE_ACTIONS + DEFAULT_CLASS_ACTIONS
14
+
15
+ class << self
16
+ DEFAULT_CLASS_ACTIONS.each do |action|
17
+ define_method(action) do |*_|
18
+ raise NoMethodError.new("#{action} is not implemented", action)
19
+ end
20
+ end
21
+
22
+ def endpoint(mod = nil, options = {})
23
+ return define_endpoint(mod, options) if mod
24
+ _endpoint
25
+ end
26
+
27
+ def _endpoint
28
+ DEFAULT_ENDPOINT.new(self)
29
+ end
30
+
31
+ def define_endpoint(mod, options)
32
+ singleton_class.class_eval do
33
+ define_method(:_endpoint) do
34
+ @_endpoint ||= mod.new(options.fetch(:target_class, self))
35
+ end
36
+ end
37
+ end
38
+
39
+ def actions(actions)
40
+ actions.each { |m| action(m) }
41
+ end
42
+
43
+ def instance_action(name)
44
+ define_method(name) do |*args|
45
+ endpoint.send(name, self, *args)
46
+ end
47
+ end
48
+
49
+ def class_action(name)
50
+ singleton_class.class_eval do
51
+ define_method(name) do |*args|
52
+ endpoint.send(name, *args)
53
+ end
54
+ end
55
+ end
56
+
57
+ def action(name)
58
+ instance_action(name) if [:save, :create].include?(name)
59
+
60
+ if name == :update
61
+ define_method(name) do |*args|
62
+ endpoint.update(id, self, *args)
63
+ end
64
+ end
65
+
66
+ if name == :delete
67
+ define_method(:delete) do |*_args|
68
+ endpoint.delete(id)
69
+ end
70
+ end
71
+
72
+ class_action(name)
73
+ end
74
+
75
+ def blacklist_action(name)
76
+ define_method(name) do |*_|
77
+ raise NoMethodError.new("#{name} is blacklisted", name)
78
+ end
79
+
80
+ singleton_class.class_eval do
81
+ define_method(name) do |*_|
82
+ raise NoMethodError.new("#{name} is blacklisted", name)
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ DEFAULT_INSTANCE_ACTIONS.each do |action|
89
+ define_method(action) do |*_|
90
+ raise NoMethodError.new("#{action} is not implemented", action)
91
+ end
92
+ end
93
+
94
+ def endpoint
95
+ self.class.endpoint
96
+ end
97
+ end
98
+ end
99
+ end