Class: Io::Flow::V0::Models::RatecardForm

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RatecardForm

Returns a new instance of RatecardForm.



57453
57454
57455
57456
57457
57458
57459
57460
57461
57462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57453

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:direction, :effective_at, :origination_zones, :service], 'RatecardForm')
  @direction = (x = opts.delete(:direction); x.is_a?(::Io::Flow::V0::Models::Direction) ? x : ::Io::Flow::V0::Models::Direction.apply(x))
  @effective_at = HttpClient::Preconditions.assert_class('effective_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:effective_at)), DateTime)
  @origination_zones = HttpClient::Preconditions.assert_class('origination_zones', opts.delete(:origination_zones), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Zone) ? x : ::Io::Flow::V0::Models::Zone.new(x)) }
  @service = HttpClient::Preconditions.assert_class('service', opts.delete(:service), String)
  @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, String))
  @ratecard_owner = (x = (x = opts.delete(:ratecard_owner); x.nil? ? "flow" : x); x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x))
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



57451
57452
57453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57451

def direction
  @direction
end

#effective_atObject (readonly)

Returns the value of attribute effective_at.



57451
57452
57453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57451

def effective_at
  @effective_at
end

#numberObject (readonly)

Returns the value of attribute number.



57451
57452
57453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57451

def number
  @number
end

#origination_zonesObject (readonly)

Returns the value of attribute origination_zones.



57451
57452
57453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57451

def origination_zones
  @origination_zones
end

#ratecard_ownerObject (readonly)

Returns the value of attribute ratecard_owner.



57451
57452
57453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57451

def ratecard_owner
  @ratecard_owner
end

#serviceObject (readonly)

Returns the value of attribute service.



57451
57452
57453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57451

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



57468
57469
57470
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57468

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

#to_hashObject



57472
57473
57474
57475
57476
57477
57478
57479
57480
57481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57472

def to_hash
  {
    :direction => direction.value,
    :effective_at => effective_at,
    :origination_zones => origination_zones.map { |o| o.to_hash },
    :service => service,
    :number => number,
    :ratecard_owner => ratecard_owner.value
  }
end

#to_jsonObject



57464
57465
57466
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57464

def to_json
  JSON.dump(to_hash)
end