Class: SuggestGrid::GetSimilarItemsBody

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/suggestgrid/models/get_similar_items_body.rb

Overview

Query for similar items.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(type = nil, types = nil, item_id = nil, item_ids = nil, from = nil, size = nil, fields = nil, filter = nil, except = nil) ⇒ GetSimilarItemsBody

Returns a new instance of GetSimilarItemsBody.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 68

def initialize(type = nil,
               types = nil,
               item_id = nil,
               item_ids = nil,
               from = nil,
               size = nil,
               fields = nil,
               filter = nil,
               except = nil)
  @type = type
  @types = types
  @item_id = item_id
  @item_ids = item_ids
  @from = from
  @size = size
  @fields = fields
  @filter = filter
  @except = except
end

Instance Attribute Details

#exceptList of String

These item ids that will not be included in the response.

Returns:



51
52
53
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 51

def except
  @except
end

#fieldsList of String

The metadata fields to be included in returned item objects.

Returns:



40
41
42
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 40

def fields
  @fields
end

#filterArray<String, Boolean>

Contraints on the returned users or items. Filter structure is defined in [the filter parameter documentation](www.suggestgrid.com/docs/advanced-features#filters-p arameter).

Returns:



47
48
49
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 47

def filter
  @filter
end

#fromInteger

The number of most similar items to be skipped from the response. Defaults to 0.

Returns:

  • (Integer)


31
32
33
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 31

def from
  @from
end

#item_idString

The item id of the query. Get similar items to given item id. Either item id or item ids must be provided.

Returns:



20
21
22
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 20

def item_id
  @item_id
end

#item_idsList of String

The item ids of the query. Exactly one of item id or item ids parameters must be provided. Get similar items to given item ids. Either item id or item ids must be provided.

Returns:



26
27
28
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 26

def item_ids
  @item_ids
end

#sizeInteger

The number of items requested. Defaults to 10. Must be between 1 and 10,000 inclusive.

Returns:

  • (Integer)


36
37
38
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 36

def size
  @size
end

#typeString

The type of the query. Similarities will be calculated based on actions of this type.

Returns:



10
11
12
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 10

def type
  @type
end

#typesList of String

The types of the query. Exactly one of type or types parameters must be provided.

Returns:



15
16
17
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 15

def types
  @types
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 89

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  type = hash['type']
  types = hash['types']
  item_id = hash['item_id']
  item_ids = hash['item_ids']
  from = hash['from']
  size = hash['size']
  fields = hash['fields']
  filter = hash['filter']
  except = hash['except']

  # Create object from extracted values.

  GetSimilarItemsBody.new(type,
                          types,
                          item_id,
                          item_ids,
                          from,
                          size,
                          fields,
                          filter,
                          except)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/suggestgrid/models/get_similar_items_body.rb', line 54

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['types'] = 'types'
  @_hash['item_id'] = 'item_id'
  @_hash['item_ids'] = 'item_ids'
  @_hash['from'] = 'from'
  @_hash['size'] = 'size'
  @_hash['fields'] = 'fields'
  @_hash['filter'] = 'filter'
  @_hash['except'] = 'except'
  @_hash
end