ovh-api 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ovh-api/client.rb +26 -0
- data/lib/ovh-api/exceptions.rb +1 -0
- 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: e933d314a1697da8e6d10453aac95a8ffa1190fc
|
4
|
+
data.tar.gz: 3ca3fdc93e82ecc7b65767619212acf1b8067b00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47356d383cd69a81c26971a86e05587f7f052fcd1c4cca53a889cbe900574e648410acbfb46b63ae88f3f089eef45a90ba11c4db61078ef728737afa7c4117f8
|
7
|
+
data.tar.gz: aed83ad2769f62bee3fe0eb99275b16c6ee7aebd0cbb74ede55fe968c219fc74f4bb9c8a67cda22517e53ee4e670c962984eabca8c274591a3fc48a473db665b
|
data/lib/ovh-api/client.rb
CHANGED
@@ -65,6 +65,32 @@ module OVHApi
|
|
65
65
|
signature
|
66
66
|
end
|
67
67
|
|
68
|
+
|
69
|
+
# Helper to make a request to the OVH api then return the body as parsed JSON tree
|
70
|
+
#
|
71
|
+
# If body cannot be parsed, error is rescued and :body is set to nil.
|
72
|
+
#
|
73
|
+
# This function raise OVHApiNotImplementedError if method is not valid
|
74
|
+
#
|
75
|
+
# @param method [Symbol]: :get, :post, :put, :delete
|
76
|
+
# @param url [String]
|
77
|
+
# @return [Hash] { :resp => [Net::HTTPResponse] response, :body => [Hash|NilClass] (:resp body JSON parsed) }
|
78
|
+
def request_json(method, url)
|
79
|
+
raise OVHApiNotImplementedError.new(
|
80
|
+
"#{method.to_s} is not implemented. Please refere to documentation."
|
81
|
+
) unless [:get, :post, :delete, :put].include?method
|
82
|
+
resp = self.public_send(method, url)
|
83
|
+
body = nil
|
84
|
+
begin
|
85
|
+
body = JSON.parse(resp.body)
|
86
|
+
rescue
|
87
|
+
end
|
88
|
+
return {
|
89
|
+
:resp => resp,
|
90
|
+
:body => body
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
68
94
|
# Make a get request to the OVH api
|
69
95
|
#
|
70
96
|
# @param url [String]
|
data/lib/ovh-api/exceptions.rb
CHANGED
data/lib/ovh-api/version.rb
CHANGED