magento 0.13.1 → 0.14.0

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: bb31fed59d9d16923e61b3f77d218087e2c2dc0e40912f59c0f0f447886ec6a4
4
- data.tar.gz: 7d93a4d2dcef4ad968a7dacd9eb0445f7f6885791ef202873df555efad9fc4dd
3
+ metadata.gz: 3df17670fd9bcb57f90cdb5cfdb17f098fc2e68676b32205d60db11609fdc346
4
+ data.tar.gz: 7ab232a58616a24b0b1c672d3d5d8e8510eda79c4f72b7baf85950d3c06f7895
5
5
  SHA512:
6
- metadata.gz: 0b15c59d8eb5f07ebc3df8e875128463790c3a26f6e96f0b076404a3aa18c7760f0d66636f3292b596f0d527da180f1125a8789dc59ed38b769b215bf02be580
7
- data.tar.gz: 193242af27b216087e158b95bd136ee9fc70b66ca0e68711e5eda257b854beba663949a70a385b495191b12273ded59fb7dec44595a28d52704a4fe5ea1f38d5
6
+ metadata.gz: b3486c69930399a5b002ca33f014f1e5abc725c741d125790588bdadd472855b9858c6d1a596b07ac6e4e63e4069954bf75cc77b391ec06aec900fc868d5048f
7
+ data.tar.gz: 17f02541d592aa6fdc1211685bb0163bbaadb59f4f31d635b5b894a3f37c22082b19a8e55bbefc383831f8617c818685a23813648723adf6a6f380c1378d5162
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add in your Gemfile
6
6
 
7
7
  ```rb
8
- gem 'magento', '~> 0.13.1'
8
+ gem 'magento', '~> 0.14.0'
9
9
  ```
10
10
 
11
11
  or run
@@ -339,6 +339,17 @@ cart.payment_information(
339
339
  >> "234575" # return the order id
340
340
  ```
341
341
 
342
+ Add coupon to cart
343
+ ```rb
344
+ cart = Magento::GuestCart.find('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
345
+
346
+ cart.add_coupon('COAU4HXE0I')
347
+ # You can also use the class method
348
+ Magento::GuestCart.add_coupon('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7', 'COAU4HXE0I')
349
+
350
+ >> true # return true on success
351
+ ```
352
+
342
353
  ## Invoice an Order
343
354
 
344
355
  ```rb
@@ -42,12 +42,12 @@ module Magento
42
42
  self.token = ENV['MAGENTO_TOKEN']
43
43
  self.store = ENV['MAGENTO_STORE'] || :all
44
44
 
45
- def self.with_config(utl: Magento.url, token: Magento.token, store: Magento.store)
45
+ def self.with_config(url: Magento.url, token: Magento.token, store: Magento.store)
46
46
  @old_url = self.url
47
47
  @old_token = self.token
48
48
  @old_store = self.store
49
-
50
- self.url = utl
49
+
50
+ self.url = url
51
51
  self.token = token
52
52
  self.store = store
53
53
 
@@ -32,6 +32,18 @@ module Magento
32
32
  self.class.payment_information(attributes)
33
33
  end
34
34
 
35
+ #
36
+ # Add a coupon by code to the current cart.
37
+ #
38
+ # Example
39
+ # cart = Magento::GuestCart.find('gXsepZcgJbY8RCJXgGioKOO9iBCR20r7')
40
+ # cart.add_coupon('COAU4HXE0I')
41
+ #
42
+ # @return Boolean: true on success, false otherwise
43
+ def add_coupon(coupon)
44
+ self.class.add_coupon(cart_id, coupon)
45
+ end
46
+
35
47
  class << self
36
48
  def create(load_cart_info: false)
37
49
  cart = build(cart_id: request.post(api_resource).parse)
@@ -64,6 +76,21 @@ module Magento
64
76
  hash = request.post(url, attributes).parse
65
77
  Magento::ModelMapper.map_hash(Magento::Item, hash)
66
78
  end
79
+
80
+ #
81
+ # Add a coupon by code to a specified cart.
82
+ #
83
+ # Example
84
+ # Magento::GuestCart.add_coupon(
85
+ # 'aj8oUtY1Qi44Fror6UWVN7ftX1idbBKN',
86
+ # 'COAU4HXE0I'
87
+ # )
88
+ #
89
+ # @return Boolean: true on success, false otherwise
90
+ def add_coupon(id, coupon)
91
+ url = "#{api_resource}/#{id}/coupons/#{coupon}"
92
+ request.put(url, nil).parse
93
+ end
67
94
  end
68
95
  end
69
96
  end
@@ -1,3 +1,3 @@
1
1
  module Magento
2
- VERSION = '0.13.1'
2
+ VERSION = '0.14.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.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria