magento 0.4.2 → 0.4.3
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 +4 -4
- data/README.md +267 -267
- data/lib/magento/shared/billing_address.rb +4 -0
- data/lib/magento/shared/status_history.rb +4 -0
- data/lib/magento/version.rb +2 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e1d4dc0ca7f0297a7bf5e735663772a68a0251a6e042bb39dea0e80149e5b19
|
4
|
+
data.tar.gz: 99b623dfff145efed9dc2b1ae32588e5cc67ac34247a95efec5b4fce56efd932
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef981adfa2b1d5f44412ee9f5d6aa70100935b79b91cda3885f13127017f3ce884a0a35d375de81c0abf237c69ef475b7b5731a9c0fc50bc367e04362c90d0a5
|
7
|
+
data.tar.gz: a997a2ffe333830a1648b11525508e9007bc75188bc6ebcdedaf09d7c5f832fe292f4401f32b5b35eb370cad61966f2af34c16f664e0cea3c884bc2c720a6d83
|
data/README.md
CHANGED
@@ -1,267 +1,267 @@
|
|
1
|
-
# Magento Ruby library
|
2
|
-
|
3
|
-
## Install
|
4
|
-
|
5
|
-
Add in your Gemfile
|
6
|
-
|
7
|
-
```rb
|
8
|
-
gem 'magento', '~> 0.4.
|
9
|
-
```
|
10
|
-
|
11
|
-
or run
|
12
|
-
|
13
|
-
```sh
|
14
|
-
gem install magento
|
15
|
-
```
|
16
|
-
|
17
|
-
### Setup
|
18
|
-
|
19
|
-
```rb
|
20
|
-
Magento.url = 'https://yourstore.com'
|
21
|
-
Magento.token = 'MAGENTO_API_KEY'
|
22
|
-
Magento.store = :default # optional, Default is :all
|
23
|
-
```
|
24
|
-
|
25
|
-
## Models
|
26
|
-
```rb
|
27
|
-
Magento::Product
|
28
|
-
Magento::Order
|
29
|
-
Magento::Country
|
30
|
-
Magento::Category
|
31
|
-
```
|
32
|
-
|
33
|
-
## Get details
|
34
|
-
|
35
|
-
```rb
|
36
|
-
Magento::Product.find('sku-test')
|
37
|
-
Magento::Order.find(25)
|
38
|
-
Magento::Country.find('BR')
|
39
|
-
```
|
40
|
-
\* _same pattern to all models_
|
41
|
-
|
42
|
-
**Outside pattern**
|
43
|
-
|
44
|
-
Get customer by token
|
45
|
-
|
46
|
-
```rb
|
47
|
-
Magento::Customer.find_by_token('user_token')
|
48
|
-
```
|
49
|
-
|
50
|
-
## Get List
|
51
|
-
|
52
|
-
```rb
|
53
|
-
Magento::Product.all
|
54
|
-
```
|
55
|
-
|
56
|
-
#### Select fields:
|
57
|
-
```rb
|
58
|
-
Magento::Product.select(:id, :sku, :name).all
|
59
|
-
Magento::Product.select(:id, :sku, :name, extension_attributes: :category_links).all
|
60
|
-
Magento::Product.select(:id, :sku, :name, extension_attributes: [:category_links, :website_ids]).all
|
61
|
-
Magento::Product.select(:id, :sku, :name, extension_attributes: [:website_ids, { category_links: :category_id }]).all
|
62
|
-
```
|
63
|
-
|
64
|
-
#### Filters:
|
65
|
-
|
66
|
-
```rb
|
67
|
-
Magento::Product.where(name_like: 'IPhone%').all
|
68
|
-
Magento::Product.where(price_gt: 100).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
|
78
|
-
```
|
79
|
-
|
80
|
-
| Condition | Notes |
|
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 |
|
98
|
-
|
99
|
-
|
100
|
-
#### SortOrder:
|
101
|
-
|
102
|
-
```rb
|
103
|
-
Magento::Product.order(:sku).all
|
104
|
-
Magento::Product.order(sku: :desc).all
|
105
|
-
Magento::Product.order(status: :desc, name: :asc).all
|
106
|
-
```
|
107
|
-
|
108
|
-
#### Pagination:
|
109
|
-
|
110
|
-
```rb
|
111
|
-
# Set page and quantity per page
|
112
|
-
Magento::Product.page(1) # Current page, Default is 1
|
113
|
-
.page_size(25) # Default is 50
|
114
|
-
.all
|
115
|
-
|
116
|
-
# per is an alias to page_size
|
117
|
-
Magento::Product.per(25).all
|
118
|
-
```
|
119
|
-
|
120
|
-
#### Example of several options together:
|
121
|
-
```rb
|
122
|
-
products = Magento::Product.select(:sku, :name)
|
123
|
-
.where(name_like: 'biscoito%')
|
124
|
-
.page(1)
|
125
|
-
.page_size(5)
|
126
|
-
.all
|
127
|
-
```
|
128
|
-
|
129
|
-
\* _same pattern to all models_
|
130
|
-
|
131
|
-
### Response
|
132
|
-
|
133
|
-
The `all` method retorns a `Magento::RecordCollection` instance
|
134
|
-
|
135
|
-
```rb
|
136
|
-
products.first
|
137
|
-
>> <Magento::Product @sku="2100", @name="Biscoito Piraque Salgadinho 100G">
|
138
|
-
|
139
|
-
products[0]
|
140
|
-
>> <Magento::Product @sku="2100", @name="Biscoito Piraque Salgadinho 100G">
|
141
|
-
|
142
|
-
products.last
|
143
|
-
>> <Magento::Product @sku="964", @name="Biscoito Negresco 140 G Original">
|
144
|
-
|
145
|
-
products.map(&:sku)
|
146
|
-
>> ["2100", "792", "836", "913", "964"]
|
147
|
-
|
148
|
-
products.size
|
149
|
-
>> 5
|
150
|
-
|
151
|
-
products.current_page
|
152
|
-
>> 1
|
153
|
-
|
154
|
-
products.page_size
|
155
|
-
>> 5
|
156
|
-
|
157
|
-
products.total_count
|
158
|
-
>> 307
|
159
|
-
|
160
|
-
products.filter_groups
|
161
|
-
>> [<Magento::FilterGroup @filters=[<Magento::Filter @field="name", @value="biscoito%", @condition_type="like">]>]
|
162
|
-
```
|
163
|
-
|
164
|
-
All Methods:
|
165
|
-
|
166
|
-
```rb
|
167
|
-
# Information about search criteria
|
168
|
-
:current_page
|
169
|
-
:page_size
|
170
|
-
:total_count
|
171
|
-
:filter_groups
|
172
|
-
|
173
|
-
# Iterating with the list of items
|
174
|
-
:count
|
175
|
-
:length
|
176
|
-
:size
|
177
|
-
|
178
|
-
:first
|
179
|
-
:last
|
180
|
-
:[]
|
181
|
-
:find
|
182
|
-
|
183
|
-
:each
|
184
|
-
:each_with_index
|
185
|
-
:sample
|
186
|
-
|
187
|
-
:map
|
188
|
-
:select
|
189
|
-
:filter
|
190
|
-
:reject
|
191
|
-
:collect
|
192
|
-
:take
|
193
|
-
:take_while
|
194
|
-
|
195
|
-
:sort
|
196
|
-
:sort_by
|
197
|
-
:reverse_each
|
198
|
-
:reverse
|
199
|
-
|
200
|
-
:all?
|
201
|
-
:any?
|
202
|
-
:none?
|
203
|
-
:one?
|
204
|
-
:empty?
|
205
|
-
```
|
206
|
-
|
207
|
-
## Create
|
208
|
-
|
209
|
-
```rb
|
210
|
-
Magento::Order.create(
|
211
|
-
customer_firstname: '',
|
212
|
-
customer_lastname: '',
|
213
|
-
customer_email: '',
|
214
|
-
# others attrbutes ...,
|
215
|
-
items: [
|
216
|
-
{
|
217
|
-
sku: '',
|
218
|
-
price: '',
|
219
|
-
qty_ordered: 1,
|
220
|
-
# others attrbutes ...,
|
221
|
-
}
|
222
|
-
],
|
223
|
-
billing_address: {
|
224
|
-
# attrbutes...
|
225
|
-
},
|
226
|
-
payment: {
|
227
|
-
# attrbutes...
|
228
|
-
},
|
229
|
-
extension_attributes: {
|
230
|
-
# attrbutes...
|
231
|
-
}
|
232
|
-
)
|
233
|
-
```
|
234
|
-
|
235
|
-
### Update
|
236
|
-
|
237
|
-
```rb
|
238
|
-
product = Magento::Product.find('sku-teste')
|
239
|
-
|
240
|
-
product.name = 'Updated name'
|
241
|
-
product.save
|
242
|
-
|
243
|
-
# or
|
244
|
-
|
245
|
-
product.update(name: 'Updated name')
|
246
|
-
```
|
247
|
-
|
248
|
-
### Delete
|
249
|
-
|
250
|
-
```rb
|
251
|
-
product = Magento::Product.find('sku-teste')
|
252
|
-
|
253
|
-
product.delete
|
254
|
-
|
255
|
-
# or
|
256
|
-
|
257
|
-
Magento::Product.delete('sku-teste')
|
258
|
-
```
|
259
|
-
|
260
|
-
___
|
261
|
-
|
262
|
-
##TODO:
|
263
|
-
|
264
|
-
### Search products
|
265
|
-
```rb
|
266
|
-
Magento::Product.search('tshort')
|
267
|
-
```
|
1
|
+
# Magento Ruby library
|
2
|
+
|
3
|
+
## Install
|
4
|
+
|
5
|
+
Add in your Gemfile
|
6
|
+
|
7
|
+
```rb
|
8
|
+
gem 'magento', '~> 0.4.3'
|
9
|
+
```
|
10
|
+
|
11
|
+
or run
|
12
|
+
|
13
|
+
```sh
|
14
|
+
gem install magento
|
15
|
+
```
|
16
|
+
|
17
|
+
### Setup
|
18
|
+
|
19
|
+
```rb
|
20
|
+
Magento.url = 'https://yourstore.com'
|
21
|
+
Magento.token = 'MAGENTO_API_KEY'
|
22
|
+
Magento.store = :default # optional, Default is :all
|
23
|
+
```
|
24
|
+
|
25
|
+
## Models
|
26
|
+
```rb
|
27
|
+
Magento::Product
|
28
|
+
Magento::Order
|
29
|
+
Magento::Country
|
30
|
+
Magento::Category
|
31
|
+
```
|
32
|
+
|
33
|
+
## Get details
|
34
|
+
|
35
|
+
```rb
|
36
|
+
Magento::Product.find('sku-test')
|
37
|
+
Magento::Order.find(25)
|
38
|
+
Magento::Country.find('BR')
|
39
|
+
```
|
40
|
+
\* _same pattern to all models_
|
41
|
+
|
42
|
+
**Outside pattern**
|
43
|
+
|
44
|
+
Get customer by token
|
45
|
+
|
46
|
+
```rb
|
47
|
+
Magento::Customer.find_by_token('user_token')
|
48
|
+
```
|
49
|
+
|
50
|
+
## Get List
|
51
|
+
|
52
|
+
```rb
|
53
|
+
Magento::Product.all
|
54
|
+
```
|
55
|
+
|
56
|
+
#### Select fields:
|
57
|
+
```rb
|
58
|
+
Magento::Product.select(:id, :sku, :name).all
|
59
|
+
Magento::Product.select(:id, :sku, :name, extension_attributes: :category_links).all
|
60
|
+
Magento::Product.select(:id, :sku, :name, extension_attributes: [:category_links, :website_ids]).all
|
61
|
+
Magento::Product.select(:id, :sku, :name, extension_attributes: [:website_ids, { category_links: :category_id }]).all
|
62
|
+
```
|
63
|
+
|
64
|
+
#### Filters:
|
65
|
+
|
66
|
+
```rb
|
67
|
+
Magento::Product.where(name_like: 'IPhone%').all
|
68
|
+
Magento::Product.where(price_gt: 100).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
|
78
|
+
```
|
79
|
+
|
80
|
+
| Condition | Notes |
|
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 |
|
98
|
+
|
99
|
+
|
100
|
+
#### SortOrder:
|
101
|
+
|
102
|
+
```rb
|
103
|
+
Magento::Product.order(:sku).all
|
104
|
+
Magento::Product.order(sku: :desc).all
|
105
|
+
Magento::Product.order(status: :desc, name: :asc).all
|
106
|
+
```
|
107
|
+
|
108
|
+
#### Pagination:
|
109
|
+
|
110
|
+
```rb
|
111
|
+
# Set page and quantity per page
|
112
|
+
Magento::Product.page(1) # Current page, Default is 1
|
113
|
+
.page_size(25) # Default is 50
|
114
|
+
.all
|
115
|
+
|
116
|
+
# per is an alias to page_size
|
117
|
+
Magento::Product.per(25).all
|
118
|
+
```
|
119
|
+
|
120
|
+
#### Example of several options together:
|
121
|
+
```rb
|
122
|
+
products = Magento::Product.select(:sku, :name)
|
123
|
+
.where(name_like: 'biscoito%')
|
124
|
+
.page(1)
|
125
|
+
.page_size(5)
|
126
|
+
.all
|
127
|
+
```
|
128
|
+
|
129
|
+
\* _same pattern to all models_
|
130
|
+
|
131
|
+
### Response
|
132
|
+
|
133
|
+
The `all` method retorns a `Magento::RecordCollection` instance
|
134
|
+
|
135
|
+
```rb
|
136
|
+
products.first
|
137
|
+
>> <Magento::Product @sku="2100", @name="Biscoito Piraque Salgadinho 100G">
|
138
|
+
|
139
|
+
products[0]
|
140
|
+
>> <Magento::Product @sku="2100", @name="Biscoito Piraque Salgadinho 100G">
|
141
|
+
|
142
|
+
products.last
|
143
|
+
>> <Magento::Product @sku="964", @name="Biscoito Negresco 140 G Original">
|
144
|
+
|
145
|
+
products.map(&:sku)
|
146
|
+
>> ["2100", "792", "836", "913", "964"]
|
147
|
+
|
148
|
+
products.size
|
149
|
+
>> 5
|
150
|
+
|
151
|
+
products.current_page
|
152
|
+
>> 1
|
153
|
+
|
154
|
+
products.page_size
|
155
|
+
>> 5
|
156
|
+
|
157
|
+
products.total_count
|
158
|
+
>> 307
|
159
|
+
|
160
|
+
products.filter_groups
|
161
|
+
>> [<Magento::FilterGroup @filters=[<Magento::Filter @field="name", @value="biscoito%", @condition_type="like">]>]
|
162
|
+
```
|
163
|
+
|
164
|
+
All Methods:
|
165
|
+
|
166
|
+
```rb
|
167
|
+
# Information about search criteria
|
168
|
+
:current_page
|
169
|
+
:page_size
|
170
|
+
:total_count
|
171
|
+
:filter_groups
|
172
|
+
|
173
|
+
# Iterating with the list of items
|
174
|
+
:count
|
175
|
+
:length
|
176
|
+
:size
|
177
|
+
|
178
|
+
:first
|
179
|
+
:last
|
180
|
+
:[]
|
181
|
+
:find
|
182
|
+
|
183
|
+
:each
|
184
|
+
:each_with_index
|
185
|
+
:sample
|
186
|
+
|
187
|
+
:map
|
188
|
+
:select
|
189
|
+
:filter
|
190
|
+
:reject
|
191
|
+
:collect
|
192
|
+
:take
|
193
|
+
:take_while
|
194
|
+
|
195
|
+
:sort
|
196
|
+
:sort_by
|
197
|
+
:reverse_each
|
198
|
+
:reverse
|
199
|
+
|
200
|
+
:all?
|
201
|
+
:any?
|
202
|
+
:none?
|
203
|
+
:one?
|
204
|
+
:empty?
|
205
|
+
```
|
206
|
+
|
207
|
+
## Create
|
208
|
+
|
209
|
+
```rb
|
210
|
+
Magento::Order.create(
|
211
|
+
customer_firstname: '',
|
212
|
+
customer_lastname: '',
|
213
|
+
customer_email: '',
|
214
|
+
# others attrbutes ...,
|
215
|
+
items: [
|
216
|
+
{
|
217
|
+
sku: '',
|
218
|
+
price: '',
|
219
|
+
qty_ordered: 1,
|
220
|
+
# others attrbutes ...,
|
221
|
+
}
|
222
|
+
],
|
223
|
+
billing_address: {
|
224
|
+
# attrbutes...
|
225
|
+
},
|
226
|
+
payment: {
|
227
|
+
# attrbutes...
|
228
|
+
},
|
229
|
+
extension_attributes: {
|
230
|
+
# attrbutes...
|
231
|
+
}
|
232
|
+
)
|
233
|
+
```
|
234
|
+
|
235
|
+
### Update
|
236
|
+
|
237
|
+
```rb
|
238
|
+
product = Magento::Product.find('sku-teste')
|
239
|
+
|
240
|
+
product.name = 'Updated name'
|
241
|
+
product.save
|
242
|
+
|
243
|
+
# or
|
244
|
+
|
245
|
+
product.update(name: 'Updated name')
|
246
|
+
```
|
247
|
+
|
248
|
+
### Delete
|
249
|
+
|
250
|
+
```rb
|
251
|
+
product = Magento::Product.find('sku-teste')
|
252
|
+
|
253
|
+
product.delete
|
254
|
+
|
255
|
+
# or
|
256
|
+
|
257
|
+
Magento::Product.delete('sku-teste')
|
258
|
+
```
|
259
|
+
|
260
|
+
___
|
261
|
+
|
262
|
+
##TODO:
|
263
|
+
|
264
|
+
### Search products
|
265
|
+
```rb
|
266
|
+
Magento::Product.search('tshort')
|
267
|
+
```
|
data/lib/magento/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Magento
|
2
|
-
VERSION = '0.4.
|
1
|
+
module Magento
|
2
|
+
VERSION = '0.4.3'
|
3
3
|
end
|
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.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wallas Faria
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/magento/request.rb
|
63
63
|
- lib/magento/shared/address.rb
|
64
64
|
- lib/magento/shared/available_regions.rb
|
65
|
+
- lib/magento/shared/billing_address.rb
|
65
66
|
- lib/magento/shared/bundle_product_option.rb
|
66
67
|
- lib/magento/shared/category_link.rb
|
67
68
|
- lib/magento/shared/configurable_product_option.rb
|
@@ -79,6 +80,7 @@ files:
|
|
79
80
|
- lib/magento/shared/search_criterium.rb
|
80
81
|
- lib/magento/shared/shipping.rb
|
81
82
|
- lib/magento/shared/shipping_assignment.rb
|
83
|
+
- lib/magento/shared/status_history.rb
|
82
84
|
- lib/magento/shared/stock_item.rb
|
83
85
|
- lib/magento/shared/tier_price.rb
|
84
86
|
- lib/magento/shared/total.rb
|