stbaldricks 12.11.0 → 12.12.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stbaldricks/configuration.rb +2 -2
  3. data/lib/stbaldricks/default_logger.rb +2 -2
  4. data/lib/stbaldricks/endpoints/blog_post.rb +8 -8
  5. data/lib/stbaldricks/endpoints/communicate.rb +1 -1
  6. data/lib/stbaldricks/endpoints/config.rb +1 -1
  7. data/lib/stbaldricks/endpoints/deduplicator_match.rb +2 -2
  8. data/lib/stbaldricks/endpoints/kid.rb +1 -1
  9. data/lib/stbaldricks/endpoints/lib/entity.rb +13 -11
  10. data/lib/stbaldricks/endpoints/newsletter_recipient.rb +11 -5
  11. data/lib/stbaldricks/endpoints/participant.rb +3 -3
  12. data/lib/stbaldricks/endpoints/photo.rb +5 -4
  13. data/lib/stbaldricks/endpoints/search.rb +2 -2
  14. data/lib/stbaldricks/endpoints/user.rb +1 -1
  15. data/lib/stbaldricks/entities/batch.rb +3 -5
  16. data/lib/stbaldricks/entities/blog_post.rb +1 -7
  17. data/lib/stbaldricks/entities/campaign.rb +6 -13
  18. data/lib/stbaldricks/entities/challenge.rb +4 -6
  19. data/lib/stbaldricks/entities/challenger.rb +4 -6
  20. data/lib/stbaldricks/entities/concerns/entity_response_concern.rb +1 -1
  21. data/lib/stbaldricks/entities/config.rb +3 -8
  22. data/lib/stbaldricks/entities/contact.rb +4 -7
  23. data/lib/stbaldricks/entities/contact_group.rb +2 -2
  24. data/lib/stbaldricks/entities/deduplicator_history.rb +1 -6
  25. data/lib/stbaldricks/entities/deduplicator_match.rb +4 -7
  26. data/lib/stbaldricks/entities/disease.rb +2 -5
  27. data/lib/stbaldricks/entities/document_library.rb +3 -8
  28. data/lib/stbaldricks/entities/document_library_category.rb +1 -4
  29. data/lib/stbaldricks/entities/donation.rb +12 -18
  30. data/lib/stbaldricks/entities/donor.rb +1 -5
  31. data/lib/stbaldricks/entities/event.rb +32 -43
  32. data/lib/stbaldricks/entities/event_application.rb +6 -10
  33. data/lib/stbaldricks/entities/event_donation_summary.rb +2 -5
  34. data/lib/stbaldricks/entities/event_participant_summary.rb +1 -3
  35. data/lib/stbaldricks/entities/event_supporter.rb +3 -3
  36. data/lib/stbaldricks/entities/fund.rb +6 -23
  37. data/lib/stbaldricks/entities/fundraiser.rb +16 -29
  38. data/lib/stbaldricks/entities/grant.rb +12 -25
  39. data/lib/stbaldricks/entities/institution.rb +3 -4
  40. data/lib/stbaldricks/entities/international_partner.rb +4 -16
  41. data/lib/stbaldricks/entities/kid.rb +11 -28
  42. data/lib/stbaldricks/entities/kid_honor.rb +1 -0
  43. data/lib/stbaldricks/entities/kid_institution.rb +2 -2
  44. data/lib/stbaldricks/entities/lib/address.rb +3 -6
  45. data/lib/stbaldricks/entities/lib/alternate_shipping_address.rb +1 -3
  46. data/lib/stbaldricks/entities/lib/base.rb +47 -39
  47. data/lib/stbaldricks/entities/lib/collection.rb +2 -2
  48. data/lib/stbaldricks/entities/lib/email_address.rb +1 -2
  49. data/lib/stbaldricks/entities/lib/fundraising_page.rb +1 -2
  50. data/lib/stbaldricks/entities/lib/location.rb +1 -0
  51. data/lib/stbaldricks/entities/lib/milestone.rb +1 -3
  52. data/lib/stbaldricks/entities/lib/name.rb +2 -2
  53. data/lib/stbaldricks/entities/lib/not_implemented_object.rb +1 -1
  54. data/lib/stbaldricks/entities/lib/permissions.rb +2 -4
  55. data/lib/stbaldricks/entities/lib/phone.rb +2 -3
  56. data/lib/stbaldricks/entities/lib/third_party_media.rb +1 -5
  57. data/lib/stbaldricks/entities/lib/top_level.rb +1 -1
  58. data/lib/stbaldricks/entities/matching_gift_company.rb +16 -39
  59. data/lib/stbaldricks/entities/memorial.rb +9 -14
  60. data/lib/stbaldricks/entities/message.rb +4 -15
  61. data/lib/stbaldricks/entities/organization.rb +11 -17
  62. data/lib/stbaldricks/entities/page.rb +9 -15
  63. data/lib/stbaldricks/entities/participant.rb +18 -28
  64. data/lib/stbaldricks/entities/participant_donation_summary.rb +2 -4
  65. data/lib/stbaldricks/entities/person.rb +22 -30
  66. data/lib/stbaldricks/entities/person_donation_by_year_summary.rb +1 -2
  67. data/lib/stbaldricks/entities/photo.rb +5 -11
  68. data/lib/stbaldricks/entities/recurring_gift.rb +10 -18
  69. data/lib/stbaldricks/entities/response.rb +1 -0
  70. data/lib/stbaldricks/entities/search.rb +30 -168
  71. data/lib/stbaldricks/entities/section.rb +1 -4
  72. data/lib/stbaldricks/entities/shave_schedule.rb +4 -13
  73. data/lib/stbaldricks/entities/summary.rb +1 -7
  74. data/lib/stbaldricks/entities/team.rb +12 -16
  75. data/lib/stbaldricks/entities/team_donation_summary.rb +2 -4
  76. data/lib/stbaldricks/request.rb +2 -2
  77. data/lib/stbaldricks/version.rb +1 -1
  78. metadata +87 -281
  79. data/lib/stbaldricks_factories.rb +0 -5
  80. data/spec/factories/address.rb +0 -14
  81. data/spec/factories/campaign/totals.rb +0 -9
  82. data/spec/factories/campaign.rb +0 -9
  83. data/spec/factories/challenge.rb +0 -19
  84. data/spec/factories/challenger.rb +0 -33
  85. data/spec/factories/collection.rb +0 -17
  86. data/spec/factories/contact.rb +0 -18
  87. data/spec/factories/contact_group.rb +0 -18
  88. data/spec/factories/diagnosis.rb +0 -12
  89. data/spec/factories/disease.rb +0 -11
  90. data/spec/factories/donation/participant.rb +0 -27
  91. data/spec/factories/donation.rb +0 -68
  92. data/spec/factories/donor.rb +0 -13
  93. data/spec/factories/email_address.rb +0 -11
  94. data/spec/factories/error.rb +0 -9
  95. data/spec/factories/event/coach_tracking/coaching_interactions.rb +0 -12
  96. data/spec/factories/event/coach_tracking/plaque.rb +0 -12
  97. data/spec/factories/event/coach_tracking/proceeds.rb +0 -12
  98. data/spec/factories/event/coach_tracking.rb +0 -18
  99. data/spec/factories/event/contacts/contact.rb +0 -17
  100. data/spec/factories/event/contacts/name_pieces.rb +0 -12
  101. data/spec/factories/event/contacts.rb +0 -16
  102. data/spec/factories/event/photos.rb +0 -12
  103. data/spec/factories/event/totals.rb +0 -15
  104. data/spec/factories/event/venue/location.rb +0 -18
  105. data/spec/factories/event/venue/social.rb +0 -16
  106. data/spec/factories/event/venue.rb +0 -16
  107. data/spec/factories/event.rb +0 -66
  108. data/spec/factories/event_application.rb +0 -34
  109. data/spec/factories/event_supporter.rb +0 -19
  110. data/spec/factories/fund.rb +0 -18
  111. data/spec/factories/fundraiser/photos.rb +0 -12
  112. data/spec/factories/fundraiser/policies.rb +0 -11
  113. data/spec/factories/fundraiser/totals.rb +0 -11
  114. data/spec/factories/fundraiser.rb +0 -24
  115. data/spec/factories/fundraising_page.rb +0 -29
  116. data/spec/factories/grant.rb +0 -22
  117. data/spec/factories/grant_institution.rb +0 -17
  118. data/spec/factories/institution.rb +0 -18
  119. data/spec/factories/kid/custom_institution.rb +0 -12
  120. data/spec/factories/kid.rb +0 -58
  121. data/spec/factories/kid_honor.rb +0 -16
  122. data/spec/factories/kid_institution.rb +0 -23
  123. data/spec/factories/lib/faker_patch.rb +0 -27
  124. data/spec/factories/lib/helpers.rb +0 -7
  125. data/spec/factories/location.rb +0 -17
  126. data/spec/factories/memorial/photos.rb +0 -14
  127. data/spec/factories/memorial/totals.rb +0 -11
  128. data/spec/factories/memorial/tribute.rb +0 -19
  129. data/spec/factories/memorial.rb +0 -22
  130. data/spec/factories/message.rb +0 -31
  131. data/spec/factories/milestone.rb +0 -15
  132. data/spec/factories/name_pieces.rb +0 -24
  133. data/spec/factories/newsletter_recipient.rb +0 -13
  134. data/spec/factories/organization/addresses.rb +0 -16
  135. data/spec/factories/organization/email_addresses.rb +0 -14
  136. data/spec/factories/organization/phone_numbers.rb +0 -14
  137. data/spec/factories/organization.rb +0 -34
  138. data/spec/factories/page.rb +0 -5
  139. data/spec/factories/participant/photos.rb +0 -14
  140. data/spec/factories/participant/policies.rb +0 -12
  141. data/spec/factories/participant/rankings/ranking.rb +0 -12
  142. data/spec/factories/participant/rankings.rb +0 -16
  143. data/spec/factories/participant/roles/role.rb +0 -154
  144. data/spec/factories/participant/roles.rb +0 -37
  145. data/spec/factories/participant/totals.rb +0 -11
  146. data/spec/factories/participant.rb +0 -95
  147. data/spec/factories/payment.rb +0 -13
  148. data/spec/factories/permissions.rb +0 -12
  149. data/spec/factories/person/addresses.rb +0 -16
  150. data/spec/factories/person/email_addresses.rb +0 -14
  151. data/spec/factories/person/phone_numbers.rb +0 -14
  152. data/spec/factories/person/policies.rb +0 -13
  153. data/spec/factories/person.rb +0 -22
  154. data/spec/factories/phone.rb +0 -11
  155. data/spec/factories/photo.rb +0 -11
  156. data/spec/factories/photos.rb +0 -9
  157. data/spec/factories/recurring_gift.rb +0 -22
  158. data/spec/factories/researcher.rb +0 -15
  159. data/spec/factories/response.rb +0 -38
  160. data/spec/factories/search_event.rb +0 -19
  161. data/spec/factories/search_fundraiser.rb +0 -15
  162. data/spec/factories/search_kid.rb +0 -13
  163. data/spec/factories/search_participant.rb +0 -15
  164. data/spec/factories/search_team.rb +0 -13
  165. data/spec/factories/shave_schedule/time_selection_permissions.rb +0 -12
  166. data/spec/factories/shave_schedule.rb +0 -33
  167. data/spec/factories/team/photos.rb +0 -12
  168. data/spec/factories/team/rankings/ranking.rb +0 -12
  169. data/spec/factories/team/rankings.rb +0 -15
  170. data/spec/factories/team/totals.rb +0 -14
  171. data/spec/factories/team.rb +0 -43
  172. data/spec/factories/third_party_media.rb +0 -12
  173. data/spec/factories/treatment_status.rb +0 -10
  174. data/spec/factories/user.rb +0 -14
  175. data/spec/factories/venue.rb +0 -15
@@ -11,8 +11,8 @@ module SBF
11
11
  blacklist_action :update
12
12
  blacklist_action :aggregate
13
13
 
14
- entity_attr_accessor :kid, 'SBF::Client::FullKid', 'SBF::Client::PartialKid', true
15
- entity_attr_accessor :institution, 'SBF::Client::FullInstitution', 'SBF::Client::PartialInstitution', true
14
+ entity_attr_accessor :kid, 'SBF::Client::FullKid', 'SBF::Client::PartialKid', optional: true
15
+ entity_attr_accessor :institution, 'SBF::Client::FullInstitution', 'SBF::Client::PartialInstitution', optional: true
16
16
  end
17
17
  end
18
18
  end
@@ -8,15 +8,12 @@ module SBF
8
8
  BUSINESS = 'business'.freeze
9
9
  end
10
10
 
11
- attr_accessor :type
12
- attr_accessor :business_name
13
- attr_accessor :address1, :address2, :city, :state, :state_name, :zip, :country, :country_name
14
- attr_accessor :latitude, :longitude
11
+ attr_accessor :type, :business_name, :address1, :address2, :city, :state, :state_name, :zip, :country, :country_name, :latitude, :longitude
15
12
 
16
13
  def city_state_zip
17
14
  csz = ''
18
- csz += @city + ', ' unless @city.nil?
19
- csz += @state + ' ' unless @state.nil?
15
+ csz += "#{@city}, " unless @city.nil?
16
+ csz += "#{@state} " unless @state.nil?
20
17
  csz += @zip unless @zip.nil?
21
18
  csz.strip
22
19
  end
@@ -8,9 +8,7 @@ module SBF
8
8
  BUSINESS = 'business'.freeze
9
9
  end
10
10
 
11
- attr_accessor :type
12
- attr_accessor :business_name
13
- attr_accessor :address1, :address2, :city, :state, :state_name, :zip, :country, :country_name
11
+ attr_accessor :type, :business_name, :address1, :address2, :city, :state, :state_name, :zip, :country, :country_name
14
12
  end
15
13
  end
16
14
  end
@@ -25,14 +25,14 @@ module SBF
25
25
  @not_provided_attributes = nil
26
26
  @disallow_instantiation = nil
27
27
 
28
- def initialize(data = {}, clear_changes = false)
28
+ def initialize(data = {}, clear_changes: false)
29
29
  # If disallow instantiation has been set, raise an error if someone is trying to call initilaize
30
30
  raise SBF::Client::Error, 'Initialize is not valid on a base object. Use the full or partial version' unless self.class.allow_instantiation?
31
31
 
32
32
  super()
33
33
 
34
34
  @errors = SBF::Client::Entity::Errors.new(self)
35
- initialize_attributes(data)
35
+ initialize_attributes(**data)
36
36
  reload_recursive if clear_changes
37
37
  end
38
38
 
@@ -70,29 +70,30 @@ module SBF
70
70
  def to_partial
71
71
  base_class = self.class.name.gsub(/(.*::)(Full|Partial)(.*)/, '\1')
72
72
  base_name = self.class.name.gsub(/(.*::)(Full|Partial)(.*)/, '\3')
73
- "#{base_class}Partial#{base_name}".to_class.new(to_hash)
73
+ "#{base_class}Partial#{base_name}".to_class.new(to_hash, clear_changes: false)
74
74
  end
75
75
 
76
76
  ## Returns a hash of changed data for the entity and its sub-entities
77
77
  # @param with_keys [Boolean] when true, include the keys of the current entity. (sub-entity keys will always be included if they are present)
78
78
  # @return [Hash] the changed data
79
- def dirty_data(with_keys = false)
79
+ def dirty_data(with_keys: false)
80
80
  data = {}
81
81
  changes.each { |k, arr| data[k.to_sym] = arr[1] }
82
82
 
83
83
  instance_variables.each do |var|
84
84
  attribute_symbol = var.to_s.delete('@').to_sym
85
85
  attribute = instance_variable_get(var)
86
- if attribute.is_a?(BaseEntity)
87
- if attribute.dirty_data(true).empty?
86
+ case attribute
87
+ when BaseEntity
88
+ if attribute.dirty_data(with_keys: true).empty?
88
89
  next unless changed.map(&:to_sym).include?(attribute_symbol)
89
90
 
90
91
  data.merge!(attribute_symbol => attribute.keys_hash)
91
92
  else
92
- data.merge!(attribute_symbol => attribute.dirty_data(true))
93
+ data.merge!(attribute_symbol => attribute.dirty_data(with_keys: true))
93
94
  end
94
- elsif attribute.is_a?(Array)
95
- next unless attribute.all? { |e| e.is_a?(BaseEntity) } && attribute.any? { |e| !e.dirty_data(true).empty? }
95
+ when Array
96
+ next unless attribute.all?(BaseEntity) && attribute.any? { |e| !e.dirty_data(with_keys: true).empty? }
96
97
 
97
98
  data.merge!(attribute_symbol => attribute)
98
99
  end
@@ -104,7 +105,7 @@ module SBF
104
105
  end
105
106
 
106
107
  def keys_hash
107
- respond_to?(:id) && id ? {id: id} : {}
108
+ (respond_to?(:id) && id) ? {id: id} : {}
108
109
  end
109
110
 
110
111
  # Mimic ActiveRecord::AttributeAssignment alias
@@ -241,7 +242,7 @@ module SBF
241
242
  define_changing_attr_methods attribute
242
243
  end
243
244
 
244
- add_boolean_methods(vars, true)
245
+ add_boolean_methods(vars, setter: true)
245
246
  end
246
247
 
247
248
  def self.attr_accessor(*vars)
@@ -250,10 +251,10 @@ module SBF
250
251
 
251
252
  vars.each do |attribute|
252
253
  define_attribute_methods attribute
253
- define_changing_attr_methods attribute, false, true
254
+ define_changing_attr_methods attribute, is_boolean: false, define_reader: true
254
255
  end
255
256
 
256
- add_boolean_methods(vars, true)
257
+ add_boolean_methods(vars, setter: true)
257
258
  end
258
259
  ###########################################################################################
259
260
 
@@ -261,24 +262,27 @@ module SBF
261
262
  # Multitype Attribute accessors. These methods take an array of type to class mappings.
262
263
  # Expected form is:
263
264
  # [[<lamda method which evals to true if this type should be used>, <full class>, <partial class>], [...]]
264
- def self.multitype_attr_reader(attribute, class_mappings, optional = false)
265
+ def self.multitype_attr_reader(attribute, class_mappings, optional: false)
265
266
  entity_attributes << attribute
266
267
  optional_attributes << attribute if optional
267
268
  attr_reader(attribute)
268
- add_multitype_setter_method(attribute, class_mappings, true)
269
+
270
+ add_multitype_setter_method(attribute, class_mappings, private_method: true)
269
271
  end
270
272
 
271
- def self.multitype_attr_writer(attribute, class_mappings, optional = false)
273
+ def self.multitype_attr_writer(attribute, class_mappings, optional: false)
272
274
  entity_attributes << attribute
273
275
  optional_attributes << attribute if optional
274
276
  attr_writer(attribute)
277
+
275
278
  add_multitype_setter_method(attribute, class_mappings)
276
279
  end
277
280
 
278
- def self.multitype_attr_accessor(attribute, class_mappings, optional = false)
281
+ def self.multitype_attr_accessor(attribute, class_mappings, optional: false)
279
282
  entity_attributes << attribute
280
283
  optional_attributes << attribute if optional
281
284
  attr_accessor(attribute)
285
+
282
286
  add_multitype_setter_method(attribute, class_mappings)
283
287
  end
284
288
  ###########################################################################################
@@ -286,19 +290,19 @@ module SBF
286
290
  ###########################################################################################
287
291
  # Entity attr accessors are simpler to define/easier to read but they really just create a type mapping
288
292
  # for the given inputs and then function the same as the multitype attribute accessors do.
289
- def self.entity_attr_reader(attribute, full_class, partial_class = nil, optional = false)
293
+ def self.entity_attr_reader(attribute, full_class, partial_class = nil, optional: false)
290
294
  mapping_for_single_class = [[ELSE, full_class, partial_class]]
291
- multitype_attr_reader(attribute, mapping_for_single_class, optional)
295
+ multitype_attr_reader(attribute, mapping_for_single_class, optional: optional)
292
296
  end
293
297
 
294
- def self.entity_attr_writer(attribute, full_class, partial_class = nil, optional = false)
298
+ def self.entity_attr_writer(attribute, full_class, partial_class = nil, optional: false)
295
299
  mapping_for_single_class = [[ELSE, full_class, partial_class]]
296
- multitype_attr_writer(attribute, mapping_for_single_class, optional)
300
+ multitype_attr_writer(attribute, mapping_for_single_class, optional: optional)
297
301
  end
298
302
 
299
- def self.entity_attr_accessor(attribute, full_class, partial_class = nil, optional = false)
303
+ def self.entity_attr_accessor(attribute, full_class, partial_class = nil, optional: false)
300
304
  mapping_for_single_class = [[ELSE, full_class, partial_class]]
301
- multitype_attr_accessor(attribute, mapping_for_single_class, optional)
305
+ multitype_attr_accessor(attribute, mapping_for_single_class, optional: optional)
302
306
  end
303
307
  ###########################################################################################
304
308
 
@@ -306,24 +310,27 @@ module SBF
306
310
  # Multitype Collection accessors. These methods take an array of type to class mappings.
307
311
  # Expected form is:
308
312
  # [[<lamda method which evals to true if this type should be used>, <full class>, <partial class>], [...]]
309
- def self.multitype_collection_attr_reader(attribute, class_mappings, optional = false)
313
+ def self.multitype_collection_attr_reader(attribute, class_mappings, optional: false)
310
314
  collection_attributes << attribute
311
315
  optional_attributes << attribute if optional
312
316
  attr_reader(attribute)
313
- add_multitype_collection_setter_method(attribute, class_mappings, true)
317
+
318
+ add_multitype_collection_setter_method(attribute, class_mappings, private_method: true)
314
319
  end
315
320
 
316
- def self.multitype_collection_attr_writer(attribute, class_mappings, optional = false)
321
+ def self.multitype_collection_attr_writer(attribute, class_mappings, optional: false)
317
322
  collection_attributes << attribute
318
323
  optional_attributes << attribute if optional
319
324
  attr_writer(attribute)
325
+
320
326
  add_multitype_collection_setter_method(attribute, class_mappings)
321
327
  end
322
328
 
323
- def self.multitype_collection_attr_accessor(attribute, class_mappings, optional = false)
329
+ def self.multitype_collection_attr_accessor(attribute, class_mappings, optional: false)
324
330
  collection_attributes << attribute
325
331
  optional_attributes << attribute if optional
326
332
  attr_accessor(attribute)
333
+
327
334
  add_multitype_collection_setter_method(attribute, class_mappings)
328
335
  end
329
336
  ###########################################################################################
@@ -331,19 +338,19 @@ module SBF
331
338
  ###########################################################################################
332
339
  # Entity attr accessors are simpler to define/easier to read but they really just create a type mapping
333
340
  # for the given inputs and then function the same as the multitype attribute accessors do.
334
- def self.entity_collection_attr_reader(attribute, full_class, partial_class = nil, optional = false)
341
+ def self.entity_collection_attr_reader(attribute, full_class, partial_class = nil, optional: false)
335
342
  mapping_for_single_class = [[ELSE, full_class, partial_class]]
336
- multitype_collection_attr_reader(attribute, mapping_for_single_class, optional)
343
+ multitype_collection_attr_reader(attribute, mapping_for_single_class, optional: optional)
337
344
  end
338
345
 
339
- def self.entity_collection_attr_writer(attribute, full_class, partial_class = nil, optional = false)
346
+ def self.entity_collection_attr_writer(attribute, full_class, partial_class = nil, optional: false)
340
347
  mapping_for_single_class = [[ELSE, full_class, partial_class]]
341
- multitype_collection_attr_writer(attribute, mapping_for_single_class, optional)
348
+ multitype_collection_attr_writer(attribute, mapping_for_single_class, optional: optional)
342
349
  end
343
350
 
344
- def self.entity_collection_attr_accessor(attribute, full_class, partial_class = nil, optional = false)
351
+ def self.entity_collection_attr_accessor(attribute, full_class, partial_class = nil, optional: false)
345
352
  mapping_for_single_class = [[ELSE, full_class, partial_class]]
346
- multitype_collection_attr_accessor(attribute, mapping_for_single_class, optional)
353
+ multitype_collection_attr_accessor(attribute, mapping_for_single_class, optional: optional)
347
354
  end
348
355
  ###########################################################################################
349
356
 
@@ -363,18 +370,18 @@ module SBF
363
370
  @collection_attributes ||= Set.new
364
371
  end
365
372
 
366
- def self.add_boolean_methods(vars, setter = false)
373
+ def self.add_boolean_methods(vars, setter: false)
367
374
  vars.each do |attribute|
368
375
  split_attribute = attribute.to_s.split('is_')
369
376
  next if split_attribute.length <= 1
370
377
 
371
378
  define_method(:"#{split_attribute.last}?") { send(attribute) }
372
- define_changing_attr_methods(attribute, true) if setter
379
+ define_changing_attr_methods(attribute, is_boolean: true) if setter
373
380
  end
374
381
  end
375
382
  private_class_method :add_boolean_methods
376
383
 
377
- def self.define_changing_attr_methods(attribute, is_boolean = false, define_reader = false)
384
+ def self.define_changing_attr_methods(attribute, is_boolean: false, define_reader: false)
378
385
  if define_reader
379
386
  define_method(:"#{attribute}") do
380
387
  instance_variable_get("@#{attribute}".to_sym)
@@ -503,12 +510,12 @@ module SBF
503
510
  value = value.to_hash if !value.is_a?(Hash) && value.respond_to?(:to_hash)
504
511
 
505
512
  # Convert to an instance of the appropriate entity class.
506
- entity_class.new(value)
513
+ entity_class.new(value, clear_changes: false)
507
514
  end
508
515
  private :convert_value
509
516
 
510
517
  # Base entity setter. Allows for the property to be an array of types.
511
- def self.add_multitype_setter_method(attribute, class_mappings, private_method = false)
518
+ def self.add_multitype_setter_method(attribute, class_mappings, private_method: false)
512
519
  add_class_selector_method(attribute, class_mappings)
513
520
 
514
521
  method_name = :"#{attribute}="
@@ -523,7 +530,7 @@ module SBF
523
530
  private_class_method :add_multitype_setter_method
524
531
 
525
532
  # Base collection setter. Allows for the collection to be an array types of types.
526
- def self.add_multitype_collection_setter_method(attribute, class_mappings, private_method = false)
533
+ def self.add_multitype_collection_setter_method(attribute, class_mappings, private_method: false)
527
534
  add_class_selector_method(attribute, class_mappings)
528
535
 
529
536
  define_method(:"#{attribute}=") do |values|
@@ -583,6 +590,7 @@ module SBF
583
590
  end
584
591
 
585
592
  def self.inherited(base)
593
+ super
586
594
  # Add all of our attributes to the class that is inheriting us.
587
595
  base.defined_attributes.merge(defined_attributes) unless defined_attributes.empty?
588
596
  base.optional_attributes.merge(optional_attributes) unless optional_attributes.empty?
@@ -4,10 +4,10 @@ module SBF
4
4
  module Client
5
5
  class EntityCollection < Array
6
6
  include EntityResponseConcern
7
- attr_reader :total_count
8
- attr_reader :errors
7
+ attr_reader :total_count, :errors
9
8
 
10
9
  def initialize(entities = [], total_count = 0, errors = nil)
10
+ super()
11
11
  concat(entities)
12
12
  @total_count = total_count
13
13
  @errors = errors || SBF::Client::Entity::Errors.new(self)
@@ -8,8 +8,7 @@ module SBF
8
8
  BUSINESS = 'business'.freeze
9
9
  end
10
10
 
11
- attr_accessor :type
12
- attr_accessor :email_address
11
+ attr_accessor :type, :email_address
13
12
  end
14
13
  end
15
14
  end
@@ -3,8 +3,7 @@ require 'stbaldricks/entities/lib/base'
3
3
  module SBF
4
4
  module Client
5
5
  class FundraisingPage < SBF::Client::BaseEntity
6
- attr_accessor :is_enabled
7
- attr_accessor :custom_url_segment
6
+ attr_accessor :is_enabled, :custom_url_segment
8
7
  attr_reader :url
9
8
 
10
9
  HTTP_REGEX = %r{^https?://}.freeze
@@ -5,6 +5,7 @@ module SBF
5
5
  module Client
6
6
  class Location < SBF::Client::BaseEntity
7
7
  attr_accessor :name
8
+
8
9
  entity_attr_accessor :address, 'SBF::Client::Address'
9
10
  end
10
11
  end
@@ -4,9 +4,7 @@ module SBF
4
4
  module Client
5
5
  class Milestone < SBF::Client::BaseEntity
6
6
  attr_reader :id
7
- attr_accessor :amount
8
- attr_accessor :description
9
- attr_accessor :icon
7
+ attr_accessor :amount, :description, :icon
10
8
  end
11
9
  end
12
10
  end
@@ -5,8 +5,8 @@ module SBF
5
5
  class NamePiecesBase < SBF::Client::BaseEntity
6
6
  def combined_name
7
7
  name = ''
8
- name += @first_name + ' ' unless @first_name.nil?
9
- name += @middle_initial + '. ' unless @middle_initial.nil?
8
+ name += "#{@first_name} " unless @first_name.nil?
9
+ name += "#{@middle_initial}. " unless @middle_initial.nil?
10
10
  name += @last_name unless @last_name.nil?
11
11
  name.strip
12
12
  end
@@ -13,7 +13,7 @@ module SBF
13
13
  end
14
14
  end
15
15
 
16
- super
16
+ super(attributes, clear_changes: false)
17
17
  end
18
18
 
19
19
  # rubocop:disable Style/MissingRespondToMissing
@@ -5,8 +5,7 @@ require 'set'
5
5
  module SBF
6
6
  module Client
7
7
  class Permissions < SBF::Client::BaseEntity
8
- attr_accessor :is_owner
9
- attr_accessor :permission_ids
8
+ attr_accessor :is_owner, :permission_ids
10
9
 
11
10
  # rubocop:disable Style/MissingRespondToMissing
12
11
  def method_missing(method, *arguments, &block)
@@ -28,8 +27,7 @@ module SBF
28
27
  end
29
28
 
30
29
  class PermissionsAtEvent < SBF::Client::BaseEntity
31
- attr_accessor :granted
32
- attr_accessor :inherited_from_roles
30
+ attr_accessor :granted, :inherited_from_roles
33
31
  end
34
32
  end
35
33
  end
@@ -9,12 +9,11 @@ module SBF
9
9
  MOBILE = 'mobile'.freeze
10
10
  end
11
11
 
12
- attr_accessor :type
13
- attr_accessor :number, :extension
12
+ attr_accessor :type, :number, :extension
14
13
 
15
14
  # (402)555-5555 --> tel:4025555555
16
15
  def format_href
17
- return 'tel:' + number.gsub(/\D/, '') unless number.nil?
16
+ return "tel:#{number.gsub(/\D/, '')}" unless number.nil?
18
17
 
19
18
  number
20
19
  end
@@ -14,11 +14,7 @@ module SBF
14
14
  TWITCH = 'twitch'.freeze
15
15
  end
16
16
 
17
- attr_accessor :id
18
- attr_accessor :type
19
- attr_accessor :identifier
20
- attr_accessor :title
21
- attr_accessor :caption
17
+ attr_accessor :id, :type, :identifier, :title, :caption
22
18
  end
23
19
  end
24
20
  end
@@ -45,7 +45,7 @@ module SBF
45
45
  define_method(name) do |*args|
46
46
  result = endpoint.send(name, self, *args)
47
47
  result unless result.is_a?(SBF::Client::TopLevelEntity)
48
- %i(save create).include?(name) && result.errors? ? false : result
48
+ (%i(save create).include?(name) && result.errors?) ? false : result
49
49
  end
50
50
  end
51
51
 
@@ -12,71 +12,48 @@ module SBF
12
12
  disallow_instantiation
13
13
 
14
14
  class Contact < SBF::Client::BaseEntity
15
- attr_reader :title
16
- attr_reader :name
15
+ attr_reader :title, :name, :websites
16
+
17
17
  entity_attr_reader :name_pieces, 'SBF::Client::NamePieces'
18
18
  entity_attr_reader :address, 'SBF::Client::Address'
19
19
  entity_attr_reader :phone, 'SBF::Client::Phone'
20
20
  entity_attr_reader :email, 'SBF::Client::EmailAddress'
21
- attr_reader :websites
22
21
  end
23
22
 
24
23
  class GiftRatio < SBF::Client::BaseEntity
25
- attr_reader :match_ratio
26
- attr_reader :minimum_matched
27
- attr_reader :maximum_matched
28
- attr_reader :total_matched_per_employee
29
- attr_reader :fiscal_year
30
- attr_reader :deadline
24
+ attr_reader :match_ratio, :minimum_matched, :maximum_matched, :total_matched_per_employee, :fiscal_year, :deadline
31
25
  end
32
26
 
33
27
  class EmployeeEligibility < SBF::Client::BaseEntity
34
- attr_reader :full_time
35
- attr_reader :part_time
36
- attr_reader :retired
37
- attr_reader :spouse
38
- attr_reader :board
28
+ attr_reader :full_time, :part_time, :retired, :spouse, :board
39
29
  end
40
30
 
41
31
  class Procedures < SBF::Client::BaseEntity
42
- attr_reader :officer_certification
43
- attr_reader :fax
44
- attr_reader :website
45
- attr_reader :phone
46
- attr_reader :presenting_evidence
47
- attr_reader :sending_check
48
- attr_reader :sending_letter
32
+ attr_reader :officer_certification, :fax, :website, :phone, :presenting_evidence, :sending_check, :sending_letter
49
33
  end
50
34
 
51
35
  class Requirements < SBF::Client::BaseEntity
52
- attr_reader :gift_receipt
53
- attr_reader :ack_letter
36
+ attr_reader :gift_receipt, :ack_letter
54
37
  end
55
38
 
56
39
  class Restrictions < SBF::Client::BaseEntity
57
- attr_reader :follow_donor_designation
58
- attr_reader :match_unrestricted
40
+ attr_reader :follow_donor_designation, :match_unrestricted
59
41
  end
60
42
  end
61
43
 
62
44
  class PartialCompany < Company
63
- attr_reader :name
64
- attr_reader :id
45
+ attr_reader :name, :id
65
46
  end
66
47
 
67
48
  class FullCompany < Company
68
- attr_reader :id
69
- attr_reader :name
70
- attr_reader :matching_gift_forms
71
- attr_reader :special_comments
72
- attr_reader :last_updated
73
-
74
- entity_attr_reader :contact_info, 'SBF::Client::MatchingGift::Company::Contact', nil, true
75
- entity_attr_reader :match_info, 'SBF::Client::MatchingGift::Company::GiftRatio', nil, true
76
- entity_attr_reader :employee_eligibility, 'SBF::Client::MatchingGift::Company::EmployeeEligibility', nil, true
77
- entity_attr_reader :procedures, 'SBF::Client::MatchingGift::Company::Procedures', nil, true
78
- entity_attr_reader :requirements, 'SBF::Client::MatchingGift::Company::Requirements', nil, true
79
- entity_attr_reader :restrictions, 'SBF::Client::MatchingGift::Company::Restrictions', nil, true
49
+ attr_reader :id, :name, :matching_gift_forms, :special_comments, :last_updated
50
+
51
+ entity_attr_reader :contact_info, 'SBF::Client::MatchingGift::Company::Contact', nil, optional: true
52
+ entity_attr_reader :match_info, 'SBF::Client::MatchingGift::Company::GiftRatio', nil, optional: true
53
+ entity_attr_reader :employee_eligibility, 'SBF::Client::MatchingGift::Company::EmployeeEligibility', nil, optional: true
54
+ entity_attr_reader :procedures, 'SBF::Client::MatchingGift::Company::Procedures', nil, optional: true
55
+ entity_attr_reader :requirements, 'SBF::Client::MatchingGift::Company::Requirements', nil, optional: true
56
+ entity_attr_reader :restrictions, 'SBF::Client::MatchingGift::Company::Restrictions', nil, optional: true
80
57
  end
81
58
  end
82
59
  end
@@ -21,14 +21,11 @@ module SBF
21
21
  end
22
22
 
23
23
  class Tribute < SBF::Client::BaseEntity
24
- attr_accessor :birthday
25
- attr_accessor :date_of_passing
26
- attr_accessor :name
24
+ attr_accessor :birthday, :date_of_passing, :name
27
25
  end
28
26
 
29
27
  class Totals < SBF::Client::BaseEntity
30
- attr_reader :amount_raised
31
- attr_reader :donations
28
+ attr_reader :amount_raised, :donations
32
29
  end
33
30
 
34
31
  class Photos < SBF::Client::BaseEntity
@@ -41,20 +38,18 @@ module SBF
41
38
  end
42
39
 
43
40
  class FullMemorial < Memorial
44
- attr_accessor :id
45
- attr_accessor :status
46
- attr_accessor :website_message
47
- attr_reader :display_name
41
+ attr_accessor :id, :status, :website_message, :expires_at, :offline_donation_uuid, :offline_donation_form
42
+ attr_reader :display_name, :created_at, :modified_at
43
+
48
44
  entity_attr_accessor :address, 'SBF::Client::Address'
49
45
  entity_attr_accessor :tribute, 'SBF::Client::Memorial::Tribute'
50
46
  entity_attr_reader :totals, 'SBF::Client::Memorial::Totals'
51
47
  entity_collection_attr_accessor :donations, 'SBF::Client::FullDonation', 'SBF::Client::PartialDonation'
52
- attr_reader :created_at, :modified_at
53
- attr_accessor :expires_at
48
+
54
49
  entity_attr_accessor :photos, 'SBF::Client::Memorial::Photos'
55
- entity_attr_accessor :third_party_media, 'SBF::Client::ThirdPartyMedia', nil, true
56
- attr_accessor :offline_donation_uuid, :offline_donation_form
57
- entity_attr_accessor :fundraising_page, 'SBF::Client::FundraisingPage', nil, true
50
+ entity_attr_accessor :third_party_media, 'SBF::Client::ThirdPartyMedia', nil, optional: true
51
+
52
+ entity_attr_accessor :fundraising_page, 'SBF::Client::FundraisingPage', nil, optional: true
58
53
 
59
54
  def active?
60
55
  status == SBF::Client::Memorial::Status::ACTIVE
@@ -32,30 +32,19 @@ module SBF
32
32
  DELETED = 'deleted'.freeze
33
33
  end
34
34
 
35
- attr_accessor :id
36
- attr_accessor :status
35
+ attr_accessor :id, :status, :message_id, :display_name, :email
37
36
 
38
- attr_accessor :message_id
39
37
  entity_attr_reader :person, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
40
- attr_accessor :display_name
41
- attr_accessor :email
42
38
 
43
39
  attr_reader :modified_at
44
40
  end
45
41
 
46
- attr_accessor :id
47
- attr_accessor :type
48
- attr_accessor :status
42
+ attr_accessor :id, :type, :status, :subject, :body
49
43
 
50
44
  entity_collection_attr_accessor :to, 'SBF::Client::Message::Recipient'
51
- attr_reader :from_ip
52
- entity_attr_reader :from_person, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
53
- attr_reader :from_email
54
- attr_reader :display_name
55
- attr_accessor :subject
56
- attr_accessor :body
45
+ attr_reader :from_ip, :from_email, :display_name, :created_at, :modified_at, :sent_at
57
46
 
58
- attr_reader :created_at, :modified_at, :sent_at
47
+ entity_attr_reader :from_person, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
59
48
  end
60
49
  end
61
50
  end
@@ -67,8 +67,7 @@ module SBF
67
67
  end
68
68
 
69
69
  class Totals < SBF::Client::BaseEntity
70
- attr_reader :amount_raised
71
- attr_reader :donations
70
+ attr_reader :amount_raised, :donations
72
71
  end
73
72
  end
74
73
 
@@ -79,28 +78,23 @@ module SBF
79
78
  class FullOrganization < SBF::Client::Organization
80
79
  class ContactName < SBF::Client::BaseEntity
81
80
  attr_reader :name
81
+
82
82
  entity_attr_accessor :name_pieces, 'SBF::Client::NamePieces'
83
83
  end
84
84
 
85
- attr_accessor :id
86
- attr_accessor :salesforce_id
87
- attr_accessor :salesforce_account_id
88
- attr_accessor :type
89
- attr_accessor :status
90
- attr_reader :display_name
91
- attr_accessor :display_name_override
92
- attr_accessor :name
85
+ attr_accessor :id, :salesforce_id, :salesforce_account_id, :type, :status, :display_name_override, :name,
86
+ :selected_shipping_method, :modified_by, :how_created
87
+ attr_reader :display_name, :created_at, :modified_at
88
+
93
89
  entity_attr_accessor :contact, 'SBF::Client::FullOrganization::ContactName'
94
90
  entity_attr_accessor :addresses, 'SBF::Client::Organization::Addresses'
95
91
  entity_attr_accessor :phone_numbers, 'SBF::Client::Organization::PhoneNumbers'
96
92
  entity_attr_accessor :email_addresses, 'SBF::Client::Organization::EmailAddresses'
97
- entity_attr_accessor :opt_out_settings, 'SBF::Client::OptOutSettings', nil, true
98
- attr_accessor :selected_shipping_method
99
- entity_attr_accessor :alternate_shipping_address, 'SBF::Client::AlternateShippingAddress', nil, true
100
- attr_reader :created_at, :modified_at
101
- attr_accessor :modified_by
102
- attr_accessor :how_created
103
- entity_attr_reader :totals, 'SBF::Client::Organization::Totals', nil, true
93
+ entity_attr_accessor :opt_out_settings, 'SBF::Client::OptOutSettings', nil, optional: true
94
+
95
+ entity_attr_accessor :alternate_shipping_address, 'SBF::Client::AlternateShippingAddress', nil, optional: true
96
+
97
+ entity_attr_reader :totals, 'SBF::Client::Organization::Totals', nil, optional: true
104
98
 
105
99
  def active?
106
100
  status == SBF::Client::Organization::Status::ACTIVE