stbaldricks 12.15.0 → 15.0.0.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -38
  3. data/lib/stbaldricks/configuration.rb +2 -2
  4. data/lib/stbaldricks/default_logger.rb +2 -2
  5. data/lib/stbaldricks/endpoints/blog_post.rb +8 -8
  6. data/lib/stbaldricks/endpoints/communicate.rb +7 -7
  7. data/lib/stbaldricks/endpoints/config.rb +1 -1
  8. data/lib/stbaldricks/endpoints/deduplicator_match.rb +4 -4
  9. data/lib/stbaldricks/endpoints/event.rb +1 -1
  10. data/lib/stbaldricks/endpoints/facebook/user.rb +2 -2
  11. data/lib/stbaldricks/endpoints/fund.rb +1 -1
  12. data/lib/stbaldricks/endpoints/fundraiser.rb +1 -1
  13. data/lib/stbaldricks/endpoints/kid.rb +2 -2
  14. data/lib/stbaldricks/endpoints/lib/entity.rb +16 -14
  15. data/lib/stbaldricks/endpoints/message.rb +12 -12
  16. data/lib/stbaldricks/endpoints/newsletter_recipient.rb +11 -5
  17. data/lib/stbaldricks/endpoints/participant.rb +3 -3
  18. data/lib/stbaldricks/endpoints/photo.rb +5 -4
  19. data/lib/stbaldricks/endpoints/promo.rb +7 -7
  20. data/lib/stbaldricks/endpoints/search.rb +3 -3
  21. data/lib/stbaldricks/endpoints/user.rb +8 -8
  22. data/lib/stbaldricks/entities/batch.rb +3 -5
  23. data/lib/stbaldricks/entities/blog_post.rb +1 -7
  24. data/lib/stbaldricks/entities/campaign.rb +6 -13
  25. data/lib/stbaldricks/entities/challenge.rb +4 -6
  26. data/lib/stbaldricks/entities/challenger.rb +4 -6
  27. data/lib/stbaldricks/entities/concerns/entity_response_concern.rb +2 -2
  28. data/lib/stbaldricks/entities/concerns/model_type_concern.rb +1 -1
  29. data/lib/stbaldricks/entities/concerns/type_concern.rb +1 -1
  30. data/lib/stbaldricks/entities/config.rb +3 -8
  31. data/lib/stbaldricks/entities/contact.rb +4 -7
  32. data/lib/stbaldricks/entities/contact_group.rb +2 -2
  33. data/lib/stbaldricks/entities/deduplicator_history.rb +1 -6
  34. data/lib/stbaldricks/entities/deduplicator_match.rb +4 -7
  35. data/lib/stbaldricks/entities/disease.rb +2 -5
  36. data/lib/stbaldricks/entities/document_library.rb +3 -8
  37. data/lib/stbaldricks/entities/document_library_category.rb +1 -4
  38. data/lib/stbaldricks/entities/donation/payment_type.rb +6 -5
  39. data/lib/stbaldricks/entities/donation.rb +13 -18
  40. data/lib/stbaldricks/entities/donor.rb +1 -5
  41. data/lib/stbaldricks/entities/event.rb +34 -45
  42. data/lib/stbaldricks/entities/event_application.rb +6 -10
  43. data/lib/stbaldricks/entities/event_donation_summary.rb +2 -5
  44. data/lib/stbaldricks/entities/event_participant_summary.rb +1 -3
  45. data/lib/stbaldricks/entities/event_supporter.rb +3 -3
  46. data/lib/stbaldricks/entities/fund.rb +6 -23
  47. data/lib/stbaldricks/entities/fundraiser.rb +16 -29
  48. data/lib/stbaldricks/entities/grant.rb +12 -25
  49. data/lib/stbaldricks/entities/institution.rb +3 -4
  50. data/lib/stbaldricks/entities/international_partner.rb +4 -16
  51. data/lib/stbaldricks/entities/kid.rb +11 -28
  52. data/lib/stbaldricks/entities/kid_honor.rb +1 -0
  53. data/lib/stbaldricks/entities/kid_institution.rb +2 -2
  54. data/lib/stbaldricks/entities/lib/address.rb +3 -6
  55. data/lib/stbaldricks/entities/lib/alternate_shipping_address.rb +1 -3
  56. data/lib/stbaldricks/entities/lib/base.rb +48 -43
  57. data/lib/stbaldricks/entities/lib/collection.rb +2 -2
  58. data/lib/stbaldricks/entities/lib/email_address.rb +1 -2
  59. data/lib/stbaldricks/entities/lib/fundraising_page.rb +2 -3
  60. data/lib/stbaldricks/entities/lib/location.rb +1 -0
  61. data/lib/stbaldricks/entities/lib/milestone.rb +1 -3
  62. data/lib/stbaldricks/entities/lib/name.rb +2 -2
  63. data/lib/stbaldricks/entities/lib/not_implemented_object.rb +1 -1
  64. data/lib/stbaldricks/entities/lib/payment.rb +25 -4
  65. data/lib/stbaldricks/entities/lib/permissions.rb +2 -5
  66. data/lib/stbaldricks/entities/lib/phone.rb +2 -3
  67. data/lib/stbaldricks/entities/lib/third_party_media.rb +1 -5
  68. data/lib/stbaldricks/entities/lib/top_level.rb +7 -7
  69. data/lib/stbaldricks/entities/matching_gift_company.rb +16 -39
  70. data/lib/stbaldricks/entities/memorial.rb +9 -14
  71. data/lib/stbaldricks/entities/message.rb +4 -15
  72. data/lib/stbaldricks/entities/organization.rb +11 -17
  73. data/lib/stbaldricks/entities/page.rb +9 -17
  74. data/lib/stbaldricks/entities/participant.rb +18 -28
  75. data/lib/stbaldricks/entities/participant_donation_summary.rb +2 -4
  76. data/lib/stbaldricks/entities/person.rb +23 -32
  77. data/lib/stbaldricks/entities/person_donation_by_year_summary.rb +1 -2
  78. data/lib/stbaldricks/entities/photo.rb +5 -11
  79. data/lib/stbaldricks/entities/recurring_gift.rb +10 -18
  80. data/lib/stbaldricks/entities/response.rb +4 -3
  81. data/lib/stbaldricks/entities/search.rb +30 -168
  82. data/lib/stbaldricks/entities/section.rb +1 -4
  83. data/lib/stbaldricks/entities/shave_schedule.rb +4 -13
  84. data/lib/stbaldricks/entities/summary.rb +1 -7
  85. data/lib/stbaldricks/entities/team.rb +12 -16
  86. data/lib/stbaldricks/entities/team_donation_summary.rb +2 -4
  87. data/lib/stbaldricks/request.rb +2 -2
  88. data/lib/stbaldricks/version.rb +1 -1
  89. metadata +85 -279
  90. data/lib/stbaldricks_factories.rb +0 -5
  91. data/spec/factories/address.rb +0 -14
  92. data/spec/factories/campaign/totals.rb +0 -9
  93. data/spec/factories/campaign.rb +0 -9
  94. data/spec/factories/challenge.rb +0 -19
  95. data/spec/factories/challenger.rb +0 -33
  96. data/spec/factories/collection.rb +0 -17
  97. data/spec/factories/contact.rb +0 -18
  98. data/spec/factories/contact_group.rb +0 -18
  99. data/spec/factories/diagnosis.rb +0 -12
  100. data/spec/factories/disease.rb +0 -11
  101. data/spec/factories/donation/participant.rb +0 -27
  102. data/spec/factories/donation.rb +0 -68
  103. data/spec/factories/donor.rb +0 -13
  104. data/spec/factories/email_address.rb +0 -11
  105. data/spec/factories/error.rb +0 -9
  106. data/spec/factories/event/coach_tracking/coaching_interactions.rb +0 -12
  107. data/spec/factories/event/coach_tracking/plaque.rb +0 -12
  108. data/spec/factories/event/coach_tracking/proceeds.rb +0 -12
  109. data/spec/factories/event/coach_tracking.rb +0 -18
  110. data/spec/factories/event/contacts/contact.rb +0 -17
  111. data/spec/factories/event/contacts/name_pieces.rb +0 -12
  112. data/spec/factories/event/contacts.rb +0 -16
  113. data/spec/factories/event/photos.rb +0 -12
  114. data/spec/factories/event/totals.rb +0 -15
  115. data/spec/factories/event/venue/location.rb +0 -18
  116. data/spec/factories/event/venue/social.rb +0 -16
  117. data/spec/factories/event/venue.rb +0 -16
  118. data/spec/factories/event.rb +0 -66
  119. data/spec/factories/event_application.rb +0 -34
  120. data/spec/factories/event_supporter.rb +0 -19
  121. data/spec/factories/fund.rb +0 -18
  122. data/spec/factories/fundraiser/photos.rb +0 -12
  123. data/spec/factories/fundraiser/policies.rb +0 -11
  124. data/spec/factories/fundraiser/totals.rb +0 -11
  125. data/spec/factories/fundraiser.rb +0 -24
  126. data/spec/factories/fundraising_page.rb +0 -29
  127. data/spec/factories/grant.rb +0 -22
  128. data/spec/factories/grant_institution.rb +0 -17
  129. data/spec/factories/institution.rb +0 -18
  130. data/spec/factories/kid/custom_institution.rb +0 -12
  131. data/spec/factories/kid.rb +0 -58
  132. data/spec/factories/kid_honor.rb +0 -16
  133. data/spec/factories/kid_institution.rb +0 -23
  134. data/spec/factories/lib/faker_patch.rb +0 -27
  135. data/spec/factories/lib/helpers.rb +0 -7
  136. data/spec/factories/location.rb +0 -17
  137. data/spec/factories/memorial/photos.rb +0 -14
  138. data/spec/factories/memorial/totals.rb +0 -11
  139. data/spec/factories/memorial/tribute.rb +0 -19
  140. data/spec/factories/memorial.rb +0 -22
  141. data/spec/factories/message.rb +0 -31
  142. data/spec/factories/milestone.rb +0 -15
  143. data/spec/factories/name_pieces.rb +0 -24
  144. data/spec/factories/newsletter_recipient.rb +0 -13
  145. data/spec/factories/organization/addresses.rb +0 -16
  146. data/spec/factories/organization/email_addresses.rb +0 -14
  147. data/spec/factories/organization/phone_numbers.rb +0 -14
  148. data/spec/factories/organization.rb +0 -34
  149. data/spec/factories/page.rb +0 -5
  150. data/spec/factories/participant/photos.rb +0 -14
  151. data/spec/factories/participant/policies.rb +0 -12
  152. data/spec/factories/participant/rankings/ranking.rb +0 -12
  153. data/spec/factories/participant/rankings.rb +0 -16
  154. data/spec/factories/participant/roles/role.rb +0 -154
  155. data/spec/factories/participant/roles.rb +0 -37
  156. data/spec/factories/participant/totals.rb +0 -11
  157. data/spec/factories/participant.rb +0 -95
  158. data/spec/factories/payment.rb +0 -13
  159. data/spec/factories/permissions.rb +0 -12
  160. data/spec/factories/person/addresses.rb +0 -16
  161. data/spec/factories/person/email_addresses.rb +0 -14
  162. data/spec/factories/person/phone_numbers.rb +0 -14
  163. data/spec/factories/person/policies.rb +0 -13
  164. data/spec/factories/person.rb +0 -22
  165. data/spec/factories/phone.rb +0 -11
  166. data/spec/factories/photo.rb +0 -11
  167. data/spec/factories/photos.rb +0 -9
  168. data/spec/factories/recurring_gift.rb +0 -22
  169. data/spec/factories/researcher.rb +0 -15
  170. data/spec/factories/response.rb +0 -38
  171. data/spec/factories/search_event.rb +0 -19
  172. data/spec/factories/search_fundraiser.rb +0 -15
  173. data/spec/factories/search_kid.rb +0 -13
  174. data/spec/factories/search_participant.rb +0 -15
  175. data/spec/factories/search_team.rb +0 -13
  176. data/spec/factories/shave_schedule/time_selection_permissions.rb +0 -12
  177. data/spec/factories/shave_schedule.rb +0 -33
  178. data/spec/factories/team/photos.rb +0 -12
  179. data/spec/factories/team/rankings/ranking.rb +0 -12
  180. data/spec/factories/team/rankings.rb +0 -15
  181. data/spec/factories/team/totals.rb +0 -14
  182. data/spec/factories/team.rb +0 -43
  183. data/spec/factories/third_party_media.rb +0 -12
  184. data/spec/factories/treatment_status.rb +0 -10
  185. data/spec/factories/user.rb +0 -14
  186. data/spec/factories/venue.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 813c14606b5395cdc40253fd5452842c29113080c185196c579a21a1c1563b5c
4
- data.tar.gz: 8d233977b90f351e8d339f09a7d77fcc000c19295030c6a62094b3db361aa6de
3
+ metadata.gz: e227814971bc43f036f273b77e3287157d6e28f38ad04641060cef2f005a24fd
4
+ data.tar.gz: 2d95e0f726ee850a3c1930f171740ad4d942ea5b863bf04df90d3fc5bc0b6f51
5
5
  SHA512:
6
- metadata.gz: f42d618564cdecc8c6776c4feb06ccb7a8741c63a5d1c1abe0785957c2adc3327697bbd4957c1ae3ef7bda7a13c01ec4e1e4e97c32cc8776d605b90295287f33
7
- data.tar.gz: 4ff2946335a23785d19023e76d14c3627961a5cb71543f3b034acb57f9a4f964e145a0d32d5f924e0c8604f6ee348e538cab02f5e5a9334b469d13ed9ff89946
6
+ metadata.gz: 117ea899c8c479324afc7dc668d808aef7393d341ae291f7aa10b62018fa28ff7d26f90785aba783b263ff450d08bde9e7844b9e7fe03bf51b21c6fde4d7d386
7
+ data.tar.gz: e4295e00834daa21bab6505827340ae889813a08c4f79f8e5202f9b09a60b6d74f5684b9fc2fef5031f72e19b7a135bc46dea857a43fd79b16a071003d3cebce
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # St. Baldrick's Ruby SDK
1
+
2
+ # Table of Contents
3
+ * [Publish Ruby Client Gem](publish-ruby-client.md)
4
+ * [Architecture](architecture.md)
5
+ * [SDK](#st-baldricks-ruby-sdk)
6
+
7
+ ## St. Baldrick's Ruby SDK
2
8
 
3
9
  ### Installation
4
10
  `gem install stbaldricks`
@@ -150,40 +156,3 @@ filter = {and: [{column: 'status_id', operator: 'equals', value: SBF::Client::Se
150
156
  active_participant_within_10_mi = request_helper { SBF::Client::Search.find(model_type, nil, filter, geo_location, limit: 2) }[:results]
151
157
  puts JSON.pretty_generate(active_participant_within_10_mi)
152
158
  ```
153
-
154
- ## Architecture
155
- | Component | Location
156
- |--------------------|------------------------------|
157
- | Endpoints | `/lib/stbaldricks/endpoints` |
158
- | Entities | `/lib/stbaldricks/entities` |
159
- | Enums | `/lib/stbaldricks/enums` |
160
- | Rspec Unit | `/spec/unit` |
161
- | Rspec Integration | `/spec/integration` |
162
-
163
- ### Endpoints
164
- * Define supported requests that can be made to the SBF API for entities in the client library.
165
- * Extend `SBF::Client::EntityEndpoint` to receive common core action for the entities.
166
- * If additional or non-standard functionality is required, actions can be added or overridden.
167
- * Return a response object which will contain an http status code and depending on the code either error details
168
- or the expected API response data for a successful request.
169
-
170
- ### Entities
171
- * Object representations of the data sent to and received from the API.
172
- * Top-level entities (those that can be directly requested or modified via the API) inherit from `SBF::Client::TopLevelEntity`.
173
- * Supported actions on the entity are defined via `action` and `actions`.
174
- * Any actions that are disallowed are blocked via `blacklist_action`.
175
- * The entities also map to their corresponding endpoint for handling all related API requests.
176
- * Sub-entities should still extend the `SBF::Client::BaseEntity`.
177
-
178
- ### Enums
179
- * Collections of constants to assist with specifying values within a finite list.
180
-
181
- ### Rspec Tests
182
- Tests are broken out into unit and integration tests. Test coverage thresholds are enforced and test additions or modifications are
183
- required for nearly any client library change.
184
-
185
- More detail on understanding and writing Rspec tests can be found in the [Rspec Guide](https://github.com/firespring/sbf/tree/master/documentation/guides/training/rspec).
186
-
187
- #### Running Tests
188
- * use `rake client:ruby:test:all` to run all tests
189
- * use `TESTS={path-to-test} rake client:ruby:test:all` to run specific test(s)
@@ -16,11 +16,11 @@ module SBF
16
16
  end
17
17
 
18
18
  def self.base_uri
19
- @base_uri ||= ENV['API_ENDPOINT'] || DEFAULT_API_ENDPOINT
19
+ @base_uri ||= ENV.fetch('API_ENDPOINT', DEFAULT_API_ENDPOINT)
20
20
  end
21
21
 
22
22
  def self.general_token
23
- @general_token ||= ENV['API_KEY'] || raise(SBF::Client::Configuration::Error.new('general_token', 'must be set'))
23
+ @general_token ||= ENV.fetch('API_KEY', nil) || 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['SBF_CLIENT_LOG_LEVEL'] || ::Logger::DEBUG
19
+ logger.level = ENV.fetch('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, order, limit, 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, order, limit, 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, order, limit, 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, order, limit, offset)
70
+ find(filter:, order:, limit:, offset:)
71
71
  end
72
72
  end
73
73
  end
@@ -11,14 +11,14 @@ module SBF
11
11
  end
12
12
 
13
13
  def years(category)
14
- response = SBF::Client::Api::Request.post_request("#{base_uri}/years", category: category)
14
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/years", category:)
15
15
  parsed_response_body = JSON.parse(response.body).symbolize!
16
16
 
17
17
  handle_parsed_response(parsed_response_body, response)
18
18
  end
19
19
 
20
20
  def groups(category, year)
21
- response = SBF::Client::Api::Request.post_request("#{base_uri}/groups", category: category, year: year)
21
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/groups", category:, year:)
22
22
  parsed_response_body = JSON.parse(response.body).symbolize!
23
23
 
24
24
  handle_parsed_response(parsed_response_body, response)
@@ -42,13 +42,13 @@ module SBF
42
42
  def contacts(category, year, group_type, group_id)
43
43
  response = SBF::Client::Api::Request.post_request(
44
44
  "#{base_uri}/contacts",
45
- category: category,
46
- year: year,
47
- group_type: group_type,
48
- group_id: group_id
45
+ category:,
46
+ year:,
47
+ group_type:,
48
+ 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, clear_changes: false) } 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, clear_changes: false)
15
15
  end
16
16
  end
17
17
  end
@@ -3,19 +3,19 @@ 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)
10
10
 
11
11
  response = SBF::Client::Api::Request.post_request(
12
12
  "#{base_uri}/checkout",
13
- filter: filter, order: order, limit: limit, offset: offset, with: with
13
+ filter:, order:, limit:, offset:, with:
14
14
  )
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, true) }
18
+ parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, clear_changes: 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!
@@ -45,7 +45,7 @@ module SBF
45
45
 
46
46
  def release_checkout(checkout_id)
47
47
  response = SBF::Client::Api::Request.post_request(
48
- "#{base_uri}/release_checkout", checkout_id: checkout_id
48
+ "#{base_uri}/release_checkout", checkout_id:
49
49
  )
50
50
  parsed_response_body = JSON.parse(response.body).symbolize!
51
51
 
@@ -24,7 +24,7 @@ module SBF
24
24
  end
25
25
 
26
26
  def invite(id, year, participant_data)
27
- event_data = {id: id, year: year}
27
+ event_data = {id:, year:}
28
28
  participant_data.store(:event, event_data)
29
29
 
30
30
  response = SBF::Client::Api::Request.post_request("#{base_uri}/invite", participant_data)
@@ -15,8 +15,8 @@ module SBF
15
15
  def login!(authorization_code, redirect_uri)
16
16
  response = SBF::Client::Api::Request.post_request(
17
17
  "/#{SBF::Client::Api::VERSION}/security/facebook/login",
18
- authorization_code: authorization_code,
19
- redirect_uri: redirect_uri
18
+ authorization_code:,
19
+ redirect_uri:
20
20
  )
21
21
  parsed_response = JSON.parse(response.body).symbolize!
22
22
 
@@ -11,7 +11,7 @@ module SBF
11
11
  data = parsed_response_body
12
12
  model_type = SBF::Client::ModelType.list[params[:dest_model_type]].capitalize
13
13
  entity_class = "SBF::Client::Full#{model_type}".to_class
14
- data[:results].map! { |entity| entity_class.new(entity) }
14
+ data[:results].map! { |entity| entity_class.new(entity, clear_changes: false) }
15
15
  else
16
16
  error = SBF::Client::ErrorEntity.new(parsed_response_body)
17
17
  data = nil
@@ -7,7 +7,7 @@ module SBF
7
7
  response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: fundraiser_id, new_team_id: new_team_id)
8
8
 
9
9
  if ok?(response)
10
- data = SBF::Client::FullFundraiser.new(JSON.parse(response.body).symbolize!)
10
+ data = SBF::Client::FullFundraiser.new(JSON.parse(response.body).symbolize!, clear_changes: false)
11
11
  else
12
12
  error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
13
13
  end
@@ -8,11 +8,11 @@ module SBF
8
8
  filter = filter.to_json unless filter.is_a? String
9
9
  with = normalize_with(with)
10
10
 
11
- response = SBF::Client::Api::Request.get_request("#{base_uri}/find_random", filter: filter, limit: limit, with: with)
11
+ response = SBF::Client::Api::Request.get_request("#{base_uri}/find_random", filter:, limit:, with:)
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, clear_changes: false) }
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,8 +10,7 @@ require 'json'
10
10
  module SBF
11
11
  module Client
12
12
  class EntityEndpoint
13
- attr_reader :orig_target_class
14
- attr_reader :base_uri
13
+ attr_reader :orig_target_class, :base_uri
15
14
 
16
15
  def initialize(target_class)
17
16
  @orig_target_class = target_class
@@ -34,7 +33,7 @@ module SBF
34
33
  # @param with [Hash] The optional entity fields to include in the response
35
34
  # @return entity [SBF::Client::BaseEntity]
36
35
  def create(entity_or_hash, with = {})
37
- entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash) : entity_or_hash
36
+ entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash, clear_changes: false) : entity_or_hash
38
37
  raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
39
38
 
40
39
  with = normalize_with(with, entity)
@@ -50,10 +49,11 @@ module SBF
50
49
  # @param with [Hash] The optional entity fields to include in the response
51
50
  # @return entity [SBF::Client::BaseEntity]
52
51
  def update(id = nil, entity_or_hash = nil, with = {})
53
- if entity_or_hash.is_a?(SBF::Client::BaseEntity)
52
+ case entity_or_hash
53
+ when 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
- elsif entity_or_hash.is_a?(Hash)
56
+ when 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
@@ -75,7 +75,7 @@ module SBF
75
75
  def get(id, with = {})
76
76
  with = normalize_with(with)
77
77
 
78
- response = SBF::Client::Api::Request.get_request("#{base_uri}/get/#{id}", with: with)
78
+ response = SBF::Client::Api::Request.get_request("#{base_uri}/get/#{id}", with:)
79
79
 
80
80
  if ok?(response)
81
81
  hydrated_entity(response, {}, nil)
@@ -89,16 +89,18 @@ 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)
96
96
 
97
- response = SBF::Client::Api::Request.get_request("#{base_uri}/find", filter: filter, order: order, limit: limit, offset: offset, with: with)
97
+ response = SBF::Client::Api::Request.get_request("#{base_uri}/find", filter:, order:, limit:, offset:, with:)
98
98
  parsed_response_body = JSON.parse(response.body).symbolize!
99
99
 
100
100
  if ok?(response)
101
- parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, true) }
101
+ parsed_response_body[:results].map! do |entity_data|
102
+ target_class.new(entity_data, clear_changes: true)
103
+ end
102
104
  SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
103
105
  else
104
106
  parsed_response_body = JSON.parse(response.body).symbolize!
@@ -113,7 +115,7 @@ module SBF
113
115
 
114
116
  # Calls the find route for the entity.
115
117
  def find_first(filter = [], order = {}, with = {})
116
- response = find(filter, order, 1, 0, with)
118
+ response = find(filter: filter, order: order, limit: 1, with: with)
117
119
  if response.is_a?(SBF::Client::EntityCollection)
118
120
  response.empty? ? nil : response.first
119
121
  else
@@ -126,7 +128,7 @@ module SBF
126
128
  filter = filter.to_json unless filter.is_a? String
127
129
  aggregate = aggregate.to_json unless aggregate.is_a? String
128
130
 
129
- response = SBF::Client::Api::Request.get_request("#{base_uri}/aggregate", filter: filter, aggregate: aggregate)
131
+ response = SBF::Client::Api::Request.get_request("#{base_uri}/aggregate", filter:, aggregate:)
130
132
  parsed_response_body = JSON.parse(response.body).symbolize!
131
133
  if ok?(response)
132
134
  data = parsed_response_body[:aggregate]
@@ -148,7 +150,7 @@ module SBF
148
150
 
149
151
  def target_class
150
152
  class_name_pieces = @orig_target_class.to_s.split('::')
151
- full_name = (class_name_pieces[0..-2] + ['Full' + class_name_pieces.last]).join('::')
153
+ full_name = (class_name_pieces[0..-2] + ["Full#{class_name_pieces.last}"]).join('::')
152
154
  Object.const_defined?(full_name) ? Object.const_get(full_name) : @orig_target_class
153
155
  end
154
156
  private :target_class
@@ -247,7 +249,7 @@ module SBF
247
249
  entity_or_hash.send(:initialize_attributes, new_data)
248
250
  entity = entity_or_hash
249
251
  else
250
- entity = target_class.new(new_data)
252
+ entity = target_class.new(new_data, clear_changes: false)
251
253
  end
252
254
 
253
255
  # Reload entity and its sub-entities so that no fields have a 'changed' state
@@ -256,7 +258,7 @@ module SBF
256
258
  entity
257
259
  else
258
260
  error = SBF::Client::ApiErrorEntity.new(parsed_response_body.merge(http_code: response.code))
259
- entity = entity_or_hash.is_a?(SBF::Client::BaseEntity) ? entity_or_hash : target_class.new(entity_or_hash)
261
+ entity = entity_or_hash.is_a?(SBF::Client::BaseEntity) ? entity_or_hash : target_class.new(entity_or_hash, clear_changes: false)
260
262
  entity.add_errors(error)
261
263
  entity.errors_http_code = response.code
262
264
 
@@ -28,12 +28,12 @@ module SBF
28
28
  def send_contact_us_message(name, sender_email, phone, subject, body, sender_profile_id)
29
29
  response = SBF::Client::Api::Request.post_request(
30
30
  "#{base_uri}/send_contact_us_message",
31
- name: name,
32
- sender_email: sender_email,
33
- phone: phone,
34
- subject: subject,
35
- body: body,
36
- sender_profile_id: sender_profile_id
31
+ name:,
32
+ sender_email:,
33
+ phone:,
34
+ subject:,
35
+ body:,
36
+ sender_profile_id:
37
37
  )
38
38
 
39
39
  error = SBF::Client::ErrorEntity.new(response) unless ok?(response)
@@ -47,12 +47,12 @@ module SBF
47
47
  def send_contact_us_response_message(name, sender_email, phone, subject, body, sender_profile_id)
48
48
  response = SBF::Client::Api::Request.post_request(
49
49
  "#{base_uri}/send_contact_us_response_message",
50
- name: name,
51
- sender_email: sender_email,
52
- phone: phone,
53
- subject: subject,
54
- body: body,
55
- sender_profile_id: sender_profile_id
50
+ name:,
51
+ sender_email:,
52
+ phone:,
53
+ subject:,
54
+ body:,
55
+ sender_profile_id:
56
56
  )
57
57
 
58
58
  error = SBF::Client::ErrorEntity.new(response) unless ok?(response)
@@ -3,9 +3,14 @@ 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(email_address: entity_or_email, first_name: first_name, last_name: last_name, welcome_email: welcome_email)
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
+ }, clear_changes: false)
9
14
  elsif entity_or_email.is_a?(SBF::Client::BaseEntity)
10
15
  entity = entity_or_email
11
16
  else
@@ -21,9 +26,10 @@ module SBF
21
26
  end
22
27
 
23
28
  def unsubscribe(entity_or_email)
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)
29
+ case entity_or_email
30
+ when String
31
+ entity = target_class.new({email_address: entity_or_email}, clear_changes: false)
32
+ when SBF::Client::BaseEntity
27
33
  entity = entity_or_email
28
34
  else
29
35
  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!, clear_changes: false)
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!, clear_changes: false)
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!, clear_changes: false)
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, clear_changes: false) : 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,12 +20,13 @@ module SBF
20
20
  end
21
21
 
22
22
  def update(id = nil, entity_or_hash = nil, with = {})
23
- if entity_or_hash.is_a?(SBF::Client::BaseEntity)
23
+ case entity_or_hash
24
+ when SBF::Client::BaseEntity
24
25
  # If someone has passed in an entity, just convert it to a hash
25
26
  data = entity_or_hash.dirty_data
26
27
  data[:id] = id unless id.nil?
27
28
  data[:id] = entity_or_hash.id if id.nil? && !entity_or_hash.id.nil?
28
- elsif entity_or_hash.is_a?(Hash)
29
+ when Hash
29
30
  # If someone has passed in a hash, make sure all of it's values match fields in the entity class
30
31
  data = sanitize(entity_or_hash)
31
32
  else
@@ -66,7 +67,7 @@ module SBF
66
67
  data.file = file
67
68
  data
68
69
  else
69
- photo = SBF::Client::Photo.new(data.is_a?(Hash) && data.any? ? data : {})
70
+ photo = SBF::Client::Photo.new((data.is_a?(Hash) && data.any?) ? data : {}, clear_changes: false)
70
71
  photo.file = file
71
72
  photo
72
73
  end
@@ -4,7 +4,7 @@ module SBF
4
4
  module Client
5
5
  class PromoEndpoint < SBF::Client::EntityEndpoint
6
6
  def render_template(body, name, promo)
7
- response = SBF::Client::Api::Request.post_request("#{base_uri}/render_email", body: body, name: name, promo: promo)
7
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/render_email", body:, name:, promo:)
8
8
 
9
9
  if ok?(response)
10
10
  data = response.body
@@ -19,12 +19,12 @@ module SBF
19
19
  def send_promo_email(donation_id, name, recipient, body, ecard_send_date = nil, ecard_confirmation_email = nil)
20
20
  response = SBF::Client::Api::Request.post_request(
21
21
  "#{base_uri}/send_promo_email",
22
- donation_id: donation_id,
23
- name: name,
24
- recipient: recipient,
25
- body: body,
26
- ecard_send_date: ecard_send_date,
27
- ecard_confirmation_email: ecard_confirmation_email
22
+ donation_id:,
23
+ name:,
24
+ recipient:,
25
+ body:,
26
+ ecard_send_date:,
27
+ ecard_confirmation_email:
28
28
  )
29
29
 
30
30
  if ok?(response)
@@ -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
@@ -30,7 +30,7 @@ module SBF
30
30
  # Build the parameter list for search
31
31
  params = {}
32
32
  response_data = {}
33
- {model_type: model_type, search_text: search_text, filters: filters, geo_location: geo_location}.each do |k, v|
33
+ {model_type:, search_text:, filters:, geo_location:}.each do |k, v|
34
34
  params[k.to_sym] = v unless v.empty?
35
35
  end
36
36
 
@@ -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], clear_changes: false)
49
49
  end
50
50
  end
51
51
 
@@ -13,14 +13,14 @@ module SBF
13
13
  def login!(username, password)
14
14
  response = SBF::Client::Api::Request.post_request(
15
15
  "/#{SBF::Client::Api::VERSION}/security/login",
16
- username: username,
17
- password: password
16
+ username:,
17
+ password:
18
18
  )
19
19
  parsed_response = JSON.parse(response.body).symbolize!
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], clear_changes: false))
24
24
  else
25
25
  SBF::Client::Configuration.user_token = nil
26
26
  error = SBF::Client::ErrorEntity.new(parsed_response)
@@ -40,8 +40,8 @@ module SBF
40
40
 
41
41
  response = SBF::Client::Api::Request.post_request(
42
42
  "/#{SBF::Client::Api::VERSION}/security/list_entities_user_has_permission",
43
- permission_id: permission_id,
44
- event_years: event_years
43
+ permission_id:,
44
+ event_years:
45
45
  )
46
46
  parsed_response = JSON.parse(response.body).symbolize!
47
47
 
@@ -63,8 +63,8 @@ module SBF
63
63
 
64
64
  response = SBF::Client::Api::Request.post_request(
65
65
  "/#{SBF::Client::Api::VERSION}/security/change_password",
66
- profile_id: profile_id,
67
- password: password
66
+ profile_id:,
67
+ password:
68
68
  )
69
69
 
70
70
  unless ok?(response)
@@ -85,7 +85,7 @@ module SBF
85
85
 
86
86
  response = SBF::Client::Api::Request.post_request(
87
87
  "/#{SBF::Client::Api::VERSION}/user/disconnect_facebook",
88
- profile_id: profile_id
88
+ profile_id:
89
89
  )
90
90
 
91
91
  SBF::Client::Configuration.user_token = nil