moki_ruby 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/moki_ruby/device.rb +10 -0
- data/lib/moki_ruby/device_managed_app.rb +11 -0
- data/lib/moki_ruby/version.rb +1 -1
- data/spec/lib/device_managed_app_spec.rb +20 -9
- data/spec/lib/device_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c8ae7261ca9359ed79b3bb5165abcec1cb84cc
|
4
|
+
data.tar.gz: a765535d108885b5a261fdbb85cf8bce1a62a7e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25fb57f791a4226edc76dbe22238470fd61e57abdc3566629544b6402dd394f89f5bbf2960c4d5183b443d4e42c97e1d9fa55562d1e9873def12d852ee5b52ba
|
7
|
+
data.tar.gz: f3babd1dfb161b7908e9edab9e8a1f70df6ff86fbf2ea3a45a5a97223915a07a8c5e2ad1d8d7745e00d73480e3435dd517c06a31b41218f3b7e8b37c83eec4ac
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,10 @@ Using this device, there are several methods available:
|
|
63
63
|
- `device.install_app(app)` takes in a `TenantManagedApp` object, and
|
64
64
|
will install the given application on the device. Returns an
|
65
65
|
`Action` object, for tracking in the future.
|
66
|
+
- `device.uninstall_app(app)` takes in a `DeviceManagedApp` object, and
|
67
|
+
will uninstall the given application on the device. Returns an
|
68
|
+
`Action` object, for tracking in the future. Note that this must be
|
69
|
+
done on a managed app.
|
66
70
|
- `device.add_profile(profile)` takes in an `TenantIOSProfile` object, and
|
67
71
|
will install the given profile on the device. Returns an `Action`
|
68
72
|
object, for tracking in the future.
|
data/lib/moki_ruby/device.rb
CHANGED
@@ -50,6 +50,16 @@ module MokiRuby
|
|
50
50
|
Action.from_hash(data.body)
|
51
51
|
end
|
52
52
|
|
53
|
+
def uninstall_app(device_managed_app)
|
54
|
+
raise "DeviceManagedApp required" unless device_managed_app && device_managed_app.is_a?(DeviceManagedApp)
|
55
|
+
|
56
|
+
data = MokiAPI.perform_action(device_id_param, device_managed_app.uninstall_hash).value
|
57
|
+
return nil unless data.status == 200
|
58
|
+
binding.pry
|
59
|
+
|
60
|
+
Action.from_hash(data.body)
|
61
|
+
end
|
62
|
+
|
53
63
|
def add_profile(profile)
|
54
64
|
raise "TenantIOSProfile required" unless profile && profile.is_a?(TenantIOSProfile)
|
55
65
|
|
@@ -18,5 +18,16 @@ module MokiRuby
|
|
18
18
|
"ManagementFlags" => self.management_flags
|
19
19
|
}
|
20
20
|
end
|
21
|
+
|
22
|
+
def uninstall_hash
|
23
|
+
{
|
24
|
+
"action" => "remove_app",
|
25
|
+
"thirdPartyUser" => "moki_ruby",
|
26
|
+
"clientName" => "MokiRuby",
|
27
|
+
"itemName" => "iOS App",
|
28
|
+
"notify" => true,
|
29
|
+
"payload" => self.app_identifier
|
30
|
+
}
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
data/lib/moki_ruby/version.rb
CHANGED
@@ -7,18 +7,29 @@ describe DeviceManagedApp do
|
|
7
7
|
"ManagementFlags" => 0 } }
|
8
8
|
|
9
9
|
it "will load from a hash with string keys" do
|
10
|
-
|
11
|
-
expect(
|
12
|
-
expect(
|
13
|
-
expect(
|
10
|
+
app = DeviceManagedApp.from_hash(response_hash)
|
11
|
+
expect(app.status).to eq(response_hash["Status"])
|
12
|
+
expect(app.app_identifier).to eq(response_hash["appIdentifier"])
|
13
|
+
expect(app.management_flags).to eq(response_hash["ManagementFlags"])
|
14
14
|
end
|
15
15
|
|
16
16
|
it "will convert the response to a hash" do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
app = DeviceManagedApp.new
|
18
|
+
app.status = "Managed"
|
19
|
+
app.app_identifier = "com.belly.gem.moki.enterprise"
|
20
|
+
app.management_flags = 0
|
21
21
|
|
22
|
-
expect(
|
22
|
+
expect(app.to_hash).to eq(response_hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "will return a hash for removal" do
|
26
|
+
app= DeviceManagedApp.from_hash(response_hash)
|
27
|
+
expect(app.uninstall_hash).to eq({
|
28
|
+
"action" => "remove_app",
|
29
|
+
"thirdPartyUser" => "moki_ruby",
|
30
|
+
"clientName" => "MokiRuby",
|
31
|
+
"itemName" => "iOS App",
|
32
|
+
"notify" => true,
|
33
|
+
"payload" => response_hash["appIdentifier"] })
|
23
34
|
end
|
24
35
|
end
|
data/spec/lib/device_spec.rb
CHANGED
@@ -149,6 +149,29 @@ describe MokiRuby::Device do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
+
describe "#uninstall_app" do
|
153
|
+
it "requires a DeviceManagedApp" do
|
154
|
+
expect { device.uninstall_app('foo') }.to raise_error
|
155
|
+
end
|
156
|
+
|
157
|
+
it "calls MokiAPI.perform with store app parameters" do
|
158
|
+
load_good_stubs
|
159
|
+
|
160
|
+
device_managed_app = DeviceManagedApp.from_hash({ "Status" => "managed",
|
161
|
+
"appIdentifier" => "com.mokimobility.mokitouch2",
|
162
|
+
"ManagementFlags" => 1 })
|
163
|
+
|
164
|
+
expect(MokiAPI).to receive(:perform_action).with(udid, device_managed_app.uninstall_hash)
|
165
|
+
.and_return(Hashie::Mash.new(value: { body: @action_stub_response }))
|
166
|
+
device.uninstall_app(device_managed_app)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "returns nil if the device was not found" do
|
170
|
+
load_bad_stubs
|
171
|
+
expect(device.uninstall_app(DeviceManagedApp.new)).to be_nil
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
152
175
|
describe "#managed_apps" do
|
153
176
|
it "calls MokiAPI.device_managed_app_list" do
|
154
177
|
response = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moki_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Springer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|