reward_sciences 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +24 -0
- data/README.md +380 -0
- data/lib/reward_sciences/api_helper.rb +151 -0
- data/lib/reward_sciences/configuration.rb +10 -0
- data/lib/reward_sciences/controllers/activities.rb +75 -0
- data/lib/reward_sciences/controllers/base_controller.rb +32 -0
- data/lib/reward_sciences/controllers/reward_categories.rb +61 -0
- data/lib/reward_sciences/controllers/rewards.rb +246 -0
- data/lib/reward_sciences/controllers/users.rb +123 -0
- data/lib/reward_sciences/exceptions/api_exception.rb +28 -0
- data/lib/reward_sciences/http/http_call_back.rb +17 -0
- data/lib/reward_sciences/http/http_client.rb +112 -0
- data/lib/reward_sciences/http/http_context.rb +15 -0
- data/lib/reward_sciences/http/http_method_enum.rb +7 -0
- data/lib/reward_sciences/http/http_request.rb +28 -0
- data/lib/reward_sciences/http/http_response.rb +19 -0
- data/lib/reward_sciences/http/unirest_client.rb +44 -0
- data/lib/reward_sciences/reward_sciences_client.rb +37 -0
- data/lib/reward_sciences.rb +28 -0
- metadata +107 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class RewardCategories < BaseController
|
5
|
+
@@instance = RewardCategories.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# List all the available reward categories.
|
12
|
+
# @param [Integer] limit Optional parameter: The number of reward categories you want to be retrieved.
|
13
|
+
# @param [Integer] offset Optional parameter: The number of reward categories you want to skip before starting the retrieval.
|
14
|
+
# @return Mixed response from the API call
|
15
|
+
def list(limit = 25,
|
16
|
+
offset = 0)
|
17
|
+
# the base uri for api requests
|
18
|
+
_query_builder = Configuration.base_uri.dup
|
19
|
+
|
20
|
+
# prepare query string for API call
|
21
|
+
_query_builder << '/reward_categories'
|
22
|
+
|
23
|
+
# process optional query parameters
|
24
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
25
|
+
'limit' => limit,
|
26
|
+
'offset' => offset
|
27
|
+
}
|
28
|
+
|
29
|
+
# validate and preprocess url
|
30
|
+
_query_url = APIHelper.clean_url _query_builder
|
31
|
+
|
32
|
+
# prepare headers
|
33
|
+
_headers = {
|
34
|
+
'user-agent' => 'APIMATIC 2.0',
|
35
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
36
|
+
}
|
37
|
+
|
38
|
+
# Create the HttpRequest object for the call
|
39
|
+
_request = @http_client.get _query_url, headers: _headers
|
40
|
+
|
41
|
+
# Call the on_before_request callback
|
42
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
43
|
+
|
44
|
+
# Invoke the API call and get the response
|
45
|
+
_response = @http_client.execute_as_string(_request)
|
46
|
+
|
47
|
+
# Wrap the request and response in an HttpContext object
|
48
|
+
_context = HttpContext.new(_request, _response)
|
49
|
+
|
50
|
+
# Call the on_after_response callback
|
51
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
52
|
+
|
53
|
+
# Global error handling using HTTP status codes.
|
54
|
+
validate_response(_context)
|
55
|
+
|
56
|
+
# Return appropriate response type
|
57
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
58
|
+
return decoded
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class Rewards < BaseController
|
5
|
+
@@instance = Rewards.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Bid on a reward auction.
|
12
|
+
# @param [Integer] user_id Required parameter: The ID of the user who is bidding on the reward auction.
|
13
|
+
# @param [Integer] reward_id Required parameter: The ID of the reward auction to be bid on.
|
14
|
+
# @param [String] amount Required parameter: Can be either 'max' (when max bidding) or the number of points the user wants to bid.
|
15
|
+
# @return Mixed response from the API call
|
16
|
+
def bid(user_id,
|
17
|
+
reward_id,
|
18
|
+
amount)
|
19
|
+
|
20
|
+
# Validate required parameters
|
21
|
+
if user_id == nil
|
22
|
+
raise ArgumentError.new "Required parameter 'user_id' cannot be nil."
|
23
|
+
elsif reward_id == nil
|
24
|
+
raise ArgumentError.new "Required parameter 'reward_id' cannot be nil."
|
25
|
+
elsif amount == nil
|
26
|
+
raise ArgumentError.new "Required parameter 'amount' cannot be nil."
|
27
|
+
end
|
28
|
+
|
29
|
+
# the base uri for api requests
|
30
|
+
_query_builder = Configuration.base_uri.dup
|
31
|
+
|
32
|
+
# prepare query string for API call
|
33
|
+
_query_builder << '/rewards/{reward_id}/bids'
|
34
|
+
|
35
|
+
# process optional query parameters
|
36
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
37
|
+
'reward_id' => reward_id
|
38
|
+
}
|
39
|
+
|
40
|
+
# process optional query parameters
|
41
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
42
|
+
'user_id' => user_id,
|
43
|
+
'amount' => amount
|
44
|
+
}
|
45
|
+
|
46
|
+
# validate and preprocess url
|
47
|
+
_query_url = APIHelper.clean_url _query_builder
|
48
|
+
|
49
|
+
# prepare headers
|
50
|
+
_headers = {
|
51
|
+
'user-agent' => 'APIMATIC 2.0',
|
52
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
53
|
+
}
|
54
|
+
|
55
|
+
# Create the HttpRequest object for the call
|
56
|
+
_request = @http_client.post _query_url, headers: _headers
|
57
|
+
|
58
|
+
# Call the on_before_request callback
|
59
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
60
|
+
|
61
|
+
# Invoke the API call and get the response
|
62
|
+
_response = @http_client.execute_as_string(_request)
|
63
|
+
|
64
|
+
# Wrap the request and response in an HttpContext object
|
65
|
+
_context = HttpContext.new(_request, _response)
|
66
|
+
|
67
|
+
# Call the on_after_response callback
|
68
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
69
|
+
|
70
|
+
# Global error handling using HTTP status codes.
|
71
|
+
validate_response(_context)
|
72
|
+
|
73
|
+
# Return appropriate response type
|
74
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
75
|
+
return decoded
|
76
|
+
end
|
77
|
+
|
78
|
+
# List all the available rewards.
|
79
|
+
# @param [Integer] category_id Optional parameter: The id of the category to filter rewards by
|
80
|
+
# @param [Integer] limit Optional parameter: The number of rewards you want to be retrieved.
|
81
|
+
# @param [Integer] offset Optional parameter: The number of rewards you want to skip before starting the retrieval.
|
82
|
+
# @return Mixed response from the API call
|
83
|
+
def list(category_id = nil,
|
84
|
+
limit = 25,
|
85
|
+
offset = 0)
|
86
|
+
# the base uri for api requests
|
87
|
+
_query_builder = Configuration.base_uri.dup
|
88
|
+
|
89
|
+
# prepare query string for API call
|
90
|
+
_query_builder << '/rewards'
|
91
|
+
|
92
|
+
# process optional query parameters
|
93
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
94
|
+
'category_id' => category_id,
|
95
|
+
'limit' => limit,
|
96
|
+
'offset' => offset
|
97
|
+
}
|
98
|
+
|
99
|
+
# validate and preprocess url
|
100
|
+
_query_url = APIHelper.clean_url _query_builder
|
101
|
+
|
102
|
+
# prepare headers
|
103
|
+
_headers = {
|
104
|
+
'user-agent' => 'APIMATIC 2.0',
|
105
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
106
|
+
}
|
107
|
+
|
108
|
+
# Create the HttpRequest object for the call
|
109
|
+
_request = @http_client.get _query_url, headers: _headers
|
110
|
+
|
111
|
+
# Call the on_before_request callback
|
112
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
113
|
+
|
114
|
+
# Invoke the API call and get the response
|
115
|
+
_response = @http_client.execute_as_string(_request)
|
116
|
+
|
117
|
+
# Wrap the request and response in an HttpContext object
|
118
|
+
_context = HttpContext.new(_request, _response)
|
119
|
+
|
120
|
+
# Call the on_after_response callback
|
121
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
122
|
+
|
123
|
+
# Global error handling using HTTP status codes.
|
124
|
+
validate_response(_context)
|
125
|
+
|
126
|
+
# Return appropriate response type
|
127
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
128
|
+
return decoded
|
129
|
+
end
|
130
|
+
|
131
|
+
# Redeem a reward.
|
132
|
+
# @param [Integer] user_id Required parameter: The ID of the user who is redeeming the reward.
|
133
|
+
# @param [Integer] reward_id Required parameter: The ID of the reward to be redeemed.
|
134
|
+
# @return Mixed response from the API call
|
135
|
+
def redeem(user_id,
|
136
|
+
reward_id)
|
137
|
+
|
138
|
+
# Validate required parameters
|
139
|
+
if user_id == nil
|
140
|
+
raise ArgumentError.new "Required parameter 'user_id' cannot be nil."
|
141
|
+
elsif reward_id == nil
|
142
|
+
raise ArgumentError.new "Required parameter 'reward_id' cannot be nil."
|
143
|
+
end
|
144
|
+
|
145
|
+
# the base uri for api requests
|
146
|
+
_query_builder = Configuration.base_uri.dup
|
147
|
+
|
148
|
+
# prepare query string for API call
|
149
|
+
_query_builder << '/rewards/{reward_id}/redemptions'
|
150
|
+
|
151
|
+
# process optional query parameters
|
152
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
153
|
+
'reward_id' => reward_id
|
154
|
+
}
|
155
|
+
|
156
|
+
# process optional query parameters
|
157
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
158
|
+
'user_id' => user_id
|
159
|
+
}
|
160
|
+
|
161
|
+
# validate and preprocess url
|
162
|
+
_query_url = APIHelper.clean_url _query_builder
|
163
|
+
|
164
|
+
# prepare headers
|
165
|
+
_headers = {
|
166
|
+
'user-agent' => 'APIMATIC 2.0',
|
167
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
168
|
+
}
|
169
|
+
|
170
|
+
# Create the HttpRequest object for the call
|
171
|
+
_request = @http_client.post _query_url, headers: _headers
|
172
|
+
|
173
|
+
# Call the on_before_request callback
|
174
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
175
|
+
|
176
|
+
# Invoke the API call and get the response
|
177
|
+
_response = @http_client.execute_as_string(_request)
|
178
|
+
|
179
|
+
# Wrap the request and response in an HttpContext object
|
180
|
+
_context = HttpContext.new(_request, _response)
|
181
|
+
|
182
|
+
# Call the on_after_response callback
|
183
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
184
|
+
|
185
|
+
# Global error handling using HTTP status codes.
|
186
|
+
validate_response(_context)
|
187
|
+
|
188
|
+
# Return appropriate response type
|
189
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
190
|
+
return decoded
|
191
|
+
end
|
192
|
+
|
193
|
+
# Show a reward's details.
|
194
|
+
# @param [Integer] reward_id Required parameter: The ID of the reward to be retrieved.
|
195
|
+
# @return Mixed response from the API call
|
196
|
+
def show(reward_id)
|
197
|
+
|
198
|
+
# Validate required parameters
|
199
|
+
if reward_id == nil
|
200
|
+
raise ArgumentError.new "Required parameter 'reward_id' cannot be nil."
|
201
|
+
end
|
202
|
+
|
203
|
+
# the base uri for api requests
|
204
|
+
_query_builder = Configuration.base_uri.dup
|
205
|
+
|
206
|
+
# prepare query string for API call
|
207
|
+
_query_builder << '/rewards/{reward_id}'
|
208
|
+
|
209
|
+
# process optional query parameters
|
210
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
211
|
+
'reward_id' => reward_id
|
212
|
+
}
|
213
|
+
|
214
|
+
# validate and preprocess url
|
215
|
+
_query_url = APIHelper.clean_url _query_builder
|
216
|
+
|
217
|
+
# prepare headers
|
218
|
+
_headers = {
|
219
|
+
'user-agent' => 'APIMATIC 2.0',
|
220
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
221
|
+
}
|
222
|
+
|
223
|
+
# Create the HttpRequest object for the call
|
224
|
+
_request = @http_client.get _query_url, headers: _headers
|
225
|
+
|
226
|
+
# Call the on_before_request callback
|
227
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
228
|
+
|
229
|
+
# Invoke the API call and get the response
|
230
|
+
_response = @http_client.execute_as_string(_request)
|
231
|
+
|
232
|
+
# Wrap the request and response in an HttpContext object
|
233
|
+
_context = HttpContext.new(_request, _response)
|
234
|
+
|
235
|
+
# Call the on_after_response callback
|
236
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
237
|
+
|
238
|
+
# Global error handling using HTTP status codes.
|
239
|
+
validate_response(_context)
|
240
|
+
|
241
|
+
# Return appropriate response type
|
242
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
243
|
+
return decoded
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class Users < BaseController
|
5
|
+
@@instance = Users.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# This endpoint lets retrieve a user's details.
|
12
|
+
# @param [Integer] user_id Required parameter: The ID of the user to be retrieved.
|
13
|
+
# @return Mixed response from the API call
|
14
|
+
def show(user_id)
|
15
|
+
|
16
|
+
# Validate required parameters
|
17
|
+
if user_id == nil
|
18
|
+
raise ArgumentError.new "Required parameter 'user_id' cannot be nil."
|
19
|
+
end
|
20
|
+
|
21
|
+
# the base uri for api requests
|
22
|
+
_query_builder = Configuration.base_uri.dup
|
23
|
+
|
24
|
+
# prepare query string for API call
|
25
|
+
_query_builder << '/users/{user_id}'
|
26
|
+
|
27
|
+
# process optional query parameters
|
28
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
29
|
+
'user_id' => user_id
|
30
|
+
}
|
31
|
+
|
32
|
+
# validate and preprocess url
|
33
|
+
_query_url = APIHelper.clean_url _query_builder
|
34
|
+
|
35
|
+
# prepare headers
|
36
|
+
_headers = {
|
37
|
+
'user-agent' => 'APIMATIC 2.0',
|
38
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
39
|
+
}
|
40
|
+
|
41
|
+
# Create the HttpRequest object for the call
|
42
|
+
_request = @http_client.get _query_url, headers: _headers
|
43
|
+
|
44
|
+
# Call the on_before_request callback
|
45
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
46
|
+
|
47
|
+
# Invoke the API call and get the response
|
48
|
+
_response = @http_client.execute_as_string(_request)
|
49
|
+
|
50
|
+
# Wrap the request and response in an HttpContext object
|
51
|
+
_context = HttpContext.new(_request, _response)
|
52
|
+
|
53
|
+
# Call the on_after_response callback
|
54
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
55
|
+
|
56
|
+
# Global error handling using HTTP status codes.
|
57
|
+
validate_response(_context)
|
58
|
+
|
59
|
+
# Return appropriate response type
|
60
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
61
|
+
return decoded
|
62
|
+
end
|
63
|
+
|
64
|
+
# This endpoint lets you tie a user with his/her activities. You’ll want to identify a user with any relevant information as soon as they log-in or sign-up.
|
65
|
+
# @param [String] email Required parameter: The user's email address
|
66
|
+
# @param [String] first_name Optional parameter: The user's first name
|
67
|
+
# @param [String] last_name Optional parameter: The user's last name
|
68
|
+
# @return Mixed response from the API call
|
69
|
+
def identify(email,
|
70
|
+
first_name = nil,
|
71
|
+
last_name = nil)
|
72
|
+
|
73
|
+
# Validate required parameters
|
74
|
+
if email == nil
|
75
|
+
raise ArgumentError.new "Required parameter 'email' cannot be nil."
|
76
|
+
end
|
77
|
+
|
78
|
+
# the base uri for api requests
|
79
|
+
_query_builder = Configuration.base_uri.dup
|
80
|
+
|
81
|
+
# prepare query string for API call
|
82
|
+
_query_builder << '/users'
|
83
|
+
|
84
|
+
# process optional query parameters
|
85
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
86
|
+
'email' => email,
|
87
|
+
'first_name' => first_name,
|
88
|
+
'last_name' => last_name
|
89
|
+
}
|
90
|
+
|
91
|
+
# validate and preprocess url
|
92
|
+
_query_url = APIHelper.clean_url _query_builder
|
93
|
+
|
94
|
+
# prepare headers
|
95
|
+
_headers = {
|
96
|
+
'user-agent' => 'APIMATIC 2.0',
|
97
|
+
'Authorization' => 'Bearer %s' % (Configuration.o_auth_access_token)
|
98
|
+
}
|
99
|
+
|
100
|
+
# Create the HttpRequest object for the call
|
101
|
+
_request = @http_client.post _query_url, headers: _headers
|
102
|
+
|
103
|
+
# Call the on_before_request callback
|
104
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
105
|
+
|
106
|
+
# Invoke the API call and get the response
|
107
|
+
_response = @http_client.execute_as_string(_request)
|
108
|
+
|
109
|
+
# Wrap the request and response in an HttpContext object
|
110
|
+
_context = HttpContext.new(_request, _response)
|
111
|
+
|
112
|
+
# Call the on_after_response callback
|
113
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
114
|
+
|
115
|
+
# Global error handling using HTTP status codes.
|
116
|
+
validate_response(_context)
|
117
|
+
|
118
|
+
# Return appropriate response type
|
119
|
+
decoded = APIHelper.json_deserialize(_response.raw_body) if not (_response.raw_body.nil? or _response.raw_body.to_s.strip.empty?)
|
120
|
+
return decoded
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class APIException < StandardError
|
5
|
+
attr_reader :context, :response_code
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [String] The reason for raising an exception
|
9
|
+
# @param [HttpContext] The HttpContext of the API call.
|
10
|
+
def initialize(reason, context)
|
11
|
+
response = context.response
|
12
|
+
super("#{ reason }: #{ exception_details(response) }")
|
13
|
+
@context = context
|
14
|
+
@response_code = response.status_code
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def exception_details(response)
|
20
|
+
begin
|
21
|
+
detail = JSON.parse(response.raw_body)['detail']
|
22
|
+
detail.is_a?(Array) ? detail.to_sentence : detail
|
23
|
+
rescue JSON::ParserError
|
24
|
+
'Please contact support'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class HttpCallBack
|
5
|
+
# A controller will call this method before making an HTTP Request.
|
6
|
+
# @param [HttpRequest] The HttpRequest object which the HttpClient will execute.
|
7
|
+
def on_before_request(http_request)
|
8
|
+
raise NotImplementedError, "This method needs to be implemented in a child class."
|
9
|
+
end
|
10
|
+
|
11
|
+
# A controller will call this method after making an HTTP Request.
|
12
|
+
# @param [HttpResponse] The HttpResponse object received from the HttpClient.
|
13
|
+
def on_after_response(http_response)
|
14
|
+
raise NotImplementedError, "This method needs to be implemented in a child class."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class HttpClient
|
5
|
+
# Execute an HttpRequest when the response is expected to be a string.
|
6
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
7
|
+
def execute_as_string(http_request)
|
8
|
+
raise NotImplementedError, "This method needs to be implemented in a child class."
|
9
|
+
end
|
10
|
+
|
11
|
+
# Execute an HttpRequest when the response is expected to be binary.
|
12
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
13
|
+
def execute_as_binary(http_request)
|
14
|
+
raise NotImplementedError, "This method needs to be implemented in a child class."
|
15
|
+
end
|
16
|
+
|
17
|
+
# Converts the HTTP Response from the client to an HttpResponse object.
|
18
|
+
# @param [Dynamic] The response object received from the client.
|
19
|
+
def convert_response(response)
|
20
|
+
raise NotImplementedError, "This method needs to be implemented in a child class."
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a GET HttpRequest object.
|
24
|
+
# @param [String] The URL to send the request to.
|
25
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
26
|
+
# @param [String, Optional] Username for Basic Auth requests.
|
27
|
+
# @param [String, Optional] Password for Basic Auth requests.
|
28
|
+
def get(query_url,
|
29
|
+
headers: nil,
|
30
|
+
username: nil,
|
31
|
+
password: nil)
|
32
|
+
return HttpRequest.new(HttpMethodEnum::GET,
|
33
|
+
query_url,
|
34
|
+
headers: headers,
|
35
|
+
username: username,
|
36
|
+
password: password)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get a POST HttpRequest object.
|
40
|
+
# @param [String] The URL to send the request to.
|
41
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
42
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
43
|
+
# @param [String, Optional] Username for Basic Auth requests.
|
44
|
+
# @param [String, Optional] Password for Basic Auth requests.
|
45
|
+
def post(query_url,
|
46
|
+
headers: nil,
|
47
|
+
parameters: nil,
|
48
|
+
username: nil,
|
49
|
+
password: nil)
|
50
|
+
return HttpRequest.new(HttpMethodEnum::POST,
|
51
|
+
query_url,
|
52
|
+
headers: headers,
|
53
|
+
parameters: parameters,
|
54
|
+
username: username,
|
55
|
+
password: password)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Get a PUT HttpRequest object.
|
59
|
+
# @param [String] The URL to send the request to.
|
60
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
61
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
62
|
+
# @param [String, Optional] Username for Basic Auth requests.
|
63
|
+
# @param [String, Optional] Password for Basic Auth requests.
|
64
|
+
def put(query_url,
|
65
|
+
headers: nil,
|
66
|
+
parameters: nil,
|
67
|
+
username: nil,
|
68
|
+
password: nil)
|
69
|
+
return HttpRequest.new(HttpMethodEnum::PUT,
|
70
|
+
query_url,
|
71
|
+
headers: headers,
|
72
|
+
parameters: parameters,
|
73
|
+
username: username,
|
74
|
+
password: password)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Get a PATCH HttpRequest object.
|
78
|
+
# @param [String] The URL to send the request to.
|
79
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
80
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
81
|
+
# @param [String, Optional] Username for Basic Auth requests.
|
82
|
+
# @param [String, Optional] Password for Basic Auth requests.
|
83
|
+
def patch(query_url,
|
84
|
+
headers: nil,
|
85
|
+
parameters: nil,
|
86
|
+
username: nil,
|
87
|
+
password: nil)
|
88
|
+
return HttpRequest.new(HttpMethodEnum::PATCH,
|
89
|
+
query_url,
|
90
|
+
headers: headers,
|
91
|
+
parameters: parameters,
|
92
|
+
username: username,
|
93
|
+
password: password)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Get a DELETE HttpRequest object.
|
97
|
+
# @param [String] The URL to send the request to.
|
98
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
99
|
+
# @param [String, Optional] Username for Basic Auth requests.
|
100
|
+
# @param [String, Optional] Password for Basic Auth requests.
|
101
|
+
def delete(query_url,
|
102
|
+
headers: nil,
|
103
|
+
username: nil,
|
104
|
+
password: nil)
|
105
|
+
return HttpRequest.new(HttpMethodEnum::DELETE,
|
106
|
+
query_url,
|
107
|
+
headers: headers,
|
108
|
+
username: username,
|
109
|
+
password: password)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class HttpContext
|
5
|
+
attr_accessor :request, :response
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [HttpRequest] An HttpRequest object representing the HTTP request.
|
9
|
+
# @param [HttpResponse] An HttpResponse object representing the HTTP response.
|
10
|
+
def initialize(request, response)
|
11
|
+
@request = request
|
12
|
+
@response = response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class HttpRequest
|
5
|
+
attr_accessor :http_method, :query_url, :headers, :parameters, :username, :password
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [HttpMethodEnum] The HTTP method.
|
9
|
+
# @param [String] The URL to send the request to.
|
10
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
11
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
12
|
+
# @param [String, Optional] Username for Basic Auth requests.
|
13
|
+
# @param [String, Optional] Password for Basic Auth requests.
|
14
|
+
def initialize(http_method,
|
15
|
+
query_url,
|
16
|
+
headers: nil,
|
17
|
+
parameters: nil,
|
18
|
+
username: nil,
|
19
|
+
password: nil)
|
20
|
+
@http_method = http_method
|
21
|
+
@query_url = query_url
|
22
|
+
@headers = headers
|
23
|
+
@parameters = parameters
|
24
|
+
@username = username
|
25
|
+
@password = password
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module RewardSciences
|
4
|
+
class HttpResponse
|
5
|
+
attr_accessor :status_code, :headers, :raw_body
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [Integer] The status code returned by the server.
|
9
|
+
# @param [Hash] The headers sent by the server in the response.
|
10
|
+
# @param [String] The raw body of the response.
|
11
|
+
def initialize(status_code,
|
12
|
+
headers,
|
13
|
+
raw_body)
|
14
|
+
@status_code = status_code
|
15
|
+
@headers = headers
|
16
|
+
@raw_body = raw_body
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|