RongCloud Server API SDK in Ruby
This repository implements most essential apis for RongCloud Server API in Ruby programming language.
Getting Started
- Install the gem:
$ gem install rong_cloud_server
or, install it in Gemfile:
gem 'rong_cloud_server'
- Append the following configurations in a initializer file:
require 'rong_cloud'
RongCloud.configure do |config|
config.app_key = "APP_KEY"
config.app_secret = "SECRET_KEY"
# config.host = "http://api.cn.ronghub.com" # default: https://api.cn.ronghub.com, use http here is just convenient for debugging
# config.timeout = 10 # set open timeout and read timeout in seconds for http request, default is 2 seconds
# config.debug_mode = true # if need to log request and response details, the log file is at "log/rong_cloud_debug.log", default is `false`
end
- Use the instance of
RongCloud::Service
to talk to RongCloud Server:
service = RongCloud::Service.new
# Find more usage from test files under https://github.com/Martin91/rong_cloud/tree/master/test/rong_cloud/services
service.get_token(..., ..., ...)
Features
- Lightweight:No other third-party gems dependences;
- Straight and Simple:Just wrap api connections in Ruby, no any DSL and so that you do not learn too many new syntax, no any process on response;
- Detailed Exceptions:Detailed and different exceptions according to the http status code,and you can get the detailed error code, officially defined by RongCloud, through calling the extended method
business_code
on a exception, please refer to request test.
How to work with Realtime Message Forward or Online Status Subscription
Just include RongCloud::Signature
in your codes to validate api signature and then parse params.
More infos about parameters, refer to the official documents.
Run tests
ruby -Ilib -Itest -e 'ARGV.each { |f| require f }' ./test/**/*_test.rb
How to contribute
- Fork this repo;
- Write your code and test;
- Open a new Pull Request.