Project

zquickblox

0.01
No commit activity in last 3 years
No release in over 3 years
A simple API client for Quickblox in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
>= 3.0.0
~> 10.0

Runtime

>= 0.9.2
>= 1.8.3
 Project Readme

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: "abc@email.com", 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("abc@email.com")

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

To delete user, call:

ZQuickblox::User.delete("user_login", "user_password", "user_id")

The result will be {} if the account is deletable.

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.