Class: Io::Flow::V0::Models::AvailableService

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

Overview

Representation of a service level available at a center and the special pickup times during the week. If pickup schedules are not provided, assumption is once a day during the weekdays.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AvailableService

Returns a new instance of AvailableService.



29447
29448
29449
29450
29451
29452
29453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29447

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:service], 'AvailableService')
  @service = HttpClient::Preconditions.assert_class('service', opts.delete(:service), String)
  @scheduled_pickups = (x = opts.delete(:scheduled_pickups); x.nil? ? nil : HttpClient::Preconditions.assert_class('scheduled_pickups', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ScheduledPickup) ? x : ::Io::Flow::V0::Models::ScheduledPickup.new(x)) })
  @lead_days = (x = opts.delete(:lead_days); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::NumberRange) ? x : ::Io::Flow::V0::Models::NumberRange.new(x)))
end

Instance Attribute Details

#lead_daysObject (readonly)

Returns the value of attribute lead_days.



29445
29446
29447
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29445

def lead_days
  @lead_days
end

#scheduled_pickupsObject (readonly)

Returns the value of attribute scheduled_pickups.



29445
29446
29447
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29445

def scheduled_pickups
  @scheduled_pickups
end

#serviceObject (readonly)

Returns the value of attribute service.



29445
29446
29447
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29445

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



29459
29460
29461
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29459

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

#to_hashObject



29463
29464
29465
29466
29467
29468
29469
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29463

def to_hash
  {
    :service => service,
    :scheduled_pickups => scheduled_pickups.nil? ? nil : scheduled_pickups.map { |o| o.to_hash },
    :lead_days => lead_days.nil? ? nil : lead_days.to_hash
  }
end

#to_jsonObject



29455
29456
29457
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29455

def to_json
  JSON.dump(to_hash)
end