Class: WCC::Arena::ProfileMemberSaveData

Inherits:
Object
  • Object
show all
Defined in:
lib/wcc/arena/profile_member_save.rb

Constant Summary collapse

TIME_FORMAT =
"%Y-%m-%dT%H:%M:%S.%L"
NEVER =
Time.local(9999, 12, 31, 23, 59, 59, 997000)
ATTRIBUTE_MAP =
{
  "active_at" => "DateActive",
  "pending_at" => "DatePending",
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ProfileMemberSaveData

Returns a new instance of ProfileMemberSaveData.



51
52
53
# File 'lib/wcc/arena/profile_member_save.rb', line 51

def initialize(attributes={})
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



41
42
43
# File 'lib/wcc/arena/profile_member_save.rb', line 41

def attributes
  @attributes
end

Instance Method Details

#arena_attributes(now = Time.now) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/wcc/arena/profile_member_save.rb', line 55

def arena_attributes(now = Time.now)
  {
    "DateActive" => now,
    "DateDormant" => NEVER,
    "DateInReview" => NEVER,
    "DatePending" => now,
    "MemberNotes" => nil,
    "PrerequisitesMet" => false,
    "SourceID" => 272,
    "SourceValue" => "Unknown",
    "StatusID" => 255,
    "StatusReason" => nil,
    "StatusValue" => "Connected",
  }.merge(mapped_attributes)
end

#to_xmlObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/wcc/arena/profile_member_save.rb', line 71

def to_xml
  doc = Nokogiri::XML::Builder.new
  doc.ProfileMember do |root|
    arena_attributes.each do |key, value|
      case value
      when nil
        root.send key
      when Time
        root.send key, value.strftime(TIME_FORMAT)
      else
        root.send key, value
      end
    end
  end
  doc.to_xml
end