magentwo 0.1.84 → 0.1.85

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: adcb433fd8d46b83ef5d89919f7458c9b3cf66c305dfefa5dda9847241b12db1
4
- data.tar.gz: 83b23e44c235493a1db438db4a55ffc1ba4f1ea6f32e822a7d417e014f0666c6
3
+ metadata.gz: c389ffd5dfd801c072750c3187115827d82b4a3ff72cd07dcd2dd54729e1d8d5
4
+ data.tar.gz: 6a72bd03b8e4941e4acbafb446e2618166cbbc9b0e81dc3699f35f3ebfa1266c
5
5
  SHA512:
6
- metadata.gz: 0a1a25c71c970ecc41523a37651751ade3ed48f7129fdc6dfa140d213f32f3b6de4e4ef6cfe2721b421969b4ce7473267468b23a4cb25fa9b7c576f47c888116
7
- data.tar.gz: 27cdc022eae14d7cd0e2900c8cb1c380dc6110eafccffd634388b9727b3d0729c4a5b6563a1c39731055526a26a07b8711a3955642f8826d01422c4f6c1d7761
6
+ metadata.gz: ba50d3ac4eb38a5058bcbd1dfdbedc540aea54bf125819347b1bdbfa56b97de8425eb1defa7f6a059e78d93498b9d155858bee0634e8ffab6ef399b08362e9f5
7
+ data.tar.gz: 6b911f6f943d9dfb7eeee47a2fd7f9d51fc2262968dc7b92769e1e1e20d6fb50462428e14d902300f98de9ba9c8519ef12ee859b2509a7650d9bcfb021f5067b
@@ -37,7 +37,8 @@ module Magentwo
37
37
  when "200"
38
38
  JSON.parse response.body, :symbolize_names => true
39
39
  else
40
- puts "request failed #{response.code} #{response.body}"
40
+ puts "error #{response.code}: #{JSON.parse(response.body)}"
41
+ return nil
41
42
  end
42
43
  end
43
44
 
@@ -21,7 +21,7 @@ module Magentwo
21
21
  end
22
22
 
23
23
  class CompareArray < Compare
24
- def to_query id
24
+ def to_query idx
25
25
  [
26
26
  "searchCriteria[filter_groups][#{idx}][filters][0][field]=#{self.field}",
27
27
  "searchCriteria[filter_groups][#{idx}][filters][0][value]=#{URI::encode(self.value.map(&:to_s).join(","))}",
@@ -65,7 +65,8 @@ module Magentwo
65
65
  attr_accessor :adapter
66
66
 
67
67
  def [] unique_identifier_value
68
- self.new (Magentwo::Base.get nil, path:"#{base_path}/#{unique_identifier_value}")
68
+ result = Magentwo::Base.get nil, path:"#{base_path}/#{unique_identifier_value}"
69
+ self.new result if result
69
70
  end
70
71
 
71
72
  def unique_identifier
@@ -87,6 +88,7 @@ module Magentwo
87
88
 
88
89
  def all ds=self.dataset, meta_data:false
89
90
  response = self.get(ds.to_query, :meta_data => meta_data)
91
+ return [] if response.nil?
90
92
  items = (meta_data ? response[:items] : response)
91
93
  .map do |item|
92
94
  self.new item
@@ -100,7 +102,8 @@ module Magentwo
100
102
  end
101
103
 
102
104
  def first ds=self.dataset
103
- self.new self.get(ds.page(1, 1).to_query).first
105
+ response = self.get(ds.page(1, 1).to_query).first
106
+ self.new response if response
104
107
  end
105
108
 
106
109
  def each_page page_size=Magentwo.default_page_size, &block
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'magentwo'
3
- s.version = '0.1.84'
3
+ s.version = '0.1.85'
4
4
  s.date = '2019-01-17'
5
5
  s.summary = "Magento 2 API Wrapper"
6
6
  s.description = "Provides a simple Ruby Interface to interact with the Magento 2 API"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magentwo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.84
4
+ version: 0.1.85
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Mueß