stbaldricks 12.12.0.alpha.2 → 12.12.0.alpha.3

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