Class: Io::Flow::V0::Models::Return

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

Returns a new instance of Return.



59211
59212
59213
59214
59215
59216
59217
59218
59219
59220
59221
59222
59223
59224
59225
59226
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59211

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :service, :items, :origin, :destination, :source], 'Return')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ReturnOrderReference) ? x : ::Io::Flow::V0::Models::ReturnOrderReference.new(x)))
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(x))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ReturnLineItem) ? x : ::Io::Flow::V0::Models::ReturnLineItem.new(x)) }
  @labels = (x = opts.delete(:labels); x.nil? ? nil : HttpClient::Preconditions.assert_class('labels', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShippingLabel) ? x : ::Io::Flow::V0::Models::ShippingLabel.new(x)) })
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @source = (x = opts.delete(:source); x.is_a?(::Io::Flow::V0::Models::ReturnSource) ? x : ::Io::Flow::V0::Models::ReturnSource.from_json(x))
  @tracking_status = (x = opts.delete(:tracking_status); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ReturnTrackingStatus) ? x : ::Io::Flow::V0::Models::ReturnTrackingStatus.apply(x)))
  @tracking_status_timestamp = (x = opts.delete(:tracking_status_timestamp); x.nil? ? nil : HttpClient::Preconditions.assert_class('tracking_status_timestamp', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @carrier_tracking_number = (x = opts.delete(:carrier_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('carrier_tracking_number', x, String))
end

Instance Attribute Details

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def carrier_tracking_number
  @carrier_tracking_number
end

#destinationObject (readonly)

Returns the value of attribute destination.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def destination
  @destination
end

#idObject (readonly)

Returns the value of attribute id.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def key
  @key
end

#labelsObject (readonly)

Returns the value of attribute labels.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def labels
  @labels
end

#orderObject (readonly)

Returns the value of attribute order.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def order
  @order
end

#originObject (readonly)

Returns the value of attribute origin.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def origin
  @origin
end

#serviceObject (readonly)

Returns the value of attribute service.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def service
  @service
end

#sourceObject (readonly)

Returns the value of attribute source.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def source
  @source
end

#tracking_statusObject (readonly)

Returns the value of attribute tracking_status.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def tracking_status
  @tracking_status
end

#tracking_status_timestampObject (readonly)

Returns the value of attribute tracking_status_timestamp.



59209
59210
59211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59209

def tracking_status_timestamp
  @tracking_status_timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



59232
59233
59234
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59232

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

#to_hashObject



59236
59237
59238
59239
59240
59241
59242
59243
59244
59245
59246
59247
59248
59249
59250
59251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59236

def to_hash
  {
    :id => id,
    :key => key,
    :order => order.nil? ? nil : order.to_hash,
    :service => service.to_hash,
    :items => items.map { |o| o.to_hash },
    :labels => labels.nil? ? nil : labels.map { |o| o.to_hash },
    :origin => origin.to_hash,
    :destination => destination.to_hash,
    :source => source.to_hash,
    :tracking_status => tracking_status.nil? ? nil : tracking_status.value,
    :tracking_status_timestamp => tracking_status_timestamp,
    :carrier_tracking_number => carrier_tracking_number
  }
end

#to_jsonObject



59228
59229
59230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59228

def to_json
  JSON.dump(to_hash)
end