magentwo 0.1.1 → 0.1.2

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: aec00d3aa4f9cead374c52e885a4e5caf630faaa072e4bf5502757008ca4e58e
4
- data.tar.gz: 1c6688ed66e1f3a7264f33fe11e897a5a464280d1e40e2400439fddd5f7ade91
3
+ metadata.gz: bbfcf734cacec9410f80c4d5a085157f0f2edce0930fd571d7fedf4efbd88075
4
+ data.tar.gz: b80ffe47e76bcbdbfb0985659445c52130e39979906b6d7d8e6c83835a863246
5
5
  SHA512:
6
- metadata.gz: 49108b46b30b97ca463d4fecfdcbc33ee2f029e66ad3152ea67fde75909e9369eeb470c4af6cb82710c9cefa753991c8bf570007c97a6f4d28d605e5ad8595cd
7
- data.tar.gz: 922da63238bbea63fea0a34beee23227a9564568a72352d91e6075a3093d5268236c3ad678a256c6f1198b223375083849d0aa97618b5976a1c2e5961e2eeff6
6
+ metadata.gz: d46ccae8ffb8d49a32d700fcd7fcf51ed2f16733cdac54ff1bd5d08df20de7d92f0834c2fb3687db53b0737bb25ffb5f330b5d4c142b217082ac38d60c65baef
7
+ data.tar.gz: b4fb8c1a291913fcca762ddc7bfb0e5552780c9767161d3ca025ff7e9c90723b404e62bc610dd903bac276c7256441cd46bca3102bde6043f7d5774cedd5f7c6
@@ -27,7 +27,7 @@ module Magentwo
27
27
  end
28
28
  end
29
29
 
30
- def call method, path, query
30
+ def call method, path, query:nil
31
31
  url = "#{base_path}/#{path}?#{query}"
32
32
  case method
33
33
  when :get then self.get url
@@ -64,7 +64,7 @@ module Magentwo
64
64
  # Fetching
65
65
  ################
66
66
  def info
67
- result = self.model.call :get, self.page(1, 1).to_query
67
+ result = self.model.call :get, {:query => self.page(1, 1).to_query}
68
68
  {
69
69
  :fields => result[:items]&.first&.keys,
70
70
  :total_count => result[:total_count]
@@ -80,12 +80,12 @@ module Magentwo
80
80
  end
81
81
 
82
82
  def first
83
- result = self.model.call :get, self.page(1, 1).to_query
83
+ result = self.model.call :get, {:query => self.page(1, 1).to_query}
84
84
  self.model.new result[:items].first
85
85
  end
86
86
 
87
87
  def all
88
- result = self.model.call :get, self.to_query
88
+ result = self.model.call :get, {:query => self.to_query}
89
89
  return [] if result.nil?
90
90
  (result[:items] || []).map do |item|
91
91
  self.model.new item
@@ -122,7 +122,7 @@ module Magentwo
122
122
  self.all.map(&block)
123
123
  end
124
124
 
125
- def each &block
125
+ def each(&block)
126
126
  raise ArgumentError, "no block given" unless block_given?
127
127
  self.all.each(&block)
128
128
  end
@@ -16,24 +16,16 @@ module Magentwo
16
16
  end
17
17
  end
18
18
 
19
- def method_missing m, *args, &block
20
- if custom_attr = self.custom_attributes[m]
21
- return custom_attr
22
- end
23
-
24
- if extension_attr = self.extension_attributes[m]
25
- return extension_attr
26
- end
27
- nil
19
+ def call method, path, query:nil
20
+ Magentwo::Base.call method, path, {:query => query}
28
21
  end
29
22
 
30
23
  class << self; attr_accessor :connection end
31
24
 
32
25
  class << self
33
26
  #args may container searchCriteria, fields, ...
34
- def call method, query
35
- model_name = "#{self.name.split("::").last.downcase}s"
36
- Magentwo::Base.connection.call method, model_name, query
27
+ def call method, path="#{self.name.split("::").last.downcase}s", query:nil
28
+ Magentwo::Base.connection.call method, path, {:query => query}
37
29
  end
38
30
 
39
31
  def dataset
@@ -1,15 +1,18 @@
1
1
  module Magentwo
2
2
  class Customer < Base
3
- Attributes = %i(id group_id default_billing default_shipping created_at updated_at created_in dob email firstname lastname gender store_id website_id addresses disable_auto_group_change)
3
+ Attributes = %i(id group_id default_billing default_shipping created_at updated_at created_in dob email firstname lastname gender store_id website_id addresses disable_auto_group_change extension_attributes)
4
4
 
5
5
  Attributes.each do |attr|
6
6
  attr_accessor attr
7
7
  end
8
8
 
9
+ def with_extension_attributes
10
+ self.call :get, "customers/#{self.id}"
11
+ end
12
+
9
13
  class << self
10
- def call method, query
11
- model_name = "customers/search"
12
- Magentwo::Base.connection.call method, model_name, query
14
+ def call method, path="customers/search", query:nil
15
+ Magentwo::Base.connection.call method, path, {:query => query}
13
16
  end
14
17
  end
15
18
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'magentwo'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.2'
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Mueß