finapps 5.0.30 → 5.0.31

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c74f2340d52ad3cd13dc2bdf8415e7cf89e48f0993dbb346456546910a69ba9
4
- data.tar.gz: 3bdefc2032a2efa241d5cc72ab5d6b74fc44b568599f0054bf5477e473fab81f
3
+ metadata.gz: 9245578f87d01b1010faa9e0f1d426873a24c86f860e83883027b966ba5ac129
4
+ data.tar.gz: d2b313cbdddb91c8645684727f91b1b7359becbcad1678758a604e43c4e0587c
5
5
  SHA512:
6
- metadata.gz: 9cb6732ca1b8ba09cc84920ec7fdd086259cd339f012f72cf19c30387f877f3af1aa495bea47f019ee638e9a32eb3f76bbd0397e89b6e773e108da98e9bc8300
7
- data.tar.gz: 5dedcdb78fa82b22011520031aae7aa55b1c6e35a7f5ccd55e16fdaa1c6d3b19bd4d17e300a00849d1768be6528b2396adff43ef96b6c6f060740af4315c857f
6
+ metadata.gz: 46be47b08a87fa355fe54b4db658074496561a6cf0f95c32a239f9b7164159b2aa13ce3a9a8030c5050c30086534212e0d947e88875e686a51edaf197d69c47d
7
+ data.tar.gz: afa0a48469d1538cc2af130a61d5765c4f7dd3e72c24a2c624a20d28f6436d16074b8e73bb25f68c4751946ea1b062b2438309173857ebbe1a314b18948ff874
@@ -1,3 +1,12 @@
1
+ ## [5.0.31] - 2020-06-11
2
+
3
+ ### Changed
4
+ * Consumer and Doc-order search to query names on spaces ([#224][i224])
5
+
6
+ [i224]: https://github.com/finapps/ruby-client/issues/224
7
+
8
+ [5.0.31]: https://github.com/finapps/ruby-client/compare/5.0.30...5.0.31
9
+
1
10
  ## [5.0.30] - 2020-05-28
2
11
 
3
12
  ### Added
@@ -54,14 +54,25 @@ module FinApps
54
54
  end
55
55
 
56
56
  def search_query(term)
57
+ query = with_space_search(term).concat(name_search(term))
57
58
  {
58
- "$or": [
59
- { "email": term },
60
- { "first_name": term },
61
- { "last_name": term }
62
- ]
59
+ "$or": query
63
60
  }
64
61
  end
62
+
63
+ def with_space_search(term)
64
+ [
65
+ { "email": term },
66
+ { "first_name": term },
67
+ { "last_name": term }
68
+ ]
69
+ end
70
+
71
+ def name_search(term)
72
+ search_arr = []
73
+ term.split.each { |t| search_arr.append({ "first_name": t }, "last_name": t) } if term.match(/\s/)
74
+ search_arr
75
+ end
65
76
  end
66
77
  end
67
78
  end
@@ -51,23 +51,36 @@ module FinApps
51
51
 
52
52
  def search_query(term)
53
53
  if term
54
+ query = with_space_search(term).concat(name_search(term))
54
55
  {
55
- "$or": [
56
- { "applicant.email": term },
57
- { "applicant.first_name": term },
58
- { "applicant.last_name": term },
59
- {
60
- "reference_no": {
61
- "$regex": "^#{term}", "$options": 'i'
62
- }
63
- }
64
- ]
56
+ "$or": query
65
57
  }
66
58
  else
67
59
  {}
68
60
  end
69
61
  end
70
62
 
63
+ def name_search(term)
64
+ search_arr = []
65
+ if term.match(/\s/)
66
+ term.split.each { |t| search_arr.append({ "applicant.first_name": t }, "applicant.last_name": t) }
67
+ end
68
+ search_arr
69
+ end
70
+
71
+ def with_space_search(term)
72
+ [
73
+ { "applicant.email": term },
74
+ { "applicant.first_name": term },
75
+ { "applicant.last_name": term },
76
+ {
77
+ "reference_no": {
78
+ "$regex": "^#{term}", "$options": 'i'
79
+ }
80
+ }
81
+ ]
82
+ end
83
+
71
84
  def tag_query(tag)
72
85
  if tag
73
86
  { "tag": tag.empty? ? nil : tag }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FinApps
4
- VERSION = '5.0.30'
4
+ VERSION = '5.0.31'
5
5
  end
@@ -110,6 +110,25 @@ RSpec.describe FinApps::REST::Consumers,
110
110
  '&sort=date_created'
111
111
  expect(WebMock).to have_requested(:get, url)
112
112
  end
113
+
114
+ context 'when search term contains a space' do
115
+ let(:params) do
116
+ {
117
+ page: 2,
118
+ sort: 'date_created',
119
+ requested: 25,
120
+ searchTerm: 'Two terms'
121
+ }
122
+ end
123
+ it 'treats space as start of a new query for first and last name' do
124
+ list
125
+ url = "#{versioned_api_path}/consumers?filter=%7B%22$or%22:%5B%7B%22email%22:%22Two%20terms%22%7D,"\
126
+ '%7B%22first_name%22:%22Two%20terms%22%7D,%7B%22last_name%22:%22Two%20terms%22%7D,%7B%22first_name%22:'\
127
+ '%22Two%22%7D,%7B%22last_name%22:%22Two%22%7D,%7B%22first_name%22:%22terms%22%7D,%7B%22last_name%22:'\
128
+ '%22terms%22%7D%5D%7D&page=2&requested=25&sort=date_created'
129
+ expect(WebMock).to have_requested(:get, url)
130
+ end
131
+ end
113
132
  end
114
133
  end
115
134
 
@@ -60,6 +60,21 @@ RSpec.describe FinApps::REST::DocumentsOrders do
60
60
 
61
61
  expect(WebMock).to have_requested(:get, url)
62
62
  end
63
+
64
+ context 'with search term containing spaces' do
65
+ let(:params) { { "searchTerm": 'Blue Jay', "page": 2 } }
66
+ it 'builds query and sends proper request' do
67
+ list
68
+ url =
69
+ "#{versioned_api_path}/documents/orders?filter=%7B%22$or%22:%5B%7B%22applicant.email%22:"\
70
+ '%22Blue%20Jay%22%7D,%7B%22applicant.first_name%22:%22Blue%20Jay%22%7D,%7B%22applicant.last_name%22:'\
71
+ '%22Blue%20Jay%22%7D,%7B%22reference_no%22:%7B%22$regex%22:%22%5EBlue%20Jay%22,%22$options%22:'\
72
+ '%22i%22%7D%7D,%7B%22applicant.first_name%22:%22Blue%22%7D,%7B%22applicant.last_name%22:%22Blue%22%7D,'\
73
+ '%7B%22applicant.first_name%22:%22Jay%22%7D,%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
74
+
75
+ expect(WebMock).to have_requested(:get, url)
76
+ end
77
+ end
63
78
  end
64
79
  end
65
80
 
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.30
4
+ version: 5.0.31
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-05-28 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: finapps_core
@@ -468,7 +468,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
468
468
  - !ruby/object:Gem::Version
469
469
  version: '0'
470
470
  requirements: []
471
- rubygems_version: 3.1.3
471
+ rubygems_version: 3.1.4
472
472
  signing_key:
473
473
  specification_version: 4
474
474
  summary: FinApps REST API ruby client.