magento 0.3.1 → 0.3.2

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: eb33e9b6de9d7be6774a547b6c8cca7e25893d13d8c2095944d91a1b0bfdcc57
4
- data.tar.gz: e2074b421ade2bd63d369edade42aea984cdd6df352074f5b68fde7eb446ec34
3
+ metadata.gz: 02761b4b3a2e3b5da2082816534436f4f007f5f657b32400483bfd36d02f610b
4
+ data.tar.gz: 98e66dfd540d759b3e024de58bc43575b1c3437864584c4797d27391e5ec279e
5
5
  SHA512:
6
- metadata.gz: 28a92f51420661f86c3a0b632e00eb037f12cb92c84127d40f816f0be369c85a246e0ee4a9cb4036c8309666ccb0304e0918765a8866337d86258474f07ce45f
7
- data.tar.gz: 5a106aeee7305e8bdcea2f2b064cd902e095d159547ee8ec77e26b39477f2b9fc829a48f5df8dc1c4093c3b548c621aed0a9d0857cfa8e37f24c391959e41377
6
+ metadata.gz: 9523a813be0fc77cc4fea9a751b639994a1a8e03869326ae967b9b98bcee93edcdc03f81abae60110514a5833fc5d123d91c634af5bd149d7ff586e732b77db9
7
+ data.tar.gz: 40bba87521d8624056cee96a8832a6dfcaf99353c9c69038684e8bf7d29cd7d9883fd97330eb45e646a438415bb533934cbccca6847770e41255b38d4c237ebb
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add in your Gemfile
6
6
 
7
7
  ```rb
8
- gem 'magento', '~> 0.3.1'
8
+ gem 'magento', '~> 0.3.2'
9
9
  ```
10
10
 
11
11
  or run
@@ -66,27 +66,35 @@ Magento::Product.select(:id, :sku, :name, extension_attributes: [:website_ids, {
66
66
  ```rb
67
67
  Magento::Product.where(name_like: 'IPhone%').all
68
68
  Magento::Product.where(price_gt: 100).all
69
- Magento::Product.where(price_gt: 100, price_lt: 200).all
69
+
70
+ # price > 10 AND price < 20
71
+ Magento::Product.where(price_gt: 10)
72
+ .where(price_lt: 20).all
73
+
74
+ # price < 1 OR price > 100
75
+ Magento::Product.where(price_lt: 1, price_gt: 100).all
76
+
77
+ Magento::Order.where(status_in: [:canceled, :complete]).all
70
78
  ```
71
79
 
72
80
  | Condition | Notes |
73
- | ----------| ------|
74
- |eq | Equals. |
75
- |finset | A value within a set of values |
76
- |from | The beginning of a range. Must be used with to |
77
- |gt | Greater than |
78
- |gteq | Greater than or equal |
79
- |in | In. The value can contain a comma-separated list of values. |
80
- |like | Like. The value can contain the SQL wildcard characters when like is |specified.
81
- |lt | Less than |
82
- |lteq | Less than or equal |
83
- |moreq | More or equal |
84
- |neq | Not equal |
85
- |nfinset | A value that is not within a set of values |
86
- |nin | Not in. The value can contain a comma-separated list of values. |
87
- |notnull | Not null |
88
- |null | Null |
89
- |to | The end of a range. Must be used with from |
81
+ | --------- | ----- |
82
+ |eq | Equals. |
83
+ |finset | A value within a set of values |
84
+ |from | The beginning of a range. Must be used with to |
85
+ |gt | Greater than |
86
+ |gteq | Greater than or equal |
87
+ |in | In. The value is an array |
88
+ |like | Like. The value can contain the SQL wildcard characters when like is specified. |
89
+ |lt | Less than |
90
+ |lteq | Less than or equal |
91
+ |moreq | More or equal |
92
+ |neq | Not equal |
93
+ |nfinset | A value that is not within a set of values |
94
+ |nin | Not in. The value is an array |
95
+ |notnull | Not null |
96
+ |null | Null |
97
+ |to | The end of a range. Must be used with from |
90
98
 
91
99
 
92
100
  #### SortOrder:
@@ -38,6 +38,7 @@ module Magento
38
38
  filters = []
39
39
  attributes.each do |key, value|
40
40
  field, condition = parse_filter(key)
41
+ value = parse_value_filter(condition, value)
41
42
  filters << { field: field, conditionType: condition, value: value }
42
43
  end
43
44
  filter_groups << { filters: filters }
@@ -115,6 +116,14 @@ module Magento
115
116
  key.match(patter).to_a[1..2]
116
117
  end
117
118
 
119
+ def parse_value_filter(condition, value)
120
+ if ['in', 'nin'].include?(condition) && value.is_a?(Array)
121
+ value = value.join(',')
122
+ end
123
+
124
+ value
125
+ end
126
+
118
127
  def parse_field(value)
119
128
  return verify_id(value) unless value.is_a? Hash
120
129
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'magento'
5
- s.version = '0.3.1'
5
+ s.version = '0.3.2'
6
6
  s.date = '2020-07-31'
7
7
  s.summary = 'Magento Ruby library'
8
8
  s.description = 'Magento Ruby library'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magento
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria