simplemdm 0.1.0 → 0.1.1
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/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/README.md +31 -4
- data/lib/simplemdm/app_group.rb +30 -0
- data/lib/simplemdm/base.rb +4 -0
- data/lib/simplemdm/version.rb +1 -1
- data/simplemdm.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de59962356b55faa25bc1d8393f21592f182bebc
|
4
|
+
data.tar.gz: 213c0d915c20f2f88ef560ebe0a5a22f258f707d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cf2f52c57b12329639b67eedcbbbb0e4ddacbb6f9f842bff35be534e709fac8a2611293b1e90c166e5526ff6a7257fe293ca0a113f2b733ce3bbeadbfffeeb0
|
7
|
+
data.tar.gz: a4939f9f2a11fdd798ef24846526887b982ea4e01aaf3c859beba4a81c4d84bc375b43f8fd3c524bc3f1f3332d17a40668d16a17e3d9c4d6484ccd035c801910
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# SimpleMDM Ruby bindings
|
2
2
|
|
3
|
-
This is a lightweight SDK that acts as a launching point for integrating ruby-based applications with SimpleMDM. The native API is a RESTful JSON implementation. These bindings wrap the API.
|
3
|
+
This is a lightweight SDK that acts as a launching point for integrating ruby-based applications with [SimpleMDM](http://www.simplemdm.com/). The native API is a RESTful JSON implementation. These bindings wrap the API.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'simplemdm
|
10
|
+
gem 'simplemdm'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -16,11 +16,38 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install simplemdm
|
19
|
+
$ gem install simplemdm
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Full documentation is available here:
|
23
|
+
Full documentation is available here: [http://www.simplemdm.com/docs/api/](http://www.simplemdm.com/docs/api/)
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'simplemdm'
|
27
|
+
|
28
|
+
# provide your api key for access
|
29
|
+
|
30
|
+
SimpleMDM::api_key = 'j75m8YtUGEaEO5TysjzAXihE07nKoUm9'
|
31
|
+
|
32
|
+
# lock a device
|
33
|
+
|
34
|
+
device = SimpleMDM::Device.find(23)
|
35
|
+
device.lock message: "This device has been locked. Please call the number provided.",
|
36
|
+
phone_number: "5035555847"
|
37
|
+
|
38
|
+
|
39
|
+
# upload an enterprise app and deploy it to a group of devices
|
40
|
+
|
41
|
+
app_data = IO.binread('surfreport2.2.ipa')
|
42
|
+
app = SimpleMDM::App.new name: "Surf Report",
|
43
|
+
binary: data
|
44
|
+
app.save
|
45
|
+
|
46
|
+
app_group = SimpleMDM::AppGroup.find(37)
|
47
|
+
app_group.add_app(app)
|
48
|
+
app_group.push_apps
|
49
|
+
```
|
50
|
+
|
24
51
|
|
25
52
|
## Development
|
26
53
|
|
data/lib/simplemdm/app_group.rb
CHANGED
@@ -124,6 +124,36 @@ module SimpleMDM
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
def add_device(device)
|
128
|
+
raise "You must save this app group before changing associations." if new?
|
129
|
+
raise "The object you provided is not a device" unless device.kind_of?(SimpleMDM::Device)
|
130
|
+
raise "You must save the device before associating it" if device.id.nil?
|
131
|
+
|
132
|
+
hash, code = fetch("app_groups/#{self.id}/devices/#{device.id}", :post)
|
133
|
+
|
134
|
+
if code == 204
|
135
|
+
self['device_ids'] = self['device_ids'] | [device.id]
|
136
|
+
true
|
137
|
+
else
|
138
|
+
false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def remove_device(device)
|
143
|
+
raise "You must save this app group before changing associations" if new?
|
144
|
+
raise "The object you provided is not a device" unless device.kind_of?(SimpleMDM::Device)
|
145
|
+
raise "The device you provided doesn't exist" if device.id.nil?
|
146
|
+
|
147
|
+
hash, code = fetch("app_groups/#{self.id}/devices/#{device.id}", :delete)
|
148
|
+
|
149
|
+
if code == 204
|
150
|
+
self['device_ids'].delete(device.id)
|
151
|
+
true
|
152
|
+
else
|
153
|
+
false
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
127
157
|
def push_apps
|
128
158
|
raise "You cannot push apps for an app group that hasn't been created yet" if new?
|
129
159
|
|
data/lib/simplemdm/base.rb
CHANGED
@@ -26,6 +26,10 @@ module SimpleMDM
|
|
26
26
|
attrs['device_group_ids'] = hash['relationships']['device_groups']['data'].collect { |o| o['id'] }
|
27
27
|
end
|
28
28
|
|
29
|
+
if hash['relationships']['devices']
|
30
|
+
attrs['device_ids'] = hash['relationships']['devices']['data'].collect { |o| o['id'] }
|
31
|
+
end
|
32
|
+
|
29
33
|
if hash['relationships']['apps']
|
30
34
|
attrs['app_ids'] = hash['relationships']['apps']['data'].collect { |o| o['id'] }
|
31
35
|
end
|
data/lib/simplemdm/version.rb
CHANGED
data/simplemdm.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplemdm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Boyko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.4.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.4.4
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- taylor@wrprojects.com
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
77
|
+
- CHANGELOG.md
|
63
78
|
- CODE_OF_CONDUCT.md
|
64
79
|
- Gemfile
|
65
80
|
- LICENSE.txt
|