applocate 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 468efd2520ecc1a8d0ca539261a7105cecd61013
4
- data.tar.gz: e3d93987a697c56958ca289c88c766848b27630e
3
+ metadata.gz: 567f2cda14537e4d92569ae62db36e4f8062f100
4
+ data.tar.gz: 56b1d3ac871cf8ca8b89429279b763242484520d
5
5
  SHA512:
6
- metadata.gz: 854a0c54742a9071e84e9ea0d966aab1abd9d29c689a3d8a64cb5164290f25c5158c0e92b4b12b64a0e845cba2b5d28ca76e341e4784671d60b8ee6c90ed913a
7
- data.tar.gz: 5fa73757974f74738dcd77969ef613bf89c5e89a9cf55424d2108f69ea9f7200dd0b3e38a447f068c74ab3a499f023152dde1446ab1203b6535e673d855b638b
6
+ metadata.gz: 11448db8587fbf384b3291992bbae44bad93d6ed0654f200e5561ef5a8678a622f1ee54fb648170bbf014e5b8bef8042ebd2298d2cafce8927724cc5defaf5b4
7
+ data.tar.gz: b0da9bf360435f23858f0a06241048cc227fb79cf0d4af0d62dbece537d86673f565f66ad53006794aa6d03f13b0c271d8705ece506d3d8098cfeb27e6212459
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem provides access to the Applocate API.
4
4
 
5
+ [![Build Status](https://travis-ci.org/aai/applocate.svg?branch=master)](https://travis-ci.org/aai/applocate)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -35,7 +37,6 @@ the server with ```APPLOCATE_BASE_URL```
35
37
  Applocate.configure do |config|
36
38
  config.token = ENV['APPLOCATE_TOKEN']
37
39
  config.secret = ENV['APPLOCATE_SECRET']
38
- config.base_url = ENV['BASE_URL']
39
40
  end
40
41
  ```
41
42
 
@@ -59,6 +60,15 @@ Applocate::API.install_app(options)
59
60
  # expected options -> { uuid: "ABCD-DCCDDC-12394812389-CDC" }
60
61
  Applocate::API.app_list(options)
61
62
  # returns a list (Array) of UUIDs with their apps.
63
+
64
+ Applocate::API.register_device
65
+ # returns :id, :uuid, :enrollment_url
66
+ # since the uuid comes from the device it will be nil until the device enrolls
67
+
68
+ Applocate::API.list_devices
69
+ # return an array of devices containing :id, :uuid, :enrollment_url
70
+ # once the device has enrolled it will have a :uuid but no :enrollment_url
71
+
62
72
  ```
63
73
 
64
74
  ## Contributing
@@ -9,29 +9,45 @@ module Applocate
9
9
 
10
10
  # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
11
11
  def self.restrict(options)
12
- response = self.post('/deploy/profile', body: options.to_json)
12
+ response = self.post('/deploy/profile', { body: options.to_json }, authentication)
13
13
  JSON.parse response.body rescue []
14
14
  end
15
15
 
16
16
  # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
17
17
  def self.unrestrict(options)
18
- response = self.delete('/deploy/profile', body: options.to_json)
18
+ response = self.delete('/deploy/profile', { body: options.to_json }, authentication)
19
19
  JSON.parse response.body rescue []
20
20
  end
21
21
 
22
- # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "003274092" }
22
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "284910350" }
23
23
  def self.install_app(options)
24
- response = self.post('/deploy/app', body: options.to_json)
24
+ response = self.post('/deploy/app', { body: options.to_json }, authentication)
25
25
  JSON.parse response.body rescue []
26
26
  end
27
27
 
28
28
  # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
29
29
  def self.app_list(options)
30
- response = self.post('/deploy/app_list', body: options.to_json)
30
+ response = self.post('/deploy/app_list', { body: options.to_json }, authentication)
31
31
  JSON.parse response.body rescue []
32
32
  end
33
33
 
34
- def self.key
34
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "284910350" }
35
+ def self.register_device
36
+ response = self.post('/api/devices', { body: options.to_json }, authentication)
37
+ JSON.parse response.body rescue []
38
+ end
39
+
40
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
41
+ def self.list_devices
42
+ response = self.get('/api/devices', { body: options.to_json }, authentication)
43
+ JSON.parse response.body rescue []
44
+ end
45
+
46
+ def self.authentication
47
+ { "X-Applocate-Secret" => secret, "X-Applocate-Token" => token }
48
+ end
49
+
50
+ def self.token
35
51
  Applocate.configuration.token
36
52
  end
37
53
 
@@ -1,3 +1,3 @@
1
1
  module Applocate
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -10,8 +10,8 @@ describe Applocate::API do
10
10
  end
11
11
  }
12
12
 
13
- it 'uses the configured key' do
14
- expect(subject.key).to eq('token')
13
+ it 'uses the configured token' do
14
+ expect(subject.token).to eq('token')
15
15
  end
16
16
  it 'uses the configured secret' do
17
17
  expect(subject.secret).to eq('secret')
@@ -27,7 +27,7 @@ describe Applocate::API do
27
27
  results = []
28
28
 
29
29
  Applocate::API.should_receive(:post)
30
- .with('/deploy/profile', body: device_list.to_json)
30
+ .with('/deploy/profile', { body: device_list.to_json }, Applocate::API.authentication)
31
31
  .and_return(results)
32
32
 
33
33
  Applocate::API.restrict device_list
@@ -39,7 +39,7 @@ describe Applocate::API do
39
39
  results = []
40
40
 
41
41
  Applocate::API.should_receive(:delete)
42
- .with('/deploy/profile', body: device_list.to_json)
42
+ .with('/deploy/profile', { body: device_list.to_json }, Applocate::API.authentication)
43
43
  .and_return(results)
44
44
 
45
45
  Applocate::API.unrestrict device_list
@@ -48,11 +48,11 @@ describe Applocate::API do
48
48
 
49
49
  describe '.install_app' do
50
50
  it 'removes the restrictions profile from devices' do
51
- options = { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "00123487" }
51
+ options = { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "284910350" }
52
52
  results = []
53
53
 
54
54
  Applocate::API.should_receive(:post)
55
- .with('/deploy/app', body: options.to_json)
55
+ .with('/deploy/app', { body: options.to_json }, Applocate::API.authentication)
56
56
  .and_return(results)
57
57
 
58
58
  Applocate::API.install_app options
@@ -65,7 +65,7 @@ describe Applocate::API do
65
65
  results = []
66
66
 
67
67
  Applocate::API.should_receive(:post)
68
- .with('/deploy/app_list', body: device_list.to_json)
68
+ .with('/deploy/app_list', { body: device_list.to_json }, Applocate::API.authentication)
69
69
  .and_return(results)
70
70
 
71
71
  Applocate::API.app_list device_list
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: applocate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Madsen