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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44f33adbf5ffc5496b64a1f441adc196278dbbad3a8aadc318ca19b676aa6858
4
- data.tar.gz: 20b45d22c24da87f886cb8b09033b6148adc8fe3ea6004ce48423480cf64c965
3
+ metadata.gz: 15cb810f21e6410e34b764567e40378ca481d8b2ba9133a6981a2b6738818c8a
4
+ data.tar.gz: c5f1fe3851888baf2d6371e849fa44a87087c54ea91adcf574ed2ff79f384d3b
5
5
  SHA512:
6
- metadata.gz: 2fcce9091f7e9ef49383278c230d8c61b7eb0248ba97c4fc002c8385494fe5fc803bcda137e8b1bc6732f320299a6309d8d9c1789ffa01b29d6944b451791411
7
- data.tar.gz: 32f13b1fdcf0c182bd6151566bba566a0d6ebfec22220805e03deb6205b0cd7815dc7d274606c7213fa37e41b75573a2d0881f17605ab789aab0e41241518297
6
+ metadata.gz: a18862fc3e2792a23539d840ffea2591d90c232ce17d2fa0d114707d759554bbd114bcd726c7d1a5bc13ce67bb4c9c7d482ff038d0e2e98ca4d55eaec4e6535c
7
+ data.tar.gz: 49fca1ac96a80a6a3373f65340fd1e5bc8861fba62c3957b0bf6e2d4154c94ee90ecb5dd98a4e89265dd3e16acbca2104e8c2f76bbbd7813a17dc00cd6345863
data/.gitignore CHANGED
@@ -52,3 +52,4 @@ build-iPhoneSimulator/
52
52
  .rvmrc
53
53
 
54
54
  /cplus
55
+ run.rb
data/lib/connection.rb CHANGED
@@ -14,7 +14,7 @@ module Magentwo
14
14
  @password = password
15
15
  request_token
16
16
  elsif (token)
17
- @token = token
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 delete path, data
38
- Magentwo.logger.info "DELETE #{host}/#{base_path}/#{path}"
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 = Net::HTTP::Delete.new(url)
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
- Magentwo.logger.info "PUT #{host}/#{base_path}/#{path}"
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
- Magentwo.logger.info "POST #{host}/#{path}"
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
- Magentwo.logger.info "GET #{host}#{base_path}/#{path}?#{query}"
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 ({token: token, uri: host})
20
+ Base.adapter = Adapter.new(token: token, uri: host)
21
21
  end
22
22
 
23
23
  def self.with connection
data/magentwo.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'magentwo'
3
- s.version = '0.1.90'
3
+ s.version = '0.1.91'
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.90
4
+ version: 0.1.91
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Mueß