ovh-api 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ovh-api/client.rb +11 -3
- data/lib/ovh-api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04ca798d8a38c49b5cbcf1380d2bc712454a7cc9
|
4
|
+
data.tar.gz: c8fa15c43882f9f4ed35e6ac484b6ba1b9856702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf6dd0bf81d316421b4941d436b7f9a5c1ef28548109f6948b91b884283f53e38a40cf276f77f17650d2751a77862ebe42002a15a05d65860e95e91bb5d5e0a0
|
7
|
+
data.tar.gz: c83ad30e5c659832da8e9c575269bb8bcdd723dba5e047c373d664e9d2a9b14e1335e7520d50a0462ab74de5f18d5ad7c4e240e85d4b794758d9620c1bd4e236
|
data/lib/ovh-api/client.rb
CHANGED
@@ -73,13 +73,21 @@ module OVHApi
|
|
73
73
|
# This function raise OVHApiNotImplementedError if method is not valid
|
74
74
|
#
|
75
75
|
# @param method [Symbol]: :get, :post, :put, :delete
|
76
|
-
# @param
|
76
|
+
# @param path [String]
|
77
|
+
# @param arguments: [Hash]: will be encoded to be URL friendly with URI.encode_www_form and then pass as URL parameters
|
78
|
+
# @param body [String]: function parameters to be JSONified and sent as body in the request
|
77
79
|
# @return [Hash] { :resp => [Net::HTTPResponse] response, :body => [Hash|NilClass] (:resp body JSON parsed) }
|
78
|
-
def request_json(method,
|
80
|
+
def request_json(method, path, arguments = nil, body = '')
|
79
81
|
raise OVHApiNotImplementedError.new(
|
80
82
|
"#{method.to_s} is not implemented. Please refere to documentation."
|
81
83
|
) unless [:get, :post, :delete, :put].include?method
|
82
|
-
|
84
|
+
method_str = method.to_s.upcase
|
85
|
+
if arguments.nil? then
|
86
|
+
url = path
|
87
|
+
else
|
88
|
+
url = "#{path}?#{URI.encode_www_form(arguments)}"
|
89
|
+
end
|
90
|
+
resp = request(url, method_str, body)
|
83
91
|
body = nil
|
84
92
|
begin
|
85
93
|
body = JSON.parse(resp.body)
|
data/lib/ovh-api/version.rb
CHANGED