stbaldricks 1.5.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/lib/stbaldricks.rb +2 -0
- data/lib/stbaldricks/api.rb +7 -0
- data/lib/stbaldricks/api_connector.rb +47 -0
- data/lib/stbaldricks/client.rb +7 -0
- data/lib/stbaldricks/configuration.rb +47 -0
- data/lib/stbaldricks/default_logger.rb +24 -0
- data/lib/stbaldricks/endpoints/communicate.rb +67 -0
- data/lib/stbaldricks/endpoints/config.rb +18 -0
- data/lib/stbaldricks/endpoints/contact.rb +12 -0
- data/lib/stbaldricks/endpoints/event.rb +39 -0
- data/lib/stbaldricks/endpoints/event_application.rb +32 -0
- data/lib/stbaldricks/endpoints/fund.rb +24 -0
- data/lib/stbaldricks/endpoints/kid.rb +24 -0
- data/lib/stbaldricks/endpoints/kid_honor.rb +17 -0
- data/lib/stbaldricks/endpoints/lib/entity.rb +247 -0
- data/lib/stbaldricks/endpoints/message.rb +27 -0
- data/lib/stbaldricks/endpoints/newsletter_recipient.rb +41 -0
- data/lib/stbaldricks/endpoints/participant.rb +66 -0
- data/lib/stbaldricks/endpoints/photo.rb +51 -0
- data/lib/stbaldricks/endpoints/recurring_gift.rb +18 -0
- data/lib/stbaldricks/endpoints/search.rb +63 -0
- data/lib/stbaldricks/endpoints/shave_schedule.rb +28 -0
- data/lib/stbaldricks/endpoints/user.rb +106 -0
- data/lib/stbaldricks/entities/batch.rb +29 -0
- data/lib/stbaldricks/entities/campaign.rb +37 -0
- data/lib/stbaldricks/entities/communicate.rb +20 -0
- data/lib/stbaldricks/entities/config.rb +41 -0
- data/lib/stbaldricks/entities/contact.rb +40 -0
- data/lib/stbaldricks/entities/contact_group.rb +29 -0
- data/lib/stbaldricks/entities/document_library.rb +19 -0
- data/lib/stbaldricks/entities/document_library_category.rb +14 -0
- data/lib/stbaldricks/entities/donation.rb +372 -0
- data/lib/stbaldricks/entities/donation/donor_type.rb +13 -0
- data/lib/stbaldricks/entities/donation/how_created.rb +22 -0
- data/lib/stbaldricks/entities/donation/payment_type.rb +17 -0
- data/lib/stbaldricks/entities/donation/promo_code.rb +22 -0
- data/lib/stbaldricks/entities/donation/recipient_type.rb +17 -0
- data/lib/stbaldricks/entities/donation/special_donation_type.rb +78 -0
- data/lib/stbaldricks/entities/donation/status.rb +12 -0
- data/lib/stbaldricks/entities/donation/submitter_type.rb +13 -0
- data/lib/stbaldricks/entities/donor.rb +15 -0
- data/lib/stbaldricks/entities/event.rb +173 -0
- data/lib/stbaldricks/entities/event/fund_relationship_type.rb +15 -0
- data/lib/stbaldricks/entities/event/how_created.rb +14 -0
- data/lib/stbaldricks/entities/event/promo_code.rb +11 -0
- data/lib/stbaldricks/entities/event/status.rb +13 -0
- data/lib/stbaldricks/entities/event/sub_type.rb +16 -0
- data/lib/stbaldricks/entities/event/type.rb +12 -0
- data/lib/stbaldricks/entities/event_application.rb +135 -0
- data/lib/stbaldricks/entities/event_application/model_type.rb +15 -0
- data/lib/stbaldricks/entities/event_application/status.rb +23 -0
- data/lib/stbaldricks/entities/event_donation_summary.rb +18 -0
- data/lib/stbaldricks/entities/event_participant_summary.rb +17 -0
- data/lib/stbaldricks/entities/event_supporter.rb +24 -0
- data/lib/stbaldricks/entities/fund.rb +98 -0
- data/lib/stbaldricks/entities/fundraiser.rb +124 -0
- data/lib/stbaldricks/entities/international_partner.rb +58 -0
- data/lib/stbaldricks/entities/kid.rb +190 -0
- data/lib/stbaldricks/entities/kid_honor.rb +123 -0
- data/lib/stbaldricks/entities/lib/address.rb +25 -0
- data/lib/stbaldricks/entities/lib/base.rb +505 -0
- data/lib/stbaldricks/entities/lib/cacheable.rb +43 -0
- data/lib/stbaldricks/entities/lib/default_cacheable.rb +17 -0
- data/lib/stbaldricks/entities/lib/email_address.rb +15 -0
- data/lib/stbaldricks/entities/lib/error.rb +38 -0
- data/lib/stbaldricks/entities/lib/fundraising_page.rb +20 -0
- data/lib/stbaldricks/entities/lib/geo_location.rb +9 -0
- data/lib/stbaldricks/entities/lib/location.rb +27 -0
- data/lib/stbaldricks/entities/lib/name.rb +17 -0
- data/lib/stbaldricks/entities/lib/not_implemented_object.rb +32 -0
- data/lib/stbaldricks/entities/lib/opt_out_settings.rb +21 -0
- data/lib/stbaldricks/entities/lib/payment.rb +86 -0
- data/lib/stbaldricks/entities/lib/permissions.rb +33 -0
- data/lib/stbaldricks/entities/lib/phone.rb +29 -0
- data/lib/stbaldricks/entities/lib/third_party_media.rb +20 -0
- data/lib/stbaldricks/entities/lib/top_level.rb +99 -0
- data/lib/stbaldricks/entities/lib/venue.rb +18 -0
- data/lib/stbaldricks/entities/memorial.rb +61 -0
- data/lib/stbaldricks/entities/message.rb +65 -0
- data/lib/stbaldricks/entities/newsletter_recipient.rb +17 -0
- data/lib/stbaldricks/entities/organization.rb +90 -0
- data/lib/stbaldricks/entities/page.rb +49 -0
- data/lib/stbaldricks/entities/participant.rb +216 -0
- data/lib/stbaldricks/entities/person.rb +403 -0
- data/lib/stbaldricks/entities/photo.rb +260 -0
- data/lib/stbaldricks/entities/recurring_gift.rb +215 -0
- data/lib/stbaldricks/entities/response.rb +37 -0
- data/lib/stbaldricks/entities/search.rb +223 -0
- data/lib/stbaldricks/entities/section.rb +15 -0
- data/lib/stbaldricks/entities/shave_schedule.rb +69 -0
- data/lib/stbaldricks/entities/summary.rb +32 -0
- data/lib/stbaldricks/entities/team.rb +95 -0
- data/lib/stbaldricks/entities/user.rb +76 -0
- data/lib/stbaldricks/enums/country.rb +223 -0
- data/lib/stbaldricks/enums/feature.rb +29 -0
- data/lib/stbaldricks/enums/league_status.rb +16 -0
- data/lib/stbaldricks/enums/model_type.rb +39 -0
- data/lib/stbaldricks/enums/permission.rb +223 -0
- data/lib/stbaldricks/enums/permission_model_type.rb +21 -0
- data/lib/stbaldricks/enums/province.rb +39 -0
- data/lib/stbaldricks/enums/state.rb +137 -0
- data/lib/stbaldricks/enums/top_level_category_type.rb +25 -0
- data/lib/stbaldricks/errors.rb +18 -0
- data/lib/stbaldricks/log.rb +16 -0
- data/lib/stbaldricks/patches/array.rb +6 -0
- data/lib/stbaldricks/patches/boolean.rb +25 -0
- data/lib/stbaldricks/patches/class.rb +13 -0
- data/lib/stbaldricks/patches/float.rb +9 -0
- data/lib/stbaldricks/patches/hash.rb +16 -0
- data/lib/stbaldricks/patches/integer.rb +9 -0
- data/lib/stbaldricks/patches/nil.rb +25 -0
- data/lib/stbaldricks/patches/string.rb +54 -0
- data/lib/stbaldricks/request.rb +146 -0
- data/lib/stbaldricks/version.rb +5 -0
- metadata +215 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'stbaldricks/endpoints/communicate'
|
2
|
+
require 'stbaldricks/entities/lib/base'
|
3
|
+
require 'stbaldricks/entities/message'
|
4
|
+
require 'stbaldricks/entities/contact'
|
5
|
+
|
6
|
+
module SBF
|
7
|
+
module Client
|
8
|
+
class Communicate < SBF::Client::Message
|
9
|
+
endpoint SBF::Client::CommunicateEndpoint
|
10
|
+
|
11
|
+
action :categories
|
12
|
+
action :years
|
13
|
+
action :groups
|
14
|
+
instance_action :compose
|
15
|
+
action :contacts
|
16
|
+
|
17
|
+
entity_collection_attr_accessor :to, 'SBF::Client::Contact'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'stbaldricks/endpoints/config'
|
3
|
+
require 'stbaldricks/entities/lib/top_level'
|
4
|
+
|
5
|
+
module SBF
|
6
|
+
module Client
|
7
|
+
class Config < SBF::Client::TopLevelEntity
|
8
|
+
include Singleton
|
9
|
+
endpoint SBF::Client::ConfigEndpoint
|
10
|
+
|
11
|
+
action :get
|
12
|
+
instance_action :reload
|
13
|
+
|
14
|
+
attr_reader :open_registration_years
|
15
|
+
attr_reader :default_year
|
16
|
+
attr_reader :years_for_squire
|
17
|
+
attr_reader :years_for_knight
|
18
|
+
attr_reader :years_for_knight_commander
|
19
|
+
attr_reader :years_for_crusader
|
20
|
+
attr_reader :braintree_client_encryption_key
|
21
|
+
attr_reader :website_url
|
22
|
+
#NOTE: If you add another attribute, be sure to mock it out in `configure :test` of app.rb
|
23
|
+
|
24
|
+
# Attempts to call the method on the cached configuration object
|
25
|
+
def self.method_missing(method_name, *arguments, &block)
|
26
|
+
# The first time a missing method is called, call reload to make sure the instance has been populated
|
27
|
+
unless @_loaded
|
28
|
+
@_loaded = true
|
29
|
+
reload
|
30
|
+
end
|
31
|
+
|
32
|
+
# If the method being called exists on the instance, call it. Otherwise forward the request on to 'super'.
|
33
|
+
if instance.respond_to?(method_name)
|
34
|
+
return instance.send(method_name)
|
35
|
+
else
|
36
|
+
super(method_name, *arguments, &block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'stbaldricks/endpoints/contact'
|
2
|
+
require 'stbaldricks/entities/lib/top_level'
|
3
|
+
require 'stbaldricks/entities/person'
|
4
|
+
require 'stbaldricks/entities/contact_group'
|
5
|
+
require 'htmlentities'
|
6
|
+
|
7
|
+
module SBF
|
8
|
+
module Client
|
9
|
+
class Contact < SBF::Client::TopLevelEntity
|
10
|
+
endpoint SBF::Client::ContactEndpoint
|
11
|
+
|
12
|
+
actions DEFAULT_CRUD_ACTIONS
|
13
|
+
|
14
|
+
module Type
|
15
|
+
WEBSITE = 'website'
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :id
|
19
|
+
entity_attr_accessor :owner, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
|
20
|
+
entity_attr_accessor :person, 'SBF::Client::FullPerson', 'SBF::Client::PartialPerson'
|
21
|
+
attr_accessor :type
|
22
|
+
attr_reader :display_name
|
23
|
+
attr_reader :email
|
24
|
+
attr_reader :created_at, :modified_at
|
25
|
+
entity_collection_attr_reader :contact_groups, 'SBF::Client::ContactGroup'
|
26
|
+
|
27
|
+
def display_name
|
28
|
+
HTMLEntities.new.decode(@display_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class CustomContact < SBF::Client::Contact
|
33
|
+
endpoint SBF::Client::ContactEndpoint
|
34
|
+
|
35
|
+
attr_accessor :id
|
36
|
+
attr_accessor :display_name
|
37
|
+
attr_accessor :email
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'stbaldricks/entities/lib/top_level'
|
2
|
+
require 'stbaldricks/entities/person'
|
3
|
+
require 'stbaldricks/entities/contact'
|
4
|
+
require 'htmlentities'
|
5
|
+
|
6
|
+
module SBF
|
7
|
+
module Client
|
8
|
+
class ContactGroup < SBF::Client::TopLevelEntity
|
9
|
+
actions DEFAULT_CRUD_ACTIONS
|
10
|
+
|
11
|
+
attr_accessor :id
|
12
|
+
attr_accessor :display_name
|
13
|
+
entity_attr_accessor :owner, 'SBF::Client::FullPerson'
|
14
|
+
attr_accessor :contacts
|
15
|
+
multitype_collection_attr_accessor(
|
16
|
+
:contacts,
|
17
|
+
[
|
18
|
+
[->(v) { v.key?(:person) && !v[:person].empty? }, 'SBF::Client::Contact'],
|
19
|
+
[ELSE, 'SBF::Client::CustomContact']
|
20
|
+
]
|
21
|
+
)
|
22
|
+
attr_reader :created_at, :modified_at
|
23
|
+
|
24
|
+
def display_name
|
25
|
+
HTMLEntities.new.decode(@display_name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'stbaldricks/entities/lib/top_level'
|
2
|
+
require 'stbaldricks/entities/document_library_category'
|
3
|
+
|
4
|
+
module SBF
|
5
|
+
module Client
|
6
|
+
class DocumentLibrary < SBF::Client::TopLevelEntity
|
7
|
+
actions DEFAULT_CRUD_ACTIONS
|
8
|
+
|
9
|
+
attr_accessor :id
|
10
|
+
attr_accessor :type
|
11
|
+
attr_accessor :title
|
12
|
+
attr_accessor :description
|
13
|
+
attr_accessor :url
|
14
|
+
attr_accessor :media_storage_id
|
15
|
+
attr_accessor :sort_order
|
16
|
+
entity_attr_reader :category, 'SBF::Client::DocumentLibraryCategory', nil, true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'stbaldricks/entities/lib/top_level'
|
2
|
+
|
3
|
+
module SBF
|
4
|
+
module Client
|
5
|
+
class DocumentLibraryCategory < SBF::Client::TopLevelEntity
|
6
|
+
actions DEFAULT_CRUD_ACTIONS
|
7
|
+
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :top_level_category
|
10
|
+
attr_accessor :name
|
11
|
+
attr_accessor :sort_order
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,372 @@
|
|
1
|
+
require 'stbaldricks/entities/fund'
|
2
|
+
require 'stbaldricks/entities/event'
|
3
|
+
require 'stbaldricks/entities/team'
|
4
|
+
require 'stbaldricks/entities/participant'
|
5
|
+
require 'stbaldricks/entities/fundraiser'
|
6
|
+
require 'stbaldricks/entities/person'
|
7
|
+
require 'stbaldricks/entities/organization'
|
8
|
+
require 'stbaldricks/entities/memorial'
|
9
|
+
require 'stbaldricks/entities/lib/address'
|
10
|
+
require 'stbaldricks/entities/lib/top_level'
|
11
|
+
require 'stbaldricks/entities/lib/name'
|
12
|
+
require 'stbaldricks/entities/lib/payment'
|
13
|
+
require 'stbaldricks/entities/lib/default_cacheable'
|
14
|
+
|
15
|
+
module SBF
|
16
|
+
module Client
|
17
|
+
class Donation < SBF::Client::TopLevelEntity
|
18
|
+
include Entities::DefaultCacheable
|
19
|
+
actions DEFAULT_CRUD_ACTIONS
|
20
|
+
|
21
|
+
disallow_instantiation
|
22
|
+
|
23
|
+
class EmployerMatching < SBF::Client::BaseEntity
|
24
|
+
attr_accessor :is_match, :employer, :matched_donation_id
|
25
|
+
|
26
|
+
def matched_donation_id=(value)
|
27
|
+
@matched_donation_id = value.to_i
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Tribute < SBF::Client::BaseEntity
|
32
|
+
attr_accessor :type
|
33
|
+
attr_reader :name
|
34
|
+
entity_attr_accessor :name_pieces, 'SBF::Client::NamePieces'
|
35
|
+
|
36
|
+
module Type
|
37
|
+
HONOR = 'honor'
|
38
|
+
TRIBUTE = 'tribute'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class FullParticipant < SBF::Client::FullParticipant
|
43
|
+
attr_reader :model_type
|
44
|
+
|
45
|
+
def model_type
|
46
|
+
SBF::Client::Donation::RecipientType::PARTICIPANT
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class PartialParticipant < SBF::Client::PartialParticipant
|
51
|
+
attr_reader :model_type
|
52
|
+
|
53
|
+
def model_type
|
54
|
+
SBF::Client::Donation::RecipientType::PARTICIPANT
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class FullFundraiser < SBF::Client::FullFundraiser
|
59
|
+
attr_reader :model_type
|
60
|
+
|
61
|
+
def model_type
|
62
|
+
SBF::Client::Donation::RecipientType::FUNDRAISER
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class PartialFundraiser < SBF::Client::PartialFundraiser
|
67
|
+
attr_reader :model_type
|
68
|
+
|
69
|
+
def model_type
|
70
|
+
SBF::Client::Donation::RecipientType::FUNDRAISER
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class FullTeam < SBF::Client::FullTeam
|
75
|
+
attr_reader :model_type
|
76
|
+
|
77
|
+
def model_type
|
78
|
+
SBF::Client::Donation::RecipientType::TEAM
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class PartialTeam < SBF::Client::PartialTeam
|
83
|
+
attr_reader :model_type
|
84
|
+
|
85
|
+
def model_type
|
86
|
+
SBF::Client::Donation::RecipientType::TEAM
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class FullEvent < SBF::Client::FullEvent
|
91
|
+
attr_reader :model_type
|
92
|
+
|
93
|
+
def model_type
|
94
|
+
SBF::Client::Donation::RecipientType::EVENT
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class PartialEvent < SBF::Client::PartialEvent
|
99
|
+
attr_reader :model_type
|
100
|
+
|
101
|
+
def model_type
|
102
|
+
SBF::Client::Donation::RecipientType::EVENT
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class FullFund < SBF::Client::FullFund
|
107
|
+
attr_reader :model_type
|
108
|
+
|
109
|
+
def model_type
|
110
|
+
SBF::Client::Donation::RecipientType::FUND
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class PartialFund < SBF::Client::PartialFund
|
115
|
+
attr_reader :model_type
|
116
|
+
|
117
|
+
def model_type
|
118
|
+
SBF::Client::Donation::RecipientType::FUND
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class FullMemorial < SBF::Client::FullMemorial
|
123
|
+
attr_reader :model_type
|
124
|
+
|
125
|
+
def model_type
|
126
|
+
SBF::Client::Donation::RecipientType::MEMORIAL
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class PartialMemorial < SBF::Client::PartialMemorial
|
131
|
+
attr_reader :model_type
|
132
|
+
|
133
|
+
def model_type
|
134
|
+
SBF::Client::Donation::RecipientType::MEMORIAL
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class SBFGeneralFund < SBF::Client::BaseEntity
|
139
|
+
attr_reader :model_type
|
140
|
+
|
141
|
+
def id
|
142
|
+
nil
|
143
|
+
end
|
144
|
+
|
145
|
+
def model_type
|
146
|
+
SBF::Client::Donation::RecipientType::SBF_GENERAL_FUND
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
class RecognitionCard < SBF::Client::BaseEntity
|
151
|
+
class Recipient < SBF::Client::BaseEntity
|
152
|
+
attr_reader :name
|
153
|
+
entity_attr_accessor :name_pieces, SBF::Client::NamePieces
|
154
|
+
entity_attr_accessor :address, SBF::Client::Address
|
155
|
+
end
|
156
|
+
|
157
|
+
entity_attr_accessor :recipient, SBF::Client::Donation::RecognitionCard::Recipient
|
158
|
+
attr_accessor :salutation, :message, :signature
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.generate_special_donation_type(entity)
|
162
|
+
return if entity.nil?
|
163
|
+
|
164
|
+
# Calculate the country and state
|
165
|
+
country, state = get_country_and_state_for_special_donation_type(entity)
|
166
|
+
|
167
|
+
# state only applicable for United States, others only use international value
|
168
|
+
unless country.empty?
|
169
|
+
if country.to_sym == SBF::Client::Country.list[SBF::Client::Country::UNITED_STATES]
|
170
|
+
state_value = state.to_s.upcase.to_sym
|
171
|
+
if !state_value.empty? && SBF::Client::Donation::SpecialDonationType.const_defined?(state_value)
|
172
|
+
return SBF::Client::Donation::SpecialDonationType.const_get(state_value)
|
173
|
+
|
174
|
+
else
|
175
|
+
return SBF::Client::Donation::SpecialDonationType::NO_STATE
|
176
|
+
end
|
177
|
+
|
178
|
+
else
|
179
|
+
international_value = "INT_#{country}".upcase.to_sym
|
180
|
+
if SBF::Client::Donation::SpecialDonationType.const_defined?(international_value)
|
181
|
+
return SBF::Client::Donation::SpecialDonationType.const_get(international_value)
|
182
|
+
|
183
|
+
else
|
184
|
+
return SBF::Client::Donation::SpecialDonationType::INTERNATIONAL
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
SBF::Client::Donation::SpecialDonationType::GENERAL_EVENT
|
191
|
+
end
|
192
|
+
|
193
|
+
def self.get_country_and_state_for_special_donation_type(entity)
|
194
|
+
case entity
|
195
|
+
when SBF::Client::Search::Participant, SBF::Client::Search::Fundraiser, SBF::Client::Search::Team, SBF::Client::Search::Event
|
196
|
+
if entity.event_id == 1
|
197
|
+
# Look up the person since it is a Search::Participant and doesn't have sub-objects
|
198
|
+
response = SBF::Client::Person.get(entity.profile_id)
|
199
|
+
person = response.data
|
200
|
+
raise SBF::Client::Error, 'Invalid Entity' if response.error? || person.nil?
|
201
|
+
|
202
|
+
# Get country and state from the person
|
203
|
+
country = person.addresses.primary.country
|
204
|
+
state = (country.to_sym == SBF::Client::Country.list[SBF::Client::Country::UNITED_STATES] ? person.addresses.primary.state : '')
|
205
|
+
|
206
|
+
else
|
207
|
+
country = (defined?(entity.country).nil? ? nil : entity.country)
|
208
|
+
state = (defined?(entity.state).nil? ? nil : entity.state)
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
return [country, state]
|
213
|
+
|
214
|
+
when SBF::Client::Participant
|
215
|
+
return get_event_country_and_state_for_special_donation_type(entity.event, entity.person)
|
216
|
+
|
217
|
+
when SBF::Client::Fundraiser
|
218
|
+
return [entity.venue.location.address.country, entity.venue.location.address.state]
|
219
|
+
|
220
|
+
when SBF::Client::Team
|
221
|
+
return get_event_country_and_state_for_special_donation_type(entity.event)
|
222
|
+
|
223
|
+
when SBF::Client::Event
|
224
|
+
return get_event_country_and_state_for_special_donation_type(entity)
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
228
|
+
private_class_method :get_country_and_state_for_special_donation_type
|
229
|
+
|
230
|
+
def self.get_event_country_and_state_for_special_donation_type(event, person = nil)
|
231
|
+
if event.virtual?
|
232
|
+
raise SBF::Client::Error, 'Invalid Entity' if person.nil?
|
233
|
+
|
234
|
+
# Get country and state from the person
|
235
|
+
country = person.addresses.primary.country
|
236
|
+
state = (country.to_sym == SBF::Client::Country.list[SBF::Client::Country::UNITED_STATES] ? person.addresses.primary.state : '')
|
237
|
+
|
238
|
+
else
|
239
|
+
country = (defined?(event.venue.location.address.country).nil? ? nil : event.venue.location.address.country)
|
240
|
+
state = (defined?(event.venue.location.address.state).nil? ? nil : event.venue.location.address.state)
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
[country, state]
|
245
|
+
end
|
246
|
+
private_class_method :get_event_country_and_state_for_special_donation_type
|
247
|
+
end
|
248
|
+
|
249
|
+
class PartialDonation < SBF::Client::Donation
|
250
|
+
attr_accessor :id
|
251
|
+
end
|
252
|
+
|
253
|
+
class FullDonation < SBF::Client::Donation
|
254
|
+
attr_accessor :id
|
255
|
+
attr_accessor :status
|
256
|
+
attr_accessor :amount
|
257
|
+
attr_accessor :display_name
|
258
|
+
multitype_attr_accessor(
|
259
|
+
:recipient,
|
260
|
+
[
|
261
|
+
[
|
262
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::PARTICIPANT },
|
263
|
+
'SBF::Client::Donation::FullParticipant',
|
264
|
+
'SBF::Client::Donation::PartialParticipant'
|
265
|
+
],
|
266
|
+
[
|
267
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::FUNDRAISER },
|
268
|
+
'SBF::Client::Donation::FullFundraiser',
|
269
|
+
'SBF::Client::Donation::PartialFundraiser'
|
270
|
+
],
|
271
|
+
[
|
272
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::TEAM },
|
273
|
+
'SBF::Client::Donation::FullTeam',
|
274
|
+
'SBF::Client::Donation::PartialTeam'
|
275
|
+
],
|
276
|
+
[
|
277
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::EVENT },
|
278
|
+
'SBF::Client::Donation::FullEvent',
|
279
|
+
'SBF::Client::Donation::PartialEvent'
|
280
|
+
],
|
281
|
+
[
|
282
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::FUND },
|
283
|
+
'SBF::Client::Donation::FullFund',
|
284
|
+
'SBF::Client::Donation::PartialFund'
|
285
|
+
],
|
286
|
+
[
|
287
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::MEMORIAL },
|
288
|
+
'SBF::Client::Donation::FullMemorial',
|
289
|
+
'SBF::Client::Donation::PartialMemorial'
|
290
|
+
],
|
291
|
+
[
|
292
|
+
->(v) { v[:model_type] == SBF::Client::Donation::RecipientType::SBF_GENERAL_FUND },
|
293
|
+
'SBF::Client::Donation::SBFGeneralFund'
|
294
|
+
]
|
295
|
+
],
|
296
|
+
optional: true
|
297
|
+
)
|
298
|
+
|
299
|
+
attr_accessor :is_unrecognized, :special_donation_type
|
300
|
+
multitype_attr_accessor(
|
301
|
+
:donor,
|
302
|
+
[
|
303
|
+
[
|
304
|
+
->(v) { v[:type] == SBF::Client::Donation::DonorType::INDIVIDUAL },
|
305
|
+
'SBF::Client::FullPerson',
|
306
|
+
'SBF::Client::PartialPerson'
|
307
|
+
],
|
308
|
+
[
|
309
|
+
->(v) { v[:type] == SBF::Client::Donation::DonorType::BUSINESS },
|
310
|
+
'SBF::Client::FullOrganization',
|
311
|
+
'SBF::Client::PartialOrganization'
|
312
|
+
],
|
313
|
+
[
|
314
|
+
->(v) { v[:type] == SBF::Client::Donation::DonorType::ORGANIZATION_FOUNDATION },
|
315
|
+
'SBF::Client::FullOrganization',
|
316
|
+
'SBF::Client::PartialOrganization'
|
317
|
+
]
|
318
|
+
],
|
319
|
+
optional: true
|
320
|
+
)
|
321
|
+
|
322
|
+
multitype_attr_accessor(
|
323
|
+
:submitter,
|
324
|
+
[
|
325
|
+
[
|
326
|
+
->(v) { v[:type] == SBF::Client::Donation::DonorType::INDIVIDUAL },
|
327
|
+
'SBF::Client::FullPerson',
|
328
|
+
'SBF::Client::PartialPerson'
|
329
|
+
],
|
330
|
+
[
|
331
|
+
->(v) { v[:type] == SBF::Client::Donation::DonorType::BUSINESS },
|
332
|
+
'SBF::Client::FullOrganization',
|
333
|
+
'SBF::Client::PartialOrganization'
|
334
|
+
],
|
335
|
+
[
|
336
|
+
->(v) { v[:type] == SBF::Client::Donation::DonorType::ORGANIZATION_FOUNDATION },
|
337
|
+
'SBF::Client::FullOrganization',
|
338
|
+
'SBF::Client::PartialOrganization'
|
339
|
+
]
|
340
|
+
],
|
341
|
+
optional: true
|
342
|
+
)
|
343
|
+
|
344
|
+
entity_attr_accessor :employer_matching, 'SBF::Client::Donation::EmployerMatching'
|
345
|
+
attr_accessor :foreign_beneficiary_country
|
346
|
+
attr_accessor :promotional_code
|
347
|
+
entity_attr_accessor :recurring_gift, 'SBF::Client::FullRecurringGift'
|
348
|
+
multitype_attr_accessor(
|
349
|
+
:payment_details,
|
350
|
+
[
|
351
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::CREDIT_CARD }, 'SBF::Client::Payment::CreditCardDetails'],
|
352
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::CASH }, 'SBF::Client::Payment::CashDetails'],
|
353
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::CHECK }, 'SBF::Client::Payment::CheckDetails'],
|
354
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::MONEY_ORDER }, 'SBF::Client::Payment::MoneyOrderDetails'],
|
355
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::NONCE }, 'SBF::Client::Payment::NonceDetails'],
|
356
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::WIRE_TRANSFER }, 'SBF::Client::Payment::WireTransferDetails'],
|
357
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::RECURRING_GIFTS }, 'SBF::Client::Payment::BraintreeSubscriptionDetails'],
|
358
|
+
[->(v) { v[:type] == SBF::Client::Payment::Type::UNKNOWN }, 'SBF::Client::Payment::UnknownDetails']
|
359
|
+
]
|
360
|
+
)
|
361
|
+
entity_attr_accessor :tribute, 'SBF::Client::Donation::Tribute'
|
362
|
+
entity_attr_accessor :recognition_card, 'SBF::Client::Donation::RecognitionCard'
|
363
|
+
attr_accessor :collected_at
|
364
|
+
attr_accessor :created_at, :modified_at, :modified_by, :how_created
|
365
|
+
attr_accessor :is_thanked
|
366
|
+
|
367
|
+
def amount=(value)
|
368
|
+
@amount = value.to_s.gsub(/[^0-9\.]/, '').to_f
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|