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 +4 -4
- data/README.md +2 -1
- data/lib/nilpart/nilpart.rb +14 -8
- data/lib/nilpart/version.rb +1 -1
- data/nilpart.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8254584b1124768360bda7136358b1e6048e704a2afe527453b7be682153221a
|
4
|
+
data.tar.gz: afeb103e1b6c9acf5ae2cac41d032d889eb21e95482968884bd2bfb22325a923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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
|
data/lib/nilpart/nilpart.rb
CHANGED
@@ -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
|
12
|
+
attr_accessor :production
|
13
|
+
attr_accessor :conn
|
12
14
|
|
13
15
|
#
|
14
16
|
# +api_key+ your api_key
|
15
|
-
# +mode+ "
|
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 "
|
23
|
+
raise ':mode params must be "production" or "sandbox"' unless ['production', 'sandbox'].include?(params[:mode])
|
22
24
|
|
23
|
-
@production = params[:mode].to_s == '
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
data/lib/nilpart/version.rb
CHANGED
data/nilpart.gemspec
CHANGED
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:
|
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-
|
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: []
|