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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96ca47ee21ab68e24e8d82e84df3f2b9cc20aa90
4
- data.tar.gz: c41979993008cad08e5ff23dd461739c14121e08
3
+ metadata.gz: ef2d46358f4d2d42284a442e1c300d7c42406a95
4
+ data.tar.gz: 3d47259a67267c1ba6f9c4d275856e280e51e6cd
5
5
  SHA512:
6
- metadata.gz: 707f806edba8b108707f83a22383891079fd4da4c63b4ba8ffb703a518cfcdff3907fdb772242b7cca3436b6f2df51d4374ddc2a8836fa8399562743b7d28039
7
- data.tar.gz: ce97c10e8b1d2605ff07c11b697b0665cae97ee61c25ee015f88cdf1a3e4a1bea0f61d63f52c93c9df720503ed217477a8ec2a82dc2db682da83699c1a553106
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
- response = self.class.get('/devices/types', access_headers)
33
- Response.new(response).keys
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
- response = self.class.get("/devices/#{type.pluralize}/categories", access_headers)
38
- Response.new(response).keys
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
- response = self.class.post("/devices/#{type}/#{category}", access_headers.merge(body: data))
43
- Response.new(response)
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
- response = self.class.get("/devices/#{type}/#{category}/form_data", access_headers)
48
- Response.new(response)
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
@@ -10,7 +10,7 @@ module Testcloud
10
10
  MAJOR = 0
11
11
  MINOR = 0
12
12
  PATCH = 0
13
- PRE = 3
13
+ PRE = 4
14
14
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
15
15
  end
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcloud_devices_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.3
4
+ version: 0.0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Faucett