magento 0.28.1 → 0.31.0
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 +23 -1
- data/lib/magento/cart.rb +39 -0
- data/lib/magento/customer.rb +33 -0
- data/lib/magento/inventory.rb +27 -0
- data/lib/magento/shared/title.rb +3 -0
- data/lib/magento/tax_rate.rb +16 -0
- data/lib/magento/tax_rule.rb +16 -0
- data/lib/magento/version.rb +1 -1
- data/lib/magento.rb +2 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc9ad161c82e02dd0daaa2e8f6b24dfba7111df4e8609035f9d286538c6ae020
|
4
|
+
data.tar.gz: 3f9f0d37e0cfabb0d066c95ee6e092e72b19ec8f2280366d1df46fed9727902f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72851026859b037633935af3dc83d7a32ae2269785a677377bc334827270d1794e2084bf2e86c2826bbff023c047618d27e934d2c17266de720fa78318cb8acb
|
7
|
+
data.tar.gz: f02efe20c7cb6b52628cd4e4833184f7b3ccda2ed6901de0f0169e48ec51692fa1433eb595fedf0f005be649e7ceb3d5848c6b3d4b12e7c3cf82fcb0e2b0511f
|
data/README.md
CHANGED
@@ -55,6 +55,8 @@ Ruby library to consume the magento 2 api
|
|
55
55
|
|
56
56
|
[Customer](#customer)
|
57
57
|
- [Find by token](#get-customer-by-token)
|
58
|
+
- [Login](#customer-login)
|
59
|
+
- [Reset Password](#customer-reset-password)
|
58
60
|
|
59
61
|
[Guest cart](#guest-cart)
|
60
62
|
- [Payment information](#payment-information)
|
@@ -77,7 +79,7 @@ Ruby library to consume the magento 2 api
|
|
77
79
|
Add in your Gemfile
|
78
80
|
|
79
81
|
```rb
|
80
|
-
gem 'magento', '~> 0.
|
82
|
+
gem 'magento', '~> 0.31.0'
|
81
83
|
```
|
82
84
|
|
83
85
|
or run
|
@@ -916,6 +918,26 @@ Magento::SalesRule.generate_coupon(
|
|
916
918
|
Magento::Customer.find_by_token('user_token')
|
917
919
|
```
|
918
920
|
|
921
|
+
### Customer login
|
922
|
+
Exemple:
|
923
|
+
```rb
|
924
|
+
Magento::Customer.login('username', 'password')
|
925
|
+
|
926
|
+
>> 'aj8oer4eQi44FrghgfhVdbBKN' #return user token
|
927
|
+
```
|
928
|
+
|
929
|
+
### Customer reset password
|
930
|
+
Exemple:
|
931
|
+
```rb
|
932
|
+
Magento::Customer.reset_password(
|
933
|
+
email: 'user_email',
|
934
|
+
reset_token: 'user_reset_token',
|
935
|
+
new_password: 'user_new_password'
|
936
|
+
)
|
937
|
+
|
938
|
+
>> true # return true on success
|
939
|
+
```
|
940
|
+
|
919
941
|
## Guest Cart
|
920
942
|
|
921
943
|
### Payment information
|
data/lib/magento/cart.rb
CHANGED
@@ -31,6 +31,27 @@ module Magento
|
|
31
31
|
self.class.delete_coupon(id)
|
32
32
|
end
|
33
33
|
|
34
|
+
#
|
35
|
+
# Place order for cart
|
36
|
+
#
|
37
|
+
# Example:
|
38
|
+
#
|
39
|
+
# cart = Magento::Cart.find('12345')
|
40
|
+
#
|
41
|
+
# # or use "build" to not request information from the magento API
|
42
|
+
# cart = Magento::GuestCart.build({ 'cart_id' => '12345' })
|
43
|
+
#
|
44
|
+
# cart.order(
|
45
|
+
# email: 'customer@gmail.com',
|
46
|
+
# payment: { method: 'cashondelivery' }
|
47
|
+
# )
|
48
|
+
#
|
49
|
+
# @return String: return the order id
|
50
|
+
def order(email:, payment:)
|
51
|
+
attributes = { cartId: id, paymentMethod: payment, email: email }
|
52
|
+
self.class.order(attributes)
|
53
|
+
end
|
54
|
+
|
34
55
|
class << self
|
35
56
|
#
|
36
57
|
# Add a coupon by code to a specified cart.
|
@@ -60,6 +81,24 @@ module Magento
|
|
60
81
|
url = "#{api_resource}/#{id}/coupons"
|
61
82
|
request.delete(url).parse
|
62
83
|
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Place order for cart
|
87
|
+
#
|
88
|
+
# Example:
|
89
|
+
#
|
90
|
+
# Magento::Cart.order(
|
91
|
+
# cartId: '12345',
|
92
|
+
# paymentMethod: { method: 'cashondelivery' },
|
93
|
+
# email: email
|
94
|
+
# )
|
95
|
+
#
|
96
|
+
# @return String: return the order id
|
97
|
+
def order(attributes)
|
98
|
+
attributes.transform_keys(&:to_sym)
|
99
|
+
url = "#{api_resource}/#{attributes[:cartId]}/order"
|
100
|
+
request.put(url, attributes).parse
|
101
|
+
end
|
63
102
|
end
|
64
103
|
end
|
65
104
|
end
|
data/lib/magento/customer.rb
CHANGED
@@ -42,6 +42,39 @@ module Magento
|
|
42
42
|
hash = request.get("customers/#{id}").parse
|
43
43
|
build(hash)
|
44
44
|
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Log in to a user account
|
48
|
+
#
|
49
|
+
# Example:
|
50
|
+
# Magento::Customer.login('customer@gmail.com', '123456')
|
51
|
+
#
|
52
|
+
# @return String: return the user token
|
53
|
+
def login(username, password)
|
54
|
+
request.post("integration/customer/token", {
|
55
|
+
username: username,
|
56
|
+
password: password
|
57
|
+
})
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Reset a user's password
|
62
|
+
#
|
63
|
+
# Example:
|
64
|
+
# Magento::Customer.reset_password(
|
65
|
+
# email: 'customer@gmail.com',
|
66
|
+
# reset_token: 'mEKMTciuhPfWkQ3zHTCLIJNC',
|
67
|
+
# new_password: '123456'
|
68
|
+
# )
|
69
|
+
#
|
70
|
+
# @return Bolean: true on success, raise exception otherwise
|
71
|
+
def reset_password(email:, reset_token:, new_password:)
|
72
|
+
request.post("customers/resetPassword", {
|
73
|
+
email: email,
|
74
|
+
reset_token: reset_token,
|
75
|
+
new_password: new_password
|
76
|
+
}).parse
|
77
|
+
end
|
45
78
|
end
|
46
79
|
end
|
47
80
|
end
|
data/lib/magento/inventory.rb
CHANGED
@@ -35,6 +35,33 @@ module Magento
|
|
35
35
|
"inventory/get-product-salable-quantity/#{sku}/#{stock_id}"
|
36
36
|
).parse
|
37
37
|
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# ==== Example
|
41
|
+
#
|
42
|
+
# Inventory.update_source_items(
|
43
|
+
# [
|
44
|
+
# {
|
45
|
+
# "sku": "new_product1",
|
46
|
+
# "source_code": "central",
|
47
|
+
# "quantity": 1000,
|
48
|
+
# "status": 1
|
49
|
+
# },
|
50
|
+
# {
|
51
|
+
# "sku": "new_product1",
|
52
|
+
# "source_code": "east",
|
53
|
+
# "quantity": 2000,
|
54
|
+
# "status": 1
|
55
|
+
# }
|
56
|
+
# ]
|
57
|
+
# )
|
58
|
+
# # => []
|
59
|
+
#
|
60
|
+
# @return Array
|
61
|
+
def update_source_items(source_items)
|
62
|
+
body = { sourceItems: source_items }
|
63
|
+
Request.new.post('inventory/source-items', body).parse
|
64
|
+
end
|
38
65
|
end
|
39
66
|
end
|
40
67
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magento
|
4
|
+
class TaxRate < Model
|
5
|
+
self.primary_key = :id
|
6
|
+
self.endpoint = 'taxRates'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
protected
|
10
|
+
|
11
|
+
def query
|
12
|
+
Query.new(self, api_resource: 'taxRates/search')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magento
|
4
|
+
class TaxRule < Model
|
5
|
+
self.primary_key = :id
|
6
|
+
self.endpoint = 'taxRules'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
protected
|
10
|
+
|
11
|
+
def query
|
12
|
+
Query.new(self, api_resource: 'taxRules/search')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/magento/version.rb
CHANGED
data/lib/magento.rb
CHANGED
@@ -26,6 +26,8 @@ require_relative 'magento/sales_rule'
|
|
26
26
|
require_relative 'magento/inventory'
|
27
27
|
require_relative 'magento/import'
|
28
28
|
require_relative 'magento/cart'
|
29
|
+
require_relative 'magento/tax_rule'
|
30
|
+
require_relative 'magento/tax_rate'
|
29
31
|
|
30
32
|
require_relative 'magento/params/create_custom_attribute'
|
31
33
|
require_relative 'magento/params/create_image'
|
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
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wallas Faria
|
@@ -153,8 +153,11 @@ files:
|
|
153
153
|
- lib/magento/shared/status_history.rb
|
154
154
|
- lib/magento/shared/stock_item.rb
|
155
155
|
- lib/magento/shared/tier_price.rb
|
156
|
+
- lib/magento/shared/title.rb
|
156
157
|
- lib/magento/shared/total.rb
|
157
158
|
- lib/magento/shared/value.rb
|
159
|
+
- lib/magento/tax_rate.rb
|
160
|
+
- lib/magento/tax_rule.rb
|
158
161
|
- lib/magento/version.rb
|
159
162
|
- magento.gemspec
|
160
163
|
- spec/magento/core/model_mapper_spec.rb
|