xively_api_client 0.0.1 → 0.1.0

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: a38d53e059dc99c23892f4b49526f64a280cebd2
4
- data.tar.gz: a3aca7988b85d41128e85f918c5a9f2de024117d
3
+ metadata.gz: b46ad248025242802ead6faf3877446d12da3418
4
+ data.tar.gz: 3f4fc2793a0be9164b2ea518e8d10a8e51a41109
5
5
  SHA512:
6
- metadata.gz: bd0791825f0f272b8b35778a3e17cd484d1fe1c254cf63f053c996fa2816096869ab833733a2fdd94a9b85eb6a0926077d396c52182fcf4c18b48756fc00e127
7
- data.tar.gz: 721b7f3b75e66c8d6ea57ca51b93b4f9cf977d60549eb75e13fcea71125e54e6aede472ac79843141d409cf73ac1202ea2c5d84285d9b3d513dd2e52702b8f38
6
+ metadata.gz: db64196b09aa3c90aa5e2a967997ee072496355ac993f4016d88797c9c7feb5e0fb21b8a70abd9bb11b53212f2033c8f22bacc20d223ee3f0de654e83e02b615
7
+ data.tar.gz: 51462e317806b71a2240e40dc8fff8c00da3f0ee59545ac4eca90427928b614f9e50616578737298eb85b038f18a23a50a3a00f438790d64d95eb800473c474a
@@ -13,18 +13,35 @@ module XivelyApiClient
13
13
  @pass = args[:pass] || ENV['XIVELY_PASS']
14
14
  end
15
15
 
16
- def create_device serial_id, options = {}
17
- json_parse(post(create_device_json serial_id, options)).first
16
+ def index_devices
17
+ json_parse(get device_url)
18
18
  end
19
19
 
20
- def find_by serial_id
21
- json_parse( get device_url serial_id ).first
20
+ def show_device serial_id
21
+ response = get device_url serial_id
22
+ json_parse(response).first
22
23
  end
23
24
 
24
- def devices
25
- json_parse(get device_url)
25
+ def create_device serial_id, options = {}
26
+ json_parse(post(build_json serial_id, options)).first
26
27
  end
27
28
 
29
+ # Not implemented in API? Or only can change "batch_id": and "device_secret":
30
+
31
+ # def update_device serial_id, options = {}
32
+ # device = show_device serial_id
33
+ # unless (device)
34
+ # json_parse put(device.to_json).first
35
+ # end
36
+ # end
37
+
38
+ # def put body
39
+ # HTTParty.put device_url,
40
+ # :body => body,
41
+ # :basic_auth => credentials,
42
+ # :headers => {'Content-Type' => 'application/json'}
43
+ # end
44
+
28
45
  def destroy_device serial
29
46
  delete device_url(serial)
30
47
  end
@@ -32,7 +49,7 @@ module XivelyApiClient
32
49
  private
33
50
 
34
51
  def json_parse response
35
- JSON.parse(response.body)["devices"]
52
+ JSON.parse(response.body)["devices"] || []
36
53
  end
37
54
 
38
55
  def get url
@@ -47,21 +64,18 @@ module XivelyApiClient
47
64
  end
48
65
 
49
66
  def delete url
50
- HTTParty.delete url,
51
- :basic_auth => credentials
67
+ HTTParty.delete url, :basic_auth => credentials
52
68
  end
53
69
 
54
70
  def device_url serial = nil
55
- url = "https://v3api.xively.com/v3/service_instances/#{ instance }/domains/#{ domain }/devices"
56
- url += "/#{ serial }" if serial
57
- url
71
+ url = "https://v3api.xively.com/v3/service_instances/#{ instance }/domains/#{ domain }/devices/#{serial}"
58
72
  end
59
73
 
60
74
  def credentials
61
75
  { username: @user, password: @pass }
62
76
  end
63
77
 
64
- def create_device_json serial_id, options = {}
78
+ def build_json serial_id, options = {}
65
79
  queues = options[:queues] || []
66
80
  batch_id = options[:batch_id] || "2ndnozefwvbsi"
67
81
  { devices:
@@ -1,3 +1,3 @@
1
1
  module XivelyApiClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xively_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Piccioni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler