finapps 2.3.5 → 2.3.6
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 +10 -0
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/orders_spec.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6193020d474b6c3868abc58a633736652f2bface
|
4
|
+
data.tar.gz: 8fec9d538fc88e8706a27f6a6eb009a45e0d2368
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f39b661759572f31166f54ca5839eef3260b0b426ab0db32422f310632508b65ed57e35a247397dc0bc7307601cf88cae72be7d1b36b0f6467299420cf454c2d
|
7
|
+
data.tar.gz: 785951c200e8749f45c42a91754849d7cc5533d6b6598a70823fcf18d6dcb5ea7c8b272f091c6ae75d8ee404dac668c039781938637ed98d6236a433c83ecefc
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -56,6 +56,7 @@ module FinApps
|
|
56
56
|
filter.merge!(search_query(params[:searchTerm])) if params[:searchTerm]
|
57
57
|
filter.merge!(status_query(params[:status])) if params[:status]
|
58
58
|
filter.merge!(assignment_query(params[:assignment])) if params.key?(:assignment) # assignment can be nil
|
59
|
+
filter.merge!(relation_query(params[:relation])) if !params[:searchTerm] && !nil_or_empty?(params[:relation])
|
59
60
|
filter
|
60
61
|
end
|
61
62
|
|
@@ -92,6 +93,15 @@ module FinApps
|
|
92
93
|
def assignment_query(assignment)
|
93
94
|
{"assignment.operator_id": assignment}
|
94
95
|
end
|
96
|
+
|
97
|
+
def relation_query(relation)
|
98
|
+
{
|
99
|
+
"$or": [
|
100
|
+
{"public_id": {"$in": relation}},
|
101
|
+
{"original_order_id": {"$in": relation}}
|
102
|
+
]
|
103
|
+
}
|
104
|
+
end
|
95
105
|
end
|
96
106
|
end
|
97
107
|
end
|
data/lib/finapps/version.rb
CHANGED
data/spec/rest/orders_spec.rb
CHANGED
@@ -78,7 +78,7 @@ RSpec.describe FinApps::REST::Orders do
|
|
78
78
|
subject { FinApps::REST::Orders.new(client).list(params) }
|
79
79
|
let(:params) do
|
80
80
|
{page: 2, sort: 'status', requested: 25, searchTerm: 'term', status: %w(1 7),
|
81
|
-
assignment: 'valid_operator'}
|
81
|
+
assignment: 'valid_operator', relation: ['valid_order_id']}
|
82
82
|
end
|
83
83
|
|
84
84
|
it { expect { subject }.not_to raise_error }
|
@@ -96,6 +96,15 @@ RSpec.describe FinApps::REST::Orders do
|
|
96
96
|
'valid_operator%22%7D&page=2&requested=25&sort=status'
|
97
97
|
expect(WebMock).to have_requested(:get, url)
|
98
98
|
end
|
99
|
+
it 'builds query and sends proper request with searchTerm/relation exclusivity' do
|
100
|
+
params[:searchTerm] = nil
|
101
|
+
subject
|
102
|
+
url = "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v2/orders?filter=%7B%22status%22:%7B%22$in%22:%5B1," \
|
103
|
+
'7%5D%7D,%22assignment.operator_id%22:%22valid_operator%22,%22$or%22:%5B%7B%22public_id%22:%7B%22$in' \
|
104
|
+
'%22:%5B%22valid_order_id%22%5D%7D%7D,%7B%22original_order_id%22:%7B%22$in%22:%5B%22valid_order_id%22' \
|
105
|
+
'%5D%7D%7D%5D%7D&page=2&requested=25&sort=status'
|
106
|
+
expect(WebMock).to have_requested(:get, url)
|
107
|
+
end
|
99
108
|
end
|
100
109
|
end
|
101
110
|
|