erp_integration 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18ec55a600cfb88679e7c8ac4a8e397cd304312a5f85a7c2e54d63307d7c86ff
|
4
|
+
data.tar.gz: 106c3c7f314668d09bb8589d1ea5243e4586a705871f891edf95efd0d9228028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b8cd54866c82420eed9237a40d8d668494763ed7ef15ac588a15d73260e163eb416a1fb8bc316cd4e08624dddfc70a99e99b3056b046ed4ebb0601298ae0728
|
7
|
+
data.tar.gz: 90e3145efef13b1d5f6307dd75a74811604cc2766f643970847d3570ff7dcba62fa11c252590b94d9f43f46df2b42352e1de754cf3a55a17f2472ce89a8fc980
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ErpIntegration
|
4
|
+
module Fulfil
|
5
|
+
class OrClause
|
6
|
+
LOGIC_OPERATOR = 'OR'
|
7
|
+
|
8
|
+
def initialize(where_clauses:)
|
9
|
+
@where_clauses = where_clauses
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_filter
|
13
|
+
return [] unless @where_clauses.any?
|
14
|
+
|
15
|
+
@where_clauses.map(&:to_filter).unshift(LOGIC_OPERATOR)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -23,9 +23,10 @@ module ErpIntegration
|
|
23
23
|
|
24
24
|
# @param fields [Array<String|Symbol>] A list of fields for Fulfil.
|
25
25
|
# @param filters [Array<WhereClause>] A list of where clauses for Fulfil.
|
26
|
-
def initialize(fields, filters)
|
26
|
+
def initialize(fields, filters, alternative_filters = [])
|
27
27
|
@fields = (fields || DEFAULT_FIELDS).map(&:to_s).uniq
|
28
28
|
@filters = (filters || []).map(&:to_filter).uniq
|
29
|
+
@filters += alternative_filters.map(&:to_filter).uniq if alternative_filters&.any?
|
29
30
|
end
|
30
31
|
|
31
32
|
def to_json(*_object)
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
require_relative 'query'
|
4
4
|
require_relative 'where_clause'
|
5
|
+
require_relative 'or_clause'
|
5
6
|
|
6
7
|
module ErpIntegration
|
7
8
|
module Fulfil
|
8
9
|
module QueryMethods
|
9
|
-
attr_accessor :selected_fields, :where_clauses
|
10
|
+
attr_accessor :selected_fields, :where_clauses, :or_clauses
|
10
11
|
|
11
12
|
# The `QueryMethods#select` works in two unique ways
|
12
13
|
#
|
@@ -82,6 +83,47 @@ module ErpIntegration
|
|
82
83
|
self
|
83
84
|
end
|
84
85
|
|
86
|
+
# The `or` method introduces an interface to query resources in Fulfil
|
87
|
+
# Is quite similar to the `where` method but with one big difference.
|
88
|
+
# The `or` method allows us to use the OR operator with several conditions
|
89
|
+
#
|
90
|
+
# @example
|
91
|
+
# $ ErpIntegration::SalesOrder.or(id: 100, carrier: 12).all
|
92
|
+
# # => <ErpIntegration::Fulfil::Collection @items=[
|
93
|
+
# <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @carrier=12, @id=3179663 />
|
94
|
+
# <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @carrier=16, @id=100 /> ] />
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# $ ErpIntegration::SalesOrder.or(id: [100, 200]).all
|
98
|
+
# # => <ErpIntegration::Fulfil::Collection @items=[
|
99
|
+
# <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @id=100 />
|
100
|
+
# <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @id=200 /> ] />
|
101
|
+
#
|
102
|
+
# Now we are just accepting the last 'or' method so if we have multiple
|
103
|
+
# we are only accepting the last one.
|
104
|
+
def or(*args)
|
105
|
+
clone.or!(*args)
|
106
|
+
end
|
107
|
+
|
108
|
+
def or!(args)
|
109
|
+
where_clauses = []
|
110
|
+
args.each_pair do |key, value_or_values|
|
111
|
+
[*value_or_values].each do |value|
|
112
|
+
where_clauses << WhereClause.new(
|
113
|
+
key: key, value: value
|
114
|
+
)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
self.or_clauses = [
|
119
|
+
OrClause.new(
|
120
|
+
where_clauses: where_clauses
|
121
|
+
)
|
122
|
+
]
|
123
|
+
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
85
127
|
def where_ilike(args)
|
86
128
|
where(args.merge(comparison_operator: 'ilike'))
|
87
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erp_integration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Vermaas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- lib/erp_integration/fulfil/client.rb
|
272
272
|
- lib/erp_integration/fulfil/context.rb
|
273
273
|
- lib/erp_integration/fulfil/finder_methods.rb
|
274
|
+
- lib/erp_integration/fulfil/or_clause.rb
|
274
275
|
- lib/erp_integration/fulfil/persistence.rb
|
275
276
|
- lib/erp_integration/fulfil/query.rb
|
276
277
|
- lib/erp_integration/fulfil/query_methods.rb
|
@@ -334,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
335
|
- !ruby/object:Gem::Version
|
335
336
|
version: '0'
|
336
337
|
requirements: []
|
337
|
-
rubygems_version: 3.
|
338
|
+
rubygems_version: 3.3.7
|
338
339
|
signing_key:
|
339
340
|
specification_version: 4
|
340
341
|
summary: Connects Mejuri with third-party ERP vendors
|