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 +4 -4
- data/lib/connection.rb +1 -1
- data/lib/dataset.rb +4 -4
- data/lib/model/base.rb +4 -12
- data/lib/model/customer.rb +7 -4
- data/magentwo.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbfcf734cacec9410f80c4d5a085157f0f2edce0930fd571d7fedf4efbd88075
|
4
|
+
data.tar.gz: b80ffe47e76bcbdbfb0985659445c52130e39979906b6d7d8e6c83835a863246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d46ccae8ffb8d49a32d700fcd7fcf51ed2f16733cdac54ff1bd5d08df20de7d92f0834c2fb3687db53b0737bb25ffb5f330b5d4c142b217082ac38d60c65baef
|
7
|
+
data.tar.gz: b4fb8c1a291913fcca762ddc7bfb0e5552780c9767161d3ca025ff7e9c90723b404e62bc610dd903bac276c7256441cd46bca3102bde6043f7d5774cedd5f7c6
|
data/lib/connection.rb
CHANGED
data/lib/dataset.rb
CHANGED
@@ -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
|
125
|
+
def each(&block)
|
126
126
|
raise ArgumentError, "no block given" unless block_given?
|
127
127
|
self.all.each(&block)
|
128
128
|
end
|
data/lib/model/base.rb
CHANGED
@@ -16,24 +16,16 @@ module Magentwo
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
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
|
-
|
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
|
data/lib/model/customer.rb
CHANGED
@@ -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
|
-
|
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
|
data/magentwo.gemspec
CHANGED