magentwo 0.1.90 → 0.1.91
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/connection.rb +12 -34
- data/lib/magentwo.rb +1 -1
- 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: 15cb810f21e6410e34b764567e40378ca481d8b2ba9133a6981a2b6738818c8a
|
4
|
+
data.tar.gz: c5f1fe3851888baf2d6371e849fa44a87087c54ea91adcf574ed2ff79f384d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a18862fc3e2792a23539d840ffea2591d90c232ce17d2fa0d114707d759554bbd114bcd726c7d1a5bc13ce67bb4c9c7d482ff038d0e2e98ca4d55eaec4e6535c
|
7
|
+
data.tar.gz: 49fca1ac96a80a6a3373f65340fd1e5bc8861fba62c3957b0bf6e2d4154c94ee90ecb5dd98a4e89265dd3e16acbca2104e8c2f76bbbd7813a17dc00cd6345863
|
data/.gitignore
CHANGED
data/lib/connection.rb
CHANGED
@@ -14,7 +14,7 @@ module Magentwo
|
|
14
14
|
@password = password
|
15
15
|
request_token
|
16
16
|
elsif (token)
|
17
|
-
|
17
|
+
@token = token
|
18
18
|
else
|
19
19
|
raise ArgumentError, "expected user/password or token"
|
20
20
|
end
|
@@ -34,13 +34,13 @@ module Magentwo
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
Magentwo.logger.info "
|
37
|
+
def request verb, path:, data:nil
|
38
|
+
Magentwo.logger.info "#{verb.to_s} #{host}/#{base_path}/#{path}"
|
39
39
|
Magentwo.logger.debug "DATA #{data}"
|
40
40
|
|
41
41
|
url = "#{base_path}/#{path}"
|
42
42
|
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
43
|
-
req =
|
43
|
+
req = verb.new(url)
|
44
44
|
req["Authorization"] = "Bearer #{self.token}"
|
45
45
|
req['Content-Type'] = "application/json"
|
46
46
|
req.body = data
|
@@ -48,42 +48,20 @@ module Magentwo
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def delete path, data
|
52
|
+
request Net::HTTP::Delete, path:path, data:data
|
53
|
+
end
|
54
|
+
|
51
55
|
def put path, data
|
52
|
-
|
53
|
-
Magentwo.logger.debug "DATA #{data}"
|
54
|
-
url = "#{base_path}/#{path}"
|
55
|
-
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
56
|
-
req = Net::HTTP::Put.new(url)
|
57
|
-
req["Authorization"] = "Bearer #{self.token}"
|
58
|
-
req['Content-Type'] = "application/json"
|
59
|
-
req.body = data
|
60
|
-
http.request(req)
|
61
|
-
end
|
56
|
+
request Net::HTTP::Put, path:path, data:data
|
62
57
|
end
|
63
58
|
|
64
59
|
def post path, data
|
65
|
-
|
66
|
-
Magentwo.logger.debug "DATA #{data}"
|
67
|
-
url = "#{base_path}/#{path}"
|
68
|
-
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
69
|
-
req = Net::HTTP::Post.new(url)
|
70
|
-
req["Authorization"] = "Bearer #{self.token}"
|
71
|
-
req['Content-Type'] = "application/json"
|
72
|
-
req.body = data
|
73
|
-
http.request(req)
|
74
|
-
end
|
60
|
+
request Net::HTTP::Put, path:path, data:data
|
75
61
|
end
|
76
62
|
|
77
|
-
|
78
63
|
def get path, query
|
79
|
-
|
80
|
-
url = "#{base_path}/#{path}?#{query}"
|
81
|
-
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
82
|
-
req = Net::HTTP::Get.new(url)
|
83
|
-
req["Authorization"] = "Bearer #{self.token}"
|
84
|
-
req['Content-Type'] = "application/json"
|
85
|
-
http.request(req)
|
86
|
-
end
|
64
|
+
request Net::HTTP::Get, path:"#{path}?#{query}"
|
87
65
|
end
|
88
66
|
end
|
89
|
-
end
|
67
|
+
end
|
data/lib/magentwo.rb
CHANGED
@@ -17,7 +17,7 @@ module Magentwo
|
|
17
17
|
def self.connect_with_token host=nil, token=nil
|
18
18
|
raise ArgumentError, "no host specified" unless host
|
19
19
|
raise ArgumentError, "no token specified" unless token
|
20
|
-
Base.adapter = Adapter.new
|
20
|
+
Base.adapter = Adapter.new(token: token, uri: host)
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.with connection
|
data/magentwo.gemspec
CHANGED