class Citrix::Training::Serializer::Training

Attributes

attributes[RW]

Set attributes that can be (de)serialized.

Public Instance Methods

deserialize() click to toggle source
# File lib/citrix/training/serializer/training.rb, line 24
def deserialize
  {
    key: attributes["trainingKey"],
    name: attributes["name"],
    description: attributes["description"],
    timezone: attributes["timeZone"],
    dates: deserialize_dates(attributes["times"] || []),
    web_registration: !attributes["registrationSettings"]["disableWebRegistration"],
    confirmation_email: !attributes["registrationSettings"]["disableConfirmationEmail"]
  }
end
serialize() click to toggle source
# File lib/citrix/training/serializer/training.rb, line 10
def serialize
  {
    name: attributes[:name],
    description: attributes[:description],
    timeZone: attributes[:timezone],
    times: (attributes[:dates] || []).map(&:serialize),
    organizers: (attributes[:organizers] || []).map(&:key),
    registrationSettings: {
      disableWebRegistration: !attributes.fetch(:web_registration, true),
      disableConfirmationEmail: !attributes.fetch(:confirmation_email, true),
    }
  }
end

Private Instance Methods

deserialize_dates(dates) click to toggle source
# File lib/citrix/training/serializer/training.rb, line 38
def deserialize_dates(dates)
  dates.map do |date|
    Resource::TrainingDate.new(
      Time.parse(date["startDate"]),
      Time.parse(date["endDate"])
    )
  end
end