magentwo 0.1.82 → 0.1.83

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/connection.rb +7 -6
  3. data/magentwo.gemspec +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 762b1ff6602d28d8c0016f48853837c9d04f550eedfbdf473f76fa49b9aeac4d
4
- data.tar.gz: eec1223e6e50059395b536df7b5dd130cba61fcced963dbed9fd581cf1d7b67c
3
+ metadata.gz: 8971d5fe11cfc1ec134a18f9af85f9dcca858ca2068ed85a7cc7af82b520105b
4
+ data.tar.gz: 70c047455ec6ca0773f4274c21b5bd1c7af151972c6adbab99e1aced62b1fd04
5
5
  SHA512:
6
- metadata.gz: b2aac1f5d4db03d4ab60edbf8520b632ed3b87279ca4ccf4769d4db75ff5955877e9a5ca289967c6c5fb395e7cc734f279f4909bb24aa59a793c4c573270da97
7
- data.tar.gz: 293e42cc723f68a9a34ac295c6d93105a3f3f72c3818c8430b1eafa001e99f85833f146e37f63bbdb6b0fe526587f95ccc4d08fc7efa5dddc3714683e5ceb423
6
+ metadata.gz: b564e84256ee706f9f0ac8fa5437bc3cdd8ece89bae0467181eddce99fd9747f12ee1c6d758e7dcc6ee8dfe24bd5ef20981a89c453f38efdfb64845dd8465954
7
+ data.tar.gz: 05f575ebbb8541056bddc170f441f0ae99e4c89b54a3bdef0b9e390c44ce89e6dd53208dc008894843b38413fef6c883ebae2f4cbae413ad614b1b1a4850164d
@@ -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"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'magentwo'
3
- s.version = '0.1.82'
3
+ s.version = '0.1.83'
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.82
4
+ version: 0.1.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Mueß