restful-tradecontributions 0.1.7

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f8220cade3b8e2483ad3893d63c713bbc5f2d326
4
+ data.tar.gz: c5b5ef886bba0fdc920362b38dc73ac9bb88b279
5
+ SHA512:
6
+ metadata.gz: 5f6b64a7a0e6c830fcd16aeefc5f2bee303c44ccc20b76480fd141ebdd4adf63a7f12292fa21027839fe79fc11dab2a4420c38db2ba1dad448f5297b50fac7cc
7
+ data.tar.gz: 8383cf9b0e65be45cab73be9890b8fd479da20d7e647df5f26b525ab2703ef75b6641fd584ee890aac74359aa6f6f2a94866692f92e93bb73a949811a120168e
@@ -0,0 +1,372 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # ######################################################################## #
5
+ # File: tools/servers/restful/trade_contributions/ws.rb
6
+ #
7
+ # Purpose: Main module/entry file for the Trade-Contributions Microservice
8
+ #
9
+ # Copyright (c) 2018, Razor Risk Technologies Pty Ltd
10
+ # All rights reserved.
11
+ #
12
+ # ######################################################################## #
13
+
14
+
15
+ # ##########################################################################
16
+
17
+ # Microservices: Trade-Contributions (trade_contributions)
18
+ #
19
+ # Supported:
20
+ #
21
+ # - [GET] / {Unsecured}
22
+ # - [GET] /get/:id {Secured}
23
+
24
+ # ##########################################################################
25
+ # requires
26
+
27
+ require 'razor_risk/cassini/diagnostics/zeroth_include'
28
+
29
+ require 'razor_risk/cassini/applications/microservices/restful/trade_contributions'
30
+
31
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions'
32
+
33
+ require 'razor_risk/cassini/main'
34
+
35
+ require 'razor_risk/cassini/applications/rest_framework/route_verb_dispatcher'
36
+ require 'razor_risk/cassini/applications/secured_microservice'
37
+ require 'razor_risk/cassini/authorisation'
38
+ require 'razor_risk/cassini/common/version'
39
+ require 'razor_risk/cassini/util/version_util'
40
+
41
+ require 'razor_risk/razor/connectivity/razor_3/header_maker'
42
+ require 'razor_risk/razor/connectivity/razor_3/razor_requester'
43
+ require 'razor_risk/razor/connectivity/version'
44
+
45
+ require 'razor_risk/core/diagnostics/extensions/libclimate'
46
+ require 'razor_risk/core/diagnostics/logger'
47
+
48
+ require 'active_support/core_ext/hash'
49
+ require 'pantheios'
50
+ require 'xqsr3/version'
51
+
52
+ require 'csv'
53
+ require 'json'
54
+ require 'nokogiri'
55
+
56
+ # ##########################################################################
57
+ # includes
58
+
59
+ include ::RazorRisk::Cassini::Applications
60
+ include ::RazorRisk::Cassini::Applications::RESTFramework
61
+ include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors
62
+ include ::RazorRisk::Cassini::Authorisation::SecurityModelHelpers
63
+ include ::RazorRisk::Cassini::Constants
64
+ include ::RazorRisk::Cassini::Util::SecretsUtil
65
+ include ::RazorRisk::Cassini::Util::VersionUtil
66
+
67
+ include ::RazorRisk::Razor::Connectivity::Razor3
68
+
69
+ include ::RazorRisk::Cassini::Diagnostics
70
+ include ::RazorRisk::Core::Diagnostics::Logger
71
+
72
+ include ::Pantheios
73
+
74
+ # ##########################################################################
75
+ # constants
76
+
77
+ PROGRAM_VERSION = ::RazorRisk::Cassini::Applications::Microservices::RESTful::TradeContributions::VERSION
78
+
79
+ SUPPORTED_ROUTES = [
80
+ [ '/get/:id', :get, 'gets the trade contributions for the specified portfolio', ],
81
+ [ '/get/:id/structured', :get, 'gets the structured trade contributions for the specified portfolio', ],
82
+ [ '/get/:id/structured/summary', :get, 'gets the structured summary trade contributions for the specified portfolio', ],
83
+ [ '/get/:id/structured/:tradeId', :get, 'gets the structured summary trade contributions for the specified portfolio including the specified trade', ],
84
+ [ '/get/:id/structured/:profile/:netting', :get, 'gets the structured summary trade contributions for the specified portfolio including trades for the specified netting group', ],
85
+ [ '/get/:id/structured/:profile/:netting/:currency', :get, 'gets the structured summary trade contributions for the specified portfolio including trades for the specified currency', ],
86
+ ]
87
+
88
+ HTTP_ACCEPTS = %w{ text/html application/json application/xml text/xml text/csv text/plain text/tab-separated-values text/tsv }
89
+
90
+ # ##########################################################################
91
+ # compatibility checks
92
+
93
+ check_version_compatibility ::RazorRisk::Cassini::Common, [ 0, 21 ], 'RazorRisk.Cassini.Common'
94
+ check_version_compatibility ::RazorRisk::Razor::Connectivity, [ 0, 11, 2 ], 'RazorRisk.Razor.Connectivity'
95
+ check_version_compatibility ::LibCLImate, '0.8'
96
+ check_version_compatibility ::Pantheios, '0.20'
97
+ check_version_compatibility ::Xqsr3::VERSION, '0.27'
98
+
99
+ # ##########################################################################
100
+ # functions
101
+
102
+ def make_CSV_routes routes
103
+
104
+ CSV.generate do |csv|
105
+
106
+ routes.each do |ar|
107
+
108
+ csv << ar
109
+ end
110
+ end
111
+ end
112
+
113
+ def make_HTML_routes routes, **options
114
+
115
+ # TODO: use erb
116
+
117
+ routes = routes.map do |ar|
118
+
119
+ <<END_OF_tr
120
+ <tr>
121
+ <td>#{ar[0]}</td>
122
+ <td>#{ar[1]}</td>
123
+ <td>#{ar[2]}</td>
124
+ </tr>
125
+ END_OF_tr
126
+ end
127
+
128
+ <<END_OF_html
129
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.we.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
130
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
131
+ <head>
132
+ <title>Razor Risk Web Service API - Internal Microservice - trade</title>
133
+ <meta name="revisit-after" content="24 hours" />
134
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
135
+ </head>
136
+ <body>
137
+ <h1>Routes</h1>
138
+ <table>
139
+ <tr>
140
+ <th>Route</th>
141
+ <th>Verb</th>
142
+ <th>Description</th>
143
+ </tr>
144
+ #{routes.map { |r| r.chomp("\n") }.join("\n")}
145
+ </table>
146
+ </body>
147
+ </html>
148
+ END_OF_html
149
+ end
150
+
151
+ def make_JSON_routes routes, **options
152
+
153
+ r = {
154
+
155
+ 'routes' => []
156
+ }
157
+
158
+ r['routes'] = SUPPORTED_ROUTES.map { |ar| { route: ar[0], verb: ar[1].to_s.upcase, description: ar[2] } }
159
+
160
+ r.to_json
161
+ end
162
+
163
+ def make_Plain_routes routes
164
+
165
+ make_TSV_routes routes
166
+ end
167
+
168
+ def make_TSV_routes routes
169
+
170
+ routes.map { |ar| "#{ar[0]}\t#{ar[1]}\t#{ar[2]}\n" }
171
+ end
172
+
173
+ def make_XML_routes routes
174
+
175
+ <<END_OF_xml
176
+ <?xml version="1.0">
177
+ <routes>#{routes.map { |ar| %Q{ <route route="#{ar[0]}" verb="#{ar[1].to_s.upcase}" description="#{ar[2]}"/>}}.join(%Q{\n})}
178
+ </routes>
179
+ END_OF_xml
180
+ end
181
+
182
+ # ##########################################################################
183
+ # static set-up
184
+
185
+ # ##########################################################################
186
+ # lambdas
187
+
188
+ Lambdas_XML_to_JSON = lambda do |xml|
189
+
190
+ ConversionUtil.convert_XML_to_JSON xml
191
+ end
192
+
193
+ # ##########################################################################
194
+ # application
195
+
196
+ class TradeContributionsApp < SecuredMicroservice
197
+
198
+ include RouteVerbDispatch
199
+
200
+ include ::Pantheios
201
+
202
+
203
+ FULL_DESIGNATION = 'TradeContributions'
204
+ SHORT_DESIGNATION = 'trade_contributions'
205
+ SERVICE_TYPE = :microservice
206
+
207
+ PROGRAM_FEATURES = {
208
+
209
+ has_web_server: true,
210
+
211
+ has_host_and_port: true,
212
+
213
+ has_razor_connectivity: true,
214
+
215
+ authentication: :with_credentials_algorithm,
216
+
217
+ copyright_year: 2018,
218
+ }
219
+
220
+
221
+ def self.on_init_service options
222
+
223
+ trace ParamNames[ :options ], options
224
+
225
+ raise ArgumentError, 'missing keyword: razor_requester' unless options.has_key? :razor_requester
226
+
227
+ set :razor_requester, options[:razor_requester]
228
+ end
229
+
230
+
231
+
232
+ private
233
+ def sec
234
+
235
+ return '' if credentials.empty?
236
+ " (for #{credentials.join(':')})"
237
+ end
238
+ public
239
+
240
+
241
+ # functional routes (GET)
242
+
243
+ get '/get/:id/structured/:profile/:netting/:currency/:tradeId/?' do
244
+
245
+ trace ParamNames[ :request, :params ], request, params
246
+
247
+ dispatch TradeContributions::PagedItemGet
248
+ end
249
+
250
+ get '/get/:id/structured/:profile/:netting/:currency/?' do
251
+
252
+ trace ParamNames[ :request, :params ], request, params
253
+
254
+ dispatch TradeContributions::PagedItemGet
255
+ end
256
+
257
+ get '/get/:id/structured/:profile/:netting/?' do
258
+
259
+ trace ParamNames[ :request, :params ], request, params
260
+
261
+ dispatch TradeContributions::PagedItemGet
262
+ end
263
+
264
+ get '/get/:id/structured/summary/?' do
265
+
266
+ trace ParamNames[ :request, :params ], request, params
267
+
268
+ dispatch TradeContributions::StructuredSummaryGet
269
+ end
270
+
271
+ get '/get/:id/structured/:tradeId/?' do
272
+
273
+ trace ParamNames[ :request, :params ], request, params
274
+
275
+ dispatch TradeContributions::TradeItemGet
276
+ end
277
+
278
+ get '/get/:id/structured/?' do
279
+
280
+ trace ParamNames[ :request, :params ], request, params
281
+
282
+ dispatch TradeContributions::StructuredItemGet
283
+ end
284
+
285
+ get '/get/:id/?' do
286
+
287
+ trace ParamNames[ :request, :params ], request, params
288
+
289
+ dispatch TradeContributions::ItemGet
290
+ end
291
+
292
+ get '/' do
293
+
294
+ HTTP_ACCEPTS.each do |accept_type|
295
+
296
+ if request.accept? accept_type
297
+
298
+ content_type accept_type
299
+
300
+ case accept_type
301
+ when 'application/json'
302
+
303
+ r = make_JSON_routes SUPPORTED_ROUTES
304
+ when 'application/xml', 'text/xml'
305
+
306
+ r = make_XML_routes SUPPORTED_ROUTES
307
+ when 'text/csv'
308
+
309
+ r = make_CSV_routes SUPPORTED_ROUTES
310
+ when 'text/html'
311
+
312
+ r = make_HTML_routes SUPPORTED_ROUTES
313
+ when 'text/plain'
314
+
315
+ r = make_Plain_routes SUPPORTED_ROUTES
316
+ when 'text/tsv', 'text/tab-separated-values'
317
+
318
+ r = make_TSV_routes SUPPORTED_ROUTES
319
+ else
320
+
321
+ log :violation, 'unrecognised accept type \'', accept_type, '\''
322
+
323
+ halt *[ 500, {}, 'internal server failure' ]
324
+ end
325
+
326
+ return r
327
+ end
328
+ end
329
+
330
+ halt *[ 406, {}, "supports only the Accept types #{HTTP_ACCEPTS.map { |t| %Q<'#{t}'> }.join(', ')}" ]
331
+ end
332
+
333
+ define_catch_all_handlers
334
+ end
335
+
336
+ TheApp = TradeContributionsApp
337
+
338
+ # now define the OPTIONS support
339
+
340
+ supported_routes = Hash.new { |h, k| h[k] = [] }
341
+
342
+ SUPPORTED_ROUTES.each do |ar|
343
+
344
+ supported_routes[ar[0]].push ar[1]
345
+ end
346
+
347
+ supported_routes.each do |k, v|
348
+
349
+ if k =~ /:id(?:\/\?)?$/
350
+
351
+ route = "#$`*"
352
+ else
353
+
354
+ route = k
355
+ end
356
+
357
+ TheApp.options route do
358
+
359
+ verbs = v.map { |t| t.upcase }.join(',')
360
+
361
+ halt *[200, { 'Allow' => verbs }, [ verbs ] ]
362
+ end
363
+ end
364
+
365
+ TheApp.options '/' do
366
+
367
+ halt *[200, { 'Allow' => 'GET' }, '' ]
368
+ end
369
+
370
+ # ############################## end of file ############################# #
371
+
372
+
@@ -0,0 +1,48 @@
1
+ # encoding: UTF-8
2
+
3
+ # ##########################################################################
4
+ #
5
+ # Version for RazorRisk.Cassini.Microservices.RESTful.TradeContributions library
6
+ #
7
+ # Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
8
+ #
9
+ # ##########################################################################
10
+
11
+ module RazorRisk
12
+ module Cassini
13
+ module Applications
14
+ module Microservices
15
+ module RESTful
16
+
17
+ module TradeContributions
18
+
19
+ # Current version of the RazorRisk.Cassini.Microservices.RESTful.TradeContributions library
20
+ VERSION = '0.1.7'
21
+
22
+ private
23
+ VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
24
+ public
25
+ # Major version of the RazorRisk.Cassini.Microservices.RESTful.TradeContributions library
26
+ VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
27
+ # Minor version of the RazorRisk.Cassini.Microservices.RESTful.TradeContributions library
28
+ VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
29
+ # Patch version of the RazorRisk.Cassini.Microservices.RESTful.TradeContributions library
30
+ VERSION_PATCH = VERSION_PARTS_[2] # :nodoc:
31
+ # Commit version of the RazorRisk.Cassini.Microservices.RESTful.TradeContributions library
32
+ VERSION_COMMIT = VERSION_PARTS_[3] || 0 # :nodoc:
33
+
34
+
35
+ # The description of the framework
36
+ DESCRIPTION = "Razor Risk's Cassini Web-framework's Trade Contributions RESTful microservice"
37
+
38
+ end # module TradeContributions
39
+
40
+ end # module RESTful
41
+ end # module Microservices
42
+ end # module Applications
43
+ end # module Cassini
44
+ end # module RazorRisk
45
+
46
+ # ############################## end of file ############################# #
47
+
48
+
@@ -0,0 +1,2 @@
1
+
2
+ require 'razor_risk/cassini/applications/microservices/restful/trade_contributions/version'
@@ -0,0 +1,62 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ #
5
+ # Adaptor for TradeContributions microservice GET verb, unstructured item.
6
+ #
7
+ # Copyright (c) 2018 Razor Risk Technologies Pty Limited. All rights reserved.
8
+ #
9
+ # ######################################################################## #
10
+
11
+
12
+ # ##########################################################################
13
+ # requires
14
+
15
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get_helper'
16
+
17
+ require 'pantheios'
18
+
19
+ # ##########################################################################
20
+ # module
21
+
22
+ module RazorRisk
23
+ module Cassini
24
+ module Applications
25
+ module RouteVerbAdaptors
26
+ module TradeContributions
27
+
28
+ # ##########################################################################
29
+ # classes
30
+
31
+ class ItemGet < RESTFramework::VerbHandler
32
+
33
+ include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::TradeContributions::ItemGetHelper
34
+
35
+ ROUTE_VARIABLES = %w{
36
+ id
37
+ }
38
+
39
+ QUERY_PARAMETERS = %w{
40
+ }
41
+
42
+ def handle env, params, request, response
43
+
44
+ trace ParamNames[ :env, :params, :request, :response ], env, params, request, response
45
+
46
+ super env, params, request, response
47
+ end
48
+ end # class ItemGet
49
+
50
+ # ##########################################################################
51
+ # module
52
+
53
+ end # module TradeContributions
54
+ end # module RouteVerbAdaptors
55
+ end # module Applications
56
+ end # module Cassini
57
+ end # module RazorRisk
58
+
59
+ # ############################## end of file ############################# #
60
+
61
+
62
+
@@ -0,0 +1,165 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ #
5
+ # Copyright (c) 2018 Razor Risk Technologies Pty Limited. All rights reserved.
6
+ #
7
+ # ######################################################################## #
8
+
9
+
10
+ # ##########################################################################
11
+ # requires
12
+
13
+ require 'razor_risk/cassini/applications/rest_framework/verb_handler'
14
+
15
+ require 'razor_risk/cassini/util/conversion_util'
16
+
17
+ require 'razor_risk/razor/connectivity/razor_3/entity_connectors/trade_contributions_connector'
18
+ require 'razor_risk/core/diagnostics/logger'
19
+
20
+ require 'pantheios'
21
+
22
+ require 'csv'
23
+
24
+ # ##########################################################################
25
+ # module
26
+
27
+ module RazorRisk
28
+ module Cassini
29
+ module Applications
30
+ module RouteVerbAdaptors
31
+ module TradeContributions
32
+
33
+ # ##########################################################################
34
+ # classes
35
+
36
+ module ItemGetHelper
37
+
38
+ include ::RazorRisk::Razor::Connectivity::EntityConnectors::Exceptions
39
+ include ::RazorRisk::Razor::Connectivity::Razor3::EntityConnectors
40
+
41
+ include ::RazorRisk::Cassini::Util::ConversionUtil
42
+
43
+ include ::RazorRisk::Core::Diagnostics::Logger
44
+
45
+ include ::Pantheios
46
+
47
+ include ::Xqsr3::Conversion
48
+
49
+ HTTP_VERB = :get
50
+
51
+ HTTP_ACCEPTS = %w{
52
+ text/xml
53
+ application/xml
54
+ application/json
55
+ }
56
+
57
+ def handle env, params, request, response, **request_options
58
+
59
+ trace ParamNames[ :env, :params, :request, :response ], env, params, request, response
60
+
61
+ # params
62
+
63
+ id = Integer(params['id']) do
64
+ halt 404, {}, 'invalid identifier for GET verb - must be an integer'
65
+ end
66
+
67
+ # get credentials
68
+
69
+ cr = get_required_credentials
70
+
71
+ # get requester
72
+
73
+ rr = settings.razor_requester
74
+
75
+ # get connector
76
+
77
+ ec = TradeContributionsConnector.new(rr, credentials: cr)
78
+
79
+ # issue request
80
+
81
+ begin
82
+
83
+ qr = ec.get_trade_contributions(
84
+ id,
85
+ indicate_result_by: :qualified_result,
86
+ **request_options,
87
+ )
88
+ rescue RazorRequester::Exception, TradeContributionsConnector::EntityConnectorInternalStepException => x
89
+
90
+ log :failure, "exception (#{x.class}): #{x}"
91
+
92
+ headers = {
93
+ 'Content-Type' => 'text/plain',
94
+ }
95
+
96
+ if RazorRequester::InvalidCredentialsException === x
97
+
98
+ code = 401
99
+ msg = 'Invalid credentials'
100
+ else
101
+
102
+ code = 500
103
+ msg = x.message
104
+ end
105
+
106
+ halt(code, headers, msg)
107
+ end
108
+
109
+ log :debug1, "qr(#{qr.class})='#{qr}'"
110
+
111
+ unless qr.succeeded?
112
+
113
+ if qr.result.nil?
114
+ log :debug1, 'failed to retrieve trade contributions'
115
+ halt 404, {}, "could not retrieve the requested trade contributions"
116
+ elsif r = qr.failure_qualifier.reasons.lookup?('RZ0011')
117
+ log :debug1, 'failed to retrieve trade contributions'
118
+ halt 404, {}, "#{r.message}: #{r.details}"
119
+ else
120
+ log :warning, 'failed to retrieve trade contributions'
121
+ halt 500, {}, qr.failure_qualifier.reasons.join("\n")
122
+ end
123
+ end
124
+
125
+ r = qr.result.to_s
126
+
127
+ # return result
128
+
129
+ status 200
130
+
131
+ if request.accept?('application/xml')
132
+
133
+ log :debug1, 'application/xml'
134
+ content_type 'application/xml'
135
+ r
136
+ elsif request.accept?('text/xml')
137
+
138
+ log :debug1, 'text/xml'
139
+ content_type 'text/xml'
140
+ r
141
+ elsif request.accept?('application/json')
142
+
143
+ log :debug1, 'application/json'
144
+ content_type 'application/json'
145
+ convert_XML_to_JSON r, { scheme: :gdata }
146
+ else
147
+
148
+ log :violation, "unexpected failure to match given 'Accept' header '#{request.accept}'"
149
+ status 500
150
+ end
151
+ end
152
+ end # class ItemGet
153
+
154
+ # ##########################################################################
155
+ # module
156
+
157
+ end # module TradeContributions
158
+ end # module RouteVerbAdaptors
159
+ end # module Applications
160
+ end # module Cassini
161
+ end # module RazorRisk
162
+
163
+ # ############################## end of file ############################# #
164
+
165
+
@@ -0,0 +1,144 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ #
5
+ # Adaptor for TradeContributions microservice GET verb, structured item with
6
+ # paged trades.
7
+ #
8
+ # Copyright (c) 2018 Razor Risk Technologies Pty Limited. All rights reserved.
9
+ #
10
+ # ######################################################################## #
11
+
12
+
13
+ # ##########################################################################
14
+ # requires
15
+
16
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get_helper'
17
+
18
+ require 'pantheios'
19
+
20
+ # ##########################################################################
21
+ # module
22
+
23
+ module RazorRisk
24
+ module Cassini
25
+ module Applications
26
+ module RouteVerbAdaptors
27
+ module TradeContributions
28
+
29
+ # ##########################################################################
30
+ # classes
31
+
32
+ class PagedItemGet < RESTFramework::VerbHandler
33
+
34
+ include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::TradeContributions::ItemGetHelper
35
+
36
+ ROUTE_VARIABLES = %w{
37
+ id
38
+ profile
39
+ netting
40
+ currency
41
+ tradeId
42
+ }
43
+
44
+ QUERY_PARAMETERS = %w{
45
+ page-base
46
+ page-extent
47
+ }
48
+
49
+ PAGE_BASE_DEFAULT = 0
50
+ PAGE_EXTENT_DEFAULT = 1000
51
+
52
+ def handle env, params, request, response
53
+
54
+ trace ParamNames[ :env, :params, :request, :response ], env, params, request, response
55
+
56
+ profile = validate_param_(
57
+ params,
58
+ 'profile',
59
+ values: [ 'direct', 'indirect' ],
60
+ strip_str_whitespace: true,
61
+ ) { |p| p.to_sym }
62
+ netting = validate_param_(
63
+ params,
64
+ 'netting',
65
+ strip_str_whitespace: true,
66
+ reject_empty: true,
67
+ )
68
+ currency = validate_param_(
69
+ params,
70
+ 'currency',
71
+ strip_str_whitespace: true,
72
+ reject_empty: true,
73
+ allow_nil: true,
74
+ ) { |c| '-' == c ? nil : c }
75
+ trade_id = validate_param_(
76
+ params,
77
+ 'tradeId',
78
+ allow_nil: true
79
+ )
80
+ page_base = validate_param_(
81
+ params,
82
+ 'page-base',
83
+ allow_nil: true
84
+ ) { |p| convert_to_positive_integer_ p }
85
+ page_extent = validate_param_(
86
+ params,
87
+ 'page-extent',
88
+ allow_nil: true
89
+ ) { |p| convert_to_positive_integer_ p }
90
+
91
+ type = trade_id ? :singleTrade : :paged
92
+
93
+ options = {
94
+ extended: true,
95
+ type: type,
96
+ profile: profile,
97
+ netting: netting,
98
+ currency: currency,
99
+ page_base: page_base,
100
+ page_extent: page_extent,
101
+ trade_id: trade_id,
102
+ }
103
+
104
+ super env, params, request, response, options
105
+ end
106
+
107
+ private
108
+ def validate_param_ params, name, **options, &block
109
+ begin
110
+ param = check_option(params, name, **options)
111
+ param = yield param if block_given?
112
+ param
113
+ rescue => x
114
+ halt(
115
+ 422,
116
+ { 'Content-Type' => 'text/plain' },
117
+ "invalid parameter: '#{name}=#{params[name]}'; #{x.message}"
118
+ )
119
+ end
120
+ end
121
+
122
+ def convert_to_positive_integer_ int
123
+ if int
124
+ int = ::Xqsr3::Conversion::IntegerParser.to_integer(int) {
125
+ raise ::ArgumentError.new "must be a number"
126
+ }
127
+ raise ::ArgumentError.new "must be a positive" unless 0 <= int
128
+ int
129
+ end
130
+ end
131
+ end # class StructuredItemGet
132
+
133
+ # ##########################################################################
134
+ # module
135
+
136
+ end # module TradeContributions
137
+ end # module RouteVerbAdaptors
138
+ end # module Applications
139
+ end # module Cassini
140
+ end # module RazorRisk
141
+
142
+ # ############################## end of file ############################# #
143
+
144
+
@@ -0,0 +1,61 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ #
5
+ # Adaptor for TradeContributions microservice GET verb, structured item.
6
+ #
7
+ # Copyright (c) 2018 Razor Risk Technologies Pty Limited. All rights reserved.
8
+ #
9
+ # ######################################################################## #
10
+
11
+
12
+ # ##########################################################################
13
+ # requires
14
+
15
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get_helper'
16
+
17
+ require 'pantheios'
18
+
19
+ # ##########################################################################
20
+ # module
21
+
22
+ module RazorRisk
23
+ module Cassini
24
+ module Applications
25
+ module RouteVerbAdaptors
26
+ module TradeContributions
27
+
28
+ # ##########################################################################
29
+ # classes
30
+
31
+ class StructuredItemGet < RESTFramework::VerbHandler
32
+
33
+ include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::TradeContributions::ItemGetHelper
34
+
35
+ ROUTE_VARIABLES = %w{
36
+ id
37
+ }
38
+
39
+ QUERY_PARAMETERS = %w{
40
+ }
41
+
42
+ def handle env, params, request, response
43
+
44
+ trace ParamNames[ :env, :params, :request, :response ], env, params, request, response
45
+
46
+ super env, params, request, response, extended: true
47
+ end
48
+ end # class StructuredItemGet
49
+
50
+ # ##########################################################################
51
+ # module
52
+
53
+ end # module TradeContributions
54
+ end # module RouteVerbAdaptors
55
+ end # module Applications
56
+ end # module Cassini
57
+ end # module RazorRisk
58
+
59
+ # ############################## end of file ############################# #
60
+
61
+
@@ -0,0 +1,68 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ # File: razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get.rb
5
+ #
6
+ # Purpose: Adaptor for TradeContributions microservice's item GET verb
7
+ #
8
+ # Copyright (c) 2018, Razor Risk Technologies Pty Ltd
9
+ # All rights reserved.
10
+ #
11
+ # ######################################################################## #
12
+
13
+
14
+ # ##########################################################################
15
+ # requires
16
+
17
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get_helper'
18
+
19
+ require 'pantheios'
20
+
21
+ # ##########################################################################
22
+ # module
23
+
24
+ module RazorRisk
25
+ module Cassini
26
+ module Applications
27
+ module RouteVerbAdaptors
28
+ module TradeContributions
29
+
30
+ # ##########################################################################
31
+ # classes
32
+
33
+ class StructuredSummaryGet < RESTFramework::VerbHandler
34
+
35
+ include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::TradeContributions::ItemGetHelper
36
+
37
+ ROUTE_VARIABLES = %w{
38
+ id
39
+ }
40
+
41
+ QUERY_PARAMETERS = %w{
42
+ }
43
+
44
+ def handle env, params, request, response
45
+
46
+ trace ParamNames[ :env, :params, :request, :response ], env, params, request, response
47
+
48
+ options = {
49
+ extended: true,
50
+ type: :summary,
51
+ }
52
+
53
+ super env, params, request, response, options
54
+ end
55
+ end # class StructuredItemGet
56
+
57
+ # ##########################################################################
58
+ # module
59
+
60
+ end # module TradeContributions
61
+ end # module RouteVerbAdaptors
62
+ end # module Applications
63
+ end # module Cassini
64
+ end # module RazorRisk
65
+
66
+ # ############################## end of file ############################# #
67
+
68
+
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ #
5
+ # Adaptor for TradeContributions microservice GET verb, structured item with
6
+ # paged trades.
7
+ #
8
+ # Copyright (c) 2018 Razor Risk Technologies Pty Limited. All rights reserved.
9
+ #
10
+ # ######################################################################## #
11
+
12
+
13
+ # ##########################################################################
14
+ # requires
15
+
16
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get_helper'
17
+
18
+ require 'pantheios'
19
+
20
+ # ##########################################################################
21
+ # module
22
+
23
+ module RazorRisk
24
+ module Cassini
25
+ module Applications
26
+ module RouteVerbAdaptors
27
+ module TradeContributions
28
+
29
+ # ##########################################################################
30
+ # classes
31
+
32
+ class TradeItemGet < RESTFramework::VerbHandler
33
+
34
+ include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::TradeContributions::ItemGetHelper
35
+
36
+ ROUTE_VARIABLES = %w{
37
+ id
38
+ tradeId
39
+ }
40
+
41
+ QUERY_PARAMETERS = %w{
42
+ page-base
43
+ page-extent
44
+ }
45
+
46
+ PAGE_BASE_DEFAULT = 0
47
+ PAGE_EXTENT_DEFAULT = 1000
48
+
49
+ def handle env, params, request, response
50
+
51
+ trace ParamNames[ :env, :params, :request, :response ], env, params, request, response
52
+
53
+ trade_id = params['tradeId']
54
+
55
+ options = {
56
+ extended: true,
57
+ type: :singleTrade,
58
+ trade_id: trade_id
59
+ }
60
+
61
+ super env, params, request, response, options
62
+ end
63
+ end # class TradeItemGet
64
+
65
+ # ##########################################################################
66
+ # module
67
+
68
+ end # module TradeContributions
69
+ end # module RouteVerbAdaptors
70
+ end # module Applications
71
+ end # module Cassini
72
+ end # module RazorRisk
73
+
74
+ # ############################## end of file ############################# #
75
+
76
+
@@ -0,0 +1,7 @@
1
+
2
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get'
3
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/paged_item_get'
4
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/structured_item_get'
5
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/structured_summary_get'
6
+ require 'razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/trade_item_get'
7
+
metadata ADDED
@@ -0,0 +1,260 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: restful-tradecontributions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.7
5
+ platform: ruby
6
+ authors:
7
+ - Razor Risk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: razorrisk-cassini-common
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.24'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.24.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.24'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.24.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: razorrisk-razor-connectivity
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.11.2
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.11.2
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: razorrisk-razor-connectivity-entityconnectors
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.26.27
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.26.27
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: razorrisk-razor-connectivity-search
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.1.0
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.1.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: razorrisk-core-diagnostics-extensions
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.2'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '0.2'
101
+ - !ruby/object:Gem::Dependency
102
+ name: activesupport
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '4.0'
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '4.0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: clasp-ruby
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '0.14'
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: '0.14'
129
+ - !ruby/object:Gem::Dependency
130
+ name: json
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: '1.8'
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 1.8.3
139
+ type: :runtime
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.8'
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 1.8.3
149
+ - !ruby/object:Gem::Dependency
150
+ name: libclimate-ruby
151
+ requirement: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '0.10'
156
+ type: :runtime
157
+ prerelease: false
158
+ version_requirements: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: '0.10'
163
+ - !ruby/object:Gem::Dependency
164
+ name: nokogiri
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '1.6'
170
+ type: :runtime
171
+ prerelease: false
172
+ version_requirements: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - "~>"
175
+ - !ruby/object:Gem::Version
176
+ version: '1.6'
177
+ - !ruby/object:Gem::Dependency
178
+ name: pantheios-ruby
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: 0.20.2
184
+ type: :runtime
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: 0.20.2
191
+ - !ruby/object:Gem::Dependency
192
+ name: sinatra
193
+ requirement: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - "~>"
196
+ - !ruby/object:Gem::Version
197
+ version: 1.4.8
198
+ type: :runtime
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - "~>"
203
+ - !ruby/object:Gem::Version
204
+ version: 1.4.8
205
+ - !ruby/object:Gem::Dependency
206
+ name: xqsr3
207
+ requirement: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - "~>"
210
+ - !ruby/object:Gem::Version
211
+ version: '0.30'
212
+ type: :runtime
213
+ prerelease: false
214
+ version_requirements: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - "~>"
217
+ - !ruby/object:Gem::Version
218
+ version: '0.30'
219
+ description: Razor Risk's Cassini Web-framework's Trade Contributions RESTful microservice
220
+ email: operations@razor-risk.com
221
+ executables:
222
+ - razorrisk-microservice-tradecontributions
223
+ extensions: []
224
+ extra_rdoc_files: []
225
+ files:
226
+ - bin/razorrisk-microservice-tradecontributions
227
+ - lib/razor_risk/cassini/applications/microservices/restful/trade_contributions.rb
228
+ - lib/razor_risk/cassini/applications/microservices/restful/trade_contributions/version.rb
229
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions.rb
230
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get.rb
231
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/item_get_helper.rb
232
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/paged_item_get.rb
233
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/structured_item_get.rb
234
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/structured_summary_get.rb
235
+ - lib/razor_risk/cassini/applications/route_verb_adaptors/trade_contributions/trade_item_get.rb
236
+ homepage: https://razor-risk.com/
237
+ licenses:
238
+ - Nonstandard
239
+ metadata: {}
240
+ post_install_message:
241
+ rdoc_options: []
242
+ require_paths:
243
+ - lib
244
+ required_ruby_version: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: '2.0'
249
+ required_rubygems_version: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - ">="
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ requirements: []
255
+ rubyforge_project:
256
+ rubygems_version: 2.6.14
257
+ signing_key:
258
+ specification_version: 4
259
+ summary: Razor Risk Cassini Trade Contributions RESTful microservice
260
+ test_files: []