A Crystal library to easily communicate with the ejabberd admin API.
It implements all ejabberd rest api reference.
This library is small and simple, it can be read and understood in no more than 10 minutes.
Add this to your application's shard.yml
:
dependencies:
ejabberd:
github: kndt/ejabberd.cr
require "ejabberd"
# ejabberd = Ejabberd.new "api_url"
ejabberd = Ejabberd.new "http://127.0.0.1:5280"
This library implements same method names as the ejabberd rest api reference and take same value types as the api reference.
For example add_rosteritem in the api reference like the following:
POST /api/add_rosteritem
{
"localuser": "user1",
"localserver": "myserver.com",
"user": "user2",
"server": "myserver.com",
"nick": "User 2",
"group": "Friends",
"subs": "both"
}
HTTP/1.1 200 OK
""
With this library the above becomes the following:
ejabberd.add_rosteritem("user1", "myserver.com", "user2", "myserver.com", "User 2", "Friends", "both")
You can also add the argument names like the following:
ejabberd.add_rosteritem(localuser: "user1", localserver: "myserver.com", user: "user2", server: "myserver.com", nick: "User 2", group: "Friends", subs: "both")
Each method return an HTTP::Client::Response
instance, so you can any call methods like body
or status_code
on it.
The library resides on the stack which makes it fast and cheap due to to no allocation on the heap.
This project requires a locally running ejabberd server running with http api set in ejabberd.yml file. The test specs are currently in implementation.
- Fork it ( https://github.com/kndt/ejabberd.cr/ )
- 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
- Bug reports and pull requests are welcome on GitHub at kndt - creator, maintainer