magento 0.27.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/magento.rb +1 -0
- data/lib/magento/cart.rb +65 -0
- data/lib/magento/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6aec96b1878cf98094666a1c656840c7cc1a8f7f08fea94ec597333b5ea32b9
|
4
|
+
data.tar.gz: 39959ab9be096fb11a8d0a13a48a957f5fc7c8ab78cd82014c586d3170c6e98a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4387d0771f06cc23a980a730e0c3c94f7a67fd9fb4f370e89f7ab175bb21ff1ba9047eab9f56e79466b808bb2a07cda84454839d6783a28b3ef97646f47f273
|
7
|
+
data.tar.gz: 2ba0b2f46693f6584b5406e70442f5d3dd2235fb4ed2000fdd0a43533655f4d060989cb3493c58004a8dcc3714686b3246ff9a4f5e617e6d60e56e3de71506e8
|
data/README.md
CHANGED
data/lib/magento.rb
CHANGED
@@ -25,6 +25,7 @@ require_relative 'magento/guest_cart'
|
|
25
25
|
require_relative 'magento/sales_rule'
|
26
26
|
require_relative 'magento/inventory'
|
27
27
|
require_relative 'magento/import'
|
28
|
+
require_relative 'magento/cart'
|
28
29
|
|
29
30
|
require_relative 'magento/params/create_custom_attribute'
|
30
31
|
require_relative 'magento/params/create_image'
|
data/lib/magento/cart.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magento
|
4
|
+
class Cart < Model
|
5
|
+
self.endpoint = 'carts'
|
6
|
+
self.primary_key = :id
|
7
|
+
|
8
|
+
#
|
9
|
+
# Add a coupon by code to the current cart.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# cart = Magento::Cart.find(1)
|
14
|
+
# cart.add_coupon('COAU4HXE0I')
|
15
|
+
#
|
16
|
+
# @return Boolean: true on success, false otherwise
|
17
|
+
def add_coupon(coupon)
|
18
|
+
self.class.add_coupon(id, coupon)
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Delete cart's coupon
|
23
|
+
#
|
24
|
+
# Example:
|
25
|
+
#
|
26
|
+
# cart = Magento::Cart.find(1)
|
27
|
+
# cart.delete_coupon()
|
28
|
+
#
|
29
|
+
# @return Boolean: true on success, raise exception otherwise
|
30
|
+
def delete_coupon
|
31
|
+
self.class.delete_coupon(id)
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
#
|
36
|
+
# Add a coupon by code to a specified cart.
|
37
|
+
#
|
38
|
+
# Example:
|
39
|
+
#
|
40
|
+
# Magento::Cart.add_coupon(
|
41
|
+
# 1,
|
42
|
+
# 'COAU4HXE0I'
|
43
|
+
# )
|
44
|
+
#
|
45
|
+
# @return Boolean: true on success, false otherwise
|
46
|
+
def add_coupon(id, coupon)
|
47
|
+
url = "#{api_resource}/#{id}/coupons/#{coupon}"
|
48
|
+
request.put(url, nil).parse
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Delete a coupon from a specified cart.
|
53
|
+
#
|
54
|
+
# Example:
|
55
|
+
#
|
56
|
+
# Magento::Cart.delete_coupon(1)
|
57
|
+
#
|
58
|
+
# @return Boolean: true on success, raise exception otherwise
|
59
|
+
def delete_coupon(id)
|
60
|
+
url = "#{api_resource}/#{id}/coupons"
|
61
|
+
request.delete(url).parse
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/magento/version.rb
CHANGED
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.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wallas Faria
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- bin/console
|
96
96
|
- bin/setup
|
97
97
|
- lib/magento.rb
|
98
|
+
- lib/magento/cart.rb
|
98
99
|
- lib/magento/category.rb
|
99
100
|
- lib/magento/configuration.rb
|
100
101
|
- lib/magento/country.rb
|
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
186
|
- !ruby/object:Gem::Version
|
186
187
|
version: '0'
|
187
188
|
requirements: []
|
188
|
-
rubygems_version: 3.0.3
|
189
|
+
rubygems_version: 3.0.3.1
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Magento Ruby library
|