The KnuVerse Knufactor SDK for Ruby
About
This project is a Ruby SDK that allows developers to create apps that use Knuverse's Knufactor Cloud APIs.
Documentation for the API can be found here
Full documentation for this SDK can be found here
Note that this SDK isn't a direct port of the Python SDK, though it is based heavily on the work done there. This SDK uses a Object-Oriented pattern, which is likely more familiar to Ruby developers than a collection of functions may be.
Building and Installing
Building the gem requires a modern Ruby:
# highly recommend using RVM here, and Ruby 2.x or above
gem build knuverse-knufactor.gemspec
# install what you just built
gem install knuverse-knufactor-*.gem
That said, recent releases should be available on rubygems.org so building is probably not necessary.
Just add the following to your Gemfile:
gem 'knuverse/knufactor'
Then run:
bundle install
If you're not using bundler for some reason (shame on you!), you can manually install like so:
gem install knuverse-knufactor
If you see a message like this:
Thanks for installing the KnuVerse Knufactor Ruby SDK!
You should be all set!
Usage
Check back, because this file will be updated with a lot more usage examples.
For a typical custom ruby application, you'll need to do something like the following to get started:
require 'knuverse/knufactor'
KnuVerse::Knufactor::APIClient.configure(
apikey: 'b1b71d68cffea1d43257fff9deadbeef',
secret: '34d04e5f05a194444e9c26358a94eaf2'
)
From here, the SDK will automatically rely on this configuration singleton unless you tell it otherwise. Here are some examples of interacting with the API:
KnuVerse::Knufactor::APIClient.about_service
include KnuVerse::Knufactor::Resources
clients = Client.all
client = clients.last
client.name
client.bypass_limit = 10
client.save
client.reload
client.bypass_limit
locked_clients = Client.where(:password_lock?, true)
happy_clients = Client.where(:state, 'enrolled').or(:state, 'installed')
z_clients = Client.where(:name, /^z/i)
For some more complex situations, you may want a specialized API Client (interact with it as an instance, or have a thread-local or context-specific client):
api_client = KnuVerse::Knufactor::APIClient.instance
local_api_client1 = KnuVerse::Knufactor::SimpleAPIClient.new(
apikey: 'b1b71d68cffea1d43257fff9deadbeef', secret: '57838344acf7f5876226ede247c5881a'
)
local_api_client2 = KnuVerse::Knufactor::SimpleAPIClient.new(
apikey: '33371d68cffea1d43257fff9deadf00d', secret: 'e7d1c88825dc96a05bc38c39cca4a1ca'
)
local_api_client1 == local_api_client2
Client.all(api_client: local_api_client1)
Client.where(:name, 'bobby', api_client: local_api_client2)
License
This project and all code contained within it are released under the MIT License. As stated in CONTRIBUTING:
All contributions to this project will be released under the MIT License. By submitting a pull request, you are agreeing to comply with this license and for any contributions to be released under it.