stbaldricks 4.6.1.alpha.3 → 4.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/lib/stbaldricks/endpoints/event_application.rb +32 -0
  3. data/lib/stbaldricks/endpoints/kid.rb +3 -7
  4. data/lib/stbaldricks/endpoints/lib/entity.rb +32 -42
  5. data/lib/stbaldricks/endpoints/photo.rb +12 -5
  6. data/lib/stbaldricks/endpoints/user.rb +1 -1
  7. data/lib/stbaldricks/entities/campaign.rb +0 -1
  8. data/lib/stbaldricks/entities/concerns/event_year_concern.rb +0 -2
  9. data/lib/stbaldricks/entities/concerns/fundraising_page_concern.rb +0 -2
  10. data/lib/stbaldricks/entities/concerns/model_type_concern.rb +0 -2
  11. data/lib/stbaldricks/entities/concerns/type_concern.rb +0 -2
  12. data/lib/stbaldricks/entities/concerns/venue_concern.rb +0 -2
  13. data/lib/stbaldricks/entities/donation.rb +1 -0
  14. data/lib/stbaldricks/entities/donation/payment_type.rb +1 -0
  15. data/lib/stbaldricks/entities/event.rb +1 -7
  16. data/lib/stbaldricks/entities/event_application.rb +2 -0
  17. data/lib/stbaldricks/entities/fundraiser.rb +1 -18
  18. data/lib/stbaldricks/entities/grant.rb +1 -0
  19. data/lib/stbaldricks/entities/kid.rb +3 -4
  20. data/lib/stbaldricks/entities/lib/base.rb +21 -37
  21. data/lib/stbaldricks/entities/lib/error.rb +0 -25
  22. data/lib/stbaldricks/entities/lib/opt_out_settings.rb +1 -1
  23. data/lib/stbaldricks/entities/lib/payment.rb +6 -5
  24. data/lib/stbaldricks/entities/lib/third_party_media.rb +0 -2
  25. data/lib/stbaldricks/entities/lib/top_level.rb +3 -15
  26. data/lib/stbaldricks/entities/page.rb +0 -33
  27. data/lib/stbaldricks/entities/participant.rb +1 -1
  28. data/lib/stbaldricks/entities/photo.rb +1 -2
  29. data/lib/stbaldricks/entities/recurring_gift.rb +4 -6
  30. data/lib/stbaldricks/entities/response.rb +4 -3
  31. data/lib/stbaldricks/entities/search.rb +0 -4
  32. data/lib/stbaldricks/entities/team.rb +1 -10
  33. data/lib/stbaldricks/version.rb +1 -1
  34. metadata +6 -16
  35. data/lib/stbaldricks/endpoints/fundraiser.rb +0 -36
  36. data/lib/stbaldricks/endpoints/kid_institution.rb +0 -17
  37. data/lib/stbaldricks/entities/concerns/entity_response_concern.rb +0 -66
  38. data/lib/stbaldricks/entities/kid_institution.rb +0 -19
  39. data/lib/stbaldricks/entities/lib/collection.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: b7ccd3a68b118457b042e75fd6d5c526399a6e0f35e9fcfd6cac082d95ed3063
4
- data.tar.gz: 87d3031eb1d377ab100cccb502b0fc3dd2b29642d82589bc8b0fd12a46862c1d
2
+ SHA1:
3
+ metadata.gz: fc5f6aa69c9ea31fe582ec5ccbfcfc0f36f0952c
4
+ data.tar.gz: 538a91e845b74a5280113853026670a61132db6d
5
5
  SHA512:
6
- metadata.gz: 13cb348aa8bc10d14ca5bce929672d55f3ba5dcc25da7731d4141e6ce2f5672e625005c7172796071c095b084413cfa25112b1443c6adf70af3afe1799db2b7e
7
- data.tar.gz: 023b058a3fdab154c491ad6a120ec7866ff04351b7205ccf6b3226e8264a950154af149ad959f5cb4913f06d552ba08c7bf40ff1b11aa9c26f2083f244b7445e
6
+ metadata.gz: 50bf9f95782265ae4332ca4920e12f4ad69233d2e99403ac55ad7f08e677714bf4934ead435dd37e265c28e70f5ca72925d6c46e0485bdba9ca30d2f108344c2
7
+ data.tar.gz: 31517761e84047c77cfd1c81df25565b2c62b722c0938e4b375e1dedbf6fb35115627ac7481bc4d8cbac61d972b394de72baa77f0795cf450e93cdea47d5111e
@@ -0,0 +1,32 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class EventApplicationEndpoint < SBF::Client::EntityEndpoint
6
+ def create(entity, with = {})
7
+ raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
8
+
9
+ with = normalize_with(with)
10
+
11
+ create_data = entity.to_hash
12
+ create_data.store(:with, with)
13
+
14
+ entity.errors.clear
15
+
16
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/create", create_data)
17
+ parsed_response_body = JSON.parse(response.body).symbolize!
18
+
19
+ if ok?(response)
20
+ # Re-initialize the entity using the existing data as a base and overwriting with all data returned from the response
21
+ # This will populate fields that have been auto-populated (e.g. id) into the original object
22
+ entity.send(:initialize_attributes, create_data.merge(parsed_response_body))
23
+ else
24
+ error = SBF::Client::ErrorEntity.new(parsed_response_body)
25
+ entity.add_errors(error)
26
+ end
27
+
28
+ SBF::Client::Api::Response.new(http_code: response.code, data: entity, error: error)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,4 @@
1
1
  require 'stbaldricks/endpoints/lib/entity'
2
- require 'stbaldricks/entities/lib/collection'
3
2
 
4
3
  module SBF
5
4
  module Client
@@ -13,15 +12,12 @@ module SBF
13
12
 
14
13
  if ok?(response)
15
14
  parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data) }
16
- SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
15
+ data = parsed_response_body
17
16
  else
18
- parsed_response_body = JSON.parse(response.body).symbolize!
19
17
  error = SBF::Client::ErrorEntity.new(parsed_response_body)
20
- collection = SBF::Client::EntityCollection.new
21
- collection.add_errors(error)
22
- collection.errors_http_code = response.code
23
- collection
24
18
  end
19
+
20
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
25
21
  end
26
22
  end
27
23
  end
@@ -1,6 +1,5 @@
1
1
  require 'stbaldricks/version'
2
2
  require 'stbaldricks/api'
3
- require 'stbaldricks/entities/lib/collection'
4
3
  require 'stbaldricks/entities/lib/error'
5
4
  require 'stbaldricks/entities/response'
6
5
  require 'stbaldricks/patches/hash'
@@ -21,7 +20,7 @@ module SBF
21
20
  def save(entity_or_hash, with = {})
22
21
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
23
22
  return create(entity_or_hash, with) if entity_or_hash.id.nil?
24
- return update(entity_or_hash.id, entity_or_hash, with)
23
+ return update(entity_or_hash.id, entity_or_hash.dirty_data, with)
25
24
  else
26
25
  return create(entity_or_hash, with) if entity_or_hash[:id].nil?
27
26
  return update(entity_or_hash[:id], entity_or_hash, with)
@@ -31,8 +30,7 @@ module SBF
31
30
  # Calls the create route for the entity. Uses the class name to generate the uri
32
31
  # @param with [Hash] The optional entity fields to include in the response
33
32
  # @return entity [SBF::Client::BaseEntity]
34
- def create(entity_or_hash, with = {})
35
- entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash) : entity_or_hash
33
+ def create(entity, with = {})
36
34
  raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
37
35
 
38
36
  with = normalize_with(with, entity)
@@ -41,7 +39,9 @@ module SBF
41
39
 
42
40
  response = SBF::Client::Api::Request.post_request("#{base_uri}/create", create_data)
43
41
 
44
- hydrated_entity(response, create_data, entity)
42
+ entity, error = hydrate_entity(response, create_data, entity)
43
+
44
+ SBF::Client::Api::Response.new(http_code: response.code, data: entity, error: error)
45
45
  end
46
46
 
47
47
  # Calls the update route for the entity. Uses the class name to generate the uri
@@ -50,7 +50,7 @@ module SBF
50
50
  def update(id = nil, entity_or_hash = nil, with = {})
51
51
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
52
52
  # If someone has passed in an entity, just convert it to a hash
53
- data = entity_or_hash.dirty_data
53
+ data = entity_or_hash.to_hash
54
54
  elsif entity_or_hash.is_a?(Hash)
55
55
  # If someone has passed in a hash, make sure all of it's values match fields in the entity class
56
56
  data = sanitize(entity_or_hash)
@@ -64,7 +64,9 @@ module SBF
64
64
  uri = id ? "#{base_uri}/update/#{id}" : "#{base_uri}/update"
65
65
  response = SBF::Client::Api::Request.post_request(uri, data)
66
66
 
67
- hydrated_entity(response, data, entity_or_hash)
67
+ data, error = hydrate_entity(response, data, entity_or_hash)
68
+
69
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
68
70
  end
69
71
 
70
72
  # Calls the get route for the entity. Uses the class name to generate the uri.
@@ -75,15 +77,9 @@ module SBF
75
77
 
76
78
  response = SBF::Client::Api::Request.get_request("#{base_uri}/get/#{id}", with: with)
77
79
 
78
- if ok?(response)
79
- hydrated_entity(response, {}, nil)
80
- elsif (response.code == 404)
81
- nil
82
- else
83
- parsed_response_body = JSON.parse(response.body).symbolize!
84
- error = SBF::Client::ErrorEntity.new(parsed_response_body)
85
- SBF::Client::Api::Response.new(http_code: response.code, data: parsed_response_body[:data], error: error)
86
- end
80
+ data, error = hydrate_entity(response, {}, nil)
81
+
82
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
87
83
  end
88
84
 
89
85
  # Calls the find route for the entity.
@@ -96,27 +92,20 @@ module SBF
96
92
  parsed_response_body = JSON.parse(response.body).symbolize!
97
93
 
98
94
  if ok?(response)
99
- parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, true) }
100
- SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
95
+ parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data) }
96
+ data = parsed_response_body
101
97
  else
102
- parsed_response_body = JSON.parse(response.body).symbolize!
103
98
  error = SBF::Client::ErrorEntity.new(parsed_response_body)
104
- SBF::Client::Api::Response.new(http_code: response.code, data: parsed_response_body[:data], error: error)
105
- collection = SBF::Client::EntityCollection.new
106
- collection.add_errors(error)
107
- collection.errors_http_code = response.code
108
- collection
109
99
  end
100
+
101
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
110
102
  end
111
103
 
112
104
  # Calls the find route for the entity.
113
105
  def find_first(filter = [], order = {}, with = {})
114
- response = find(filter, order, 1, 0, with)
115
- if response.is_a?(SBF::Client::EntityCollection)
116
- response.empty? ? nil : response.first
117
- else
118
- response
119
- end
106
+ api_response = find(filter, order, 1, 0, with)
107
+ api_response.data = api_response.data[:results].first unless api_response.error?
108
+ api_response
120
109
  end
121
110
 
122
111
  # Calls the aggregate route for the entity.
@@ -222,7 +211,7 @@ module SBF
222
211
  end
223
212
  private :normalize_with
224
213
 
225
- def hydrated_entity(response, data, entity_or_hash)
214
+ def hydrate_entity(response, data, entity_or_hash)
226
215
  parsed_response_body = JSON.parse(response.body).symbolize!
227
216
 
228
217
  entity_or_hash.errors.clear if entity_or_hash.is_a?(SBF::Client::BaseEntity)
@@ -233,28 +222,29 @@ module SBF
233
222
 
234
223
  new_data = parsed_response_body
235
224
  new_data = data.merge(parsed_response_body) if data.is_a?(Hash)
225
+ data = target_class.new(new_data)
236
226
 
237
227
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
238
228
  entity_or_hash.send(:initialize_attributes, new_data)
239
- entity = entity_or_hash
240
- else
241
- entity = target_class.new(new_data)
229
+ data = entity_or_hash
242
230
  end
243
231
 
244
232
  # Reload entity and its sub-entities so that no fields have a 'changed' state
245
- entity.reload_recursive
233
+ data.reload_recursive
246
234
 
247
- entity
235
+ return [data, nil]
248
236
  else
249
- error = SBF::Client::ApiErrorEntity.new(parsed_response_body.merge(http_code: response.code))
250
- entity = entity_or_hash.is_a?(SBF::Client::BaseEntity) ? entity_or_hash : target_class.new(entity_or_hash)
251
- entity.add_errors(error)
252
- entity.errors_http_code = response.code
237
+ data = entity_or_hash if entity_or_hash.is_a?(SBF::Client::BaseEntity)
238
+ data = nil if data == {}
239
+ data = target_class.new(entity_or_hash) if entity_or_hash.is_a?(Hash)
240
+
241
+ error = SBF::Client::ErrorEntity.new(parsed_response_body)
242
+ data.add_errors(error) if data.is_a?(SBF::Client::BaseEntity)
253
243
 
254
- entity
244
+ [data, error]
255
245
  end
256
246
  end
257
- private :hydrated_entity
247
+ private :hydrate_entity
258
248
  end
259
249
  end
260
250
  end
@@ -3,8 +3,7 @@ require 'stbaldricks/endpoints/lib/entity'
3
3
  module SBF
4
4
  module Client
5
5
  class PhotoEndpoint < SBF::Client::EntityEndpoint
6
- def create(entity_or_hash, with = {})
7
- entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash) : entity_or_hash
6
+ def create(entity, with = {})
8
7
  raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
9
8
 
10
9
  with = normalize_with(with)
@@ -16,7 +15,9 @@ module SBF
16
15
 
17
16
  response = SBF::Client::Api::Request.file_post_request(path: "#{base_uri}/create", params: create_data, file: file, filename: filename)
18
17
 
19
- hydrated_entity(response, create_data, entity)
18
+ entity, error = hydrate_entity(response, create_data, entity)
19
+
20
+ SBF::Client::Api::Response.new(http_code: response.code, data: entity, error: error)
20
21
  end
21
22
 
22
23
  def update(id = nil, entity_or_hash = nil, with = {})
@@ -43,7 +44,9 @@ module SBF
43
44
  SBF::Client::Api::Request.post_request("#{base_uri}/update", data)
44
45
  end
45
46
 
46
- hydrated_entity(response, data, entity_or_hash)
47
+ data, error = hydrate_entity(response, data, entity_or_hash)
48
+
49
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
47
50
  end
48
51
 
49
52
  def upload(image_data_url, data = {}, with = {})
@@ -57,7 +60,11 @@ module SBF
57
60
  file.seek(0)
58
61
 
59
62
  photo = photo_for_upload(file, data)
60
- photo.id.nil? ? create(photo, with) : update(photo.id, photo, with)
63
+ if photo.id.nil?
64
+ create(photo, with)
65
+ else
66
+ update(photo.id, photo, with)
67
+ end
61
68
  end
62
69
  end
63
70
 
@@ -36,7 +36,7 @@ module SBF
36
36
  def list_entities_user_has_permission(permission_id, event_years)
37
37
  raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
38
38
 
39
- event_years = [event_years] if event_years.is_a? Integer
39
+ event_years = [event_years] if event_years.is_a? Fixnum
40
40
 
41
41
  response = SBF::Client::Api::Request.post_request(
42
42
  "/#{SBF::Client::Api::VERSION}/security/list_entities_user_has_permission",
@@ -7,7 +7,6 @@ module SBF
7
7
  class Campaign < SBF::Client::TopLevelEntity
8
8
  action :get
9
9
  action :find
10
- action :find_first
11
10
 
12
11
  disallow_instantiation
13
12
 
@@ -1,5 +1,3 @@
1
- require 'active_support/concern'
2
-
3
1
  module EventYearConcern
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -1,5 +1,3 @@
1
- require 'active_support/concern'
2
-
3
1
  module FundraisingPageConcern
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -1,5 +1,3 @@
1
- require 'active_support/concern'
2
-
3
1
  module ModelTypeConcern
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -1,5 +1,3 @@
1
- require 'active_support/concern'
2
-
3
1
  module TypeConcern
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -1,5 +1,3 @@
1
- require 'active_support/concern'
2
-
3
1
  module VenueConcern
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -398,6 +398,7 @@ module SBF
398
398
  [->(v) { v[:type] == SBF::Client::Payment::Type::MONEY_ORDER }, 'SBF::Client::Payment::MoneyOrderDetails'],
399
399
  [->(v) { v[:type] == SBF::Client::Payment::Type::NONCE }, 'SBF::Client::Payment::NonceDetails'],
400
400
  [->(v) { v[:type] == SBF::Client::Payment::Type::WIRE_TRANSFER }, 'SBF::Client::Payment::WireTransferDetails'],
401
+ [->(v) { v[:type] == SBF::Client::Payment::Type::RECURRING_GIFTS }, 'SBF::Client::Payment::BraintreeSubscriptionDetails'],
401
402
  [->(v) { v[:type] == SBF::Client::Payment::Type::UNKNOWN }, 'SBF::Client::Payment::UnknownDetails'],
402
403
  [->(v) { v[:type] == SBF::Client::Payment::Type::PAYPAL }, 'SBF::Client::Payment::PaypalDetails']
403
404
  ]
@@ -10,6 +10,7 @@ module SBF
10
10
  CASH = 'cash'
11
11
  MONEY_ORDER = 'money_order'
12
12
  WIRE_TRANSFER = 'wire_transfer'
13
+ RECURRING_GIFTS = 'recurring'
13
14
  PAYPAL = 'paypal'
14
15
  end
15
16
  end
@@ -43,7 +43,7 @@ module SBF
43
43
  end
44
44
 
45
45
  class Photos < SBF::Client::BaseEntity
46
- attr_reader :avatar, :default, :icon
46
+ attr_reader :avatar, :default
47
47
  end
48
48
 
49
49
  class Contacts < SBF::Client::BaseEntity
@@ -203,12 +203,6 @@ module SBF
203
203
  def open_for_fast_registration?
204
204
  is_open_for_fast_registration
205
205
  end
206
-
207
- def past?
208
- Date.today > Date.parse(date)
209
- rescue
210
- nil
211
- end
212
206
  end
213
207
  end
214
208
  end
@@ -1,3 +1,4 @@
1
+ require 'stbaldricks/endpoints/event_application'
1
2
  require 'stbaldricks/entities/fund'
2
3
  require 'stbaldricks/entities/campaign'
3
4
  require 'stbaldricks/entities/event'
@@ -13,6 +14,7 @@ require 'stbaldricks/entities/concerns/model_type_concern'
13
14
  module SBF
14
15
  module Client
15
16
  class EventApplication < SBF::Client::TopLevelEntity
17
+ endpoint SBF::Client::EventApplicationEndpoint
16
18
  actions DEFAULT_CRUD_ACTIONS
17
19
  blacklist_action :delete
18
20
 
@@ -1,5 +1,4 @@
1
1
  require 'stbaldricks/entities/lib/top_level'
2
- require 'stbaldricks/endpoints/fundraiser'
3
2
  require 'stbaldricks/entities/person'
4
3
  require 'stbaldricks/entities/fund'
5
4
  require 'stbaldricks/entities/event'
@@ -19,12 +18,7 @@ module SBF
19
18
  include EventYearConcern
20
19
  include FundraisingPageConcern
21
20
  include VenueConcern
22
- endpoint SBF::Client::FundraiserEndpoint
23
21
  actions DEFAULT_CRUD_ACTIONS
24
- action :join_team
25
- action :leave_team
26
- action :join_event
27
- action :leave_event
28
22
 
29
23
  disallow_instantiation
30
24
 
@@ -61,7 +55,7 @@ module SBF
61
55
  end
62
56
 
63
57
  class Photos < SBF::Client::BaseEntity
64
- attr_reader :avatar, :default, :icon
58
+ attr_reader :avatar, :default
65
59
  end
66
60
 
67
61
  class Policies < SBF::Client::BaseEntity
@@ -140,17 +134,6 @@ module SBF
140
134
  def active?
141
135
  status == SBF::Client::Fundraiser::Status::ACTIVE
142
136
  end
143
-
144
- def past?
145
- return Date.today > Date.parse(end_date) if end_date
146
- Date.today > Date.parse(start_date) if start_date
147
- rescue
148
- nil
149
- end
150
-
151
- def event?
152
- event && !event.id.nil?
153
- end
154
137
  end
155
138
  end
156
139
  end
@@ -62,6 +62,7 @@ module SBF
62
62
  attr_accessor :web_message
63
63
  attr_accessor :article_url
64
64
  attr_accessor :amount
65
+ attr_accessor :description
65
66
  entity_attr_accessor :researcher, 'SBF::Client::Grant::FullResearcher', 'SBF::Client::Grant::PartialResearcher', true
66
67
  entity_attr_accessor :institution, 'SBF::Client::Grant::FullInstitution', 'SBF::Client::Grant::PartialInstitution', true
67
68
  entity_attr_accessor :funding_type, 'SBF::Client::Grant::FullFundingType', 'SBF::Client::Grant::PartialFundingType', true
@@ -91,6 +91,8 @@ module SBF
91
91
  attr_reader :avatar, :default
92
92
  end
93
93
 
94
+ class KidInstitution < SBF::Client::FullInstitution; end
95
+
94
96
  class Kid < SBF::Client::TopLevelEntity
95
97
  include Entities::DefaultCacheable
96
98
  endpoint SBF::Client::KidEndpoint
@@ -142,8 +144,6 @@ module SBF
142
144
  attr_accessor :is_submitter
143
145
  entity_attr_accessor :permissions, 'SBF::Client::Kid::Relationship::Permissions'
144
146
  end
145
-
146
- class CustomInstitution < SBF::Client::FullInstitution; end
147
147
  end
148
148
 
149
149
  class PartialKid < SBF::Client::Kid
@@ -170,8 +170,7 @@ module SBF
170
170
  entity_attr_accessor :guardian, 'SBF::Client::Guardian'
171
171
  entity_collection_attr_accessor :relationships, 'SBF::Client::Kid::Relationship'
172
172
  entity_collection_attr_accessor :urls, 'SBF::Client::KidURL'
173
- entity_collection_attr_reader :custom_institutions, 'SBF::Client::Kid::CustomInstitution', nil, true
174
- entity_attr_accessor :third_party_media, 'SBF::Client::ThirdPartyMedia', nil, true
173
+ entity_collection_attr_reader :institutions, 'SBF::Client::KidInstitution'
175
174
 
176
175
  attr_accessor :created_at
177
176
  attr_accessor :modified_at
@@ -4,7 +4,7 @@ Dir["#{patch_dir}/*.rb"].each { |file| require file }
4
4
 
5
5
  require 'set'
6
6
  require 'stbaldricks/client'
7
- require 'stbaldricks/entities/concerns/entity_response_concern'
7
+ require 'stbaldricks/entities/lib/error'
8
8
  require 'active_model'
9
9
  require 'securerandom'
10
10
 
@@ -16,7 +16,6 @@ module SBF
16
16
  extend ActiveModel::Naming
17
17
  extend ActiveModel::Translation
18
18
  include ActiveModel::Conversion
19
- include EntityResponseConcern
20
19
 
21
20
  attr_reader :errors
22
21
 
@@ -29,15 +28,14 @@ module SBF
29
28
  @not_provided_attributes = nil
30
29
  @disallow_instantiation = nil
31
30
 
32
- def initialize(data = {}, clear_changes = false)
31
+ def initialize(data = {})
33
32
  # If disallow instantiation has been set, raise an error if someone is trying to call initilaize
34
33
  raise SBF::Client::Error, 'Initialize is not valid on a base object. Use the full or partial version' unless self.class.allow_instantiation?
35
34
 
36
35
  super()
37
36
 
38
- @errors = SBF::Client::Entity::Errors.new(self)
37
+ @errors = ActiveModel::Errors.new(self)
39
38
  initialize_attributes(data)
40
- reload_recursive if clear_changes
41
39
  end
42
40
 
43
41
  # Overridden from ActiveModel::Naming to remove namespace and Full/Partial
@@ -67,10 +65,6 @@ module SBF
67
65
  restore_attributes
68
66
  end
69
67
 
70
- def destroyed?
71
- @destroyed
72
- end
73
-
74
68
  ## Returns a hash of changed data for the entity and its sub-entities
75
69
  # @param with_keys [Boolean] when true, include the keys of the current entity. (sub-entity keys will always be included if they are present)
76
70
  # @return [Hash] the changed data
@@ -89,8 +83,11 @@ module SBF
89
83
  data.merge!(attribute_symbol => attribute.dirty_data(true))
90
84
  end
91
85
  elsif attribute.is_a?(Array)
92
- next unless attribute.all? { |e| e.is_a?(BaseEntity) } && attribute.any? { |e| !e.dirty_data(true).empty? }
93
- data.merge!(attribute_symbol => attribute)
86
+ entities = attribute.all? { |e| e.is_a?(BaseEntity) } ? attribute : false
87
+ next unless entities
88
+ dirty_data_hashes = entities.map { |e| e.dirty_data(true) }.reject(&:empty?)
89
+ next if dirty_data_hashes.empty?
90
+ data.merge!(attribute_symbol => dirty_data_hashes)
94
91
  end
95
92
  end
96
93
 
@@ -115,24 +112,28 @@ module SBF
115
112
  send(setter, value)
116
113
 
117
114
  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
115
+ instance_variable_set("@#{key}".to_sym, value)
116
+
122
117
  end
123
118
  end
124
119
 
125
120
  # For each attribute that may be optional, call mark_attribute_not_provided
126
121
  # if the data set does not contain a key with the optional attribute's name
127
122
  self.class.optional_attributes.each { |name| mark_attribute_not_provided(name) unless data.key?(name) }
128
- @attributes ||= Set.new
129
- @optional_attributes ||= Set.new
130
- @not_provided_attributes ||= Set.new
131
- @entity_attributes ||= Set.new
132
- @collection_attributes ||= Set.new
133
123
  end
134
124
  private :initialize_attributes
135
125
 
126
+ def add_errors(error)
127
+ errors.clear
128
+ count = error.fields.length
129
+ error.fields.each do |field|
130
+ field = field.gsub('_id', '') # Hacky, since API returns DB field that errored instead of View Field
131
+ errors.add(field, error.details) if count > 1
132
+ errors.add(:base, "#{field}: #{error.details}") if count == 1
133
+ end
134
+ errors.add(:base, "#{error.type}: #{error.details}") if count == 0
135
+ end
136
+
136
137
  def mark_attribute_not_provided(name)
137
138
  return if not_provided_attributes.include?(name)
138
139
 
@@ -583,23 +584,6 @@ module SBF
583
584
  base.optional_attributes.merge(optional_attributes) unless optional_attributes.empty?
584
585
  base.entity_attributes.merge(entity_attributes) unless entity_attributes.empty?
585
586
  end
586
-
587
- ############ Deprecated Methods ############
588
-
589
- # Attempt to return an ErrorEntity similar to or exactly like the original
590
- def error
591
- log_deprecated('error', caller)
592
- return nil if single_active_model_error.nil?
593
- details = single_active_model_error.find { |x| x.is_a?(String) } if single_active_model_error.is_a?(Array)
594
- details ||= single_active_model_error.is_a?(String) ? single_active_model_error : nil
595
- field = single_active_model_error.is_a?(Array) ? single_active_model_error.find { |x| x.is_a?(Symbol) && x != :base } : nil
596
-
597
- fields = errors.keys.reject { |k| k == :base }.empty? ? nil : errors.keys.reject { |k| k == :base }.map(&:to_s)
598
- details = details["#{errors.type}: ".length..(details.length - 1)] if details.start_with?("#{errors.type}: ")
599
- details = details["#{field}: ".length..(details.length - 1)] if details.start_with?("#{field}: ")
600
-
601
- SBF::Client::ErrorEntity.new(code: errors.code, type: errors.type, details: details, errors: fields)
602
- end
603
587
  end
604
588
  end
605
589
  end
@@ -1,5 +1,4 @@
1
1
  require 'stbaldricks/errors'
2
- require 'active_model'
3
2
 
4
3
  module SBF
5
4
  module Client
@@ -21,10 +20,6 @@ module SBF
21
20
  @fields = Set.new(data[:errors].empty? ? [] : data[:errors]).freeze
22
21
  end
23
22
 
24
- def empty?
25
- [@code, @type, @details].all?(&:nil?) && @fields.empty?
26
- end
27
-
28
23
  def to_hash
29
24
  {code: @code, type: @type, details: @details, fields: @fields.to_a}
30
25
  end
@@ -39,25 +34,5 @@ module SBF
39
34
  error_message
40
35
  end
41
36
  end
42
-
43
- class ApiErrorEntity < ErrorEntity
44
- attr_reader :http_code
45
-
46
- def initialize(data)
47
- super(data)
48
- @http_code = data[:http_code].freeze
49
- end
50
- end
51
-
52
- module Entity
53
- class Errors < ActiveModel::Errors
54
- attr_reader :http_code, :code, :type
55
-
56
- def initialize(obj, http_code = nil)
57
- super(obj)
58
- @http_code = http_code
59
- end
60
- end
61
- end
62
37
  end
63
38
  end
@@ -3,7 +3,7 @@ require 'stbaldricks/entities/lib/base'
3
3
  module SBF
4
4
  module Client
5
5
  class OptOutSettings < SBF::Client::BaseEntity
6
- attr_accessor :email_activity, :email_members_communication, :email_mass_online, :email_mass_print, :email_reply, :email_contact_us
6
+ attr_reader :email_activity, :email_members_communication, :email_mass_online, :email_mass_print, :email_reply, :email_contact_us
7
7
 
8
8
  # Setting Types
9
9
  NOTIFICATION_TYPE = 1
@@ -12,6 +12,7 @@ module SBF
12
12
  MONEY_ORDER = 'money_order'
13
13
  NONCE = 'nonce'
14
14
  WIRE_TRANSFER = 'wire_transfer'
15
+ RECURRING_GIFTS = 'recurring'
15
16
  PAYPAL = 'paypal'
16
17
  end
17
18
 
@@ -31,19 +32,19 @@ module SBF
31
32
  end
32
33
  end
33
34
 
34
- class SubscriptionCreditCardDetails < SBF::Client::Payment::Details
35
- attr_accessor :cardholder_name, :card_type, :expiration_date, :card_number
35
+ class CreditCardDetails < SBF::Client::Payment::Details
36
+ attr_accessor :gateway, :authorization_id, :cardholder_name, :card_type, :expiration_date, :card_number
36
37
 
37
38
  def type
38
39
  SBF::Client::Payment::Type::CREDIT_CARD
39
40
  end
40
41
  end
41
42
 
42
- class CreditCardDetails < SBF::Client::Payment::Details
43
- attr_accessor :gateway, :authorization_id, :cardholder_name, :card_type, :expiration_date, :card_number
43
+ class BraintreeSubscriptionDetails < SBF::Client::Payment::Details
44
+ attr_accessor :gateway, :subscription_id, :customer_id, :cardholder_name, :card_type, :expiration_date, :card_number
44
45
 
45
46
  def type
46
- SBF::Client::Payment::Type::CREDIT_CARD
47
+ SBF::Client::Payment::Type::RECURRING_GIFTS
47
48
  end
48
49
  end
49
50
 
@@ -15,8 +15,6 @@ module SBF
15
15
  attr_accessor :id
16
16
  attr_accessor :type
17
17
  attr_accessor :identifier
18
- attr_accessor :title
19
- attr_accessor :caption
20
18
  end
21
19
  end
22
20
  end
@@ -42,9 +42,7 @@ module SBF
42
42
 
43
43
  def instance_action(name)
44
44
  define_method(name) do |*args|
45
- result = endpoint.send(name, self, *args)
46
- result unless result.is_a?(SBF::Client::TopLevelEntity)
47
- [:save, :create].include?(name) && result.errors? ? false : result
45
+ endpoint.send(name, self, *args)
48
46
  end
49
47
  end
50
48
 
@@ -61,23 +59,13 @@ module SBF
61
59
 
62
60
  if name == :update
63
61
  define_method(name) do |*args|
64
- result = endpoint.update(id, self, *args)
65
- result unless result.is_a?(SBF::Client::TopLevelEntity)
66
- result.errors? ? false : result
62
+ endpoint.update(id, self, *args)
67
63
  end
68
64
  end
69
65
 
70
66
  if name == :delete
71
67
  define_method(:delete) do |*_args|
72
- response = endpoint.delete(id)
73
- if response.error?
74
- add_errors(response.error)
75
- errors.instance_variable_set(:@http_code, response.http_code)
76
- false
77
- else
78
- @destroyed = true
79
- freeze
80
- end
68
+ endpoint.delete(id)
81
69
  end
82
70
  end
83
71
 
@@ -44,39 +44,6 @@ module SBF
44
44
  def draft_content
45
45
  content.select { |x| x.is_draft == true }
46
46
  end
47
-
48
- def editor_content
49
- published_content.map do |published|
50
- draft_content.find { |d| published.id == d.id } || published
51
- end
52
- end
53
-
54
- def lock_expired?(ttl = 300)
55
- locked_at.nil? || Time.now >= Time.parse(locked_at) + ttl
56
- end
57
-
58
- def add_draft_sections(sections)
59
- sections.each do |cid, data|
60
- #convert symbol to integer
61
- cid = cid.to_s.to_i
62
-
63
- content = published_content.find { |c| c.id == cid }
64
- update_draft_content_section(content, data, cid) unless content.nil?
65
- end
66
- end
67
-
68
- private
69
-
70
- def update_draft_content_section(content, data, cid)
71
- # update or create draft version of content
72
- draft = draft_content.find { |d| d.id == cid }
73
- if draft.nil?
74
- self.content << SBF::Client::Page::Content.new(content.to_hash.merge(is_draft: true, title: data[:title], text: data[:text]))
75
- else
76
- draft.title = data[:title]
77
- draft.text = data[:text]
78
- end
79
- end
80
47
  end
81
48
  end
82
49
  end
@@ -70,7 +70,7 @@ module SBF
70
70
  end
71
71
 
72
72
  class Photos < SBF::Client::BaseEntity
73
- attr_reader :before, :after, :avatar, :default, :icon
73
+ attr_reader :before, :after, :avatar, :default
74
74
  end
75
75
 
76
76
  class Policies < SBF::Client::BaseEntity
@@ -18,8 +18,7 @@ module SBF
18
18
  actions DEFAULT_CRUD_ACTIONS
19
19
 
20
20
  def upload(image_data_url, with = {})
21
- photo = endpoint.upload(image_data_url, self, with)
22
- photo.errors? ? false : photo
21
+ endpoint.upload(image_data_url, self, with)
23
22
  end
24
23
 
25
24
  def self.upload(*args)
@@ -157,8 +157,6 @@ module SBF
157
157
  attr_accessor :is_unrecognized
158
158
  attr_accessor :promotional_code
159
159
  attr_accessor :funding_type
160
- attr_accessor :customer_id
161
- attr_accessor :subscription_id
162
160
  entity_collection_attr_accessor :donations, 'SBF::Client::FullDonation', 'SBF::Client::PartialDonation'
163
161
  attr_accessor :created_at, :modified_at, :modified_by, :how_created, :past_due_at
164
162
 
@@ -166,12 +164,12 @@ module SBF
166
164
  :payment_details,
167
165
  [
168
166
  [
169
- ->(v) { v[:type] == SBF::Client::Payment::Type::NONCE },
170
- 'SBF::Client::Payment::NonceDetails'
167
+ ->(v) { v[:type] == SBF::Client::Payment::Type::RECURRING_GIFTS },
168
+ 'SBF::Client::Payment::BraintreeSubscriptionDetails'
171
169
  ],
172
170
  [
173
- ->(v) { v[:type] == SBF::Client::Payment::Type::CREDIT_CARD },
174
- 'SBF::Client::Payment::SubscriptionCreditCardDetails'
171
+ ->(v) { v[:type] == SBF::Client::Payment::Type::NONCE },
172
+ 'SBF::Client::Payment::NonceDetails'
175
173
  ]
176
174
  ]
177
175
  )
@@ -10,15 +10,16 @@ module SBF
10
10
  @http_code = http_code
11
11
  @data = data
12
12
  @error = error || SBF::Client::ErrorEntity.new(nil)
13
- @errors = SBF::Client::Entity::Errors.new(self, http_code)
14
- add_errors(@error) unless @error.nil? || @error.empty?
15
- @errors.instance_variable_set(:@http_code, http_code)
16
13
  end
17
14
 
18
15
  def success?
19
16
  http_code.to_s.start_with?('2')
20
17
  end
21
18
 
19
+ def error?
20
+ !success?
21
+ end
22
+
22
23
  def to_json
23
24
  to_hash.to_json
24
25
  end
@@ -69,7 +69,6 @@ module SBF
69
69
  attr_reader :website_url
70
70
  attr_reader :total_donations
71
71
  attr_reader :total_participants
72
- attr_reader :icon
73
72
  end
74
73
 
75
74
  class Team < SBF::Client::BaseEntity
@@ -92,7 +91,6 @@ module SBF
92
91
  attr_reader :status_id
93
92
  attr_reader :total_donations
94
93
  attr_reader :total_participants
95
- attr_reader :icon
96
94
  end
97
95
 
98
96
  class Participant < SBF::Client::BaseEntity
@@ -122,7 +120,6 @@ module SBF
122
120
  attr_reader :team_id
123
121
  attr_reader :virtual_participation_date
124
122
  attr_reader :total_donations
125
- attr_reader :icon
126
123
  end
127
124
 
128
125
  class Fundraiser < SBF::Client::BaseEntity
@@ -153,7 +150,6 @@ module SBF
153
150
  attr_reader :country
154
151
  attr_reader :country_full
155
152
  attr_reader :total_donations
156
- attr_reader :icon
157
153
  end
158
154
 
159
155
  class Kid < SBF::Client::BaseEntity
@@ -23,7 +23,6 @@ module SBF
23
23
  module Status
24
24
  ACTIVE = 'active'
25
25
  PENDING = 'pending'
26
- SUSPENDED = 'suspended'
27
26
  end
28
27
 
29
28
  module HowCreated
@@ -44,7 +43,7 @@ module SBF
44
43
  end
45
44
 
46
45
  class Photos < SBF::Client::BaseEntity
47
- attr_reader :avatar, :default, :icon
46
+ attr_reader :avatar, :default
48
47
  end
49
48
 
50
49
  class Totals < SBF::Client::BaseEntity
@@ -91,14 +90,6 @@ module SBF
91
90
  def active?
92
91
  status == SBF::Client::Team::Status::ACTIVE
93
92
  end
94
-
95
- def pending?
96
- status == SBF::Client::Team::Status::PENDING
97
- end
98
-
99
- def suspended?
100
- status == SBF::Client::Team::Status::SUSPENDED
101
- end
102
93
  end
103
94
  end
104
95
  end
@@ -1,5 +1,5 @@
1
1
  module SBF
2
2
  module Client
3
- VERSION = '4.6.1.alpha.3'
3
+ VERSION = '4.6.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: 4.6.1.alpha.3
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 5.0.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '5.2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 5.0.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '5.2'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: httparty
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,12 +84,11 @@ files:
90
84
  - lib/stbaldricks/endpoints/config.rb
91
85
  - lib/stbaldricks/endpoints/contact.rb
92
86
  - lib/stbaldricks/endpoints/event.rb
87
+ - lib/stbaldricks/endpoints/event_application.rb
93
88
  - lib/stbaldricks/endpoints/facebook/user.rb
94
89
  - lib/stbaldricks/endpoints/fund.rb
95
- - lib/stbaldricks/endpoints/fundraiser.rb
96
90
  - lib/stbaldricks/endpoints/kid.rb
97
91
  - lib/stbaldricks/endpoints/kid_honor.rb
98
- - lib/stbaldricks/endpoints/kid_institution.rb
99
92
  - lib/stbaldricks/endpoints/lib/entity.rb
100
93
  - lib/stbaldricks/endpoints/matching_gift_company.rb
101
94
  - lib/stbaldricks/endpoints/message.rb
@@ -112,7 +105,6 @@ files:
112
105
  - lib/stbaldricks/entities/challenger.rb
113
106
  - lib/stbaldricks/entities/challenger/model_type.rb
114
107
  - lib/stbaldricks/entities/communicate.rb
115
- - lib/stbaldricks/entities/concerns/entity_response_concern.rb
116
108
  - lib/stbaldricks/entities/concerns/event_year_concern.rb
117
109
  - lib/stbaldricks/entities/concerns/fundraising_page_concern.rb
118
110
  - lib/stbaldricks/entities/concerns/model_type_concern.rb
@@ -156,11 +148,9 @@ files:
156
148
  - lib/stbaldricks/entities/international_partner.rb
157
149
  - lib/stbaldricks/entities/kid.rb
158
150
  - lib/stbaldricks/entities/kid_honor.rb
159
- - lib/stbaldricks/entities/kid_institution.rb
160
151
  - lib/stbaldricks/entities/lib/address.rb
161
152
  - lib/stbaldricks/entities/lib/base.rb
162
153
  - lib/stbaldricks/entities/lib/cacheable.rb
163
- - lib/stbaldricks/entities/lib/collection.rb
164
154
  - lib/stbaldricks/entities/lib/default_cacheable.rb
165
155
  - lib/stbaldricks/entities/lib/email_address.rb
166
156
  - lib/stbaldricks/entities/lib/error.rb
@@ -229,12 +219,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
219
  version: '0'
230
220
  required_rubygems_version: !ruby/object:Gem::Requirement
231
221
  requirements:
232
- - - ">"
222
+ - - ">="
233
223
  - !ruby/object:Gem::Version
234
- version: 1.3.1
224
+ version: '0'
235
225
  requirements: []
236
226
  rubyforge_project:
237
- rubygems_version: 2.7.7
227
+ rubygems_version: 2.6.13
238
228
  signing_key:
239
229
  specification_version: 4
240
230
  summary: St. Baldrick's Foundation Ruby Client Library
@@ -1,36 +0,0 @@
1
- require 'stbaldricks/endpoints/lib/entity'
2
-
3
- module SBF
4
- module Client
5
- class FundraiserEndpoint < EntityEndpoint
6
- def join_team(fundraiser_id, new_team_id)
7
- response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: fundraiser_id, new_team_id: new_team_id)
8
-
9
- if ok?(response)
10
- data = SBF::Client::FullFundraiser.new(JSON.parse(response.body).symbolize!)
11
- else
12
- error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
13
- end
14
-
15
- SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
16
- end
17
-
18
- def leave_team(fundraiser_id)
19
- join_team(fundraiser_id, 0)
20
- end
21
-
22
- def join_event(fundraiser_id, new_event_id)
23
- response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_event",
24
- id: fundraiser_id, new_event_id: new_event_id)
25
-
26
- error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
27
-
28
- SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
29
- end
30
-
31
- def leave_event(fundraiser_id)
32
- join_event(fundraiser_id, 0)
33
- end
34
- end
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- require 'stbaldricks/endpoints/lib/entity'
2
-
3
- module SBF
4
- module Client
5
- class KidInstitutionEndpoint < EntityEndpoint
6
- def delete(params)
7
- response = SBF::Client::Api::Request.post_request("#{base_uri}/delete", params)
8
-
9
- unless ok?(response)
10
- error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
11
- end
12
-
13
- SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
14
- end
15
- end
16
- end
17
- end
@@ -1,66 +0,0 @@
1
- require 'active_support/concern'
2
- require 'stbaldricks/entities/lib/error'
3
-
4
- module EntityResponseConcern
5
- extend ActiveSupport::Concern
6
-
7
- def add_errors(error)
8
- errors.clear
9
- unless error.fields.nil?
10
- count = error.fields.length
11
- error.fields.each do |field|
12
- field = field.gsub('_id', '') # Hacky, since API returns DB field that errored instead of View Field
13
- errors.add(field, error.details) if respond_to?(field.to_sym)
14
- errors.add(:base, "#{field}: #{error.details}") unless respond_to?(field.to_sym)
15
- end
16
- end
17
- errors.instance_variable_set(:@code, error.code)
18
- errors.instance_variable_set(:@type, error.type)
19
- errors.add(:base, "#{error.type}: #{error.details}") if count == 0
20
- end
21
-
22
- def errors_http_code=(http_code)
23
- errors.instance_variable_set(:@http_code, http_code)
24
- end
25
-
26
- def error?
27
- !success?
28
- end
29
-
30
- def success?
31
- !errors?
32
- end
33
-
34
- def errors?
35
- errors.count > 0
36
- end
37
-
38
- ############ Deprecated Methods ############
39
-
40
- def http_code
41
- log_deprecated('http_code', caller)
42
- errors.http_code
43
- end
44
-
45
- def data
46
- log_deprecated('data', caller)
47
- self
48
- end
49
-
50
- private
51
-
52
- def single_active_model_error
53
- return if errors.empty?
54
- return [:base, errors[:base].first] if errors[:base].any?
55
- errors.first
56
- end
57
-
58
- def log_deprecated(method_name, method_caller = nil)
59
- SBF::Client::Configuration.logger.warn do
60
- caller_message = method_caller.nil? ? '' : " Called from #{method_caller.first}"
61
-
62
- "[DEPRECATION] Use of the SBF::Client::Api::Response Interface (including the `#{method_name}` method) is deprecated"\
63
- " for #{self.class}. Please update your code to use the #{self.class} interface accordingly. #{caller_message}"
64
- end
65
- end
66
- end
@@ -1,19 +0,0 @@
1
- require 'stbaldricks/endpoints/kid_institution'
2
- require 'stbaldricks/entities/kid'
3
- require 'stbaldricks/entities/institution'
4
- require 'stbaldricks/entities/lib/top_level'
5
-
6
- module SBF
7
- module Client
8
- class KidInstitution < SBF::Client::TopLevelEntity
9
- endpoint SBF::Client::KidInstitutionEndpoint
10
- actions DEFAULT_CRUD_ACTIONS
11
- blacklist_action :get
12
- blacklist_action :update
13
- blacklist_action :aggregate
14
-
15
- entity_attr_accessor :kid, 'SBF::Client::FullKid', 'SBF::Client::PartialKid'
16
- entity_attr_accessor :institution, 'SBF::Client::FullInstitution', 'SBF::Client::PartialInstitution'
17
- end
18
- end
19
- end
@@ -1,38 +0,0 @@
1
- require 'stbaldricks/entities/concerns/entity_response_concern'
2
-
3
- module SBF
4
- module Client
5
- class EntityCollection < Array
6
- include EntityResponseConcern
7
- attr_reader :total_count
8
- attr_reader :errors
9
-
10
- def initialize(entities = [], total_count = 0, errors = nil)
11
- concat(entities)
12
- @total_count = total_count
13
- @errors = errors || SBF::Client::Entity::Errors.new(self)
14
- end
15
-
16
- ############ Deprecated Methods ############
17
-
18
- # Attempt to return an ErrorEntity similar to or exactly like the original
19
- def error
20
- log_deprecated('error', caller)
21
- return nil if single_active_model_error.nil?
22
- details = single_active_model_error.find { |x| x.is_a?(String) } if single_active_model_error.is_a?(Array)
23
- details ||= single_active_model_error.is_a?(String) ? single_active_model_error : ''
24
- details = details["#{errors.type}: ".length..(details.length - 1)] if details.start_with?("#{errors.type}: ")
25
-
26
- SBF::Client::ErrorEntity.new(code: errors.code, type: errors.type, details: details)
27
- end
28
-
29
- def [](*args)
30
- log_deprecated('[]', caller) if args == [:results] || args == [:total_count]
31
- return self if args == [:results]
32
- return @total_count if args == [:total_count]
33
- result = super
34
- result.is_a?(Array) ? self.class.new(result, total_count) : result
35
- end
36
- end
37
- end
38
- end