ZQuickblox Gem Version Build Status

This gem is a Quickblox API client in Ruby. Normally, we will use Javascript or mobile SDK, but in some cases where server needs to control things, this gem will play its role.

Currently this gem ONLY supports creating users on Quickblox (used for signing up user) and creating / updating chat dialog (used for backend's need).

Installation

Add this line to your application's Gemfile:

gem 'zquickblox'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zquickblox

Config

Rails

You need to generate an initializer for ZQuickblox in order to config your Quickblox app:

rails generate zquickblox

Others

You need to config your Quickblox as below:

ZQuickblox.configure do |config|
  config.app_id      = ENV['QB_APP_ID']
  config.auth_key    = ENV['QB_AUTH_KEY']
  config.auth_secret = ENV['QB_AUTH_SECRET']
end

Usage

To create a new user, just call:

ZQuickblox::User.create({email: "[email protected]", password: "a_password"})

There are more params for you to set:

login, password, email, blob_id, external_user_id, facebook_id, twitter_id, full_name, phone, website

To get a user by his login, just call:

ZQuickblox::User.find("[email protected]")

The result will be nil if the user doesn't exist.

To create a new dialog, just call:

ZQuickblox::Dialog.create("user_login", "user_password", {type: 2, name: "Some dialog", occupants_ids: "ids of occupants separated by ,"})

To update a dialog (name, photo, occupants_ids), just call:

ZQuickblox::Dialog.update("user_login", "user_password", "dialog id", {name: "Some dialog", occupants_ids: "ids of occupants separated by ,"})

Error handling

During the API processing, errors may occur. In such cases, ZQuickblox::Error (subclass of StandardError) will be thrown with messages as an array of string error messages.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/zelic91/zquickblox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.