magento 0.20.1 → 0.21.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: 68aa93fb639c7e6d3cab0a521e91c08d38aa28dd7d508f50190ce9e718ed8022
4
- data.tar.gz: ccde7c0ccbe949e12fb97fab1c80d2dfbc18c9e8de80181b0e0dab1c763f0ee6
3
+ metadata.gz: 3369907b3576aff1a8d5199396f90b0431b629c9abf2a339917ace10ae3bdefa
4
+ data.tar.gz: 20149d57d54c0c5be44b1ca1b9006c429db2d254ff41272c201b68e2b6aa5c68
5
5
  SHA512:
6
- metadata.gz: d5ddc1d9471997748938d0942e97125b0dd6620efda44c2d80d967968677595e6837bbfbcbd43eb92a9992a50fd8c2dbd3adfef880fb84e3f322ac1ba8400bd1
7
- data.tar.gz: 631f5d649fa1bfde37f1b9662685ea400f967792b1ed293fc1d1fb20d5d49f775dacbba332f97736079dada2cc67aaecec8f6cd5ca41012537ef8a76fd61e401
6
+ metadata.gz: cd086b7748e54381a71f96af6d1356e6124ca97b169df488ff330a21de63ec4a702dc53c28ad964e4fbbcdc0ed314e83f4ffc5e400264b04de74fc1aaab964d7
7
+ data.tar.gz: 580ed9f180845668b33a46b88ab237b56e99b4237fe0d3131452b3abe7bd694d48f342b93108d85069550bc241437a503c888e6994c8aad434794def55cc8765
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add in your Gemfile
6
6
 
7
7
  ```rb
8
- gem 'magento', '~> 0.20.1'
8
+ gem 'magento', '~> 0.21.0'
9
9
  ```
10
10
 
11
11
  or run
@@ -614,6 +614,35 @@ Magento::Product.where(name_like: 'some name%').count
614
614
  >> 15
615
615
  ```
616
616
 
617
+ ## Inventory
618
+
619
+ ### Check whether a product is salable
620
+
621
+ ```rb
622
+ Inventoty.get_product_salable_quantity(sku: '4321', stock_id: 1)
623
+ >> 1
624
+ ```
625
+
626
+ ### Check whether a product is salable for a specified quantity
627
+
628
+ ```rb
629
+ Inventoty.is_product_salable_for_requested_qty(
630
+ sku: '4321',
631
+ stock_id: 1,
632
+ requested_qty: 2
633
+ )
634
+ >> OpenStruct {
635
+ :salable => false,
636
+ :errors => [
637
+ [0] {
638
+ "code" => "back_order-disabled",
639
+ "message" => "Backorders are disabled"
640
+ },
641
+ ...
642
+ ]
643
+ }
644
+ ```
645
+
617
646
  ___
618
647
 
619
648
  ##TODO:
@@ -22,6 +22,7 @@ require_relative 'magento/order'
22
22
  require_relative 'magento/invoice'
23
23
  require_relative 'magento/guest_cart'
24
24
  require_relative 'magento/sales_rule'
25
+ require_relative 'magento/inventory'
25
26
  require_relative 'magento/import'
26
27
 
27
28
  Dir[File.expand_path('magento/shared/*.rb', __dir__)].map { |f| require f }
@@ -0,0 +1,40 @@
1
+ module Magento
2
+ class Inventoty
3
+ class << self
4
+ #
5
+ # ==== Example
6
+ #
7
+ # Inventoty.is_product_salable_for_requested_qty(
8
+ # sku: '4321',
9
+ # stock_id: 1,
10
+ # requested_qty: 2
11
+ # )
12
+ # # =>
13
+ # OpenStruct {
14
+ # :salable => false,
15
+ # :errors => [
16
+ # [0] {
17
+ # "code" => "back_order-disabled",
18
+ # "message" => "Backorders are disabled"
19
+ # },
20
+ # ...
21
+ # ]
22
+ # }
23
+ #
24
+ # @return OpenStruct
25
+ def is_product_salable_for_requested_qty(sku:, stock_id:, requested_qty:)
26
+ result = Request.new.get(
27
+ "inventory/is-product-salable-for-requested-qty/#{sku}/#{stock_id}/#{requested_qty}"
28
+ ).parse
29
+
30
+ OpenStruct.new(result)
31
+ end
32
+
33
+ def get_product_salable_quantity(sku:, stock_id:)
34
+ Request.new.get(
35
+ "inventory/get-product-salable-quantity/#{sku}/#{stock_id}"
36
+ ).parse
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Magento
2
- VERSION = '0.20.1'
2
+ VERSION = '0.21.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.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria
@@ -103,6 +103,7 @@ files:
103
103
  - lib/magento/import/image_finder.rb
104
104
  - lib/magento/import/product.rb
105
105
  - lib/magento/import/template/products.csv
106
+ - lib/magento/inventory.rb
106
107
  - lib/magento/invoice.rb
107
108
  - lib/magento/model.rb
108
109
  - lib/magento/model_mapper.rb