stbaldricks 12.10.0.alpha.2 → 12.10.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 +30 -13
  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 -6
  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 +30 -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 +22 -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 +68 -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 +279 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6329ad2d96a64c2eeba118360b5884851a82f632472e57e7ff4418a605da882d
4
- data.tar.gz: 48c5b9afa7e1aed7a0e6de385b07081fa97f293e15c3de50c66e97a793727458
3
+ metadata.gz: 4d50ab8d117ea5121d0c518c1772aeed31ae95e6b7a395213d211b6de7c4b2bd
4
+ data.tar.gz: '00383ada232391ff9d5da9a947c57dff1a3084e7cdce65437df99f605ce4a679'
5
5
  SHA512:
6
- metadata.gz: 64ec0cc8de11735db6f4996bb7c9c4bc49c9abca80fc6d44c7a3f624697f4cdfc30d67f1b773ca379f1ea566be5fe3989dd2e4bf24e495cf65234b2351f80d6e
7
- data.tar.gz: d9d4c2cf4a3c048e7b9478d872ead7c6ad3e3ecbc533b8cf38b27afdab10342d9ecd7e9bed5b33d9676b36b0ca5be92ec908058769de1bdebdb3ae56c7dcd8b8
6
+ metadata.gz: 78d52b9fd0e797d993177be9069eb757ec497c8a0b9eb0f37fdb88f2a1cac708b5b441a199a743244f5fc46bccb3ab318656b3acdc090d8334841ee9a134b218
7
+ data.tar.gz: 25d7bc5cf26b692a4a58928b16f8bd987b349e74f6a9751637802c75e2266f95315b8013834bf95cbe05766cd3a886d46580bc691945bcd878a1b3d3da006a77
@@ -16,11 +16,11 @@ module SBF
16
16
  end
17
17
 
18
18
  def self.base_uri
19
- @base_uri ||= ENV.fetch('API_ENDPOINT', DEFAULT_API_ENDPOINT)
19
+ @base_uri ||= ENV['API_ENDPOINT'] || DEFAULT_API_ENDPOINT
20
20
  end
21
21
 
22
22
  def self.general_token
23
- @general_token ||= ENV.fetch('API_KEY', nil) || raise(SBF::Client::Configuration::Error.new('general_token', 'must be set'))
23
+ @general_token ||= ENV['API_KEY'] || raise(SBF::Client::Configuration::Error.new('general_token', 'must be set'))
24
24
  end
25
25
 
26
26
  def self.request_id
@@ -3,7 +3,7 @@ require 'logger'
3
3
  module SBF
4
4
  module Client
5
5
  module DefaultLogger
6
- def self.instance(default_stream = $stdout)
6
+ def self.instance(default_stream = STDOUT)
7
7
  formatter = proc { |severity, datetime, _, msg|
8
8
  # ruby logger docs suggested this method for escaping messages since messages may contain user input
9
9
  # and are not escaped by default.
@@ -16,7 +16,7 @@ module SBF
16
16
 
17
17
  logger.formatter = formatter
18
18
  logger.level = ::Logger::DEBUG
19
- logger.level = ENV.fetch('SBF_CLIENT_LOG_LEVEL', ::Logger::DEBUG)
19
+ logger.level = ENV['SBF_CLIENT_LOG_LEVEL'] || ::Logger::DEBUG
20
20
  logger
21
21
  end
22
22
  end
@@ -27,17 +27,17 @@ module SBF
27
27
  end
28
28
  end
29
29
 
30
- def find_by_term(term, order = {}, limit = 10, offset = 0, show_hidden: true)
30
+ def find_by_term(term, order = {}, limit = 10, offset = 0, show_hidden = true)
31
31
  # Build the parameter list for search; an empty find is supported
32
32
  filter = {}
33
33
  filter[:type] = FILTER_BY_TERM
34
34
  filter[:term] = term unless term.empty?
35
35
  filter[:show_hidden] = show_hidden
36
36
 
37
- find(filter: filter, order: order, limit: limit, offset: offset)
37
+ find(filter, order, limit, offset)
38
38
  end
39
39
 
40
- def find_by_author(author, order = {}, limit = 10, offset = 0, show_hidden: true)
40
+ def find_by_author(author, order = {}, limit = 10, offset = 0, show_hidden = true)
41
41
  raise SBF::Client::Error, 'Must provide author for the query' if author.empty?
42
42
 
43
43
  filter = {}
@@ -45,10 +45,10 @@ module SBF
45
45
  filter[:term] = author
46
46
  filter[:show_hidden] = show_hidden
47
47
 
48
- find(filter: filter, order: order, limit: limit, offset: offset)
48
+ find(filter, order, limit, offset)
49
49
  end
50
50
 
51
- def find_by_category(category, order = {}, limit = 10, offset = 0, show_hidden: true)
51
+ def find_by_category(category, order = {}, limit = 10, offset = 0, show_hidden = true)
52
52
  raise SBF::Client::Error, 'Must provide category for the query' if category.empty?
53
53
 
54
54
  filter = {}
@@ -56,10 +56,10 @@ module SBF
56
56
  filter[:term] = category
57
57
  filter[:show_hidden] = show_hidden
58
58
 
59
- find(filter: filter, order: order, limit: limit, offset: offset)
59
+ find(filter, order, limit, offset)
60
60
  end
61
61
 
62
- def find_by_tag(tag, order = {}, limit = 10, offset = 0, show_hidden: true)
62
+ def find_by_tag(tag, order = {}, limit = 10, offset = 0, show_hidden = true)
63
63
  raise SBF::Client::Error, 'Must provide tag for the query' if tag.empty?
64
64
 
65
65
  filter = {}
@@ -67,7 +67,7 @@ module SBF
67
67
  filter[:term] = tag
68
68
  filter[:show_hidden] = show_hidden
69
69
 
70
- find(filter: filter, order: order, limit: limit, offset: offset)
70
+ find(filter, order, limit, offset)
71
71
  end
72
72
  end
73
73
  end
@@ -48,7 +48,7 @@ module SBF
48
48
  group_id: group_id
49
49
  )
50
50
  parsed_response_body = JSON.parse(response.body).symbolize!
51
- parsed_response_body.map! { |c| SBF::Client::Contact.new(c, **(;{})) } if ok?(response)
51
+ parsed_response_body.map! { |c| SBF::Client::Contact.new(c) } if ok?(response)
52
52
 
53
53
  handle_parsed_response(parsed_response_body, response)
54
54
  end
@@ -11,7 +11,7 @@ module SBF
11
11
  raise SBF::Client::StandardError, 'Unable to retrieve settings from the api' unless ok?(response)
12
12
 
13
13
  # re-call initalize with the new api data. This should re-set all of the instance variables on the instance
14
- entity.send(:initialize, parsed_response_body, **(;{}))
14
+ entity.send(:initialize, parsed_response_body)
15
15
  end
16
16
  end
17
17
  end
@@ -3,7 +3,7 @@ require 'stbaldricks/endpoints/lib/entity'
3
3
  module SBF
4
4
  module Client
5
5
  class DeduplicatorMatchEndpoint < SBF::Client::EntityEndpoint
6
- def checkout(filter: [], order: {}, limit: 20, offset: 0, with: {})
6
+ def checkout(filter = [], order = {}, limit = 20, offset = 0, with = {})
7
7
  filter = filter.to_json unless filter.is_a? String
8
8
  order = order.to_json unless order.is_a? String
9
9
  with = normalize_with(with)
@@ -15,7 +15,7 @@ module SBF
15
15
  parsed_response_body = JSON.parse(response.body).symbolize!
16
16
 
17
17
  if ok?(response)
18
- parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, clear_changes: true) }
18
+ parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, true) }
19
19
  SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
20
20
  else
21
21
  parsed_response_body = JSON.parse(response.body).symbolize!
@@ -12,7 +12,7 @@ module SBF
12
12
  parsed_response_body = JSON.parse(response.body).symbolize!
13
13
 
14
14
  if ok?(response)
15
- parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, **(;{})) }
15
+ parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data) }
16
16
  SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
17
17
  else
18
18
  parsed_response_body = JSON.parse(response.body).symbolize!
@@ -10,7 +10,8 @@ require 'json'
10
10
  module SBF
11
11
  module Client
12
12
  class EntityEndpoint
13
- attr_reader :orig_target_class, :base_uri
13
+ attr_reader :orig_target_class
14
+ attr_reader :base_uri
14
15
 
15
16
  def initialize(target_class)
16
17
  @orig_target_class = target_class
@@ -33,7 +34,7 @@ module SBF
33
34
  # @param with [Hash] The optional entity fields to include in the response
34
35
  # @return entity [SBF::Client::BaseEntity]
35
36
  def create(entity_or_hash, with = {})
36
- entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash, **(;{})) : entity_or_hash
37
+ entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash) : entity_or_hash
37
38
  raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
38
39
 
39
40
  with = normalize_with(with, entity)
@@ -49,11 +50,10 @@ module SBF
49
50
  # @param with [Hash] The optional entity fields to include in the response
50
51
  # @return entity [SBF::Client::BaseEntity]
51
52
  def update(id = nil, entity_or_hash = nil, with = {})
52
- case entity_or_hash
53
- when SBF::Client::BaseEntity
53
+ if entity_or_hash.is_a?(SBF::Client::BaseEntity)
54
54
  # If someone has passed in an entity, just convert it to a hash
55
55
  data = entity_or_hash.dirty_data
56
- when Hash
56
+ elsif entity_or_hash.is_a?(Hash)
57
57
  # If someone has passed in a hash, make sure all of it's values match fields in the entity class
58
58
  data = sanitize(entity_or_hash)
59
59
  else
@@ -89,7 +89,7 @@ module SBF
89
89
  end
90
90
 
91
91
  # Calls the find route for the entity.
92
- def find(filter: [], order: {}, limit: 20, offset: 0, with: {})
92
+ def find(filter = [], order = {}, limit = 20, offset = 0, with = {})
93
93
  filter = filter.to_json unless filter.is_a? String
94
94
  order = order.to_json unless order.is_a? String
95
95
  with = normalize_with(with)
@@ -98,9 +98,7 @@ module SBF
98
98
  parsed_response_body = JSON.parse(response.body).symbolize!
99
99
 
100
100
  if ok?(response)
101
- parsed_response_body[:results].map! do |entity_data|
102
- target_class.new(entity_data, clear_changes: true)
103
- end
101
+ parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, true) }
104
102
  SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
105
103
  else
106
104
  parsed_response_body = JSON.parse(response.body).symbolize!
@@ -115,7 +113,7 @@ module SBF
115
113
 
116
114
  # Calls the find route for the entity.
117
115
  def find_first(filter = [], order = {}, with = {})
118
- response = find(filter: filter, order: order, limit: 1, with: with)
116
+ response = find(filter, order, 1, 0, with)
119
117
  if response.is_a?(SBF::Client::EntityCollection)
120
118
  response.empty? ? nil : response.first
121
119
  else
@@ -150,7 +148,7 @@ module SBF
150
148
 
151
149
  def target_class
152
150
  class_name_pieces = @orig_target_class.to_s.split('::')
153
- full_name = (class_name_pieces[0..-2] + ["Full#{class_name_pieces.last}"]).join('::')
151
+ full_name = (class_name_pieces[0..-2] + ['Full' + class_name_pieces.last]).join('::')
154
152
  Object.const_defined?(full_name) ? Object.const_get(full_name) : @orig_target_class
155
153
  end
156
154
  private :target_class
@@ -249,7 +247,7 @@ module SBF
249
247
  entity_or_hash.send(:initialize_attributes, new_data)
250
248
  entity = entity_or_hash
251
249
  else
252
- entity = target_class.new(new_data, **(;{}))
250
+ entity = target_class.new(new_data)
253
251
  end
254
252
 
255
253
  # Reload entity and its sub-entities so that no fields have a 'changed' state
@@ -258,7 +256,7 @@ module SBF
258
256
  entity
259
257
  else
260
258
  error = SBF::Client::ApiErrorEntity.new(parsed_response_body.merge(http_code: response.code))
261
- entity = entity_or_hash.is_a?(SBF::Client::BaseEntity) ? entity_or_hash : target_class.new(entity_or_hash, **(;{}))
259
+ entity = entity_or_hash.is_a?(SBF::Client::BaseEntity) ? entity_or_hash : target_class.new(entity_or_hash)
262
260
  entity.add_errors(error)
263
261
  entity.errors_http_code = response.code
264
262
 
@@ -3,14 +3,9 @@ require 'stbaldricks/endpoints/lib/entity'
3
3
  module SBF
4
4
  module Client
5
5
  class NewsletterRecipientEndpoint < EntityEndpoint
6
- def subscribe(entity_or_email, first_name = nil, last_name = nil, welcome_email: true)
6
+ def subscribe(entity_or_email, first_name = nil, last_name = nil, welcome_email = true)
7
7
  if entity_or_email.is_a?(String) && entity_or_email && first_name && last_name
8
- entity = target_class.new({
9
- email_address: entity_or_email,
10
- first_name: first_name,
11
- last_name: last_name,
12
- welcome_email: welcome_email
13
- }, **(;{}))
8
+ entity = target_class.new(email_address: entity_or_email, first_name: first_name, last_name: last_name, welcome_email: welcome_email)
14
9
  elsif entity_or_email.is_a?(SBF::Client::BaseEntity)
15
10
  entity = entity_or_email
16
11
  else
@@ -26,10 +21,9 @@ module SBF
26
21
  end
27
22
 
28
23
  def unsubscribe(entity_or_email)
29
- case entity_or_email
30
- when String
31
- entity = target_class.new({email_address: entity_or_email}, **(;{}))
32
- when SBF::Client::BaseEntity
24
+ if entity_or_email.is_a?(String)
25
+ entity = target_class.new(email_address: entity_or_email)
26
+ elsif entity_or_email.is_a?(SBF::Client::BaseEntity)
33
27
  entity = entity_or_email
34
28
  else
35
29
  raise SBF::Client::Error, 'Invalid Entity'
@@ -7,7 +7,7 @@ module SBF
7
7
  response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: participant_id, new_team_id: new_team_id)
8
8
 
9
9
  if ok?(response)
10
- data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!, **(;{}))
10
+ data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
11
11
  else
12
12
  error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
13
13
  end
@@ -26,7 +26,7 @@ module SBF
26
26
  )
27
27
 
28
28
  if ok?(response)
29
- data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!, **(;{}))
29
+ data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
30
30
  else
31
31
  error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
32
32
  end
@@ -38,7 +38,7 @@ module SBF
38
38
  response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: participant_id, new_team_id: 0)
39
39
 
40
40
  if ok?(response)
41
- data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!, **(;{}))
41
+ data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
42
42
  else
43
43
  error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
44
44
  end
@@ -4,7 +4,7 @@ module SBF
4
4
  module Client
5
5
  class PhotoEndpoint < SBF::Client::EntityEndpoint
6
6
  def create(entity_or_hash, with = {})
7
- entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash, **(;{})) : entity_or_hash
7
+ entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash) : entity_or_hash
8
8
  raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
9
9
 
10
10
  with = normalize_with(with)
@@ -20,13 +20,12 @@ module SBF
20
20
  end
21
21
 
22
22
  def update(id = nil, entity_or_hash = nil, with = {})
23
- case entity_or_hash
24
- when SBF::Client::BaseEntity
23
+ if entity_or_hash.is_a?(SBF::Client::BaseEntity)
25
24
  # If someone has passed in an entity, just convert it to a hash
26
25
  data = entity_or_hash.dirty_data
27
26
  data[:id] = id unless id.nil?
28
27
  data[:id] = entity_or_hash.id if id.nil? && !entity_or_hash.id.nil?
29
- when Hash
28
+ elsif entity_or_hash.is_a?(Hash)
30
29
  # If someone has passed in a hash, make sure all of it's values match fields in the entity class
31
30
  data = sanitize(entity_or_hash)
32
31
  else
@@ -67,7 +66,7 @@ module SBF
67
66
  data.file = file
68
67
  data
69
68
  else
70
- photo = SBF::Client::Photo.new((data.is_a?(Hash) && data.any?) ? data : {}, **(;{}))
69
+ photo = SBF::Client::Photo.new(data.is_a?(Hash) && data.any? ? data : {})
71
70
  photo.file = file
72
71
  photo
73
72
  end
@@ -18,7 +18,7 @@ module SBF
18
18
  # @option [Integer] :offset The query offset.
19
19
  # @return [Client::Api::Response] The data attribute on a successful response will be
20
20
  # an array of search entities matching the model type(s) specified
21
- def find(model_type, search_text: nil, filters: [], geo_location: {}, options: {})
21
+ def find(model_type, search_text = nil, filters = [], geo_location = {}, options = {})
22
22
  if [search_text, filters, geo_location].all?(&:empty?)
23
23
  raise SBF::Client::Error, 'Must provide either a search_text, filter or geo_location for the query'
24
24
  end
@@ -45,7 +45,7 @@ module SBF
45
45
  response_data[:total_count] = parsed_response_body[:total]
46
46
  response_data[:results] = [].tap do |arr|
47
47
  parsed_response_body[:hits].each do |entity_data|
48
- arr << target_class.const_get(entity_data[:type].capitalize).new(entity_data[:source], **(;{}))
48
+ arr << target_class.const_get(entity_data[:type].capitalize).new(entity_data[:source])
49
49
  end
50
50
  end
51
51
 
@@ -20,7 +20,7 @@ module SBF
20
20
 
21
21
  if ok?(response)
22
22
  SBF::Client::Configuration.user_token = parsed_response[:token]
23
- data = parsed_response.merge(user: target_class.new(parsed_response[:user], **(;{})))
23
+ data = parsed_response.merge(user: target_class.new(parsed_response[:user]))
24
24
  else
25
25
  SBF::Client::Configuration.user_token = nil
26
26
  error = SBF::Client::ErrorEntity.new(parsed_response)
@@ -12,15 +12,17 @@ module SBF
12
12
  PROCESSED = 'processed'.freeze
13
13
  end
14
14
 
15
- attr_accessor :id, :type, :amount, :filename, :created_at, :modified_at, :processed_at, :submitted_by
16
-
15
+ attr_accessor :id
16
+ attr_accessor :type
17
17
  multitype_attr_accessor(
18
18
  :payment_details, [
19
19
  [->(v) { v[:type] == SBF::Client::Payment::Type::CREDIT_CARD }, 'SBF::Client::Payment::CreditCardDetails'],
20
20
  [->(v) { v[:type] == SBF::Client::Payment::Type::NONCE }, 'SBF::Client::Payment::NonceDetails']
21
21
  ]
22
22
  )
23
-
23
+ attr_accessor :amount
24
+ attr_accessor :filename
25
+ attr_accessor :created_at, :modified_at, :processed_at, :submitted_by
24
26
  entity_collection_attr_accessor :donations, 'SBF::Client::FullDonation', 'SBF::Client::PartialDonation'
25
27
  end
26
28
  end
@@ -12,7 +12,13 @@ module SBF
12
12
  action :find_by_category
13
13
  action :find_by_tag
14
14
 
15
- attr_reader :id, :slug, :url, :title, :content, :published_at, :modified_at
15
+ attr_reader :id
16
+ attr_reader :slug
17
+ attr_reader :url
18
+ attr_reader :title
19
+ attr_reader :content
20
+ attr_reader :published_at
21
+ attr_reader :modified_at
16
22
  end
17
23
  end
18
24
  end
@@ -12,8 +12,12 @@ module SBF
12
12
  disallow_instantiation
13
13
 
14
14
  class Totals < SBF::Client::BaseEntity
15
- attr_reader :current_year_amount_raised, :previous_year_amount_raised, :all_years_amount_raised, :participants,
16
- :shavees, :number_of_events
15
+ attr_reader :current_year_amount_raised
16
+ attr_reader :previous_year_amount_raised
17
+ attr_reader :all_years_amount_raised
18
+ attr_reader :participants
19
+ attr_reader :shavees
20
+ attr_reader :number_of_events
17
21
  end
18
22
  end
19
23
 
@@ -22,12 +26,15 @@ module SBF
22
26
  end
23
27
 
24
28
  class FullCampaign < Campaign
25
- attr_accessor :id, :name, :website_url, :is_enabled
29
+ attr_accessor :id
30
+ attr_accessor :name
31
+ attr_accessor :website_url
32
+ attr_accessor :is_enabled
26
33
 
27
- entity_attr_reader :totals, 'SBF::Client::Campaign::Totals', nil, optional: true
28
- entity_attr_accessor :web_page, 'SBF::Client::WebPage', nil, optional: true
34
+ entity_attr_reader :totals, 'SBF::Client::Campaign::Totals', nil, true
35
+ entity_attr_accessor :web_page, 'SBF::Client::WebPage', nil, true
29
36
 
30
- entity_attr_accessor :photo, 'SBF::Client::Photo', nil, optional: true
37
+ entity_attr_accessor :photo, 'SBF::Client::Photo', nil, true
31
38
  end
32
39
  end
33
40
  end
@@ -16,11 +16,13 @@ module SBF
16
16
  DECLINED = 'declined'.freeze
17
17
  end
18
18
 
19
- attr_accessor :id, :status, :end_date, :modified_by
20
-
21
- entity_attr_accessor :challenger, 'SBF::Client::Challenger', nil, optional: true
22
- entity_attr_accessor :challengee, 'SBF::Client::Challenger', nil, optional: true
19
+ attr_accessor :id
20
+ attr_accessor :status
21
+ attr_accessor :end_date
22
+ entity_attr_accessor :challenger, 'SBF::Client::Challenger', nil, true
23
+ entity_attr_accessor :challengee, 'SBF::Client::Challenger', nil, true
23
24
  attr_reader :created_at, :modified_at
25
+ attr_accessor :modified_by
24
26
  end
25
27
  end
26
28
  end
@@ -97,9 +97,11 @@ module SBF
97
97
  end
98
98
  end
99
99
 
100
- attr_accessor :id, :challenge_id, :type, :is_accepted
101
-
102
- entity_attr_reader :totals, 'SBF::Client::Challenger::Totals', nil, optional: true
100
+ attr_accessor :id
101
+ attr_accessor :challenge_id
102
+ attr_accessor :type
103
+ attr_accessor :is_accepted
104
+ entity_attr_reader :totals, 'SBF::Client::Challenger::Totals', nil, true
103
105
 
104
106
  multitype_attr_accessor(
105
107
  :entity,
@@ -125,7 +127,7 @@ module SBF
125
127
  'SBF::Client::Challenger::PartialEvent'
126
128
  ]
127
129
  ],
128
- optional: true
130
+ true
129
131
  )
130
132
  end
131
133
  end
@@ -59,7 +59,7 @@ module EntityResponseConcern
59
59
  caller_message = method_caller.nil? ? '' : " Called from #{method_caller.first}"
60
60
 
61
61
  "[DEPRECATION] Use of the SBF::Client::Api::Response Interface (including the `#{method_name}` method) is deprecated"\
62
- " for #{self.class}. Please update your code to use the #{self.class} interface accordingly. #{caller_message}"
62
+ " for #{self.class}. Please update your code to use the #{self.class} interface accordingly. #{caller_message}"
63
63
  end
64
64
  end
65
65
  end
@@ -11,9 +11,14 @@ module SBF
11
11
  action :get
12
12
  instance_action :reload
13
13
 
14
- attr_reader :default_year, :open_registration_years, :website_url, :years_for_squire, :years_for_knight, :years_for_knight_commander,
15
- :years_for_crusader, :years_for_baron
16
-
14
+ attr_reader :default_year
15
+ attr_reader :open_registration_years
16
+ attr_reader :website_url
17
+ attr_reader :years_for_squire
18
+ attr_reader :years_for_knight
19
+ attr_reader :years_for_knight_commander
20
+ attr_reader :years_for_crusader
21
+ attr_reader :years_for_baron
17
22
  # NOTE: If you add another attribute, be sure to mock it out in `configure :test` of app.rb
18
23
 
19
24
  # Attempts to call the method on the cached configuration object
@@ -14,19 +14,22 @@ module SBF
14
14
  WEBSITE = 'website'.freeze
15
15
  end
16
16
 
17
- attr_reader :id, :display_name, :email, :created_at, :modified_at
18
-
17
+ attr_reader :id
19
18
  entity_attr_accessor :owner, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
20
19
  entity_attr_accessor :person, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
21
20
  attr_accessor :type
22
-
21
+ attr_reader :display_name
22
+ attr_reader :email
23
+ attr_reader :created_at, :modified_at
23
24
  entity_collection_attr_reader :contact_groups, 'SBF::Client::ContactGroup'
24
25
  end
25
26
 
26
27
  class CustomContact < SBF::Client::Contact
27
28
  endpoint SBF::Client::ContactEndpoint
28
29
 
29
- attr_accessor :id, :display_name, :email
30
+ attr_accessor :id
31
+ attr_accessor :display_name
32
+ attr_accessor :email
30
33
  end
31
34
  end
32
35
  end
@@ -8,8 +8,8 @@ module SBF
8
8
  class ContactGroup < SBF::Client::TopLevelEntity
9
9
  actions DEFAULT_CRUD_ACTIONS
10
10
 
11
- attr_accessor :id, :display_name
12
-
11
+ attr_accessor :id
12
+ attr_accessor :display_name
13
13
  entity_attr_accessor :owner, 'SBF::Client::FullPerson'
14
14
  multitype_collection_attr_accessor(
15
15
  :contacts,
@@ -6,7 +6,12 @@ module SBF
6
6
  action :get
7
7
  action :find
8
8
 
9
- attr_accessor :id, :from_profile_id, :to_profile_id, :checkout_id, :change_history, :date_merged
9
+ attr_accessor :id
10
+ attr_accessor :from_profile_id
11
+ attr_accessor :to_profile_id
12
+ attr_accessor :checkout_id
13
+ attr_accessor :change_history
14
+ attr_accessor :date_merged
10
15
  end
11
16
  end
12
17
  end
@@ -27,10 +27,13 @@ module SBF
27
27
  ERROR_OUT_OF_SYNC_UPDATE = 'error_out_of_sync_update'.freeze
28
28
  end
29
29
 
30
- attr_accessor :id, :checkout_id, :status, :date_created, :date_modified
31
-
32
- entity_collection_attr_accessor :persons, 'SBF::Client::FullPerson', nil, optional: true
33
- entity_collection_attr_accessor :organizations, 'SBF::Client::FullOrganization', nil, optional: true
30
+ attr_accessor :id
31
+ attr_accessor :checkout_id
32
+ attr_accessor :status
33
+ attr_accessor :date_created
34
+ attr_accessor :date_modified
35
+ entity_collection_attr_accessor :persons, 'SBF::Client::FullPerson', nil, true
36
+ entity_collection_attr_accessor :organizations, 'SBF::Client::FullOrganization', nil, true
34
37
  end
35
38
  end
36
39
  end
@@ -13,8 +13,11 @@ module SBF
13
13
 
14
14
  disallow_instantiation
15
15
 
16
- attr_accessor :id, :name, :description
17
- attr_reader :created_at, :modified_at
16
+ attr_accessor :id
17
+ attr_accessor :name
18
+ attr_accessor :description
19
+ attr_reader :created_at
20
+ attr_reader :modified_at
18
21
  end
19
22
  end
20
23
  end
@@ -6,9 +6,14 @@ module SBF
6
6
  class DocumentLibrary < SBF::Client::TopLevelEntity
7
7
  actions DEFAULT_CRUD_ACTIONS
8
8
 
9
- attr_accessor :id, :type, :title, :description, :url, :media_storage_id, :sort_order
10
-
11
- entity_attr_reader :category, 'SBF::Client::DocumentLibraryCategory', nil, optional: true
9
+ attr_accessor :id
10
+ attr_accessor :type
11
+ attr_accessor :title
12
+ attr_accessor :description
13
+ attr_accessor :url
14
+ attr_accessor :media_storage_id
15
+ attr_accessor :sort_order
16
+ entity_attr_reader :category, 'SBF::Client::DocumentLibraryCategory', nil, true
12
17
  end
13
18
  end
14
19
  end
@@ -5,7 +5,10 @@ module SBF
5
5
  class DocumentLibraryCategory < SBF::Client::TopLevelEntity
6
6
  actions DEFAULT_CRUD_ACTIONS
7
7
 
8
- attr_accessor :id, :top_level_category, :name, :sort_order
8
+ attr_accessor :id
9
+ attr_accessor :top_level_category
10
+ attr_accessor :name
11
+ attr_accessor :sort_order
9
12
  end
10
13
  end
11
14
  end