nilpart 1.0.0 → 2.0.0

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: d5ed84f607d7a35d58cfb5f83a075fb0030f3b54c51929f805e25919eebc1e2a
4
- data.tar.gz: df5aba9d1c3094f0160b78a79c4c058892a93e5651f85a0dd6b41ce9aaba6917
3
+ metadata.gz: 8254584b1124768360bda7136358b1e6048e704a2afe527453b7be682153221a
4
+ data.tar.gz: afeb103e1b6c9acf5ae2cac41d032d889eb21e95482968884bd2bfb22325a923
5
5
  SHA512:
6
- metadata.gz: 39cdc4447bd8a36000dc23ec7ffa783da7e1682d406adad1f9d887422751a6edd338b1d79e920e74056eda25df7b8335eaccb6dcb9d0773c1e49487df114e246
7
- data.tar.gz: 5b32dba2790bcd5667bfde39447bc73079af1372729754abd97d386b139c05f386f3d78ac1bdaceb986a009b91237bbb8bff1ef7d2b3447978c0ce4894620a6c
6
+ metadata.gz: e74dedd72429918a8c1999a136518bb702256ad5d4c00a5f1028786eb617d09e7d6ade88ea0cfda2ba30787c128d45208e8c1e0ada6b516a2e15c50385703050
7
+ data.tar.gz: 112b11cdf7e33f108c0cb95e52b9fdd2432cfbdf392e6a9f8f0adecd3e3a2ddea40702922b1b596c4f36ce8b14ba8e82764bd293bb78c02e6308286fe7226d9c
data/README.md CHANGED
@@ -5,7 +5,7 @@ You need a Partoo.co Api-Key.
5
5
 
6
6
  ## Initialize Nilpart
7
7
 
8
- np = Nilpart::Nilpart.new({ api_key: "machin", mode: "prod" }) # mode must be 'prod' or 'sandbox'
8
+ np = Nilpart::Nilpart.new({ api_key: YOUR_API_KEY, mode: "production" }) # mode must be 'production' or 'sandbox'
9
9
 
10
10
  ## Example of data returned
11
11
 
@@ -31,3 +31,4 @@ You need a Partoo.co Api-Key.
31
31
 
32
32
  ## More ?
33
33
 
34
+ See available methods here : https://github.com/rivsc/nilpart/blob/main/lib/nilpart/nilpart.rb
@@ -1,5 +1,6 @@
1
1
  require_relative './version'
2
2
  require 'faraday'
3
+ require 'faraday_middleware'
3
4
  require 'json'
4
5
 
5
6
  module Nilpart
@@ -8,19 +9,24 @@ module Nilpart
8
9
  SANDBOX_SERVER = "https://sandbox.api.partoo.co/v2/"
9
10
 
10
11
  attr_accessor :my_api_key
11
- attr_accessor :production # prod / sandbox
12
+ attr_accessor :production
13
+ attr_accessor :conn
12
14
 
13
15
  #
14
16
  # +api_key+ your api_key
15
- # +mode+ "prod" for production / "sandbox" for sandbox
17
+ # +mode+ "production" or "sandbox"
16
18
  #
17
19
  def initialize(params)
18
20
  @my_api_key = params[:api_key]
19
21
 
20
22
  raise ':api_key is required !' if @my_api_key.to_s.empty?
21
- raise ':mode params must be "prod" or "sandbox"' unless ['prod', 'sandbox'].include?(params[:mode])
23
+ raise ':mode params must be "production" or "sandbox"' unless ['production', 'sandbox'].include?(params[:mode])
22
24
 
23
- @production = params[:mode].to_s == 'prod'
25
+ @production = params[:mode].to_s == 'production'
26
+
27
+ @conn = Faraday.new do |f|
28
+ f.response :follow_redirects
29
+ end
24
30
  end
25
31
 
26
32
  def server_url
@@ -28,7 +34,7 @@ module Nilpart
28
34
  end
29
35
 
30
36
  def get_request(path, params = {})
31
- response = Faraday.get("#{self.server_url}#{path}", params, { 'x-APIKey' => @my_api_key })
37
+ response = @conn.get("#{self.server_url}#{path}", params, { 'x-APIKey' => @my_api_key })
32
38
  if response.status != 200 # Faraday has not constante for status 200
33
39
  puts "#{__method__} : Path => #{path} : Status => #{response.status}"
34
40
  end
@@ -36,7 +42,7 @@ module Nilpart
36
42
  end
37
43
 
38
44
  def delete_request(path, params = {})
39
- response = Faraday.delete("#{self.server_url}#{path}", params, { 'x-APIKey' => @my_api_key })
45
+ response = @conn.delete("#{self.server_url}#{path}", params, { 'x-APIKey' => @my_api_key })
40
46
  if response.status != 200 # Faraday has not constante for status 200
41
47
  puts "#{__method__} : Path => #{path} : Status => #{response.status}"
42
48
  end
@@ -44,7 +50,7 @@ module Nilpart
44
50
  end
45
51
 
46
52
  def post_request(path, body = {})
47
- response = Faraday.post("#{self.server_url}#{path}", body.to_json, { 'x-APIKey' => @my_api_key, "Content-Type" => "application/json" })
53
+ response = @conn.post("#{self.server_url}#{path}", body.to_json, { 'x-APIKey' => @my_api_key, "Content-Type" => "application/json" })
48
54
  if response.status != 200 # Faraday has not constante for status 200
49
55
  puts "#{__method__} : Path => #{path} : Status => #{response.status}"
50
56
  end
@@ -52,7 +58,7 @@ module Nilpart
52
58
  end
53
59
 
54
60
  def put_request(path, body = {})
55
- response = Faraday.put("#{self.server_url}#{path}", body.to_json, { 'x-APIKey' => @my_api_key, "Content-Type" => "application/json" })
61
+ response = @conn.put("#{self.server_url}#{path}", body.to_json, { 'x-APIKey' => @my_api_key, "Content-Type" => "application/json" })
56
62
  if response.status != 200 # Faraday has not constante for status 200
57
63
  puts "#{__method__} : Path => #{path} : Status => #{response.status}"
58
64
  end
@@ -1,3 +1,3 @@
1
1
  module Nilpart
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
data/nilpart.gemspec CHANGED
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
17
17
  s.license = 'MIT'
18
18
 
19
19
  s.add_runtime_dependency("faraday")
20
+ s.add_runtime_dependency("faraday_middleware")
20
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nilpart
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Claudel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Nilpart allow you to connect to Partoo RestAPI !
28
42
  email: claudel.sylvain@gmail.com
29
43
  executables: []