Sha256: 4df01980d94e9d88aefa6c3a38ec5a0bea00b204b5a10728fe23608254a2e53c

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

module Centaman
  class Object::AttendeeDetail < Centaman::Object
    attr_accessor :ticket_type, :ticket_id, :udfs

    def after_init(args= {})
      @ticket_type = args.fetch(:ticket_type, nil)
      @ticket_id = args.fetch(:ticket_id, nil)
      @udfs = set_attendee_udfs(args[:udfs] || [])
    end

    def json
      {
        'AttendeeFirstName': first_name,
        'AttendeeLastName': last_name,
        'AttendeeMemberCode': member_code || ''
      }.as_json
    end

    def set_attendee_udfs(attendee_udfs)
      attendee_udfs.map do |u|
        Centaman::Object::Udf.new(
          is_email: u[:is_email],
          value: u[:value],
          field_name: u[:field_name],
          field_type: u[:field_type],
          field_length: u[:field_length],
          tab_name: u[:tab_name]
        )
      end
    end

    def full_name
      [first_name, last_name].compact.join(' ')
    end

    def attributes
      [
        Centaman::Attribute.new(
          centaman_key: 'MemberCode',
          app_key: :member_code,
          type: :integer
        ),
        Centaman::Attribute.new(
          centaman_key: 'FirstName',
          app_key: :first_name,
          type: :string
        ),
        Centaman::Attribute.new(
          centaman_key: 'LastName',
          app_key: :last_name,
          type: :string
        ),
        Centaman::Attribute.new(
          centaman_key: 'Email',
          app_key: :email,
          type: :string
        )
      ]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
centaman-8.0.0 lib/centaman/object/attendee_detail.rb
centaman-7.0.5 lib/centaman/object/attendee_detail.rb
centaman-7.0.4 lib/centaman/object/attendee_detail.rb
centaman-7.0.3 lib/centaman/object/attendee_detail.rb
centaman-7.0.2 lib/centaman/object/attendee_detail.rb
centaman-7.0.1 lib/centaman/object/attendee_detail.rb
centaman-7.0.0 lib/centaman/object/attendee_detail.rb