magento 0.27.0 → 0.28.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2d97be580b5599c9d3a9e05f945b23a8488d5c7e1c1d63b22eca9befe00fd25
4
- data.tar.gz: 6dfbc4f7d11b4f6276b54ca1907c547ad3043dd32e50b614ce0233af59644045
3
+ metadata.gz: b6aec96b1878cf98094666a1c656840c7cc1a8f7f08fea94ec597333b5ea32b9
4
+ data.tar.gz: 39959ab9be096fb11a8d0a13a48a957f5fc7c8ab78cd82014c586d3170c6e98a
5
5
  SHA512:
6
- metadata.gz: 237ac75f45cf458fafdb839861937b06cefc519096e769b9d1d57f809ff98138f5d7c801a65de00d83008372776b246e23f52c36575280f9ea36e3e053421101
7
- data.tar.gz: cfdece71be16ddd2e0ec6d887e37da176e37c224e03c6f402b20e01bba82822218eb1650154d3d4362b74b40bb35f0ed9c1c38d5e550746c57aed660aba7438d
6
+ metadata.gz: e4387d0771f06cc23a980a730e0c3c94f7a67fd9fb4f370e89f7ab175bb21ff1ba9047eab9f56e79466b808bb2a07cda84454839d6783a28b3ef97646f47f273
7
+ data.tar.gz: 2ba0b2f46693f6584b5406e70442f5d3dd2235fb4ed2000fdd0a43533655f4d060989cb3493c58004a8dcc3714686b3246ff9a4f5e617e6d60e56e3de71506e8
data/README.md CHANGED
@@ -77,7 +77,7 @@ Ruby library to consume the magento 2 api
77
77
  Add in your Gemfile
78
78
 
79
79
  ```rb
80
- gem 'magento', '~> 0.27.0'
80
+ gem 'magento', '~> 0.28.0'
81
81
  ```
82
82
 
83
83
  or run
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'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Magento
2
- VERSION = '0.27.0'
2
+ VERSION = '0.28.0'
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.27.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