Class: Io::Flow::V0::Models::FulfillmentCancellationForm

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

Overview

Changing an order for the purpose of cancelling specific line quantities

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ FulfillmentCancellationForm

Returns a new instance of FulfillmentCancellationForm.



40776
40777
40778
40779
40780
40781
40782
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40776

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:reason, :lines], 'FulfillmentCancellationForm')
  @change_source = (x = (x = opts.delete(:change_source); x.nil? ? "fulfillment" : x); x.is_a?(::Io::Flow::V0::Models::OrderChangeSource) ? x : ::Io::Flow::V0::Models::OrderChangeSource.apply(x))
  @reason = (x = opts.delete(:reason); x.is_a?(::Io::Flow::V0::Models::CancelReason) ? x : ::Io::Flow::V0::Models::CancelReason.apply(x))
  @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FulfillmentLineCancelForm) ? x : ::Io::Flow::V0::Models::FulfillmentLineCancelForm.new(x)) }
end

Instance Attribute Details

#change_sourceObject (readonly)

Returns the value of attribute change_source.



40774
40775
40776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40774

def change_source
  @change_source
end

#linesObject (readonly)

Returns the value of attribute lines.



40774
40775
40776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40774

def lines
  @lines
end

#reasonObject (readonly)

Returns the value of attribute reason.



40774
40775
40776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40774

def reason
  @reason
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40788
40789
40790
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40788

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

#to_hashObject



40792
40793
40794
40795
40796
40797
40798
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40792

def to_hash
  {
    :change_source => change_source.value,
    :reason => reason.value,
    :lines => lines.map { |o| o.to_hash }
  }
end

#to_jsonObject



40784
40785
40786
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40784

def to_json
  JSON.dump(to_hash)
end