stbaldricks 4.6.1.alpha.2 → 4.6.1.alpha.3
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.
- checksums.yaml +4 -4
- data/lib/stbaldricks/endpoints/fundraiser.rb +36 -0
- data/lib/stbaldricks/endpoints/kid.rb +7 -3
- data/lib/stbaldricks/endpoints/kid_institution.rb +17 -0
- data/lib/stbaldricks/endpoints/lib/entity.rb +42 -32
- data/lib/stbaldricks/endpoints/photo.rb +5 -12
- data/lib/stbaldricks/endpoints/user.rb +1 -1
- data/lib/stbaldricks/entities/campaign.rb +1 -0
- data/lib/stbaldricks/entities/concerns/entity_response_concern.rb +66 -0
- data/lib/stbaldricks/entities/concerns/event_year_concern.rb +2 -0
- data/lib/stbaldricks/entities/concerns/fundraising_page_concern.rb +2 -0
- data/lib/stbaldricks/entities/concerns/model_type_concern.rb +2 -0
- data/lib/stbaldricks/entities/concerns/type_concern.rb +2 -0
- data/lib/stbaldricks/entities/concerns/venue_concern.rb +2 -0
- data/lib/stbaldricks/entities/donation.rb +0 -1
- data/lib/stbaldricks/entities/donation/payment_type.rb +0 -1
- data/lib/stbaldricks/entities/event.rb +7 -1
- data/lib/stbaldricks/entities/event_application.rb +0 -2
- data/lib/stbaldricks/entities/fundraiser.rb +18 -1
- data/lib/stbaldricks/entities/grant.rb +0 -1
- data/lib/stbaldricks/entities/kid.rb +4 -3
- data/lib/stbaldricks/entities/kid_institution.rb +19 -0
- data/lib/stbaldricks/entities/lib/base.rb +37 -21
- data/lib/stbaldricks/entities/lib/collection.rb +38 -0
- data/lib/stbaldricks/entities/lib/error.rb +25 -0
- data/lib/stbaldricks/entities/lib/opt_out_settings.rb +1 -1
- data/lib/stbaldricks/entities/lib/payment.rb +5 -6
- data/lib/stbaldricks/entities/lib/third_party_media.rb +2 -0
- data/lib/stbaldricks/entities/lib/top_level.rb +15 -3
- data/lib/stbaldricks/entities/page.rb +33 -0
- data/lib/stbaldricks/entities/participant.rb +1 -1
- data/lib/stbaldricks/entities/photo.rb +2 -1
- data/lib/stbaldricks/entities/recurring_gift.rb +6 -4
- data/lib/stbaldricks/entities/response.rb +3 -4
- data/lib/stbaldricks/entities/search.rb +4 -0
- data/lib/stbaldricks/entities/team.rb +10 -1
- data/lib/stbaldricks/version.rb +1 -1
- metadata +14 -4
- data/lib/stbaldricks/endpoints/event_application.rb +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7ccd3a68b118457b042e75fd6d5c526399a6e0f35e9fcfd6cac082d95ed3063
|
|
4
|
+
data.tar.gz: 87d3031eb1d377ab100cccb502b0fc3dd2b29642d82589bc8b0fd12a46862c1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13cb348aa8bc10d14ca5bce929672d55f3ba5dcc25da7731d4141e6ce2f5672e625005c7172796071c095b084413cfa25112b1443c6adf70af3afe1799db2b7e
|
|
7
|
+
data.tar.gz: 023b058a3fdab154c491ad6a120ec7866ff04351b7205ccf6b3226e8264a950154af149ad959f5cb4913f06d552ba08c7bf40ff1b11aa9c26f2083f244b7445e
|
|
@@ -0,0 +1,36 @@
|
|
|
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,4 +1,5 @@
|
|
|
1
1
|
require 'stbaldricks/endpoints/lib/entity'
|
|
2
|
+
require 'stbaldricks/entities/lib/collection'
|
|
2
3
|
|
|
3
4
|
module SBF
|
|
4
5
|
module Client
|
|
@@ -12,12 +13,15 @@ module SBF
|
|
|
12
13
|
|
|
13
14
|
if ok?(response)
|
|
14
15
|
parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data) }
|
|
15
|
-
|
|
16
|
+
SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
|
|
16
17
|
else
|
|
18
|
+
parsed_response_body = JSON.parse(response.body).symbolize!
|
|
17
19
|
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
|
|
18
24
|
end
|
|
19
|
-
|
|
20
|
-
SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
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,5 +1,6 @@
|
|
|
1
1
|
require 'stbaldricks/version'
|
|
2
2
|
require 'stbaldricks/api'
|
|
3
|
+
require 'stbaldricks/entities/lib/collection'
|
|
3
4
|
require 'stbaldricks/entities/lib/error'
|
|
4
5
|
require 'stbaldricks/entities/response'
|
|
5
6
|
require 'stbaldricks/patches/hash'
|
|
@@ -20,7 +21,7 @@ module SBF
|
|
|
20
21
|
def save(entity_or_hash, with = {})
|
|
21
22
|
if entity_or_hash.is_a?(SBF::Client::BaseEntity)
|
|
22
23
|
return create(entity_or_hash, with) if entity_or_hash.id.nil?
|
|
23
|
-
return update(entity_or_hash.id, entity_or_hash
|
|
24
|
+
return update(entity_or_hash.id, entity_or_hash, with)
|
|
24
25
|
else
|
|
25
26
|
return create(entity_or_hash, with) if entity_or_hash[:id].nil?
|
|
26
27
|
return update(entity_or_hash[:id], entity_or_hash, with)
|
|
@@ -30,7 +31,8 @@ module SBF
|
|
|
30
31
|
# Calls the create route for the entity. Uses the class name to generate the uri
|
|
31
32
|
# @param with [Hash] The optional entity fields to include in the response
|
|
32
33
|
# @return entity [SBF::Client::BaseEntity]
|
|
33
|
-
def create(
|
|
34
|
+
def create(entity_or_hash, with = {})
|
|
35
|
+
entity = entity_or_hash.is_a?(Hash) ? target_class.new(entity_or_hash) : entity_or_hash
|
|
34
36
|
raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
|
|
35
37
|
|
|
36
38
|
with = normalize_with(with, entity)
|
|
@@ -39,9 +41,7 @@ module SBF
|
|
|
39
41
|
|
|
40
42
|
response = SBF::Client::Api::Request.post_request("#{base_uri}/create", create_data)
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
SBF::Client::Api::Response.new(http_code: response.code, data: entity, error: error)
|
|
44
|
+
hydrated_entity(response, create_data, entity)
|
|
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.
|
|
53
|
+
data = entity_or_hash.dirty_data
|
|
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,9 +64,7 @@ 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
|
-
|
|
68
|
-
|
|
69
|
-
SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
|
|
67
|
+
hydrated_entity(response, data, entity_or_hash)
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
# Calls the get route for the entity. Uses the class name to generate the uri.
|
|
@@ -77,9 +75,15 @@ module SBF
|
|
|
77
75
|
|
|
78
76
|
response = SBF::Client::Api::Request.get_request("#{base_uri}/get/#{id}", with: with)
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
# Calls the find route for the entity.
|
|
@@ -92,20 +96,27 @@ module SBF
|
|
|
92
96
|
parsed_response_body = JSON.parse(response.body).symbolize!
|
|
93
97
|
|
|
94
98
|
if ok?(response)
|
|
95
|
-
parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data) }
|
|
96
|
-
|
|
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])
|
|
97
101
|
else
|
|
102
|
+
parsed_response_body = JSON.parse(response.body).symbolize!
|
|
98
103
|
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
|
|
99
109
|
end
|
|
100
|
-
|
|
101
|
-
SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
|
|
102
110
|
end
|
|
103
111
|
|
|
104
112
|
# Calls the find route for the entity.
|
|
105
113
|
def find_first(filter = [], order = {}, with = {})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
|
109
120
|
end
|
|
110
121
|
|
|
111
122
|
# Calls the aggregate route for the entity.
|
|
@@ -211,7 +222,7 @@ module SBF
|
|
|
211
222
|
end
|
|
212
223
|
private :normalize_with
|
|
213
224
|
|
|
214
|
-
def
|
|
225
|
+
def hydrated_entity(response, data, entity_or_hash)
|
|
215
226
|
parsed_response_body = JSON.parse(response.body).symbolize!
|
|
216
227
|
|
|
217
228
|
entity_or_hash.errors.clear if entity_or_hash.is_a?(SBF::Client::BaseEntity)
|
|
@@ -222,29 +233,28 @@ module SBF
|
|
|
222
233
|
|
|
223
234
|
new_data = parsed_response_body
|
|
224
235
|
new_data = data.merge(parsed_response_body) if data.is_a?(Hash)
|
|
225
|
-
data = target_class.new(new_data)
|
|
226
236
|
|
|
227
237
|
if entity_or_hash.is_a?(SBF::Client::BaseEntity)
|
|
228
238
|
entity_or_hash.send(:initialize_attributes, new_data)
|
|
229
|
-
|
|
239
|
+
entity = entity_or_hash
|
|
240
|
+
else
|
|
241
|
+
entity = target_class.new(new_data)
|
|
230
242
|
end
|
|
231
243
|
|
|
232
244
|
# Reload entity and its sub-entities so that no fields have a 'changed' state
|
|
233
|
-
|
|
245
|
+
entity.reload_recursive
|
|
234
246
|
|
|
235
|
-
|
|
247
|
+
entity
|
|
236
248
|
else
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
error = SBF::Client::ErrorEntity.new(parsed_response_body)
|
|
242
|
-
data.add_errors(error) if data.is_a?(SBF::Client::BaseEntity)
|
|
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
|
|
243
253
|
|
|
244
|
-
|
|
254
|
+
entity
|
|
245
255
|
end
|
|
246
256
|
end
|
|
247
|
-
private :
|
|
257
|
+
private :hydrated_entity
|
|
248
258
|
end
|
|
249
259
|
end
|
|
250
260
|
end
|
|
@@ -3,7 +3,8 @@ require 'stbaldricks/endpoints/lib/entity'
|
|
|
3
3
|
module SBF
|
|
4
4
|
module Client
|
|
5
5
|
class PhotoEndpoint < SBF::Client::EntityEndpoint
|
|
6
|
-
def create(
|
|
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
8
|
raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
|
|
8
9
|
|
|
9
10
|
with = normalize_with(with)
|
|
@@ -15,9 +16,7 @@ module SBF
|
|
|
15
16
|
|
|
16
17
|
response = SBF::Client::Api::Request.file_post_request(path: "#{base_uri}/create", params: create_data, file: file, filename: filename)
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
SBF::Client::Api::Response.new(http_code: response.code, data: entity, error: error)
|
|
19
|
+
hydrated_entity(response, create_data, entity)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
def update(id = nil, entity_or_hash = nil, with = {})
|
|
@@ -44,9 +43,7 @@ module SBF
|
|
|
44
43
|
SBF::Client::Api::Request.post_request("#{base_uri}/update", data)
|
|
45
44
|
end
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
|
|
46
|
+
hydrated_entity(response, data, entity_or_hash)
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
def upload(image_data_url, data = {}, with = {})
|
|
@@ -60,11 +57,7 @@ module SBF
|
|
|
60
57
|
file.seek(0)
|
|
61
58
|
|
|
62
59
|
photo = photo_for_upload(file, data)
|
|
63
|
-
|
|
64
|
-
create(photo, with)
|
|
65
|
-
else
|
|
66
|
-
update(photo.id, photo, with)
|
|
67
|
-
end
|
|
60
|
+
photo.id.nil? ? create(photo, with) : update(photo.id, photo, with)
|
|
68
61
|
end
|
|
69
62
|
end
|
|
70
63
|
|
|
@@ -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?
|
|
39
|
+
event_years = [event_years] if event_years.is_a? Integer
|
|
40
40
|
|
|
41
41
|
response = SBF::Client::Api::Request.post_request(
|
|
42
42
|
"/#{SBF::Client::Api::VERSION}/security/list_entities_user_has_permission",
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -398,7 +398,6 @@ 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'],
|
|
402
401
|
[->(v) { v[:type] == SBF::Client::Payment::Type::UNKNOWN }, 'SBF::Client::Payment::UnknownDetails'],
|
|
403
402
|
[->(v) { v[:type] == SBF::Client::Payment::Type::PAYPAL }, 'SBF::Client::Payment::PaypalDetails']
|
|
404
403
|
]
|
|
@@ -43,7 +43,7 @@ module SBF
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
class Photos < SBF::Client::BaseEntity
|
|
46
|
-
attr_reader :avatar, :default
|
|
46
|
+
attr_reader :avatar, :default, :icon
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
class Contacts < SBF::Client::BaseEntity
|
|
@@ -203,6 +203,12 @@ 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
|
|
206
212
|
end
|
|
207
213
|
end
|
|
208
214
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'stbaldricks/endpoints/event_application'
|
|
2
1
|
require 'stbaldricks/entities/fund'
|
|
3
2
|
require 'stbaldricks/entities/campaign'
|
|
4
3
|
require 'stbaldricks/entities/event'
|
|
@@ -14,7 +13,6 @@ require 'stbaldricks/entities/concerns/model_type_concern'
|
|
|
14
13
|
module SBF
|
|
15
14
|
module Client
|
|
16
15
|
class EventApplication < SBF::Client::TopLevelEntity
|
|
17
|
-
endpoint SBF::Client::EventApplicationEndpoint
|
|
18
16
|
actions DEFAULT_CRUD_ACTIONS
|
|
19
17
|
blacklist_action :delete
|
|
20
18
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'stbaldricks/entities/lib/top_level'
|
|
2
|
+
require 'stbaldricks/endpoints/fundraiser'
|
|
2
3
|
require 'stbaldricks/entities/person'
|
|
3
4
|
require 'stbaldricks/entities/fund'
|
|
4
5
|
require 'stbaldricks/entities/event'
|
|
@@ -18,7 +19,12 @@ module SBF
|
|
|
18
19
|
include EventYearConcern
|
|
19
20
|
include FundraisingPageConcern
|
|
20
21
|
include VenueConcern
|
|
22
|
+
endpoint SBF::Client::FundraiserEndpoint
|
|
21
23
|
actions DEFAULT_CRUD_ACTIONS
|
|
24
|
+
action :join_team
|
|
25
|
+
action :leave_team
|
|
26
|
+
action :join_event
|
|
27
|
+
action :leave_event
|
|
22
28
|
|
|
23
29
|
disallow_instantiation
|
|
24
30
|
|
|
@@ -55,7 +61,7 @@ module SBF
|
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
class Photos < SBF::Client::BaseEntity
|
|
58
|
-
attr_reader :avatar, :default
|
|
64
|
+
attr_reader :avatar, :default, :icon
|
|
59
65
|
end
|
|
60
66
|
|
|
61
67
|
class Policies < SBF::Client::BaseEntity
|
|
@@ -134,6 +140,17 @@ module SBF
|
|
|
134
140
|
def active?
|
|
135
141
|
status == SBF::Client::Fundraiser::Status::ACTIVE
|
|
136
142
|
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
|
|
137
154
|
end
|
|
138
155
|
end
|
|
139
156
|
end
|
|
@@ -62,7 +62,6 @@ module SBF
|
|
|
62
62
|
attr_accessor :web_message
|
|
63
63
|
attr_accessor :article_url
|
|
64
64
|
attr_accessor :amount
|
|
65
|
-
attr_accessor :description
|
|
66
65
|
entity_attr_accessor :researcher, 'SBF::Client::Grant::FullResearcher', 'SBF::Client::Grant::PartialResearcher', true
|
|
67
66
|
entity_attr_accessor :institution, 'SBF::Client::Grant::FullInstitution', 'SBF::Client::Grant::PartialInstitution', true
|
|
68
67
|
entity_attr_accessor :funding_type, 'SBF::Client::Grant::FullFundingType', 'SBF::Client::Grant::PartialFundingType', true
|
|
@@ -91,8 +91,6 @@ module SBF
|
|
|
91
91
|
attr_reader :avatar, :default
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
class KidInstitution < SBF::Client::FullInstitution; end
|
|
95
|
-
|
|
96
94
|
class Kid < SBF::Client::TopLevelEntity
|
|
97
95
|
include Entities::DefaultCacheable
|
|
98
96
|
endpoint SBF::Client::KidEndpoint
|
|
@@ -144,6 +142,8 @@ module SBF
|
|
|
144
142
|
attr_accessor :is_submitter
|
|
145
143
|
entity_attr_accessor :permissions, 'SBF::Client::Kid::Relationship::Permissions'
|
|
146
144
|
end
|
|
145
|
+
|
|
146
|
+
class CustomInstitution < SBF::Client::FullInstitution; end
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
class PartialKid < SBF::Client::Kid
|
|
@@ -170,7 +170,8 @@ 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 :
|
|
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
|
|
174
175
|
|
|
175
176
|
attr_accessor :created_at
|
|
176
177
|
attr_accessor :modified_at
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -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/
|
|
7
|
+
require 'stbaldricks/entities/concerns/entity_response_concern'
|
|
8
8
|
require 'active_model'
|
|
9
9
|
require 'securerandom'
|
|
10
10
|
|
|
@@ -16,6 +16,7 @@ module SBF
|
|
|
16
16
|
extend ActiveModel::Naming
|
|
17
17
|
extend ActiveModel::Translation
|
|
18
18
|
include ActiveModel::Conversion
|
|
19
|
+
include EntityResponseConcern
|
|
19
20
|
|
|
20
21
|
attr_reader :errors
|
|
21
22
|
|
|
@@ -28,14 +29,15 @@ module SBF
|
|
|
28
29
|
@not_provided_attributes = nil
|
|
29
30
|
@disallow_instantiation = nil
|
|
30
31
|
|
|
31
|
-
def initialize(data = {})
|
|
32
|
+
def initialize(data = {}, clear_changes = false)
|
|
32
33
|
# If disallow instantiation has been set, raise an error if someone is trying to call initilaize
|
|
33
34
|
raise SBF::Client::Error, 'Initialize is not valid on a base object. Use the full or partial version' unless self.class.allow_instantiation?
|
|
34
35
|
|
|
35
36
|
super()
|
|
36
37
|
|
|
37
|
-
@errors =
|
|
38
|
+
@errors = SBF::Client::Entity::Errors.new(self)
|
|
38
39
|
initialize_attributes(data)
|
|
40
|
+
reload_recursive if clear_changes
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
# Overridden from ActiveModel::Naming to remove namespace and Full/Partial
|
|
@@ -65,6 +67,10 @@ module SBF
|
|
|
65
67
|
restore_attributes
|
|
66
68
|
end
|
|
67
69
|
|
|
70
|
+
def destroyed?
|
|
71
|
+
@destroyed
|
|
72
|
+
end
|
|
73
|
+
|
|
68
74
|
## Returns a hash of changed data for the entity and its sub-entities
|
|
69
75
|
# @param with_keys [Boolean] when true, include the keys of the current entity. (sub-entity keys will always be included if they are present)
|
|
70
76
|
# @return [Hash] the changed data
|
|
@@ -83,11 +89,8 @@ module SBF
|
|
|
83
89
|
data.merge!(attribute_symbol => attribute.dirty_data(true))
|
|
84
90
|
end
|
|
85
91
|
elsif attribute.is_a?(Array)
|
|
86
|
-
|
|
87
|
-
|
|
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)
|
|
92
|
+
next unless attribute.all? { |e| e.is_a?(BaseEntity) } && attribute.any? { |e| !e.dirty_data(true).empty? }
|
|
93
|
+
data.merge!(attribute_symbol => attribute)
|
|
91
94
|
end
|
|
92
95
|
end
|
|
93
96
|
|
|
@@ -112,28 +115,24 @@ module SBF
|
|
|
112
115
|
send(setter, value)
|
|
113
116
|
|
|
114
117
|
else
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
if respond_to?(key.to_sym)
|
|
119
|
+
instance_variable_set("@#{key}".to_sym, value)
|
|
120
|
+
attribute_will_change!(key.to_sym)
|
|
121
|
+
end
|
|
117
122
|
end
|
|
118
123
|
end
|
|
119
124
|
|
|
120
125
|
# For each attribute that may be optional, call mark_attribute_not_provided
|
|
121
126
|
# if the data set does not contain a key with the optional attribute's name
|
|
122
127
|
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
|
|
123
133
|
end
|
|
124
134
|
private :initialize_attributes
|
|
125
135
|
|
|
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
|
-
|
|
137
136
|
def mark_attribute_not_provided(name)
|
|
138
137
|
return if not_provided_attributes.include?(name)
|
|
139
138
|
|
|
@@ -584,6 +583,23 @@ module SBF
|
|
|
584
583
|
base.optional_attributes.merge(optional_attributes) unless optional_attributes.empty?
|
|
585
584
|
base.entity_attributes.merge(entity_attributes) unless entity_attributes.empty?
|
|
586
585
|
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
|
|
587
603
|
end
|
|
588
604
|
end
|
|
589
605
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'stbaldricks/errors'
|
|
2
|
+
require 'active_model'
|
|
2
3
|
|
|
3
4
|
module SBF
|
|
4
5
|
module Client
|
|
@@ -20,6 +21,10 @@ module SBF
|
|
|
20
21
|
@fields = Set.new(data[:errors].empty? ? [] : data[:errors]).freeze
|
|
21
22
|
end
|
|
22
23
|
|
|
24
|
+
def empty?
|
|
25
|
+
[@code, @type, @details].all?(&:nil?) && @fields.empty?
|
|
26
|
+
end
|
|
27
|
+
|
|
23
28
|
def to_hash
|
|
24
29
|
{code: @code, type: @type, details: @details, fields: @fields.to_a}
|
|
25
30
|
end
|
|
@@ -34,5 +39,25 @@ module SBF
|
|
|
34
39
|
error_message
|
|
35
40
|
end
|
|
36
41
|
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
|
|
37
62
|
end
|
|
38
63
|
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
|
-
|
|
6
|
+
attr_accessor :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,7 +12,6 @@ module SBF
|
|
|
12
12
|
MONEY_ORDER = 'money_order'
|
|
13
13
|
NONCE = 'nonce'
|
|
14
14
|
WIRE_TRANSFER = 'wire_transfer'
|
|
15
|
-
RECURRING_GIFTS = 'recurring'
|
|
16
15
|
PAYPAL = 'paypal'
|
|
17
16
|
end
|
|
18
17
|
|
|
@@ -32,19 +31,19 @@ module SBF
|
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
class
|
|
36
|
-
attr_accessor :
|
|
34
|
+
class SubscriptionCreditCardDetails < SBF::Client::Payment::Details
|
|
35
|
+
attr_accessor :cardholder_name, :card_type, :expiration_date, :card_number
|
|
37
36
|
|
|
38
37
|
def type
|
|
39
38
|
SBF::Client::Payment::Type::CREDIT_CARD
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
class
|
|
44
|
-
attr_accessor :gateway, :
|
|
42
|
+
class CreditCardDetails < SBF::Client::Payment::Details
|
|
43
|
+
attr_accessor :gateway, :authorization_id, :cardholder_name, :card_type, :expiration_date, :card_number
|
|
45
44
|
|
|
46
45
|
def type
|
|
47
|
-
SBF::Client::Payment::Type::
|
|
46
|
+
SBF::Client::Payment::Type::CREDIT_CARD
|
|
48
47
|
end
|
|
49
48
|
end
|
|
50
49
|
|
|
@@ -42,7 +42,9 @@ module SBF
|
|
|
42
42
|
|
|
43
43
|
def instance_action(name)
|
|
44
44
|
define_method(name) do |*args|
|
|
45
|
-
endpoint.send(name, self, *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
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
50
|
|
|
@@ -59,13 +61,23 @@ module SBF
|
|
|
59
61
|
|
|
60
62
|
if name == :update
|
|
61
63
|
define_method(name) do |*args|
|
|
62
|
-
endpoint.update(id, self, *args)
|
|
64
|
+
result = endpoint.update(id, self, *args)
|
|
65
|
+
result unless result.is_a?(SBF::Client::TopLevelEntity)
|
|
66
|
+
result.errors? ? false : result
|
|
63
67
|
end
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
if name == :delete
|
|
67
71
|
define_method(:delete) do |*_args|
|
|
68
|
-
endpoint.delete(id)
|
|
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
|
|
69
81
|
end
|
|
70
82
|
end
|
|
71
83
|
|
|
@@ -44,6 +44,39 @@ 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
|
|
47
80
|
end
|
|
48
81
|
end
|
|
49
82
|
end
|
|
@@ -157,19 +157,21 @@ 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
|
|
160
162
|
entity_collection_attr_accessor :donations, 'SBF::Client::FullDonation', 'SBF::Client::PartialDonation'
|
|
161
163
|
attr_accessor :created_at, :modified_at, :modified_by, :how_created, :past_due_at
|
|
162
164
|
|
|
163
165
|
multitype_attr_accessor(
|
|
164
166
|
:payment_details,
|
|
165
167
|
[
|
|
166
|
-
[
|
|
167
|
-
->(v) { v[:type] == SBF::Client::Payment::Type::RECURRING_GIFTS },
|
|
168
|
-
'SBF::Client::Payment::BraintreeSubscriptionDetails'
|
|
169
|
-
],
|
|
170
168
|
[
|
|
171
169
|
->(v) { v[:type] == SBF::Client::Payment::Type::NONCE },
|
|
172
170
|
'SBF::Client::Payment::NonceDetails'
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
->(v) { v[:type] == SBF::Client::Payment::Type::CREDIT_CARD },
|
|
174
|
+
'SBF::Client::Payment::SubscriptionCreditCardDetails'
|
|
173
175
|
]
|
|
174
176
|
]
|
|
175
177
|
)
|
|
@@ -10,16 +10,15 @@ 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)
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
def success?
|
|
16
19
|
http_code.to_s.start_with?('2')
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
def error?
|
|
20
|
-
!success?
|
|
21
|
-
end
|
|
22
|
-
|
|
23
22
|
def to_json
|
|
24
23
|
to_hash.to_json
|
|
25
24
|
end
|
|
@@ -69,6 +69,7 @@ module SBF
|
|
|
69
69
|
attr_reader :website_url
|
|
70
70
|
attr_reader :total_donations
|
|
71
71
|
attr_reader :total_participants
|
|
72
|
+
attr_reader :icon
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
class Team < SBF::Client::BaseEntity
|
|
@@ -91,6 +92,7 @@ module SBF
|
|
|
91
92
|
attr_reader :status_id
|
|
92
93
|
attr_reader :total_donations
|
|
93
94
|
attr_reader :total_participants
|
|
95
|
+
attr_reader :icon
|
|
94
96
|
end
|
|
95
97
|
|
|
96
98
|
class Participant < SBF::Client::BaseEntity
|
|
@@ -120,6 +122,7 @@ module SBF
|
|
|
120
122
|
attr_reader :team_id
|
|
121
123
|
attr_reader :virtual_participation_date
|
|
122
124
|
attr_reader :total_donations
|
|
125
|
+
attr_reader :icon
|
|
123
126
|
end
|
|
124
127
|
|
|
125
128
|
class Fundraiser < SBF::Client::BaseEntity
|
|
@@ -150,6 +153,7 @@ module SBF
|
|
|
150
153
|
attr_reader :country
|
|
151
154
|
attr_reader :country_full
|
|
152
155
|
attr_reader :total_donations
|
|
156
|
+
attr_reader :icon
|
|
153
157
|
end
|
|
154
158
|
|
|
155
159
|
class Kid < SBF::Client::BaseEntity
|
|
@@ -23,6 +23,7 @@ module SBF
|
|
|
23
23
|
module Status
|
|
24
24
|
ACTIVE = 'active'
|
|
25
25
|
PENDING = 'pending'
|
|
26
|
+
SUSPENDED = 'suspended'
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
module HowCreated
|
|
@@ -43,7 +44,7 @@ module SBF
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
class Photos < SBF::Client::BaseEntity
|
|
46
|
-
attr_reader :avatar, :default
|
|
47
|
+
attr_reader :avatar, :default, :icon
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
class Totals < SBF::Client::BaseEntity
|
|
@@ -90,6 +91,14 @@ module SBF
|
|
|
90
91
|
def active?
|
|
91
92
|
status == SBF::Client::Team::Status::ACTIVE
|
|
92
93
|
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
|
|
93
102
|
end
|
|
94
103
|
end
|
|
95
104
|
end
|
data/lib/stbaldricks/version.rb
CHANGED
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.
|
|
4
|
+
version: 4.6.1.alpha.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Firespring
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -17,6 +17,9 @@ 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'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -24,6 +27,9 @@ dependencies:
|
|
|
24
27
|
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 5.0.0
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5.2'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: httparty
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,11 +90,12 @@ files:
|
|
|
84
90
|
- lib/stbaldricks/endpoints/config.rb
|
|
85
91
|
- lib/stbaldricks/endpoints/contact.rb
|
|
86
92
|
- lib/stbaldricks/endpoints/event.rb
|
|
87
|
-
- lib/stbaldricks/endpoints/event_application.rb
|
|
88
93
|
- lib/stbaldricks/endpoints/facebook/user.rb
|
|
89
94
|
- lib/stbaldricks/endpoints/fund.rb
|
|
95
|
+
- lib/stbaldricks/endpoints/fundraiser.rb
|
|
90
96
|
- lib/stbaldricks/endpoints/kid.rb
|
|
91
97
|
- lib/stbaldricks/endpoints/kid_honor.rb
|
|
98
|
+
- lib/stbaldricks/endpoints/kid_institution.rb
|
|
92
99
|
- lib/stbaldricks/endpoints/lib/entity.rb
|
|
93
100
|
- lib/stbaldricks/endpoints/matching_gift_company.rb
|
|
94
101
|
- lib/stbaldricks/endpoints/message.rb
|
|
@@ -105,6 +112,7 @@ files:
|
|
|
105
112
|
- lib/stbaldricks/entities/challenger.rb
|
|
106
113
|
- lib/stbaldricks/entities/challenger/model_type.rb
|
|
107
114
|
- lib/stbaldricks/entities/communicate.rb
|
|
115
|
+
- lib/stbaldricks/entities/concerns/entity_response_concern.rb
|
|
108
116
|
- lib/stbaldricks/entities/concerns/event_year_concern.rb
|
|
109
117
|
- lib/stbaldricks/entities/concerns/fundraising_page_concern.rb
|
|
110
118
|
- lib/stbaldricks/entities/concerns/model_type_concern.rb
|
|
@@ -148,9 +156,11 @@ files:
|
|
|
148
156
|
- lib/stbaldricks/entities/international_partner.rb
|
|
149
157
|
- lib/stbaldricks/entities/kid.rb
|
|
150
158
|
- lib/stbaldricks/entities/kid_honor.rb
|
|
159
|
+
- lib/stbaldricks/entities/kid_institution.rb
|
|
151
160
|
- lib/stbaldricks/entities/lib/address.rb
|
|
152
161
|
- lib/stbaldricks/entities/lib/base.rb
|
|
153
162
|
- lib/stbaldricks/entities/lib/cacheable.rb
|
|
163
|
+
- lib/stbaldricks/entities/lib/collection.rb
|
|
154
164
|
- lib/stbaldricks/entities/lib/default_cacheable.rb
|
|
155
165
|
- lib/stbaldricks/entities/lib/email_address.rb
|
|
156
166
|
- lib/stbaldricks/entities/lib/error.rb
|
|
@@ -224,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
234
|
version: 1.3.1
|
|
225
235
|
requirements: []
|
|
226
236
|
rubyforge_project:
|
|
227
|
-
rubygems_version: 2.7.
|
|
237
|
+
rubygems_version: 2.7.7
|
|
228
238
|
signing_key:
|
|
229
239
|
specification_version: 4
|
|
230
240
|
summary: St. Baldrick's Foundation Ruby Client Library
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|