Class: SBF::Client::Donation

Inherits:
TopLevelEntity show all
Includes:
Entities::DefaultCacheable
Defined in:
lib/stbaldricks/entities/donation.rb,
lib/stbaldricks/entities/donation/status.rb,
lib/stbaldricks/entities/donation/donor_type.rb,
lib/stbaldricks/entities/donation/promo_code.rb,
lib/stbaldricks/entities/donation/how_created.rb,
lib/stbaldricks/entities/donation/payment_type.rb,
lib/stbaldricks/entities/donation/recipient_type.rb,
lib/stbaldricks/entities/donation/submitter_type.rb,
lib/stbaldricks/entities/donation/special_donation_type.rb

Direct Known Subclasses

FullDonation, PartialDonation

Defined Under Namespace

Modules: DonorType, HowCreated, PaymentType, PromoCode, RecipientType, SpecialDonationType, Status, SubmitterType Classes: EmployerMatching, FullEvent, FullFund, FullFundraiser, FullMemorial, FullParticipant, FullTeam, PartialEvent, PartialFund, PartialFundraiser, PartialMemorial, PartialParticipant, PartialTeam, RecognitionCard, SBFGeneralFund, Tribute

Constant Summary

Constants inherited from TopLevelEntity

TopLevelEntity::DEFAULT_CLASS_ACTIONS, TopLevelEntity::DEFAULT_CRUD_ACTIONS, TopLevelEntity::DEFAULT_ENDPOINT, TopLevelEntity::DEFAULT_INSTANCE_ACTIONS

Constants inherited from BaseEntity

BaseEntity::ELSE

Instance Attribute Summary

Attributes inherited from BaseEntity

#errors

Class Method Summary collapse

Methods included from Entities::DefaultCacheable

included

Methods inherited from TopLevelEntity

_endpoint, action, actions, blacklist_action, class_action, define_endpoint, endpoint, #endpoint, instance_action

Methods included from Entities::Cacheable

#cache_id, included

Methods inherited from BaseEntity

#add_errors, allow_instantiation?, attr_accessor, attr_reader, attr_writer, attributes, #attributes=, collection_attributes, entity_attr_accessor, entity_attr_reader, entity_attr_writer, entity_attributes, entity_collection_attr_accessor, entity_collection_attr_reader, entity_collection_attr_writer, inherited, #initialize, #model_name, multitype_attr_accessor, multitype_attr_reader, multitype_attr_writer, multitype_collection_attr_accessor, multitype_collection_attr_reader, multitype_collection_attr_writer, #not_provided_attributes, optional_attributes, #persisted?, #to_hash, #to_json

Constructor Details

This class inherits a constructor from SBF::Client::BaseEntity

Class Method Details

.generate_special_donation_type(entity) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/stbaldricks/entities/donation.rb', line 161

def self.generate_special_donation_type(entity)
  return if entity.nil?

  # Calculate the country and state
  country, state = get_country_and_state_for_special_donation_type(entity)

  # state only applicable for United States, others only use international value
  unless country.empty?
    if country.to_sym == SBF::Client::Country.list[SBF::Client::Country::UNITED_STATES]
      state_value = state.to_s.upcase.to_sym
      if !state_value.empty? && SBF::Client::Donation::SpecialDonationType.const_defined?(state_value)
        return SBF::Client::Donation::SpecialDonationType.const_get(state_value)

      else
        return SBF::Client::Donation::SpecialDonationType::NO_STATE
      end

    else
      international_value = "INT_#{country}".upcase.to_sym
      if SBF::Client::Donation::SpecialDonationType.const_defined?(international_value)
        return SBF::Client::Donation::SpecialDonationType.const_get(international_value)

      else
        return SBF::Client::Donation::SpecialDonationType::INTERNATIONAL

      end
    end
  end

  SBF::Client::Donation::SpecialDonationType::GENERAL_EVENT
end