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/payment_gateway.rb,
lib/stbaldricks/entities/donation/special_donation_type.rb

Direct Known Subclasses

FullDonation, PartialDonation

Defined Under Namespace

Modules: DonorType, HowCreated, PaymentGateway, PaymentType, PromoCode, RecipientType, SpecialDonationType, Status, SubmitterType Classes: EmployerMatched, EmployerMatching, FullEvent, FullFund, FullFundraiser, FullMemorial, FullOrganization, FullParticipant, FullPerson, FullTeam, PartialEvent, PartialFund, PartialFundraiser, PartialMemorial, PartialOrganization, PartialParticipant, PartialPerson, 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

allow_instantiation?, attr_accessor, attr_reader, attr_writer, collection_attributes, defined_attributes, #destroyed?, #dirty_data, entity_attr_accessor, entity_attr_reader, entity_attr_writer, entity_attributes, entity_collection_attr_accessor, entity_collection_attr_reader, entity_collection_attr_writer, #error, inherited, #initialize, #keys_hash, #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?, #reload!, #reload_recursive, #rollback!, #to_hash, #to_json, #to_partial

Methods included from EntityResponseConcern

#add_errors, #data, #error?, #errors?, #errors_http_code=, #http_code, #success?

Constructor Details

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

Class Method Details

.generate_special_donation_type(entity) ⇒ Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/stbaldricks/entities/donation.rb', line 214

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)
      end

      return SBF::Client::Donation::SpecialDonationType::NO_STATE
    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)
      end

      return SBF::Client::Donation::SpecialDonationType::INTERNATIONAL
    end
  end

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