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_profilesasks for all current profiles associated with this tenant. This will return an array ofTenantIOSProfileobjects. -
MokiRuby.tenant_managed_appsasks for all apps associaited with this tenant. This will return an array ofTenantManagedAppobjects.
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_detailswill populate the device's nickname, title, time it was last seen, and whether or not it is checked out. This will return the updatedDeviceobject. -
device.profilesreturns all profiles currently installed on a device. This will return an array ofDeviceIOSProfileobjects. -
device.managed_appsreturns all managed applications installed on a device. This will return an array ofDeviceManagedAppobjects. -
device.install_app(app)takes in aTenantManagedAppobject, and will install the given application on the device. Returns anActionobject, for tracking in the future. -
device.uninstall_app(app)takes in aDeviceManagedAppobject, and will uninstall the given application on the device. Returns anActionobject, for tracking in the future. Note that this must be done on a managed app. -
device.add_profile(profile)takes in anTenantIOSProfileobject, and will install the given profile on the device. Returns anActionobject, for tracking in the future. -
device.remove_profile(profile)take in anDeviceIOSProfileobject, and will remove the given profile from the device. Returns anActionobject, for tracking in the future. -
device.get_action(action_id)will take in anidfrom anActionobject, and return an updatedActionobject. -
device.pre_enrollwill send the serial number,client_id, andtokenfrom the device for pre-enrollment, and will returntrueif successful. Ifclient_idortokenare 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