Class: Io::Flow::V0::Models::ReturnPolicy

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

Overview

A global return policy allows the user to select 1 or more items by query and to globally mark those items as non-returnable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ReturnPolicy



56976
56977
56978
56979
56980
56981
56982
56983
56984
56985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56976

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :q, :query, :status, :statistics], 'ReturnPolicy')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String)
  @query = (x = opts.delete(:query); x.is_a?(::Io::Flow::V0::Models::Query) ? x : ::Io::Flow::V0::Models::Query.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ReturnItemStatus) ? x : ::Io::Flow::V0::Models::ReturnItemStatus.apply(x))
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
  @statistics = (x = opts.delete(:statistics); x.is_a?(::Io::Flow::V0::Models::ReturnPolicyStatistic) ? x : ::Io::Flow::V0::Models::ReturnPolicyStatistic.new(x))
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



56974
56975
56976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56974

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



56974
56975
56976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56974

def id
  @id
end

#qObject (readonly)

Returns the value of attribute q.



56974
56975
56976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56974

def q
  @q
end

#queryObject (readonly)

Returns the value of attribute query.



56974
56975
56976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56974

def query
  @query
end

#statisticsObject (readonly)

Returns the value of attribute statistics.



56974
56975
56976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56974

def statistics
  @statistics
end

#statusObject (readonly)

Returns the value of attribute status.



56974
56975
56976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56974

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



56991
56992
56993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56991

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

#to_hashObject



56995
56996
56997
56998
56999
57000
57001
57002
57003
57004
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56995

def to_hash
  {
    :id => id,
    :q => q,
    :query => query.to_hash,
    :status => status.value,
    :description => description,
    :statistics => statistics.to_hash
  }
end

#to_jsonObject



56987
56988
56989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56987

def to_json
  JSON.dump(to_hash)
end