class AboutYou::SDK::Model::SaleCounts

This class represents a Sale Counts model.

author

Collins GmbH & Co KG

Attributes

product_count_in_sale[RW]

count of products in sale

product_count_not_in_sale[RW]

count of prodocuts not in sale

product_count_total[RW]

count of total products

product_count_with_other_facet[RW]

count of products with other facets

product_count_without_any_facet[RW]

count of products without facet

Public Class Methods

create_from_json(json_object) click to toggle source

This method is used for creating an instance of this class by a json_object.

# File lib/AboutYou/Model/ProductSearchResult/sale_counts.rb, line 50
def self.create_from_json(json_object)
  sale_counts = new(
    json_object['total'],
    json_object['other'],
    json_object['missing']
  )
  sale_counts.parse_terms(json_object['terms'])

  sale_counts
end
new(product_count_total, product_count_with_other_facet, product_count_without_any_facet ) click to toggle source

the Constructor for the sale counts class

  • Args :

    • product_count_total -> the total productcount

    • product_count_with_other_facet -> the productcount without any facets

    • product_count_without_any_facet -> the productcount with other facets

  • Returns :

# File lib/AboutYou/Model/ProductSearchResult/sale_counts.rb, line 32
def initialize(product_count_total,
    product_count_with_other_facet,
    product_count_without_any_facet
  )
  self.product_count_total             = product_count_total
  self.product_count_with_other_facet  = product_count_with_other_facet
  self.product_count_without_any_facet = product_count_without_any_facet
end

Public Instance Methods

parse_terms(json_terms) click to toggle source

This method is used for parsing the terms of the json_object

  • Args :

    • jsonTerms -> the terms of the json_object received from the api

# File lib/AboutYou/Model/ProductSearchResult/sale_counts.rb, line 67
def parse_terms(json_terms)
  json_terms.each do |term|
    if term['term'] == 0
      self.product_count_not_in_sale = term['count']
    else
      self.product_count_in_sale     = term['count']
    end
  end
end