magentwo 0.1.82 → 0.1.83
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 +4 -4
- data/lib/connection.rb +7 -6
- 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: 8971d5fe11cfc1ec134a18f9af85f9dcca858ca2068ed85a7cc7af82b520105b
|
4
|
+
data.tar.gz: 70c047455ec6ca0773f4274c21b5bd1c7af151972c6adbab99e1aced62b1fd04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b564e84256ee706f9f0ac8fa5437bc3cdd8ece89bae0467181eddce99fd9747f12ee1c6d758e7dcc6ee8dfe24bd5ef20981a89c453f38efdfb64845dd8465954
|
7
|
+
data.tar.gz: 05f575ebbb8541056bddc170f441f0ae99e4c89b54a3bdef0b9e390c44ce89e6dd53208dc008894843b38413fef6c883ebae2f4cbae413ad614b1b1a4850164d
|
data/lib/connection.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
module Magentwo
|
2
2
|
class Connection
|
3
|
-
attr_accessor :host, :port, :user, :password, :token, :base_path
|
3
|
+
attr_accessor :host, :port, :user, :password, :token, :base_path, :scheme
|
4
4
|
|
5
5
|
def initialize uri, user, password, base_path:nil
|
6
6
|
uri = URI(uri)
|
7
7
|
@host = uri.host
|
8
8
|
@port = uri.port
|
9
9
|
@user = user
|
10
|
+
@scheme = uri.scheme
|
10
11
|
@password = password
|
11
12
|
@base_path = base_path || "/rest/V1"
|
12
13
|
request_token
|
13
14
|
end
|
14
15
|
|
15
16
|
def request_token
|
16
|
-
Net::HTTP.start(self.host,self.port) do |http|
|
17
|
+
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
17
18
|
url = "#{base_path}/integration/admin/token"
|
18
19
|
Magentwo.logger.info "POST #{url}"
|
19
20
|
req = Net::HTTP::Post.new(url)
|
@@ -30,7 +31,7 @@ module Magentwo
|
|
30
31
|
Magentwo.logger.debug "DATA #{data}"
|
31
32
|
|
32
33
|
url = "#{base_path}/#{path}"
|
33
|
-
Net::HTTP.start(self.host,self.port) do |http|
|
34
|
+
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
34
35
|
req = Net::HTTP::Delete.new(url)
|
35
36
|
req["Authorization"] = "Bearer #{self.token}"
|
36
37
|
req['Content-Type'] = "application/json"
|
@@ -43,7 +44,7 @@ module Magentwo
|
|
43
44
|
Magentwo.logger.info "PUT #{host}/#{base_path}/#{path}"
|
44
45
|
Magentwo.logger.debug "DATA #{data}"
|
45
46
|
url = "#{base_path}/#{path}"
|
46
|
-
Net::HTTP.start(self.host,self.port) do |http|
|
47
|
+
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
47
48
|
req = Net::HTTP::Put.new(url)
|
48
49
|
req["Authorization"] = "Bearer #{self.token}"
|
49
50
|
req['Content-Type'] = "application/json"
|
@@ -56,7 +57,7 @@ module Magentwo
|
|
56
57
|
Magentwo.logger.info "POST #{host}/#{path}"
|
57
58
|
Magentwo.logger.debug "DATA #{data}"
|
58
59
|
url = "#{base_path}/#{path}"
|
59
|
-
Net::HTTP.start(self.host,self.port) do |http|
|
60
|
+
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
60
61
|
req = Net::HTTP::Post.new(url)
|
61
62
|
req["Authorization"] = "Bearer #{self.token}"
|
62
63
|
req['Content-Type'] = "application/json"
|
@@ -69,7 +70,7 @@ module Magentwo
|
|
69
70
|
def get path, query
|
70
71
|
Magentwo.logger.info "GET #{host}#{base_path}/#{path}?#{query}"
|
71
72
|
url = "#{base_path}/#{path}?#{query}"
|
72
|
-
Net::HTTP.start(self.host,self.port) do |http|
|
73
|
+
Net::HTTP.start(self.host,self.port, :use_ssl => self.scheme == 'https') do |http|
|
73
74
|
req = Net::HTTP::Get.new(url)
|
74
75
|
req["Authorization"] = "Bearer #{self.token}"
|
75
76
|
req['Content-Type'] = "application/json"
|
data/magentwo.gemspec
CHANGED