Class: Io::Flow::V0::Models::ShopifyItemEventBucket

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

Instance Attribute Summary collapse

Attributes inherited from ShopifyEventBucket

#discriminator

Instance Method Summary collapse

Methods inherited from ShopifyEventBucket

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyItemEventBucket

Returns a new instance of ShopifyItemEventBucket.



51487
51488
51489
51490
51491
51492
51493
51494
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51487

def initialize(incoming={})
  super(:discriminator => ShopifyEventBucket::Types::SHOPIFY_ITEM_EVENT_BUCKET)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:range, :count, :data], 'ShopifyItemEventBucket')
  @range = (x = opts.delete(:range); x.is_a?(::Io::Flow::V0::Models::DatetimeRange) ? x : ::Io::Flow::V0::Models::DatetimeRange.new(x))
  @count = HttpClient::Preconditions.assert_class('count', opts.delete(:count), Integer)
  @data = HttpClient::Preconditions.assert_class('data', opts.delete(:data), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShopifyItemEventData) ? x : ::Io::Flow::V0::Models::ShopifyItemEventData.new(x)) }
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



51485
51486
51487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51485

def count
  @count
end

#dataObject (readonly)

Returns the value of attribute data.



51485
51486
51487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51485

def data
  @data
end

#rangeObject (readonly)

Returns the value of attribute range.



51485
51486
51487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51485

def range
  @range
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



51500
51501
51502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51500

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

#subtype_to_hashObject



51504
51505
51506
51507
51508
51509
51510
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51504

def subtype_to_hash
  {
    :range => range.to_hash,
    :count => count,
    :data => data.map { |o| o.to_hash }
  }
end

#to_jsonObject



51496
51497
51498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51496

def to_json
  JSON.dump(to_hash)
end