finapps 5.0.23 → 5.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/finapps/rest/orders.rb +51 -28
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/orders_spec.rb +10 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f21200338d07c1ab7882266ee53bb695bcd2214fd54c3dd8bd1e4f54f07003fd
|
4
|
+
data.tar.gz: 95168dfe1ade82536cd5ccb0a967a451cfabc6c3323796955e97f821c81c03ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd3183fe7bad50f52717109c80b14766a642d895d8d3fc30bce7171428324cb372258b31d5d70f14fe0f492875109b6b415dbf2008d6fe3c05e59e93e98ee2b3
|
7
|
+
data.tar.gz: c3a257358611b37562c7d34559bd69b574fdd590a7576c82cb8fa569b298bc2b907bee86a447c052f15c59480c74df81663e033c9833601be018f196fac387c2
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -56,48 +56,71 @@ module FinApps
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def build_filter(params)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
filter.merge!(relation_query(params[:relation])) if !params[:searchTerm] && !nil_or_empty?(params[:relation])
|
64
|
-
filter
|
59
|
+
search_query(params[:searchTerm]).merge(status_query(params[:status]))
|
60
|
+
.merge(assignment_query(params[:assignment]))
|
61
|
+
.merge(consumer_query(params[:consumer]))
|
62
|
+
.merge(relation_query(params[:relation], params[:searchTerm]))
|
65
63
|
end
|
66
64
|
|
67
65
|
def search_query(term)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
"
|
66
|
+
if term
|
67
|
+
{
|
68
|
+
"$or": [
|
69
|
+
{ "public_id": { "$regex": "^#{term}", "$options": 'i' } },
|
70
|
+
{ "applicant.last_name": term },
|
71
|
+
{ "assignment.last_name": term },
|
72
|
+
{
|
73
|
+
"requestor.reference_no": {
|
74
|
+
"$regex": "^#{term}", "$options": 'i'
|
75
|
+
}
|
76
76
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
]
|
78
|
+
}
|
79
|
+
else
|
80
|
+
{}
|
81
|
+
end
|
80
82
|
end
|
81
83
|
|
82
84
|
def status_query(status)
|
83
|
-
if status
|
84
|
-
|
85
|
+
if status
|
86
|
+
if status.is_a?(Array)
|
87
|
+
{ "status": { "$in": status.map(&:to_i) } }
|
88
|
+
else
|
89
|
+
{ "status": status.to_i }
|
90
|
+
end
|
85
91
|
else
|
86
|
-
{
|
92
|
+
{}
|
87
93
|
end
|
88
94
|
end
|
89
95
|
|
90
96
|
def assignment_query(assignment)
|
91
|
-
|
97
|
+
# translate "" to null assignment
|
98
|
+
if assignment
|
99
|
+
{ "assignment.operator_id": assignment.empty? ? nil : assignment }
|
100
|
+
else
|
101
|
+
{}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def consumer_query(consumer)
|
106
|
+
if consumer
|
107
|
+
{ "consumer_id": consumer.empty? ? nil : consumer }
|
108
|
+
else
|
109
|
+
{}
|
110
|
+
end
|
92
111
|
end
|
93
112
|
|
94
|
-
def relation_query(relation)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
113
|
+
def relation_query(relation, search_term)
|
114
|
+
if !search_term && !nil_or_empty?(relation)
|
115
|
+
{
|
116
|
+
"$or": [
|
117
|
+
{ "public_id": { "$in": relation } },
|
118
|
+
{ "original_order_id": { "$in": relation } }
|
119
|
+
]
|
120
|
+
}
|
121
|
+
else
|
122
|
+
{}
|
123
|
+
end
|
101
124
|
end
|
102
125
|
end
|
103
126
|
end
|
data/lib/finapps/version.rb
CHANGED
data/spec/rest/orders_spec.rb
CHANGED
@@ -102,6 +102,7 @@ RSpec.describe FinApps::REST::Orders do
|
|
102
102
|
searchTerm: 'term',
|
103
103
|
status: %w[1 7],
|
104
104
|
assignment: 'valid_operator',
|
105
|
+
consumer: 'valid_consumer_id',
|
105
106
|
relation: %w[valid_order_id]
|
106
107
|
}
|
107
108
|
end
|
@@ -121,20 +122,21 @@ RSpec.describe FinApps::REST::Orders do
|
|
121
122
|
subject
|
122
123
|
url =
|
123
124
|
"#{versioned_api_path}/orders?filter=%7B%22$or%22:%5B%7B%22public_id%22:" \
|
124
|
-
'%7B%22$regex%22:%22%5Eterm%22,%22$options%22:%22i%22%7D%7D,%7B%22applicant.last_name%22:%
|
125
|
-
',%7B%22assignment.last_name%22:%22term%22%7D,%7B%22requestor.reference_no%22:%7B%22
|
126
|
-
'
|
127
|
-
'operator_id%22:%22valid_operator%22%7D
|
125
|
+
'%7B%22$regex%22:%22%5Eterm%22,%22$options%22:%22i%22%7D%7D,%7B%22applicant.last_name%22:%22' \
|
126
|
+
'term%22%7D,%7B%22assignment.last_name%22:%22term%22%7D,%7B%22requestor.reference_no%22:%7B%22' \
|
127
|
+
'$regex%22:%22%5Eterm%22,%22$options%22:%22i%22%7D%7D%5D,%22status%22:%7B%22$in%22:%5B1,7%5D%7D,' \
|
128
|
+
'%22assignment.operator_id%22:%22valid_operator%22,%22consumer_id%22:%22valid_consumer_id%22%7D' \
|
129
|
+
'&page=2&requested=25&sort=status'
|
128
130
|
expect(WebMock).to have_requested(:get, url)
|
129
131
|
end
|
130
132
|
it 'builds query and sends proper request with searchTerm/relation exclusivity' do
|
131
133
|
params[:searchTerm] = nil
|
132
134
|
subject
|
133
135
|
url =
|
134
|
-
"#{versioned_api_path}/orders?filter=%7B%22status%22:%7B%22$in%22:%5B1," \
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
"#{versioned_api_path}/orders?filter=%7B%22status%22:%7B%22$in%22:%5B1,7%5D%7D," \
|
137
|
+
'%22assignment.operator_id%22:%22valid_operator%22,%22consumer_id%22:%22valid_consumer_id%22,' \
|
138
|
+
'%22$or%22:%5B%7B%22public_id%22:%7B%22$in%22:%5B%22valid_order_id%22%5D%7D%7D,%7B%22original_order_id%22:' \
|
139
|
+
'%7B%22$in%22:%5B%22valid_order_id%22%5D%7D%7D%5D%7D&page=2&requested=25&sort=status'
|
138
140
|
expect(WebMock).to have_requested(:get, url)
|
139
141
|
end
|
140
142
|
it 'builds null assignment query properly when supplied w/ empty string' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: finapps_core
|