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.



37200
37201
37202
37203
37204
37205
37206
37207
37208
37209
37210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37200

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.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def approvals
  @approvals
end

#customs_descriptionObject (readonly)

Returns the value of attribute customs_description.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def customs_description
  @customs_description
end

#nameObject (readonly)

Returns the value of attribute name.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def number
  @number
end

#origin_criteriaObject (readonly)

Returns the value of attribute origin_criteria.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def origin_criteria
  @origin_criteria
end

#product_idObject (readonly)

Returns the value of attribute product_id.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def product_id
  @product_id
end

#skuObject (readonly)

Returns the value of attribute sku.



37198
37199
37200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37198

def sku
  @sku
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37216
37217
37218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37216

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

#to_hashObject



37220
37221
37222
37223
37224
37225
37226
37227
37228
37229
37230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37220

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



37212
37213
37214
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37212

def to_json
  JSON.dump(to_hash)
end