Sha256: 3899b254294f79d5f0ea8c7f03fca7f2c43c1d9204c5d0442d4f6f991d215378

Contents?: true

Size: 1.87 KB

Versions: 11

Compression:

Stored size: 1.87 KB

Contents

#
# registrant.rb
# ConstantContact
#
# Copyright (c) 2013 Constant Contact. All rights reserved.

module ConstantContact
  module Components
    class Registrant < Component
      attr_accessor :attendance_status, :email, :first_name, :guest_count, :id, :last_name, :payment_status,
                    :registration_date, :registration_status, :ticket_id, :updated_date,
                    :payment_summary, :promo_code, :sections, :guests

      # Factory method to create an event Registrant object from a hash
      # @param [Hash] props - hash of properties to create object from
      # @return [Registrant]
      def self.create(props)
        obj = Registrant.new
        if props
          props.each do |key, value|
            key = key.to_s
            if key == 'payment_summary'
              obj.payment_summary = Components::EventSpot::PaymentSummary.create(value)
            elsif key == 'sections'
              obj.sections = value.collect{|section| Components::EventSpot::RegistrantSection.create(section) }
            elsif key == 'promo_code'
              obj.promo_code = Components::EventSpot::RegistrantPromoCode.create(value)
            elsif key == 'guests'
              value = value["guest_info"] || []
              obj.guests = value.collect{|guest| Components::EventSpot::Guest.create(guest) }
            else
              obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
            end
          end
        end
        obj
      end

      # Factory method to create an event Registrant summary object from a hash
      # @param [Hash] props - hash of properties to create object from
      # @return [Registrant]
      def self.create_summary(props)
        obj = Registrant.new
        props.each do |key, value|
          key = key.to_s
          obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
        end if props
        obj
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
constantcontact-4.0.0 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-3.0.0 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-2.2.1 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-ruby-2.2.1 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-ruby-2.2.0 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-2.2.0 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-2.1.0 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-2.0.1 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-2.0.0 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-1.3.2 lib/constantcontact/components/event_spot/registrant.rb
constantcontact-1.2.0 lib/constantcontact/components/event_spot/registrant.rb