testcloud_devices_ruby 0.0.0.3 → 0.0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/testcloud/devices/client.rb +14 -10
- data/lib/testcloud/devices/ruby/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: ef2d46358f4d2d42284a442e1c300d7c42406a95
|
4
|
+
data.tar.gz: 3d47259a67267c1ba6f9c4d275856e280e51e6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 815d99fc04a3df1a2eaf5ab4b3b9db0c91fc57ccaf738bea0432f0441868b0ffc9eee2f52fca4b7da41fce6daa63aee121e92123305675a384c20ffdce413e4a
|
7
|
+
data.tar.gz: db19c96dac57ba2aed49172a29dc56fefd1c7eb05701f255344401de63cf68b70879d6240c8b6a8dadd3c9606b77e681386188705e9f1e7967945513cea669d7
|
@@ -1,11 +1,15 @@
|
|
1
|
+
require 'forwardable'
|
1
2
|
module Testcloud
|
2
3
|
module Devices
|
3
4
|
class Client
|
4
5
|
include HTTParty
|
6
|
+
extend Forwardable
|
7
|
+
|
5
8
|
DEFAULT_URL ||= 'https://stan.testcloud.io'
|
6
9
|
API_TOKEN_KEY ||= 'X-Testcloud-Devices-Token'
|
7
10
|
|
8
|
-
attr_accessor :type, :category, :api_token
|
11
|
+
attr_accessor :type, :category, :api_token, :raw_response, :response
|
12
|
+
def_delegators :raw_response, :ok?, :success?, :code
|
9
13
|
|
10
14
|
class << self
|
11
15
|
def setup(&block)
|
@@ -29,28 +33,28 @@ module Testcloud
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def types
|
32
|
-
|
33
|
-
Response.new(
|
36
|
+
@raw_response = self.class.get('/devices/types', access_headers)
|
37
|
+
@response = Response.new(@raw_response).keys
|
34
38
|
end
|
35
39
|
|
36
40
|
def categories
|
37
|
-
|
38
|
-
Response.new(
|
41
|
+
@raw_response = self.class.get("/devices/#{type.pluralize}/categories", access_headers)
|
42
|
+
@response = Response.new(@raw_response).keys
|
39
43
|
end
|
40
44
|
|
41
45
|
def validate(data = {})
|
42
|
-
|
43
|
-
Response.new(
|
46
|
+
@raw_response = self.class.post("/devices/#{type}/#{category}", access_headers.merge(body: data.to_json))
|
47
|
+
@response = Response.new(@raw_response)
|
44
48
|
end
|
45
49
|
|
46
50
|
def form_data
|
47
|
-
|
48
|
-
Response.new(
|
51
|
+
@raw_response = self.class.get("/devices/#{type}/#{category}/form_data", access_headers)
|
52
|
+
@response = Response.new(@raw_response)
|
49
53
|
end
|
50
54
|
|
51
55
|
private
|
52
56
|
def access_headers
|
53
|
-
@access_headers ||= { headers: { API_TOKEN_KEY => self.class.api_token } }
|
57
|
+
@access_headers ||= { headers: { API_TOKEN_KEY => self.class.api_token, 'Content-Type' => 'application/json' } }
|
54
58
|
end
|
55
59
|
|
56
60
|
end
|