suggestgrid 0.3.0 → 0.5.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/suggestgrid/api_helper.rb +146 -54
- data/lib/suggestgrid/configuration.rb +5 -2
- data/lib/suggestgrid/controllers/action_controller.rb +178 -79
- data/lib/suggestgrid/controllers/base_controller.rb +18 -15
- data/lib/suggestgrid/controllers/metadata_controller.rb +313 -171
- data/lib/suggestgrid/controllers/recommendation_controller.rb +75 -35
- data/lib/suggestgrid/controllers/similarity_controller.rb +75 -35
- data/lib/suggestgrid/controllers/type_controller.rb +131 -74
- data/lib/suggestgrid/exceptions/api_exception.rb +4 -2
- data/lib/suggestgrid/exceptions/{detailed_error_response_error_exception.rb → detailed_error_response.rb} +9 -9
- data/lib/suggestgrid/exceptions/{error_response_error_exception.rb → error_response.rb} +9 -9
- data/lib/suggestgrid/exceptions/{limit_exceeded_error_response_error_exception.rb → limit_exceeded_error_response.rb} +9 -9
- data/lib/suggestgrid/http/auth/basic_auth.rb +8 -5
- data/lib/suggestgrid/http/faraday_client.rb +19 -7
- data/lib/suggestgrid/http/http_call_back.rb +11 -6
- data/lib/suggestgrid/http/http_client.rb +50 -32
- data/lib/suggestgrid/http/http_context.rb +5 -2
- data/lib/suggestgrid/http/http_method_enum.rb +6 -2
- data/lib/suggestgrid/http/http_request.rb +7 -3
- data/lib/suggestgrid/http/http_response.rb +3 -1
- data/lib/suggestgrid/models/action.rb +15 -14
- data/lib/suggestgrid/models/actions_response.rb +16 -14
- data/lib/suggestgrid/models/base_model.rb +11 -9
- data/lib/suggestgrid/models/bulk_post_error.rb +11 -11
- data/lib/suggestgrid/models/bulk_post_response.rb +16 -13
- data/lib/suggestgrid/models/get_recommended_items_body.rb +32 -25
- data/lib/suggestgrid/models/get_recommended_users_body.rb +32 -25
- data/lib/suggestgrid/models/get_similar_items_body.rb +33 -24
- data/lib/suggestgrid/models/get_similar_users_body.rb +30 -23
- data/lib/suggestgrid/models/get_type_response.rb +9 -9
- data/lib/suggestgrid/models/get_types_response.rb +9 -9
- data/lib/suggestgrid/models/items_response.rb +16 -14
- data/lib/suggestgrid/models/message_response.rb +9 -9
- data/lib/suggestgrid/models/metadata.rb +9 -8
- data/lib/suggestgrid/models/type_request_body.rb +11 -10
- data/lib/suggestgrid/models/users_response.rb +16 -14
- data/lib/suggestgrid/suggestgrid_client.rb +16 -14
- data/lib/suggestgrid.rb +5 -4
- data/spec/swagger.yaml +3 -3
- metadata +8 -8
@@ -1,7 +1,9 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
4
|
-
|
5
|
+
# Error response.
|
6
|
+
class DetailedErrorResponse < APIException
|
5
7
|
# Message of the response.
|
6
8
|
# @return [String]
|
7
9
|
attr_accessor :error_text
|
@@ -19,19 +21,17 @@ module SuggestGrid
|
|
19
21
|
attr_accessor :error_details
|
20
22
|
|
21
23
|
# The constructor.
|
22
|
-
# @param [String] The reason for raising an exception
|
24
|
+
# @param [String] The reason for raising an exception.
|
23
25
|
# @param [HttpContext] The HttpContext of the API call.
|
24
26
|
def initialize(reason, context)
|
25
27
|
super(reason, context)
|
26
|
-
|
27
|
-
|
28
|
-
unbox(hash)
|
29
|
-
rescue TypeError
|
30
|
-
end
|
28
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
29
|
+
unbox(hash)
|
31
30
|
end
|
32
31
|
|
33
32
|
# Populates this object by extracting properties from a hash.
|
34
|
-
# @param [Hash] The deserialized response sent by the server in the
|
33
|
+
# @param [Hash] The deserialized response sent by the server in the
|
34
|
+
# response body.
|
35
35
|
def unbox(hash)
|
36
36
|
@error_text = hash['error_text']
|
37
37
|
@error_description = hash['error_description']
|
@@ -1,7 +1,9 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
4
|
-
|
5
|
+
# Error response.
|
6
|
+
class ErrorResponse < APIException
|
5
7
|
# Message of the response.
|
6
8
|
# @return [String]
|
7
9
|
attr_accessor :error_text
|
@@ -15,19 +17,17 @@ module SuggestGrid
|
|
15
17
|
attr_accessor :error_uri
|
16
18
|
|
17
19
|
# The constructor.
|
18
|
-
# @param [String] The reason for raising an exception
|
20
|
+
# @param [String] The reason for raising an exception.
|
19
21
|
# @param [HttpContext] The HttpContext of the API call.
|
20
22
|
def initialize(reason, context)
|
21
23
|
super(reason, context)
|
22
|
-
|
23
|
-
|
24
|
-
unbox(hash)
|
25
|
-
rescue TypeError
|
26
|
-
end
|
24
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
25
|
+
unbox(hash)
|
27
26
|
end
|
28
27
|
|
29
28
|
# Populates this object by extracting properties from a hash.
|
30
|
-
# @param [Hash] The deserialized response sent by the server in the
|
29
|
+
# @param [Hash] The deserialized response sent by the server in the
|
30
|
+
# response body.
|
31
31
|
def unbox(hash)
|
32
32
|
@error_text = hash['error_text']
|
33
33
|
@error_description = hash['error_description']
|
@@ -1,7 +1,9 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
4
|
-
|
5
|
+
# Error response.
|
6
|
+
class LimitExceededErrorResponse < APIException
|
5
7
|
# Message of the response.
|
6
8
|
# @return [String]
|
7
9
|
attr_accessor :error_text
|
@@ -23,19 +25,17 @@ module SuggestGrid
|
|
23
25
|
attr_accessor :limit
|
24
26
|
|
25
27
|
# The constructor.
|
26
|
-
# @param [String] The reason for raising an exception
|
28
|
+
# @param [String] The reason for raising an exception.
|
27
29
|
# @param [HttpContext] The HttpContext of the API call.
|
28
30
|
def initialize(reason, context)
|
29
31
|
super(reason, context)
|
30
|
-
|
31
|
-
|
32
|
-
unbox(hash)
|
33
|
-
rescue TypeError
|
34
|
-
end
|
32
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
33
|
+
unbox(hash)
|
35
34
|
end
|
36
35
|
|
37
36
|
# Populates this object by extracting properties from a hash.
|
38
|
-
# @param [Hash] The deserialized response sent by the server in the
|
37
|
+
# @param [Hash] The deserialized response sent by the server in the
|
38
|
+
# response body.
|
39
39
|
def unbox(hash)
|
40
40
|
@error_text = hash['error_text']
|
41
41
|
@error_description = hash['error_description']
|
@@ -1,17 +1,20 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
|
-
require
|
4
|
+
require 'base64'
|
4
5
|
|
5
6
|
module SuggestGrid
|
7
|
+
# Utility class for basic authorization.
|
6
8
|
class BasicAuth
|
7
9
|
# Add basic authentication to the request.
|
8
|
-
# @param [HttpRequest] The HttpRequest object to which authentication will
|
10
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will
|
11
|
+
# be added.
|
9
12
|
def self.apply(http_request)
|
10
13
|
username = Configuration.basic_auth_user_name
|
11
14
|
password = Configuration.basic_auth_password
|
12
15
|
value = Base64.strict_encode64("#{username}:#{password}")
|
13
16
|
header_value = "Basic #{value}"
|
14
|
-
http_request.headers[
|
17
|
+
http_request.headers['Authorization'] = header_value
|
15
18
|
end
|
16
19
|
end
|
17
|
-
end
|
20
|
+
end
|
@@ -1,10 +1,13 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
require 'faraday/http_cache'
|
3
4
|
|
4
5
|
module SuggestGrid
|
6
|
+
# An implementation of HttpClient.
|
5
7
|
class FaradayClient < HttpClient
|
6
8
|
# The constructor.
|
7
|
-
def initialize(timeout: nil, cache: false,
|
9
|
+
def initialize(timeout: nil, cache: false,
|
10
|
+
max_retries: nil, retry_interval: nil)
|
8
11
|
@connection = Faraday.new do |faraday|
|
9
12
|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
10
13
|
faraday.request :multipart
|
@@ -13,26 +16,35 @@ module SuggestGrid
|
|
13
16
|
faraday.adapter Faraday.default_adapter
|
14
17
|
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
15
18
|
faraday.options[:open_timeout] = timeout if timeout
|
16
|
-
faraday.request :retry, max: max_retries, interval:
|
19
|
+
faraday.request :retry, max: max_retries, interval: if max_retries &&
|
20
|
+
retry_interval
|
21
|
+
retry_interval
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
26
|
# Method overridden from HttpClient.
|
21
27
|
def execute_as_string(http_request)
|
22
|
-
response = @connection.send(
|
28
|
+
response = @connection.send(
|
29
|
+
http_request.http_method.downcase,
|
30
|
+
http_request.query_url
|
31
|
+
) do |request|
|
23
32
|
request.headers = http_request.headers
|
24
33
|
request.body = http_request.parameters
|
25
34
|
end
|
26
|
-
|
35
|
+
convert_response(response)
|
27
36
|
end
|
28
37
|
|
29
38
|
# Method overridden from HttpClient.
|
30
39
|
def execute_as_binary(http_request)
|
31
|
-
response = @connection.send(
|
40
|
+
response = @connection.send(
|
41
|
+
http_request.http_method.downcase,
|
42
|
+
http_request.query_url
|
43
|
+
) do |request|
|
32
44
|
request.headers = http_request.headers
|
33
45
|
request.body = http_request.parameters
|
34
46
|
end
|
35
|
-
|
47
|
+
convert_response(response)
|
36
48
|
end
|
37
49
|
|
38
50
|
# Method overridden from HttpClient.
|
@@ -1,17 +1,22 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
4
6
|
class HttpCallBack
|
5
7
|
# A controller will call this method before making an HTTP Request.
|
6
|
-
# @param [HttpRequest] The HttpRequest object which the HttpClient
|
7
|
-
|
8
|
-
|
8
|
+
# @param [HttpRequest] The HttpRequest object which the HttpClient
|
9
|
+
# will execute.
|
10
|
+
def on_before_request(_http_request)
|
11
|
+
raise NotImplementedError, 'This method needs
|
12
|
+
to be implemented in a child class.'
|
9
13
|
end
|
10
14
|
|
11
15
|
# A controller will call this method after making an HTTP Request.
|
12
16
|
# @param [HttpContext] The HttpContext of the API call.
|
13
|
-
def on_after_response(
|
14
|
-
raise NotImplementedError, 'This method needs
|
17
|
+
def on_after_response(_http_context)
|
18
|
+
raise NotImplementedError, 'This method needs
|
19
|
+
to be implemented in a child class.'
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -1,23 +1,31 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# An interface for the methods that an HTTP Client must implement.
|
6
|
+
#
|
7
|
+
# This class should not be instantiated but should be used as a base class
|
8
|
+
# for HTTP Client classes.
|
4
9
|
class HttpClient
|
5
10
|
# Execute an HttpRequest when the response is expected to be a string.
|
6
11
|
# @param [HttpRequest] The HttpRequest to be executed.
|
7
|
-
def execute_as_string(
|
8
|
-
raise NotImplementedError, 'This method needs
|
12
|
+
def execute_as_string(_http_request)
|
13
|
+
raise NotImplementedError, 'This method needs
|
14
|
+
to be implemented in a child class.'
|
9
15
|
end
|
10
|
-
|
16
|
+
|
11
17
|
# Execute an HttpRequest when the response is expected to be binary.
|
12
18
|
# @param [HttpRequest] The HttpRequest to be executed.
|
13
|
-
def execute_as_binary(
|
14
|
-
raise NotImplementedError, 'This method needs
|
19
|
+
def execute_as_binary(_http_request)
|
20
|
+
raise NotImplementedError, 'This method needs
|
21
|
+
to be implemented in a child class.'
|
15
22
|
end
|
16
|
-
|
23
|
+
|
17
24
|
# Converts the HTTP Response from the client to an HttpResponse object.
|
18
25
|
# @param [Dynamic] The response object received from the client.
|
19
|
-
def convert_response(
|
20
|
-
raise NotImplementedError, 'This method needs
|
26
|
+
def convert_response(_response)
|
27
|
+
raise NotImplementedError, 'This method needs
|
28
|
+
to be implemented in a child class.'
|
21
29
|
end
|
22
30
|
|
23
31
|
# Get a GET HttpRequest object.
|
@@ -25,11 +33,21 @@ module SuggestGrid
|
|
25
33
|
# @param [Hash, Optional] The headers for the HTTP Request.
|
26
34
|
def get(query_url,
|
27
35
|
headers: {})
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
HttpRequest.new(HttpMethodEnum::GET,
|
37
|
+
query_url,
|
38
|
+
headers: headers)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get a HEAD HttpRequest object.
|
42
|
+
# @param [String] The URL to send the request to.
|
43
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
44
|
+
def head(query_url,
|
45
|
+
headers: {})
|
46
|
+
HttpRequest.new(HttpMethodEnum::HEAD,
|
47
|
+
query_url,
|
48
|
+
headers: headers)
|
31
49
|
end
|
32
|
-
|
50
|
+
|
33
51
|
# Get a POST HttpRequest object.
|
34
52
|
# @param [String] The URL to send the request to.
|
35
53
|
# @param [Hash, Optional] The headers for the HTTP Request.
|
@@ -37,12 +55,12 @@ module SuggestGrid
|
|
37
55
|
def post(query_url,
|
38
56
|
headers: {},
|
39
57
|
parameters: {})
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
58
|
+
HttpRequest.new(HttpMethodEnum::POST,
|
59
|
+
query_url,
|
60
|
+
headers: headers,
|
61
|
+
parameters: parameters)
|
44
62
|
end
|
45
|
-
|
63
|
+
|
46
64
|
# Get a PUT HttpRequest object.
|
47
65
|
# @param [String] The URL to send the request to.
|
48
66
|
# @param [Hash, Optional] The headers for the HTTP Request.
|
@@ -50,12 +68,12 @@ module SuggestGrid
|
|
50
68
|
def put(query_url,
|
51
69
|
headers: {},
|
52
70
|
parameters: {})
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
71
|
+
HttpRequest.new(HttpMethodEnum::PUT,
|
72
|
+
query_url,
|
73
|
+
headers: headers,
|
74
|
+
parameters: parameters)
|
57
75
|
end
|
58
|
-
|
76
|
+
|
59
77
|
# Get a PATCH HttpRequest object.
|
60
78
|
# @param [String] The URL to send the request to.
|
61
79
|
# @param [Hash, Optional] The headers for the HTTP Request.
|
@@ -63,22 +81,22 @@ module SuggestGrid
|
|
63
81
|
def patch(query_url,
|
64
82
|
headers: {},
|
65
83
|
parameters: {})
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
84
|
+
HttpRequest.new(HttpMethodEnum::PATCH,
|
85
|
+
query_url,
|
86
|
+
headers: headers,
|
87
|
+
parameters: parameters)
|
70
88
|
end
|
71
|
-
|
89
|
+
|
72
90
|
# Get a DELETE HttpRequest object.
|
73
91
|
# @param [String] The URL to send the request to.
|
74
92
|
# @param [Hash, Optional] The headers for the HTTP Request.
|
75
93
|
def delete(query_url,
|
76
94
|
headers: {},
|
77
95
|
parameters: {})
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
96
|
+
HttpRequest.new(HttpMethodEnum::DELETE,
|
97
|
+
query_url,
|
98
|
+
headers: headers,
|
99
|
+
parameters: parameters)
|
82
100
|
end
|
83
101
|
end
|
84
102
|
end
|
@@ -1,12 +1,15 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# Represents an Http call in context.
|
4
6
|
class HttpContext
|
5
7
|
attr_accessor :request, :response
|
6
8
|
|
7
9
|
# The constructor.
|
8
10
|
# @param [HttpRequest] An HttpRequest object representing the HTTP request.
|
9
|
-
# @param [HttpResponse] An HttpResponse object representing the HTTP
|
11
|
+
# @param [HttpResponse] An HttpResponse object representing the HTTP
|
12
|
+
# response.
|
10
13
|
def initialize(request, response)
|
11
14
|
@request = request
|
12
15
|
@response = response
|
@@ -1,7 +1,11 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# HTTP Methods Enumeration.
|
4
6
|
class HttpMethodEnum
|
5
|
-
HTTPMETHODENUM = [GET = 'GET', POST = 'POST',
|
7
|
+
HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
|
8
|
+
PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
|
9
|
+
DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
|
6
10
|
end
|
7
11
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# Represents a single Http Request.
|
4
6
|
class HttpRequest
|
5
|
-
attr_accessor :http_method, :query_url, :headers,
|
7
|
+
attr_accessor :http_method, :query_url, :headers,
|
8
|
+
:parameters, :username, :password
|
6
9
|
|
7
10
|
# The constructor.
|
8
11
|
# @param [HttpMethodEnum] The HTTP method.
|
@@ -37,7 +40,8 @@ module SuggestGrid
|
|
37
40
|
# @param [String] The name of the query parameter.
|
38
41
|
# @param [String] The value of the query parameter.
|
39
42
|
def add_query_parameter(name, value)
|
40
|
-
@query_url = APIHelper.append_url_with_query_parameters(@query_url,
|
43
|
+
@query_url = APIHelper.append_url_with_query_parameters(@query_url,
|
44
|
+
name => value)
|
41
45
|
@query_url = APIHelper.clean_url(@query_url)
|
42
46
|
end
|
43
47
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# Http response received.
|
4
6
|
class HttpResponse
|
5
7
|
attr_accessor :status_code, :headers, :raw_body
|
6
8
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# An action object represents a user's action of a type on an item.
|
4
6
|
class Action < BaseModel
|
5
7
|
# The type that the action belongs to.
|
6
8
|
# @return [String]
|
@@ -18,20 +20,19 @@ module SuggestGrid
|
|
18
20
|
# @return [Float]
|
19
21
|
attr_accessor :rating
|
20
22
|
|
21
|
-
# The optional UNIX epoch timestamp of the action. Defaults to the current
|
23
|
+
# The optional UNIX epoch timestamp of the action. Defaults to the current
|
24
|
+
# timestamp.
|
22
25
|
# @return [Long]
|
23
26
|
attr_accessor :timestamp
|
24
27
|
|
25
|
-
# A mapping from model property names to API property names
|
28
|
+
# A mapping from model property names to API property names.
|
26
29
|
def self.names
|
27
|
-
if @_hash.nil?
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
@_hash["timestamp"] = "timestamp"
|
34
|
-
end
|
30
|
+
@_hash = {} if @_hash.nil?
|
31
|
+
@_hash['type'] = 'type'
|
32
|
+
@_hash['user_id'] = 'user_id'
|
33
|
+
@_hash['item_id'] = 'item_id'
|
34
|
+
@_hash['rating'] = 'rating'
|
35
|
+
@_hash['timestamp'] = 'timestamp'
|
35
36
|
@_hash
|
36
37
|
end
|
37
38
|
|
@@ -47,18 +48,18 @@ module SuggestGrid
|
|
47
48
|
@timestamp = timestamp
|
48
49
|
end
|
49
50
|
|
50
|
-
# Creates an instance of the object from a hash
|
51
|
+
# Creates an instance of the object from a hash.
|
51
52
|
def self.from_hash(hash)
|
52
53
|
return nil unless hash
|
53
54
|
|
54
|
-
# Extract variables from the hash
|
55
|
+
# Extract variables from the hash.
|
55
56
|
type = hash['type']
|
56
57
|
user_id = hash['user_id']
|
57
58
|
item_id = hash['item_id']
|
58
59
|
rating = hash['rating']
|
59
60
|
timestamp = hash['timestamp']
|
60
61
|
|
61
|
-
# Create object from extracted values
|
62
|
+
# Create object from extracted values.
|
62
63
|
Action.new(type,
|
63
64
|
user_id,
|
64
65
|
item_id,
|
@@ -1,6 +1,8 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# Paged actions response.
|
4
6
|
class ActionsResponse < BaseModel
|
5
7
|
# The number of actions in the response.
|
6
8
|
# @return [Long]
|
@@ -14,14 +16,12 @@ module SuggestGrid
|
|
14
16
|
# @return [List of Action]
|
15
17
|
attr_accessor :actions
|
16
18
|
|
17
|
-
# A mapping from model property names to API property names
|
19
|
+
# A mapping from model property names to API property names.
|
18
20
|
def self.names
|
19
|
-
if @_hash.nil?
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@_hash["actions"] = "actions"
|
24
|
-
end
|
21
|
+
@_hash = {} if @_hash.nil?
|
22
|
+
@_hash['count'] = 'count'
|
23
|
+
@_hash['total_count'] = 'total_count'
|
24
|
+
@_hash['actions'] = 'actions'
|
25
25
|
@_hash
|
26
26
|
end
|
27
27
|
|
@@ -33,21 +33,23 @@ module SuggestGrid
|
|
33
33
|
@actions = actions
|
34
34
|
end
|
35
35
|
|
36
|
-
# Creates an instance of the object from a hash
|
36
|
+
# Creates an instance of the object from a hash.
|
37
37
|
def self.from_hash(hash)
|
38
38
|
return nil unless hash
|
39
39
|
|
40
|
-
# Extract variables from the hash
|
40
|
+
# Extract variables from the hash.
|
41
41
|
count = hash['count']
|
42
42
|
total_count = hash['total_count']
|
43
43
|
# Parameter is an array, so we need to iterate through it
|
44
44
|
actions = nil
|
45
|
-
|
46
|
-
actions =
|
47
|
-
hash['actions'].each
|
45
|
+
unless hash['actions'].nil?
|
46
|
+
actions = []
|
47
|
+
hash['actions'].each do |structure|
|
48
|
+
actions << (Action.from_hash(structure) if structure)
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
|
-
# Create object from extracted values
|
52
|
+
# Create object from extracted values.
|
51
53
|
ActionsResponse.new(count,
|
52
54
|
total_count,
|
53
55
|
actions)
|
@@ -1,32 +1,34 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# Base model.
|
4
6
|
class BaseModel
|
5
|
-
# Returns a Hash representation of the current object
|
7
|
+
# Returns a Hash representation of the current object.
|
6
8
|
def to_hash
|
7
9
|
hash = {}
|
8
|
-
|
9
|
-
value =
|
10
|
+
instance_variables.each do |name|
|
11
|
+
value = instance_variable_get(name)
|
10
12
|
name = name[1..-1]
|
11
13
|
key = self.class.names.key?(name) ? self.class.names[name] : name
|
12
14
|
if value.instance_of? Array
|
13
|
-
hash[key] = value.map{|v| v.
|
15
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
14
16
|
elsif value.instance_of? Hash
|
15
17
|
hash[key] = {}
|
16
18
|
value.each do |k, v|
|
17
|
-
hash[key][k] = v.
|
19
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
18
20
|
end
|
19
21
|
else
|
20
|
-
hash[key] = value.
|
22
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
21
23
|
end
|
22
24
|
end
|
23
25
|
hash
|
24
26
|
end
|
25
27
|
|
26
|
-
# Returns a JSON representation of the curent object
|
28
|
+
# Returns a JSON representation of the curent object.
|
27
29
|
def to_json(options = {})
|
28
30
|
hash = to_hash
|
29
31
|
hash.to_json(options)
|
30
32
|
end
|
31
33
|
end
|
32
|
-
end
|
34
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
|
-
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
1
|
+
# This file was automatically generated for SuggestGrid by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
2
3
|
|
3
4
|
module SuggestGrid
|
5
|
+
# Error response returned due to bulk post schema validations.
|
4
6
|
class BulkPostError < BaseModel
|
5
7
|
# Message of the response.
|
6
8
|
# @return [String]
|
@@ -14,14 +16,12 @@ module SuggestGrid
|
|
14
16
|
# @return [Object]
|
15
17
|
attr_accessor :error
|
16
18
|
|
17
|
-
# A mapping from model property names to API property names
|
19
|
+
# A mapping from model property names to API property names.
|
18
20
|
def self.names
|
19
|
-
if @_hash.nil?
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@_hash["error"] = "error"
|
24
|
-
end
|
21
|
+
@_hash = {} if @_hash.nil?
|
22
|
+
@_hash['message'] = 'message'
|
23
|
+
@_hash['value'] = 'value'
|
24
|
+
@_hash['error'] = 'error'
|
25
25
|
@_hash
|
26
26
|
end
|
27
27
|
|
@@ -33,16 +33,16 @@ module SuggestGrid
|
|
33
33
|
@error = error
|
34
34
|
end
|
35
35
|
|
36
|
-
# Creates an instance of the object from a hash
|
36
|
+
# Creates an instance of the object from a hash.
|
37
37
|
def self.from_hash(hash)
|
38
38
|
return nil unless hash
|
39
39
|
|
40
|
-
# Extract variables from the hash
|
40
|
+
# Extract variables from the hash.
|
41
41
|
message = hash['message']
|
42
42
|
value = hash['value']
|
43
43
|
error = hash['error']
|
44
44
|
|
45
|
-
# Create object from extracted values
|
45
|
+
# Create object from extracted values.
|
46
46
|
BulkPostError.new(message,
|
47
47
|
value,
|
48
48
|
error)
|