stbaldricks 6.13.0 → 6.13.1.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stbaldricks/configuration.rb +2 -1
  3. data/lib/stbaldricks/endpoints/event.rb +4 -2
  4. data/lib/stbaldricks/endpoints/facebook/user.rb +3 -3
  5. data/lib/stbaldricks/endpoints/kid_honor.rb +1 -3
  6. data/lib/stbaldricks/endpoints/kid_institution.rb +1 -3
  7. data/lib/stbaldricks/endpoints/lib/entity.rb +9 -6
  8. data/lib/stbaldricks/endpoints/participant.rb +2 -1
  9. data/lib/stbaldricks/endpoints/photo.rb +5 -5
  10. data/lib/stbaldricks/endpoints/search.rb +2 -1
  11. data/lib/stbaldricks/endpoints/user.rb +5 -6
  12. data/lib/stbaldricks/entities/concerns/entity_response_concern.rb +3 -2
  13. data/lib/stbaldricks/entities/concerns/event_year_concern.rb +1 -0
  14. data/lib/stbaldricks/entities/concerns/venue_concern.rb +1 -1
  15. data/lib/stbaldricks/entities/config.rb +5 -5
  16. data/lib/stbaldricks/entities/donation.rb +7 -11
  17. data/lib/stbaldricks/entities/fund.rb +6 -3
  18. data/lib/stbaldricks/entities/fundraiser.rb +1 -0
  19. data/lib/stbaldricks/entities/lib/base.rb +33 -32
  20. data/lib/stbaldricks/entities/lib/cacheable.rb +2 -0
  21. data/lib/stbaldricks/entities/lib/collection.rb +4 -0
  22. data/lib/stbaldricks/entities/lib/not_implemented_object.rb +3 -0
  23. data/lib/stbaldricks/entities/lib/permissions.rb +2 -0
  24. data/lib/stbaldricks/entities/lib/phone.rb +2 -0
  25. data/lib/stbaldricks/entities/lib/top_level.rb +1 -0
  26. data/lib/stbaldricks/entities/person.rb +3 -1
  27. data/lib/stbaldricks/entities/photo.rb +47 -47
  28. data/lib/stbaldricks/entities/team.rb +1 -1
  29. data/lib/stbaldricks/enums/cancer_types.rb +0 -0
  30. data/lib/stbaldricks/enums/model_type.rb +0 -0
  31. data/lib/stbaldricks/enums/province.rb +0 -0
  32. data/lib/stbaldricks/log.rb +2 -0
  33. data/lib/stbaldricks/patches/string.rb +3 -2
  34. data/lib/stbaldricks/version.rb +1 -1
  35. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e41bd59dba8f3a1d54f3b85f4f972ac5787e84798f7df480e06478590c9f43d8
4
- data.tar.gz: cedf05e63ca11292a9c32b842c36db04498794f9ffdd5a3e60de4631fb67edfe
3
+ metadata.gz: f160e1af1de76369152c9dbf97bcbdacfd37ccf464ba6f5d3cd9aa59bf5c5551
4
+ data.tar.gz: 42e01f776af7d02f1399d55b5d24c351b1cc895b0ac027bb45a684160a16ad5a
5
5
  SHA512:
6
- metadata.gz: 5439676617f24fc6670c5e02f3795efee84aaba9f0119273824631529fc9dd0dfd18a21b55bbd13a6ca667e4fe5f5988b967f39969a114d6b02c92eb504de425
7
- data.tar.gz: f05fe0663d23ade5387c6b3e29ff439701f0701eaa2e6d018a55ae0a1de9278f28580b2c3b72a966bbef6f18b94080bebe13e4e667684f62a874264461fd2146
6
+ metadata.gz: f27bf1e1e37bcb2c8578797d30009c9a2209f9c2b564f3566d2c9bbd70036c538e681d018346276ccbc1ef30518de977b92d33fac47a3693b1b3dbcbd5619a36
7
+ data.tar.gz: 0b2d540ae40eccf875d621e6a4b149cafdbe719ccec44f0318108e534d412ccbc515b23ff922c98d17abc046057aabff0fb999e28a91215880c85e03ad92c1ed
@@ -28,8 +28,9 @@ module SBF
28
28
  end
29
29
 
30
30
  def self.logger=(new_logger)
31
- missing_methods = SBF::Client::LOG::REQUIRED_METHODS.select { |method| !new_logger.respond_to?(method) }
31
+ missing_methods = SBF::Client::LOG::REQUIRED_METHODS.reject { |method| new_logger.respond_to?(method) }
32
32
  raise SBF::Client::Configuration::Error.new('logger', "must respond to: #{missing_methods.join(', ')}") unless missing_methods.empty?
33
+
33
34
  @_logger = new_logger
34
35
  end
35
36
 
@@ -10,10 +10,12 @@ module SBF
10
10
  def save(entity_or_hash, with = {})
11
11
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
12
12
  return create(entity_or_hash, with) if entity_or_hash.id.nil?
13
- return update(entity_or_hash.id, entity_or_hash.year, entity_or_hash.dirty_data, with)
13
+
14
+ update(entity_or_hash.id, entity_or_hash.year, entity_or_hash.dirty_data, with)
14
15
  else
15
16
  return create(entity_or_hash, with) if entity_or_hash[:id].nil?
16
- return update(entity_or_hash[:id], entity_or_hash[:year], entity_or_hash, with)
17
+
18
+ update(entity_or_hash[:id], entity_or_hash[:year], entity_or_hash, with)
17
19
  end
18
20
  end
19
21
 
@@ -14,9 +14,9 @@ module SBF
14
14
  # @return [string]
15
15
  def login!(authorization_code, redirect_uri)
16
16
  response = SBF::Client::Api::Request.post_request(
17
- "/#{SBF::Client::Api::VERSION}/security/facebook/login",
18
- authorization_code: authorization_code,
19
- redirect_uri: redirect_uri
17
+ "/#{SBF::Client::Api::VERSION}/security/facebook/login",
18
+ authorization_code: authorization_code,
19
+ redirect_uri: redirect_uri
20
20
  )
21
21
  parsed_response = JSON.parse(response.body).symbolize!
22
22
 
@@ -6,9 +6,7 @@ module SBF
6
6
  def delete(params)
7
7
  response = SBF::Client::Api::Request.post_request("#{base_uri}/delete", params)
8
8
 
9
- unless ok?(response)
10
- error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
11
- end
9
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
12
10
 
13
11
  SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
14
12
  end
@@ -6,9 +6,7 @@ module SBF
6
6
  def delete(params)
7
7
  response = SBF::Client::Api::Request.post_request("#{base_uri}/delete", params)
8
8
 
9
- unless ok?(response)
10
- error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
11
- end
9
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
12
10
 
13
11
  SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
14
12
  end
@@ -21,10 +21,12 @@ module SBF
21
21
  def save(entity_or_hash, with = {})
22
22
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
23
23
  return create(entity_or_hash, with) if entity_or_hash.id.nil?
24
- return update(entity_or_hash.id, entity_or_hash, with)
24
+
25
+ update(entity_or_hash.id, entity_or_hash, with)
25
26
  else
26
27
  return create(entity_or_hash, with) if entity_or_hash[:id].nil?
27
- return update(entity_or_hash[:id], entity_or_hash, with)
28
+
29
+ update(entity_or_hash[:id], entity_or_hash, with)
28
30
  end
29
31
  end
30
32
 
@@ -77,7 +79,7 @@ module SBF
77
79
 
78
80
  if ok?(response)
79
81
  hydrated_entity(response, {}, nil)
80
- elsif (response.code == 404)
82
+ elsif response.code == 404
81
83
  nil
82
84
  else
83
85
  parsed_response_body = JSON.parse(response.body).symbolize!
@@ -139,9 +141,7 @@ module SBF
139
141
  def delete(id)
140
142
  response = SBF::Client::Api::Request.post_request("#{base_uri}/delete/#{id}")
141
143
 
142
- unless ok?(response)
143
- error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
144
- end
144
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
145
145
 
146
146
  SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
147
147
  end
@@ -193,6 +193,7 @@ module SBF
193
193
  entity_class = klass.send(entity_class_selector_method, value)
194
194
 
195
195
  return nil if entity_class == NilClass
196
+
196
197
  entity_class.nil? ? value : sanitize(value, entity_class)
197
198
  end
198
199
  private :sanitize_entity
@@ -223,6 +224,7 @@ module SBF
223
224
  end
224
225
  private :normalize_with
225
226
 
227
+ # rubocop:disable IdenticalConditionalBranches
226
228
  def hydrated_entity(response, data, entity_or_hash)
227
229
  parsed_response_body = JSON.parse(response.body).symbolize!
228
230
 
@@ -256,6 +258,7 @@ module SBF
256
258
  end
257
259
  end
258
260
  private :hydrated_entity
261
+ # rubocop:enable IdenticalConditionalBranches
259
262
  end
260
263
  end
261
264
  end
@@ -22,7 +22,8 @@ module SBF
22
22
  new_team_id: 0,
23
23
  team_name: team_name,
24
24
  goal: fundraising_goal,
25
- how_created: SBF::Client::Team::HowCreated::WEBSITE)
25
+ how_created: SBF::Client::Team::HowCreated::WEBSITE
26
+ )
26
27
 
27
28
  if ok?(response)
28
29
  data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
@@ -23,8 +23,8 @@ module SBF
23
23
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
24
24
  # If someone has passed in an entity, just convert it to a hash
25
25
  data = entity_or_hash.dirty_data
26
- data.merge!(id: id) unless id.nil?
27
- data.merge!(id: entity_or_hash.id) if id.nil? && !entity_or_hash.id.nil?
26
+ data[:id] = id unless id.nil?
27
+ data[:id] = entity_or_hash.id if id.nil? && !entity_or_hash.id.nil?
28
28
  elsif entity_or_hash.is_a?(Hash)
29
29
  # If someone has passed in a hash, make sure all of it's values match fields in the entity class
30
30
  data = sanitize(entity_or_hash)
@@ -48,7 +48,7 @@ module SBF
48
48
 
49
49
  def upload(image_data_url, data = {}, with = {})
50
50
  # support image formats: png, jpeg, gif
51
- image_data_url.slice!(/data:image\/(png|jpeg|gif);base64,/)
51
+ image_data_url.slice!(%r{data:image/(png|jpeg|gif);base64,})
52
52
  image_data = Base64.decode64(image_data_url)
53
53
 
54
54
  Tempfile.create('photo_upload') do |file|
@@ -66,11 +66,11 @@ module SBF
66
66
  def photo_for_upload(file, data)
67
67
  if data.is_a?(SBF::Client::Photo)
68
68
  data.file = file
69
- return data
69
+ data
70
70
  else
71
71
  photo = SBF::Client::Photo.new(data.is_a?(Hash) && data.any? ? data : {})
72
72
  photo.file = file
73
- return photo
73
+ photo
74
74
  end
75
75
  end
76
76
  end
@@ -28,7 +28,8 @@ module SBF
28
28
  geo_location = geo_location.to_json unless geo_location.empty?
29
29
 
30
30
  # Build the parameter list for search
31
- params, response_data = {}, {}
31
+ params = {}
32
+ response_data = {}
32
33
  {model_type: model_type, search_text: search_text, filters: filters, geo_location: geo_location}.each do |k, v|
33
34
  params[k.to_sym] = v unless v.empty?
34
35
  end
@@ -59,7 +59,7 @@ module SBF
59
59
  #
60
60
  # @raise [SBFClientError]
61
61
  def change_password(profile_id, password)
62
- raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
62
+ raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
63
63
 
64
64
  response = SBF::Client::Api::Request.post_request(
65
65
  "/#{SBF::Client::Api::VERSION}/security/change_password",
@@ -81,17 +81,16 @@ module SBF
81
81
  #
82
82
  # @raise [SBFClientError]
83
83
  def disconnect_facebook(profile_id)
84
- raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
84
+ raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
85
85
 
86
86
  response = SBF::Client::Api::Request.post_request(
87
87
  "/#{SBF::Client::Api::VERSION}/user/disconnect_facebook",
88
88
  profile_id: profile_id
89
89
  )
90
90
 
91
- if ok?(response)
92
- SBF::Client::Configuration.user_token = nil
93
- else
94
- SBF::Client::Configuration.user_token = nil
91
+ SBF::Client::Configuration.user_token = nil
92
+
93
+ unless ok?(response)
95
94
  parsed_response = JSON.parse(response.body).symbolize!
96
95
  error = SBF::Client::ErrorEntity.new(parsed_response)
97
96
  end
@@ -16,7 +16,7 @@ module EntityResponseConcern
16
16
  end
17
17
  errors.instance_variable_set(:@code, error.code)
18
18
  errors.instance_variable_set(:@type, error.type)
19
- errors.add(:base, "#{error.type}: #{error.details}") if count == 0
19
+ errors.add(:base, "#{error.type}: #{error.details}") if count&.zero?
20
20
  end
21
21
 
22
22
  def errors_http_code=(http_code)
@@ -32,7 +32,7 @@ module EntityResponseConcern
32
32
  end
33
33
 
34
34
  def errors?
35
- errors.count > 0
35
+ errors.count.positive?
36
36
  end
37
37
 
38
38
  ############ Deprecated Methods ############
@@ -52,6 +52,7 @@ module EntityResponseConcern
52
52
  def single_active_model_error
53
53
  return if errors.empty?
54
54
  return [:base, errors[:base].first] if errors[:base].any?
55
+
55
56
  errors.first
56
57
  end
57
58
 
@@ -5,6 +5,7 @@ module EventYearConcern
5
5
 
6
6
  def event_year
7
7
  return year if is_a?(SBF::Client::Event)
8
+
8
9
  event.year
9
10
  end
10
11
  end
@@ -4,6 +4,6 @@ module VenueConcern
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def venue_address
7
- venue && venue.location && venue.location.address
7
+ venue&.location&.address
8
8
  end
9
9
  end
@@ -21,6 +21,7 @@ module SBF
21
21
  #NOTE: If you add another attribute, be sure to mock it out in `configure :test` of app.rb
22
22
 
23
23
  # Attempts to call the method on the cached configuration object
24
+ # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
24
25
  def self.method_missing(method_name, *arguments, &block)
25
26
  # The first time a missing method is called, call reload to make sure the instance has been populated
26
27
  unless @_loaded
@@ -29,12 +30,11 @@ module SBF
29
30
  end
30
31
 
31
32
  # If the method being called exists on the instance, call it. Otherwise forward the request on to 'super'.
32
- if instance.respond_to?(method_name)
33
- return instance.send(method_name)
34
- else
35
- super(method_name, *arguments, &block)
36
- end
33
+ return instance.send(method_name) if instance.respond_to?(method_name)
34
+
35
+ super(method_name, *arguments, &block)
37
36
  end
37
+ # rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
38
38
  end
39
39
  end
40
40
  end
@@ -214,20 +214,16 @@ module SBF
214
214
  state_value = state.to_s.upcase.to_sym
215
215
  if !state_value.empty? && SBF::Client::Donation::SpecialDonationType.const_defined?(state_value)
216
216
  return SBF::Client::Donation::SpecialDonationType.const_get(state_value)
217
-
218
- else
219
- return SBF::Client::Donation::SpecialDonationType::NO_STATE
220
217
  end
221
218
 
219
+ return SBF::Client::Donation::SpecialDonationType::NO_STATE
222
220
  else
223
221
  international_value = "INT_#{country}".upcase.to_sym
224
222
  if SBF::Client::Donation::SpecialDonationType.const_defined?(international_value)
225
223
  return SBF::Client::Donation::SpecialDonationType.const_get(international_value)
226
-
227
- else
228
- return SBF::Client::Donation::SpecialDonationType::INTERNATIONAL
229
-
230
224
  end
225
+
226
+ return SBF::Client::Donation::SpecialDonationType::INTERNATIONAL
231
227
  end
232
228
  end
233
229
 
@@ -256,16 +252,16 @@ module SBF
256
252
  return [country, state]
257
253
 
258
254
  when SBF::Client::Participant
259
- return get_event_country_and_state_for_special_donation_type(entity.event, entity.person)
255
+ get_event_country_and_state_for_special_donation_type(entity.event, entity.person)
260
256
 
261
257
  when SBF::Client::Fundraiser
262
- return [entity.venue.location.address.country, entity.venue.location.address.state]
258
+ [entity.venue.location.address.country, entity.venue.location.address.state]
263
259
 
264
260
  when SBF::Client::Team
265
- return get_event_country_and_state_for_special_donation_type(entity.event)
261
+ get_event_country_and_state_for_special_donation_type(entity.event)
266
262
 
267
263
  when SBF::Client::Event
268
- return get_event_country_and_state_for_special_donation_type(entity)
264
+ get_event_country_and_state_for_special_donation_type(entity)
269
265
 
270
266
  end
271
267
  end
@@ -75,12 +75,15 @@ module SBF
75
75
  attr_accessor :offline_donation_uuid, :offline_donation_form
76
76
 
77
77
  def totals_by_year=(value)
78
- return [] if value.nil? || value.empty?
78
+ if value.nil? || value.empty?
79
+ @totals_by_year = []
80
+ return
81
+ end
79
82
 
80
83
  totals_by_year_will_change!
81
- @totals_by_year = value.map { |k, v|
84
+ @totals_by_year = value.map do |k, v|
82
85
  SBF::Client::Fund::YearlyTotals.new(v.merge(year: k.to_s.to_i))
83
- }
86
+ end
84
87
  end
85
88
 
86
89
  def to_hash
@@ -145,6 +145,7 @@ module SBF
145
145
 
146
146
  def past?
147
147
  return Date.today > Date.parse(end_date) if end_date
148
+
148
149
  Date.today > Date.parse(start_date) if start_date
149
150
  rescue
150
151
  nil
@@ -1,5 +1,5 @@
1
1
  # Require all monkey patches
2
- patch_dir = File.expand_path('../../../patches', __FILE__)
2
+ patch_dir = File.expand_path('../../patches', __dir__)
3
3
  Dir["#{patch_dir}/*.rb"].each { |file| require file }
4
4
 
5
5
  require 'set'
@@ -79,17 +79,19 @@ module SBF
79
79
  changes.each { |k, arr| data[k.to_sym] = arr[1] }
80
80
 
81
81
  instance_variables.each do |var|
82
- attribute_symbol = var.to_s.gsub('@', '').to_sym
82
+ attribute_symbol = var.to_s.delete('@').to_sym
83
83
  attribute = instance_variable_get(var)
84
84
  if attribute.is_a?(BaseEntity)
85
85
  if attribute.dirty_data(true).empty?
86
86
  next unless changed.map(&:to_sym).include?(attribute_symbol)
87
+
87
88
  data.merge!(attribute_symbol => attribute.keys_hash)
88
89
  else
89
90
  data.merge!(attribute_symbol => attribute.dirty_data(true))
90
91
  end
91
92
  elsif attribute.is_a?(Array)
92
93
  next unless attribute.all? { |e| e.is_a?(BaseEntity) } && attribute.any? { |e| !e.dirty_data(true).empty? }
94
+
93
95
  data.merge!(attribute_symbol => attribute)
94
96
  end
95
97
  end
@@ -114,11 +116,9 @@ module SBF
114
116
  if respond_to?(setter, true)
115
117
  send(setter, value)
116
118
 
117
- else
118
- if respond_to?(key.to_sym)
119
- instance_variable_set("@#{key}".to_sym, value)
120
- attribute_will_change!(key.to_sym)
121
- end
119
+ elsif respond_to?(key.to_sym)
120
+ instance_variable_set("@#{key}".to_sym, value)
121
+ attribute_will_change!(key.to_sym)
122
122
  end
123
123
  end
124
124
 
@@ -364,6 +364,7 @@ module SBF
364
364
  vars.each do |attribute|
365
365
  split_attribute = attribute.to_s.split('is_')
366
366
  next if split_attribute.length <= 1
367
+
367
368
  define_method(:"#{split_attribute.last}?") { send(attribute) }
368
369
  define_changing_attr_methods(attribute, true) if setter
369
370
  end
@@ -371,9 +372,11 @@ module SBF
371
372
  private_class_method :add_boolean_methods
372
373
 
373
374
  def self.define_changing_attr_methods(attribute, is_boolean = false, define_reader = false)
374
- define_method(:"#{attribute}") do
375
- instance_variable_get("@#{attribute}".to_sym)
376
- end if define_reader
375
+ if define_reader
376
+ define_method(:"#{attribute}") do
377
+ instance_variable_get("@#{attribute}".to_sym)
378
+ end
379
+ end
377
380
 
378
381
  define_method(:"#{attribute}=") do |val|
379
382
  send(:"#{attribute}_will_change!") unless val == instance_variable_get("@#{attribute}".to_sym) && !val.nil?
@@ -451,9 +454,7 @@ module SBF
451
454
  def self.get_mappings(attribute, class_mappings)
452
455
  # Parse the mappings information and save it off
453
456
  mapping_var = :"@#{attribute}_class_mappings"
454
- unless instance_variable_defined?(mapping_var)
455
- instance_variable_set(mapping_var, parse_class_mappings(class_mappings))
456
- end
457
+ instance_variable_set(mapping_var, parse_class_mappings(class_mappings)) unless instance_variable_defined?(mapping_var)
457
458
 
458
459
  instance_variable_get(mapping_var)
459
460
  end
@@ -523,6 +524,7 @@ module SBF
523
524
  define_method(:"#{attribute}=") do |values|
524
525
  values ||= []
525
526
  raise SBF::Client::Error, "#{attribute} must be an array" unless values.is_a?(Array)
527
+
526
528
  converted_collection = values.map { |value| convert_value(attribute, value) }
527
529
  instance_variable_set(:"@#{attribute}", converted_collection)
528
530
  send(:"#{attribute}_will_change!") if respond_to?(:"#{attribute}_will_change!")
@@ -544,28 +546,26 @@ module SBF
544
546
  value = send(key)
545
547
 
546
548
  # If the value is an Entity, call to_hash on it (recursively)
547
- if value.is_a?(BaseEntity)
548
- entity_hash[key] = value.to_hash
549
-
550
- # If the value is an Array, need to try to call to_hash on each item
551
- elsif value.is_a?(Array)
552
- entity_hash[key] = value.map { |element|
553
- if element.is_a?(BaseEntity)
554
- next element.to_hash
555
- else
556
- next element
557
- end
558
- }
549
+ entity_hash[key] = if value.is_a?(BaseEntity)
550
+ value.to_hash
559
551
 
560
- # Collections should return empty array rather than nil
561
- elsif value.nil? && self.class.collection_attributes.include?(key)
562
- entity_hash[key] = []
552
+ # If the value is an Array, need to try to call to_hash on each item
553
+ elsif value.is_a?(Array)
554
+ value.map { |element|
555
+ next element.to_hash if element.is_a?(BaseEntity)
563
556
 
564
- # Just set the value
565
- else
566
- entity_hash[key] = value
557
+ next element
558
+ }
567
559
 
568
- end
560
+ # Collections should return empty array rather than nil
561
+ elsif value.nil? && self.class.collection_attributes.include?(key)
562
+ []
563
+
564
+ # Just set the value
565
+ else
566
+ value
567
+
568
+ end
569
569
  }
570
570
 
571
571
  # Return the hash
@@ -590,6 +590,7 @@ module SBF
590
590
  def error
591
591
  log_deprecated('error', caller)
592
592
  return nil if single_active_model_error.nil?
593
+
593
594
  details = single_active_model_error.find { |x| x.is_a?(String) } if single_active_model_error.is_a?(Array)
594
595
  details ||= single_active_model_error.is_a?(String) ? single_active_model_error : nil
595
596
  field = single_active_model_error.is_a?(Array) ? single_active_model_error.find { |x| x.is_a?(Symbol) && x != :base } : nil
@@ -27,6 +27,7 @@ module SBF
27
27
  id = @cache_id_proc.call(proc_or_hash || {}) if @cache_id_proc
28
28
  id ||= superclass.cache_id_from_hash(proc_or_hash || {}) if superclass.respond_to?(:cache_id_from_hash)
29
29
  raise CacheableInvalidDataError, "Data missing id. Data: #{proc_or_hash.to_json}" unless id
30
+
30
31
  id
31
32
  end
32
33
 
@@ -34,6 +35,7 @@ module SBF
34
35
 
35
36
  def cache_id_from_hash_func(proc)
36
37
  raise ArgumentError, "Unable to re-set cache_id_from_hash on #{name}" if @cache_id_proc
38
+
37
39
  @cache_id_proc = proc
38
40
  end
39
41
  end
@@ -19,6 +19,7 @@ module SBF
19
19
  def error
20
20
  log_deprecated('error', caller)
21
21
  return nil if single_active_model_error.nil?
22
+
22
23
  details = single_active_model_error.find { |x| x.is_a?(String) } if single_active_model_error.is_a?(Array)
23
24
  details ||= single_active_model_error.is_a?(String) ? single_active_model_error : ''
24
25
  details = details["#{errors.type}: ".length..(details.length - 1)] if details.start_with?("#{errors.type}: ")
@@ -26,13 +27,16 @@ module SBF
26
27
  SBF::Client::ErrorEntity.new(code: errors.code, type: errors.type, details: details)
27
28
  end
28
29
 
30
+ # rubocop:disable MultipleComparison
29
31
  def [](*args)
30
32
  log_deprecated('[]', caller) if args == [:results] || args == [:total_count]
31
33
  return self if args == [:results]
32
34
  return @total_count if args == [:total_count]
35
+
33
36
  result = super
34
37
  result.is_a?(Array) ? self.class.new(result, total_count) : result
35
38
  end
39
+ # rubocop:enable MultipleComparison
36
40
  end
37
41
  end
38
42
  end
@@ -16,10 +16,13 @@ module SBF
16
16
  super
17
17
  end
18
18
 
19
+ # rubocop:disable Style/MissingRespondToMissing
19
20
  def method_missing(name)
20
21
  return @props[name.to_sym] if @props.key?(name.to_sym)
22
+
21
23
  super.method_missing(name)
22
24
  end
25
+ # rubocop:enable Style/MissingRespondToMissing
23
26
 
24
27
  def to_hash
25
28
  {}.tap do |hsh|
@@ -8,6 +8,7 @@ module SBF
8
8
  attr_accessor :is_owner
9
9
  attr_accessor :permission_ids
10
10
 
11
+ # rubocop:disable Style/MissingRespondToMissing
11
12
  def method_missing(method, *arguments, &block)
12
13
  # If the method starts with 'can', assume they are trying to determine if the user has the permission
13
14
  # in their list of permission ids and return the result
@@ -23,6 +24,7 @@ module SBF
23
24
 
24
25
  super
25
26
  end
27
+ # rubocop:enable Style/MissingRespondToMissing
26
28
  end
27
29
 
28
30
  class PermissionsAtEvent < SBF::Client::BaseEntity
@@ -15,6 +15,7 @@ module SBF
15
15
  # (402)555-5555 --> tel:4025555555
16
16
  def format_href
17
17
  return 'tel:' + number.gsub(/\D/, '') unless number.nil?
18
+
18
19
  number
19
20
  end
20
21
 
@@ -22,6 +23,7 @@ module SBF
22
23
  # (402)555-5555 ext. 5555 --> 402.555.555 x5555
23
24
  def format_number
24
25
  return number.gsub(/\D/, '').gsub(/(\d{3})(\d{3})(\d{4})(\d*)/, '\1.\2.\3 x\4').gsub(/x$/, '').rstrip unless number.nil?
26
+
25
27
  number
26
28
  end
27
29
  end
@@ -21,6 +21,7 @@ module SBF
21
21
 
22
22
  def endpoint(mod = nil, options = {})
23
23
  return define_endpoint(mod, options) if mod
24
+
24
25
  _endpoint
25
26
  end
26
27
 
@@ -100,7 +100,8 @@ module SBF
100
100
  check_date = DateTime.parse(check_date) if check_date.is_a?(String)
101
101
  check_date = DateTime.parse(check_date.to_s) if check_date.is_a?(Date)
102
102
  check_date = DateTime.parse(check_date.strftime('%d/%m/%Y %H:%M:%S')) if check_date.is_a?(Time)
103
- background_check_date && check_date.is_a?(DateTime) && background_check_date > check_date.prev_year(SBF::Client::Person::Policies::BACKGROUND_CHECK_YEARS_VALID)
103
+ background_check_date && check_date.is_a?(DateTime) \
104
+ && background_check_date > check_date.prev_year(SBF::Client::Person::Policies::BACKGROUND_CHECK_YEARS_VALID)
104
105
  end
105
106
  end
106
107
 
@@ -373,6 +374,7 @@ module SBF
373
374
  when SBF::Client::LeagueStatus::BARON
374
375
  'Baron of the Brave'
375
376
  when SBF::Client::LeagueStatus::NOT_APPLICABLE
377
+ ''
376
378
  end
377
379
  end
378
380
  end
@@ -34,55 +34,55 @@ module SBF
34
34
  attr_accessor :file
35
35
  attr_accessor :filename
36
36
  multitype_attr_accessor(
37
- :model,
37
+ :model,
38
+ [
38
39
  [
39
- [
40
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::PARTICIPANT },
41
- 'SBF::Client::Photo::FullParticipant',
42
- 'SBF::Client::Photo::PartialParticipant'
43
- ],
44
- [
45
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::FUNDRAISER },
46
- 'SBF::Client::Photo::FullFundraiser',
47
- 'SBF::Client::Photo::PartialFundraiser'
48
- ],
49
- [
50
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::FUND },
51
- 'SBF::Client::Photo::FullFund',
52
- 'SBF::Client::Photo::PartialFund'
53
- ],
54
- [
55
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::CAMPAIGN },
56
- 'SBF::Client::Photo::FullCampaign',
57
- 'SBF::Client::Photo::PartialCampaign'
58
- ],
59
- [
60
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::TEAM },
61
- 'SBF::Client::Photo::FullTeam',
62
- 'SBF::Client::Photo::PartialTeam'
63
- ],
64
- [
65
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::EVENT },
66
- 'SBF::Client::Photo::FullEvent',
67
- 'SBF::Client::Photo::PartialEvent'
68
- ],
69
- [
70
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::KID },
71
- 'SBF::Client::Photo::FullKid',
72
- 'SBF::Client::Photo::PartialKid'
73
- ],
74
- [
75
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::EVENT_SUPPORTER },
76
- 'SBF::Client::Photo::FullEventSupporter',
77
- 'SBF::Client::Photo::PartialEventSupporter'
78
- ],
79
- [
80
- ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::MEMORIAL },
81
- 'SBF::Client::Photo::FullMemorial',
82
- 'SBF::Client::Photo::PartialMemorial'
83
- ]
40
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::PARTICIPANT },
41
+ 'SBF::Client::Photo::FullParticipant',
42
+ 'SBF::Client::Photo::PartialParticipant'
84
43
  ],
85
- optional: false
44
+ [
45
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::FUNDRAISER },
46
+ 'SBF::Client::Photo::FullFundraiser',
47
+ 'SBF::Client::Photo::PartialFundraiser'
48
+ ],
49
+ [
50
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::FUND },
51
+ 'SBF::Client::Photo::FullFund',
52
+ 'SBF::Client::Photo::PartialFund'
53
+ ],
54
+ [
55
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::CAMPAIGN },
56
+ 'SBF::Client::Photo::FullCampaign',
57
+ 'SBF::Client::Photo::PartialCampaign'
58
+ ],
59
+ [
60
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::TEAM },
61
+ 'SBF::Client::Photo::FullTeam',
62
+ 'SBF::Client::Photo::PartialTeam'
63
+ ],
64
+ [
65
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::EVENT },
66
+ 'SBF::Client::Photo::FullEvent',
67
+ 'SBF::Client::Photo::PartialEvent'
68
+ ],
69
+ [
70
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::KID },
71
+ 'SBF::Client::Photo::FullKid',
72
+ 'SBF::Client::Photo::PartialKid'
73
+ ],
74
+ [
75
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::EVENT_SUPPORTER },
76
+ 'SBF::Client::Photo::FullEventSupporter',
77
+ 'SBF::Client::Photo::PartialEventSupporter'
78
+ ],
79
+ [
80
+ ->(v) { v[:model_type] == SBF::Client::Photo::ModelType::MEMORIAL },
81
+ 'SBF::Client::Photo::FullMemorial',
82
+ 'SBF::Client::Photo::PartialMemorial'
83
+ ]
84
+ ],
85
+ optional: false
86
86
  )
87
87
  attr_accessor :base_photo_url
88
88
  attr_reader :original_file_id
@@ -11,7 +11,7 @@ require 'stbaldricks/entities/concerns/fundraising_page_concern'
11
11
 
12
12
  module SBF
13
13
  module Client
14
- class Team < SBF::Client::TopLevelEntity
14
+ class Team < SBF::Client::TopLevelEntity
15
15
  include Entities::DefaultCacheable
16
16
  include DonationRecipientConcern
17
17
  include EventYearConcern
File without changes
File without changes
File without changes
@@ -8,9 +8,11 @@ module SBF
8
8
 
9
9
  REQUIRED_METHODS = [:debug, :info, :warn, :error, :fatal, :unknown, :add, :level]
10
10
 
11
+ # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
11
12
  def self.method_missing(sym, *args, &block)
12
13
  SBF::Client::Configuration.logger.send(sym, *args, &block)
13
14
  end
15
+ # rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
14
16
  end
15
17
  end
16
18
  end
@@ -23,9 +23,9 @@ class String
23
23
  end
24
24
 
25
25
  def snake_case
26
- gsub(SNAKE_CASE_REGEX) {
26
+ gsub(SNAKE_CASE_REGEX) do
27
27
  (Regexp.last_match[1] ? "_#{Regexp.last_match[1]}" : Regexp.last_match[2]).downcase
28
- }.sub(ID_REGEX, '_id').sub(UUID_REGEX, '_uuid').sub(URL_REGEX, '_url')
28
+ end.sub(ID_REGEX, '_id').sub(UUID_REGEX, '_uuid').sub(URL_REGEX, '_url')
29
29
  end
30
30
 
31
31
  def blank?
@@ -49,6 +49,7 @@ class String
49
49
  def to_b
50
50
  return false if self == 'false' || self == '0'
51
51
  return true if self == 'true' || self == '1'
52
+
52
53
  nil
53
54
  end
54
55
  end
@@ -1,5 +1,5 @@
1
1
  module SBF
2
2
  module Client
3
- VERSION = '6.13.0'
3
+ VERSION = '6.13.1.alpha.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stbaldricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.13.0
4
+ version: 6.13.1.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -31,19 +31,19 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.2'
33
33
  - !ruby/object:Gem::Dependency
34
- name: httparty
34
+ name: htmlentities
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.14.0
39
+ version: 4.3.4
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 0.14.0
46
+ version: 4.3.4
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: httmultiparty
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -59,19 +59,19 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: 0.3.16
61
61
  - !ruby/object:Gem::Dependency
62
- name: htmlentities
62
+ name: httparty
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - '='
66
66
  - !ruby/object:Gem::Version
67
- version: 4.3.4
67
+ version: 0.14.0
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - '='
73
73
  - !ruby/object:Gem::Version
74
- version: 4.3.4
74
+ version: 0.14.0
75
75
  description: Ruby library for accessing and integrating with the St. Baldrick's Foundation
76
76
  API
77
77
  email: opensource@stbaldricks.org
@@ -237,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
- - - ">="
240
+ - - ">"
241
241
  - !ruby/object:Gem::Version
242
- version: '0'
242
+ version: 1.3.1
243
243
  requirements: []
244
244
  rubygems_version: 3.0.1
245
245
  signing_key: