MokiRuby
A ruby gem for interacting with the Moki API, as a part of Moki Total Control and Moki Management.
Installation
Add this line to your application's Gemfile:
gem 'moki_ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install moki_ruby
Make sure to set the following environment variables:
ENV['MOKI_API_URL']
ENV['MOKI_TENANT_ID']
ENV['MOKI_API_KEY']
Usage
Device management can be done at the Tenant Level (across all devices) or at the individual device level.
Tenant Methods
The following methods have been built out:
-
MokiRuby.ios_profiles
asks for all current profiles associated with this tenant. This will return an array ofTenantIOSProfile
objects. -
MokiRuby.tenant_managed_apps
asks for all apps associaited with this tenant. This will return an array ofTenantManagedApp
objects.
Device Methods
First, create a device through one of the following approaches:
MokiRuby::Device.new(serial_number)
MokiRuby::Device.new(udid)
Using this device, there are several methods available:
-
device.load_details
will populate the device's nickname, title, time it was last seen, and whether or not it is checked out. This will return the updatedDevice
object. -
device.profiles
returns all profiles currently installed on a device. This will return an array ofDeviceIOSProfile
objects. -
device.managed_apps
returns all managed applications installed on a device. This will return an array ofDeviceManagedApp
objects. -
device.install_app(app)
takes in aTenantManagedApp
object, and will install the given application on the device. Returns anAction
object, for tracking in the future. -
device.uninstall_app(app)
takes in aDeviceManagedApp
object, and will uninstall the given application on the device. Returns anAction
object, for tracking in the future. Note that this must be done on a managed app. -
device.add_profile(profile)
takes in anTenantIOSProfile
object, and will install the given profile on the device. Returns anAction
object, for tracking in the future. -
device.remove_profile(profile)
take in anDeviceIOSProfile
object, and will remove the given profile from the device. Returns anAction
object, for tracking in the future. -
device.get_action(action_id)
will take in anid
from anAction
object, and return an updatedAction
object. -
device.pre_enroll
will send the serial number,client_id
, andtoken
from the device for pre-enrollment, and will returntrue
if successful. Ifclient_id
ortoken
are missing, both will be sent asnil
.
Note that if the device is not found, each method will return nil
instead of an object.
To do
- Confirm if profile is on device before adding/removing
- Confirm if app is on device before installing
Special Thanks
Thank you to the Moki team (GitHub), especially Jared, Sam, and Sam.
Contributing
- Fork it ( https://github.com/bellycard/moki_ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request