Class: Io::Flow::V0::Models::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents operating calendar and holidays of a center

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Schedule

Returns a new instance of Schedule.



60311
60312
60313
60314
60315
60316
60317
60318
60319
60320
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60311

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:holiday, :exception], 'Schedule')
  @calendar = (x = opts.delete(:calendar); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Calendar) ? x : ::Io::Flow::V0::Models::Calendar.apply(x)))
  @holiday = (x = opts.delete(:holiday); x.is_a?(::Io::Flow::V0::Models::HolidayCalendar) ? x : ::Io::Flow::V0::Models::HolidayCalendar.apply(x))
  @exception = HttpClient::Preconditions.assert_class('exception', opts.delete(:exception), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Exception) ? x : ::Io::Flow::V0::Models::Exception.new(x)) }
  @cutoff = (x = opts.delete(:cutoff); x.nil? ? nil : HttpClient::Preconditions.assert_class('cutoff', x, String))
  @min_lead_time = (x = opts.delete(:min_lead_time); x.nil? ? nil : HttpClient::Preconditions.assert_class('min_lead_time', x, Integer))
  @max_lead_time = (x = opts.delete(:max_lead_time); x.nil? ? nil : HttpClient::Preconditions.assert_class('max_lead_time', x, Integer))
end

Instance Attribute Details

#calendarObject (readonly)

Returns the value of attribute calendar.



60309
60310
60311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60309

def calendar
  @calendar
end

#cutoffObject (readonly)

Returns the value of attribute cutoff.



60309
60310
60311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60309

def cutoff
  @cutoff
end

#exceptionObject (readonly)

Returns the value of attribute exception.



60309
60310
60311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60309

def exception
  @exception
end

#holidayObject (readonly)

Returns the value of attribute holiday.



60309
60310
60311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60309

def holiday
  @holiday
end

#max_lead_timeObject (readonly)

Returns the value of attribute max_lead_time.



60309
60310
60311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60309

def max_lead_time
  @max_lead_time
end

#min_lead_timeObject (readonly)

Returns the value of attribute min_lead_time.



60309
60310
60311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60309

def min_lead_time
  @min_lead_time
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



60326
60327
60328
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60326

def copy(incoming={})
  Schedule.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



60330
60331
60332
60333
60334
60335
60336
60337
60338
60339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60330

def to_hash
  {
    :calendar => calendar.nil? ? nil : calendar.value,
    :holiday => holiday.value,
    :exception => exception.map { |o| o.to_hash },
    :cutoff => cutoff,
    :min_lead_time => min_lead_time,
    :max_lead_time => max_lead_time
  }
end

#to_jsonObject



60322
60323
60324
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60322

def to_json
  JSON.dump(to_hash)
end