Class: Io::Flow::V0::Models::DutyItem

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 = {}) ⇒ DutyItem

Returns a new instance of DutyItem.



40419
40420
40421
40422
40423
40424
40425
40426
40427
40428
40429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40419

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :name, :customs_description], 'DutyItem')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @name = (x = opts.delete(:name); x.is_a?(::Io::Flow::V0::Models::TradeAgreementName) ? x : ::Io::Flow::V0::Models::TradeAgreementName.apply(x))
  @product_id = (x = opts.delete(:product_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('product_id', x, String))
  @sku = (x = opts.delete(:sku); x.nil? ? nil : HttpClient::Preconditions.assert_class('sku', x, String))
  @customs_description = HttpClient::Preconditions.assert_class('customs_description', opts.delete(:customs_description), String)
  @origin_criteria = (x = opts.delete(:origin_criteria); x.nil? ? nil : HttpClient::Preconditions.assert_class('origin_criteria', x, String))
  @approvals = (x = opts.delete(:approvals); x.nil? ? nil : HttpClient::Preconditions.assert_class('approvals', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DutyItemApproval) ? x : ::Io::Flow::V0::Models::DutyItemApproval.new(x)) })
end

Instance Attribute Details

#approvalsObject (readonly)

Returns the value of attribute approvals.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def approvals
  @approvals
end

#customs_descriptionObject (readonly)

Returns the value of attribute customs_description.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def customs_description
  @customs_description
end

#nameObject (readonly)

Returns the value of attribute name.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def number
  @number
end

#origin_criteriaObject (readonly)

Returns the value of attribute origin_criteria.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def origin_criteria
  @origin_criteria
end

#product_idObject (readonly)

Returns the value of attribute product_id.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def product_id
  @product_id
end

#skuObject (readonly)

Returns the value of attribute sku.



40417
40418
40419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40417

def sku
  @sku
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40435
40436
40437
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40435

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

#to_hashObject



40439
40440
40441
40442
40443
40444
40445
40446
40447
40448
40449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40439

def to_hash
  {
    :number => number,
    :name => name.value,
    :product_id => product_id,
    :sku => sku,
    :customs_description => customs_description,
    :origin_criteria => origin_criteria,
    :approvals => approvals.nil? ? nil : approvals.map { |o| o.to_hash }
  }
end

#to_jsonObject



40431
40432
40433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40431

def to_json
  JSON.dump(to_hash)
end