suggestgrid 0.1.27 → 0.1.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/suggest_grid/api_helper.rb +6 -0
  4. data/lib/suggest_grid/configuration.rb +1 -0
  5. data/lib/suggest_grid/controllers/action_controller.rb +94 -142
  6. data/lib/suggest_grid/controllers/base_controller.rb +3 -2
  7. data/lib/suggest_grid/controllers/metadata_controller.rb +182 -330
  8. data/lib/suggest_grid/controllers/recommendation_controller.rb +18 -42
  9. data/lib/suggest_grid/controllers/similarity_controller.rb +18 -42
  10. data/lib/suggest_grid/controllers/type_controller.rb +76 -140
  11. data/lib/suggest_grid/exceptions/delete_error_response_exception.rb +7 -7
  12. data/lib/suggest_grid/exceptions/detailed_error_response_exception.rb +1 -1
  13. data/lib/suggest_grid/exceptions/error_response_exception.rb +1 -1
  14. data/lib/suggest_grid/exceptions/limit_exceeded_error_response_exception.rb +3 -3
  15. data/lib/suggest_grid/http/faraday_client.rb +3 -1
  16. data/lib/suggest_grid/http/http_client.rb +4 -2
  17. data/lib/suggest_grid/models/action.rb +19 -2
  18. data/lib/suggest_grid/models/actions_response.rb +10 -2
  19. data/lib/suggest_grid/models/base_model.rb +17 -0
  20. data/lib/suggest_grid/models/bulk_post_error.rb +10 -2
  21. data/lib/suggest_grid/models/bulk_post_response.rb +10 -2
  22. data/lib/suggest_grid/models/delete_success_response.rb +16 -8
  23. data/lib/suggest_grid/models/get_recommended_items_body.rb +16 -8
  24. data/lib/suggest_grid/models/get_recommended_users_body.rb +16 -8
  25. data/lib/suggest_grid/models/get_similar_items_body.rb +15 -7
  26. data/lib/suggest_grid/models/get_similar_users_body.rb +15 -7
  27. data/lib/suggest_grid/models/get_type_response.rb +10 -2
  28. data/lib/suggest_grid/models/get_types_response.rb +8 -9
  29. data/lib/suggest_grid/models/items_response.rb +10 -2
  30. data/lib/suggest_grid/models/message_response.rb +10 -2
  31. data/lib/suggest_grid/models/metadata.rb +19 -10
  32. data/lib/suggest_grid/models/type_request_body.rb +11 -5
  33. data/lib/suggest_grid/models/users_response.rb +10 -2
  34. data/lib/suggest_grid.rb +2 -0
  35. data/spec/swagger.yaml +122 -194
  36. metadata +21 -7
@@ -18,6 +18,10 @@ module SuggestGrid
18
18
  # @return [Float]
19
19
  attr_accessor :rating
20
20
 
21
+ # The optional UNIX epoch timestamp of the action. Defaults to the current timestamp.
22
+ # @return [Long]
23
+ attr_accessor :timestamp
24
+
21
25
  # A mapping from model property names to API property names
22
26
  def self.names
23
27
  if @hash.nil?
@@ -26,6 +30,7 @@ module SuggestGrid
26
30
  @hash["user_id"] = "user_id"
27
31
  @hash["item_id"] = "item_id"
28
32
  @hash["rating"] = "rating"
33
+ @hash["timestamp"] = "timestamp"
29
34
  end
30
35
  @hash
31
36
  end
@@ -33,11 +38,17 @@ module SuggestGrid
33
38
  def initialize(type = nil,
34
39
  user_id = nil,
35
40
  item_id = nil,
36
- rating = nil)
41
+ rating = nil,
42
+ timestamp = nil,
43
+ additional_properties = {})
37
44
  @type = type
38
45
  @user_id = user_id
39
46
  @item_id = item_id
40
47
  @rating = rating
48
+ @timestamp = timestamp
49
+
50
+ # Add additional model properties to the instance
51
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
41
52
  end
42
53
 
43
54
  # Creates an instance of the object from a hash
@@ -50,12 +61,18 @@ module SuggestGrid
50
61
  user_id = hash["user_id"]
51
62
  item_id = hash["item_id"]
52
63
  rating = hash["rating"]
64
+ timestamp = hash["timestamp"]
65
+
66
+ # Clean out expected properties from Hash
67
+ names.values.each {|k| hash.delete(k)}
53
68
 
54
69
  # Create object from extracted values
55
70
  Action.new(type,
56
71
  user_id,
57
72
  item_id,
58
- rating)
73
+ rating,
74
+ timestamp,
75
+ hash)
59
76
  end
60
77
  end
61
78
  end
@@ -27,10 +27,14 @@ module SuggestGrid
27
27
 
28
28
  def initialize(count = nil,
29
29
  total_count = nil,
30
- actions = nil)
30
+ actions = nil,
31
+ additional_properties = {})
31
32
  @count = count
32
33
  @total_count = total_count
33
34
  @actions = actions
35
+
36
+ # Add additional model properties to the instance
37
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
34
38
  end
35
39
 
36
40
  # Creates an instance of the object from a hash
@@ -48,10 +52,14 @@ module SuggestGrid
48
52
  hash["actions"].each{|structure| actions << (Action.from_hash(structure) if structure)}
49
53
  end
50
54
 
55
+ # Clean out expected properties from Hash
56
+ names.values.each {|k| hash.delete(k)}
57
+
51
58
  # Create object from extracted values
52
59
  ActionsResponse.new(count,
53
60
  total_count,
54
- actions)
61
+ actions,
62
+ hash)
55
63
  end
56
64
  end
57
65
  end
@@ -28,5 +28,22 @@ module SuggestGrid
28
28
  hash = to_hash
29
29
  hash.to_json(options)
30
30
  end
31
+
32
+ # Use to allow additional model properties
33
+ def method_missing(method_sym, *arguments, &block)
34
+ method = method_sym.to_s
35
+ if method.end_with? '='
36
+ instance_variable_set("@%s" % [method.chomp('=')], arguments.first)
37
+ elsif instance_variable_defined?("@#{method}") && arguments.empty?
38
+ instance_variable_get("@#{method}")
39
+ else
40
+ super
41
+ end
42
+ end
43
+
44
+ # Override for additional model properties
45
+ def respond_to?(method_sym, include_private=false)
46
+ instance_variable_defined?("@#{method_sym}") ? true : super
47
+ end
31
48
  end
32
49
  end
@@ -27,10 +27,14 @@ module SuggestGrid
27
27
 
28
28
  def initialize(message = nil,
29
29
  value = nil,
30
- error = nil)
30
+ error = nil,
31
+ additional_properties = {})
31
32
  @message = message
32
33
  @value = value
33
34
  @error = error
35
+
36
+ # Add additional model properties to the instance
37
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
34
38
  end
35
39
 
36
40
  # Creates an instance of the object from a hash
@@ -43,10 +47,14 @@ module SuggestGrid
43
47
  value = hash["value"]
44
48
  error = hash["error"]
45
49
 
50
+ # Clean out expected properties from Hash
51
+ names.values.each {|k| hash.delete(k)}
52
+
46
53
  # Create object from extracted values
47
54
  BulkPostError.new(message,
48
55
  value,
49
- error)
56
+ error,
57
+ hash)
50
58
  end
51
59
  end
52
60
  end
@@ -21,9 +21,13 @@ module SuggestGrid
21
21
  end
22
22
 
23
23
  def initialize(message = nil,
24
- errors = nil)
24
+ errors = nil,
25
+ additional_properties = {})
25
26
  @message = message
26
27
  @errors = errors
28
+
29
+ # Add additional model properties to the instance
30
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
27
31
  end
28
32
 
29
33
  # Creates an instance of the object from a hash
@@ -40,9 +44,13 @@ module SuggestGrid
40
44
  hash["errors"].each{|structure| errors << (BulkPostError.from_hash(structure) if structure)}
41
45
  end
42
46
 
47
+ # Clean out expected properties from Hash
48
+ names.values.each {|k| hash.delete(k)}
49
+
43
50
  # Create object from extracted values
44
51
  BulkPostResponse.new(message,
45
- errors)
52
+ errors,
53
+ hash)
46
54
  end
47
55
  end
48
56
  end
@@ -6,16 +6,16 @@ module SuggestGrid
6
6
  # @return [String]
7
7
  attr_accessor :message
8
8
 
9
- # The number of records found for the delete query.
10
- # @return [Integer]
9
+ # The number of records found.
10
+ # @return [Long]
11
11
  attr_accessor :found
12
12
 
13
- # The number of records deleted for the delete query.
14
- # @return [Integer]
13
+ # The number of records deleted.
14
+ # @return [Long]
15
15
  attr_accessor :deleted
16
16
 
17
- # The number of records found but not deleted for the delete query.
18
- # @return [Integer]
17
+ # The number of records failed to be deleted.
18
+ # @return [Long]
19
19
  attr_accessor :failed
20
20
 
21
21
  # A mapping from model property names to API property names
@@ -33,11 +33,15 @@ module SuggestGrid
33
33
  def initialize(message = nil,
34
34
  found = nil,
35
35
  deleted = nil,
36
- failed = nil)
36
+ failed = nil,
37
+ additional_properties = {})
37
38
  @message = message
38
39
  @found = found
39
40
  @deleted = deleted
40
41
  @failed = failed
42
+
43
+ # Add additional model properties to the instance
44
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
41
45
  end
42
46
 
43
47
  # Creates an instance of the object from a hash
@@ -51,11 +55,15 @@ module SuggestGrid
51
55
  deleted = hash["deleted"]
52
56
  failed = hash["failed"]
53
57
 
58
+ # Clean out expected properties from Hash
59
+ names.values.each {|k| hash.delete(k)}
60
+
54
61
  # Create object from extracted values
55
62
  DeleteSuccessResponse.new(message,
56
63
  found,
57
64
  deleted,
58
- failed)
65
+ failed,
66
+ hash)
59
67
  end
60
68
  end
61
69
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SuggestGrid
4
4
  class GetRecommendedItemsBody < BaseModel
5
- # The type of the query.
5
+ # The type of the query. Recommendations will be calculated based on actions of this type.
6
6
  # @return [String]
7
7
  attr_accessor :type
8
8
 
@@ -18,11 +18,11 @@ module SuggestGrid
18
18
  # @return [List of String]
19
19
  attr_accessor :user_ids
20
20
 
21
- # The number of most recommended items to be skipped.
21
+ # The number of most recommended items to be skipped from the response. Defaults to 0.
22
22
  # @return [Integer]
23
23
  attr_accessor :from
24
24
 
25
- # The number of items asked to return in the response.
25
+ # The number of items requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
26
26
  # @return [Integer]
27
27
  attr_accessor :size
28
28
 
@@ -32,16 +32,16 @@ module SuggestGrid
32
32
 
33
33
  # Similar items that the response should be similar to.
34
34
  # At most one of similar item and similar items parameters can be provided.
35
- # @return [String]
35
+ # @return [List of String]
36
36
  attr_accessor :similar_item_ids
37
37
 
38
- # The metadata fields that are to be included in returned items.
38
+ # The metadata fields to be included in returned item objects.
39
39
  # @return [List of String]
40
40
  attr_accessor :fields
41
41
 
42
42
  # Contraints on the returned users or items.
43
43
  # Filter structure is defined in [the filter parameter documentation](http://www.suggestgrid.com/docs/advanced-features#filters-parameter).
44
- # @return [Object]
44
+ # @return [Array<String, Boolean>]
45
45
  attr_accessor :filter
46
46
 
47
47
  # These item ids that will not be included in the response.
@@ -77,7 +77,8 @@ module SuggestGrid
77
77
  similar_item_ids = nil,
78
78
  fields = nil,
79
79
  filter = nil,
80
- except = nil)
80
+ except = nil,
81
+ additional_properties = {})
81
82
  @type = type
82
83
  @types = types
83
84
  @user_id = user_id
@@ -89,6 +90,9 @@ module SuggestGrid
89
90
  @fields = fields
90
91
  @filter = filter
91
92
  @except = except
93
+
94
+ # Add additional model properties to the instance
95
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
92
96
  end
93
97
 
94
98
  # Creates an instance of the object from a hash
@@ -109,6 +113,9 @@ module SuggestGrid
109
113
  filter = hash["filter"]
110
114
  except = hash["except"]
111
115
 
116
+ # Clean out expected properties from Hash
117
+ names.values.each {|k| hash.delete(k)}
118
+
112
119
  # Create object from extracted values
113
120
  GetRecommendedItemsBody.new(type,
114
121
  types,
@@ -120,7 +127,8 @@ module SuggestGrid
120
127
  similar_item_ids,
121
128
  fields,
122
129
  filter,
123
- except)
130
+ except,
131
+ hash)
124
132
  end
125
133
  end
126
134
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SuggestGrid
4
4
  class GetRecommendedUsersBody < BaseModel
5
- # The type of the query.
5
+ # The type of the query. Recommendations will be calculated based on actions of this type.
6
6
  # @return [String]
7
7
  attr_accessor :type
8
8
 
@@ -18,11 +18,11 @@ module SuggestGrid
18
18
  # @return [List of String]
19
19
  attr_accessor :item_ids
20
20
 
21
- # The number of most recommended items to be skipped.
21
+ # The number of most recommended items to be skipped from the response. Defaults to 0.
22
22
  # @return [Integer]
23
23
  attr_accessor :from
24
24
 
25
- # The number of users asked to return in the response.
25
+ # The number of users requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
26
26
  # @return [Integer]
27
27
  attr_accessor :size
28
28
 
@@ -32,16 +32,16 @@ module SuggestGrid
32
32
 
33
33
  # Similar users that the response should be similar to.
34
34
  # At most one of similar user and similar users parameters can be provided.
35
- # @return [String]
35
+ # @return [List of String]
36
36
  attr_accessor :similar_user_ids
37
37
 
38
- # The metadata fields that are to be included in returned users.
38
+ # The metadata fields to be included in returned user objects.
39
39
  # @return [List of String]
40
40
  attr_accessor :fields
41
41
 
42
42
  # Contraints on the returned users or items.
43
43
  # Filter structure is defined in [the filter parameter documentation](http://www.suggestgrid.com/docs/advanced-features#filters-parameter).
44
- # @return [Object]
44
+ # @return [Array<String, Boolean>]
45
45
  attr_accessor :filter
46
46
 
47
47
  # These user ids that will not be included in the response.
@@ -77,7 +77,8 @@ module SuggestGrid
77
77
  similar_user_ids = nil,
78
78
  fields = nil,
79
79
  filter = nil,
80
- except = nil)
80
+ except = nil,
81
+ additional_properties = {})
81
82
  @type = type
82
83
  @types = types
83
84
  @item_id = item_id
@@ -89,6 +90,9 @@ module SuggestGrid
89
90
  @fields = fields
90
91
  @filter = filter
91
92
  @except = except
93
+
94
+ # Add additional model properties to the instance
95
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
92
96
  end
93
97
 
94
98
  # Creates an instance of the object from a hash
@@ -109,6 +113,9 @@ module SuggestGrid
109
113
  filter = hash["filter"]
110
114
  except = hash["except"]
111
115
 
116
+ # Clean out expected properties from Hash
117
+ names.values.each {|k| hash.delete(k)}
118
+
112
119
  # Create object from extracted values
113
120
  GetRecommendedUsersBody.new(type,
114
121
  types,
@@ -120,7 +127,8 @@ module SuggestGrid
120
127
  similar_user_ids,
121
128
  fields,
122
129
  filter,
123
- except)
130
+ except,
131
+ hash)
124
132
  end
125
133
  end
126
134
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SuggestGrid
4
4
  class GetSimilarItemsBody < BaseModel
5
- # The type of the query.
5
+ # The type of the query. Similarities will be calculated based on actions of this type.
6
6
  # @return [String]
7
7
  attr_accessor :type
8
8
 
@@ -18,21 +18,21 @@ module SuggestGrid
18
18
  # @return [List of String]
19
19
  attr_accessor :item_ids
20
20
 
21
- # The number of most similar items to be skipped.
21
+ # The number of most similar items to be skipped from the response. Defaults to 0.
22
22
  # @return [Integer]
23
23
  attr_accessor :from
24
24
 
25
- # The number of items asked to return in the response.
25
+ # The number of items requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
26
26
  # @return [Integer]
27
27
  attr_accessor :size
28
28
 
29
- # The metadata fields that are to be included in returned items.
29
+ # The metadata fields to be included in returned item objects.
30
30
  # @return [List of String]
31
31
  attr_accessor :fields
32
32
 
33
33
  # Contraints on the returned users or items.
34
34
  # Filter structure is defined in [the filter parameter documentation](http://www.suggestgrid.com/docs/advanced-features#filters-parameter).
35
- # @return [Object]
35
+ # @return [Array<String, Boolean>]
36
36
  attr_accessor :filter
37
37
 
38
38
  # These item ids that will not be included in the response.
@@ -64,7 +64,8 @@ module SuggestGrid
64
64
  size = nil,
65
65
  fields = nil,
66
66
  filter = nil,
67
- except = nil)
67
+ except = nil,
68
+ additional_properties = {})
68
69
  @type = type
69
70
  @types = types
70
71
  @item_id = item_id
@@ -74,6 +75,9 @@ module SuggestGrid
74
75
  @fields = fields
75
76
  @filter = filter
76
77
  @except = except
78
+
79
+ # Add additional model properties to the instance
80
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
77
81
  end
78
82
 
79
83
  # Creates an instance of the object from a hash
@@ -92,6 +96,9 @@ module SuggestGrid
92
96
  filter = hash["filter"]
93
97
  except = hash["except"]
94
98
 
99
+ # Clean out expected properties from Hash
100
+ names.values.each {|k| hash.delete(k)}
101
+
95
102
  # Create object from extracted values
96
103
  GetSimilarItemsBody.new(type,
97
104
  types,
@@ -101,7 +108,8 @@ module SuggestGrid
101
108
  size,
102
109
  fields,
103
110
  filter,
104
- except)
111
+ except,
112
+ hash)
105
113
  end
106
114
  end
107
115
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SuggestGrid
4
4
  class GetSimilarUsersBody < BaseModel
5
- # The type of the query.
5
+ # The type of the query. Similarities will be calculated based on actions of this type.
6
6
  # @return [String]
7
7
  attr_accessor :type
8
8
 
@@ -18,21 +18,21 @@ module SuggestGrid
18
18
  # @return [List of String]
19
19
  attr_accessor :user_ids
20
20
 
21
- # The number of most similar users to be skipped.
21
+ # The number of most similar users to be skipped from the response. Defaults to 0.
22
22
  # @return [Integer]
23
23
  attr_accessor :from
24
24
 
25
- # The number of users asked to return in the response.
25
+ # The number of users requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
26
26
  # @return [Integer]
27
27
  attr_accessor :size
28
28
 
29
- # The metadata fields that are to be included in returned users.
29
+ # The metadata fields to be included in returned user objects.
30
30
  # @return [List of String]
31
31
  attr_accessor :fields
32
32
 
33
33
  # Contraints on the returned users or items.
34
34
  # Filter structure is defined in [the filter parameter documentation](http://www.suggestgrid.com/docs/advanced-features#filters-parameter).
35
- # @return [Object]
35
+ # @return [Array<String, Boolean>]
36
36
  attr_accessor :filter
37
37
 
38
38
  # These user ids that will not be included in the response.
@@ -64,7 +64,8 @@ module SuggestGrid
64
64
  size = nil,
65
65
  fields = nil,
66
66
  filter = nil,
67
- except = nil)
67
+ except = nil,
68
+ additional_properties = {})
68
69
  @type = type
69
70
  @types = types
70
71
  @user_id = user_id
@@ -74,6 +75,9 @@ module SuggestGrid
74
75
  @fields = fields
75
76
  @filter = filter
76
77
  @except = except
78
+
79
+ # Add additional model properties to the instance
80
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
77
81
  end
78
82
 
79
83
  # Creates an instance of the object from a hash
@@ -92,6 +96,9 @@ module SuggestGrid
92
96
  filter = hash["filter"]
93
97
  except = hash["except"]
94
98
 
99
+ # Clean out expected properties from Hash
100
+ names.values.each {|k| hash.delete(k)}
101
+
95
102
  # Create object from extracted values
96
103
  GetSimilarUsersBody.new(type,
97
104
  types,
@@ -101,7 +108,8 @@ module SuggestGrid
101
108
  size,
102
109
  fields,
103
110
  filter,
104
- except)
111
+ except,
112
+ hash)
105
113
  end
106
114
  end
107
115
  end
@@ -15,8 +15,12 @@ module SuggestGrid
15
15
  @hash
16
16
  end
17
17
 
18
- def initialize(rating = nil)
18
+ def initialize(rating = nil,
19
+ additional_properties = {})
19
20
  @rating = rating
21
+
22
+ # Add additional model properties to the instance
23
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
20
24
  end
21
25
 
22
26
  # Creates an instance of the object from a hash
@@ -27,8 +31,12 @@ module SuggestGrid
27
31
  # Extract variables from the hash
28
32
  rating = hash["rating"]
29
33
 
34
+ # Clean out expected properties from Hash
35
+ names.values.each {|k| hash.delete(k)}
36
+
30
37
  # Create object from extracted values
31
- GetTypeResponse.new(rating)
38
+ GetTypeResponse.new(rating,
39
+ hash)
32
40
  end
33
41
  end
34
42
  end
@@ -6,24 +6,21 @@ module SuggestGrid
6
6
  # @return [List of String]
7
7
  attr_accessor :types
8
8
 
9
- # Status code of the response. It is not 2XX.
10
- # @return [Integer]
11
- attr_accessor :status
12
-
13
9
  # A mapping from model property names to API property names
14
10
  def self.names
15
11
  if @hash.nil?
16
12
  @hash = {}
17
13
  @hash["types"] = "types"
18
- @hash["status"] = "status"
19
14
  end
20
15
  @hash
21
16
  end
22
17
 
23
18
  def initialize(types = nil,
24
- status = nil)
19
+ additional_properties = {})
25
20
  @types = types
26
- @status = status
21
+
22
+ # Add additional model properties to the instance
23
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
27
24
  end
28
25
 
29
26
  # Creates an instance of the object from a hash
@@ -33,11 +30,13 @@ module SuggestGrid
33
30
  else
34
31
  # Extract variables from the hash
35
32
  types = hash["types"]
36
- status = hash["status"]
33
+
34
+ # Clean out expected properties from Hash
35
+ names.values.each {|k| hash.delete(k)}
37
36
 
38
37
  # Create object from extracted values
39
38
  GetTypesResponse.new(types,
40
- status)
39
+ hash)
41
40
  end
42
41
  end
43
42
  end
@@ -27,10 +27,14 @@ module SuggestGrid
27
27
 
28
28
  def initialize(count = nil,
29
29
  total_count = nil,
30
- items = nil)
30
+ items = nil,
31
+ additional_properties = {})
31
32
  @count = count
32
33
  @total_count = total_count
33
34
  @items = items
35
+
36
+ # Add additional model properties to the instance
37
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
34
38
  end
35
39
 
36
40
  # Creates an instance of the object from a hash
@@ -48,10 +52,14 @@ module SuggestGrid
48
52
  hash["items"].each{|structure| items << (Metadata.from_hash(structure) if structure)}
49
53
  end
50
54
 
55
+ # Clean out expected properties from Hash
56
+ names.values.each {|k| hash.delete(k)}
57
+
51
58
  # Create object from extracted values
52
59
  ItemsResponse.new(count,
53
60
  total_count,
54
- items)
61
+ items,
62
+ hash)
55
63
  end
56
64
  end
57
65
  end
@@ -15,8 +15,12 @@ module SuggestGrid
15
15
  @hash
16
16
  end
17
17
 
18
- def initialize(message = nil)
18
+ def initialize(message = nil,
19
+ additional_properties = {})
19
20
  @message = message
21
+
22
+ # Add additional model properties to the instance
23
+ additional_properties.each {|name, value| instance_variable_set("@#{name}", value)}
20
24
  end
21
25
 
22
26
  # Creates an instance of the object from a hash
@@ -27,8 +31,12 @@ module SuggestGrid
27
31
  # Extract variables from the hash
28
32
  message = hash["message"]
29
33
 
34
+ # Clean out expected properties from Hash
35
+ names.values.each {|k| hash.delete(k)}
36
+
30
37
  # Create object from extracted values
31
- MessageResponse.new(message)
38
+ MessageResponse.new(message,
39
+ hash)
32
40
  end
33
41
  end
34
42
  end