Rhosync_api
With this gem you can connect to the rhosync API very easy.
INTALLATION
gem install rhosync_api
HOW TO
require “rubygems” require “rhosync_api”
RhosyncApi.“method”
METHODS
- login
- logout
- get_api_token
- get_license_info
- reset
- ping
- list_users
- create_user
- delete_user
- list_clients
- create_client
- delete_client
- get_client_params
- list_sources
- get_source_params
- list_source_docs
- get_db_doc
- set_db_doc
- list_client_docs
- get_db_doc_by_type
- set_db_doc_by_type
LOGIN
this method is used to authenticate with rhosync server
RhosyncApi.login("http://localhost:3000","rhoadmin","")
params:
- RHOSYNC URL
- USERNAME
- PASSWORD
return:
this method will return a token is the authentication is correct
this method will return nil if the authentication is incorrect
LOGOUT
This method set token variable to nil
RhosyncApi.logout
GET_API_TOKEN
RhosyncApi.get_api_token
return:
this method returns the rhosync token, with this token you can authenticate to rhosync
GET_LICENSE_INFO
RhosyncApi.get_license_info
return:
this method returns all the information about the rhosync license
RESET
RhosyncApi.reset
this method will reset all the redis information in rhosync
PING
this method is used to send alerts to devices using rhosync settings
RhosyncApi.ping(user_id,ping_params)
params
- USER_ID
the rhosync user id
- PING_PARAMS
ping_params => { :message => "this is a test", :sound=>"hello.mp3" }
# :message - message which will be used to display notification popup dialog on the device
# :badge - iphone specific badge
# :sound - name of the sound file to play upon receiving PUSH notification
# :vibrate - number of seconds to vibrate upon receiving PUSH notification
# :sources - list of data source names to be synced upon receiving PUSH notification
LIST_USERS
RhosyncApi.list_users
return:
this method returns an ARRAY of users ID.
CREATE_USER
with this method you can create a new user in rhosync
RhosyncApi.create_user("username","password")
params:
- USERNAME
- PASSWORD
return:
this method will return nil if it fails
DELETE_USER
with this method you can delete an existing user in rhosync
RhosyncApi.delete_user("user_id")
params:
- USERID
return:
this method will return nil if it fails
LIST_CLIENTS
this method returns a list of devices for a given user ID
RhosyncApi.list_clients("user_id")
params:
- USERID
return:
this method will return nil if it fails
CREATE_CLIENT
this method create a device for a given user ID
RhosyncApi.create_client("user_id")
params:
- USERID
return:
this method will return nil if it fails
DELETE_CLIENT
this method deletes a device for a given user ID and device ID
RhosyncApi.delete_client("user_id","device_id")
params:
- USERID
- DEVICE_ID
return:
this method will return nil if it fails
GET_CLIENT_PARAMS
this method returns the attributes of a given device ID, such as device_type, device_pin, device_port.
RhosyncApi.get_client_params("device_id")
params:
- DEVICE_ID
return:
this method will return nil if it fails
LIST_SOURCES
this method returns a list rhosync source adapters for a given partition
RhosyncApi.list_sources("partition")
RhosyncApi.list_sources
params:
- PARTITION : this could be "user" or "app" by default if use "user" partition
return:
this method will return nil if it fails
GET_SOURCE_PARAMS
this method returns the attributes of a given source adapter
such as name, poll_interval, partition_type, sync_type, queue, query_queue, cud_queue
RhosyncApi.get_source_params("source name")
params:
- SOURCE NAME
return:
this method will return nil if it fails
LIST_SOURCE_DOCS
this method returns a list of document keys associated with given source and user.
such as md, md_size, md_copy, errors
RhosyncApi.list_source_docs("user_id","source_name")
params:
- USER ID
- SOURCE NAME
return:
this method will return nil if it fails
GET_DB_DOC
this method returns the content of a given document key.
RhosyncApi.get_db_doc("document key","data_type")
RhosyncApi.get_db_doc("document key")
params:
- DOCUMENT KEY : this is the document key listed in the LIST_SOURCE_DOCS method
- DATA TYPE: could be "string" or nil
return:
this method will return nil if it fails
SET_DB_DOC
this method set content of a given document key
RhosyncApi.set_db_doc("document key","data","data_type")
RhosyncApi.set_db_doc("document key","data")
params:
- DOCUMENT KEY : this is the document key listed in the LIST_SOURCE_DOCS method
- DATA : Data should be either a string or hash of hashes.
- DATA TYPE: could be type "string" or nil
return:
this method will return nil if it fails
LIST_CLIENT_DOC
this method returns a list of document keys associated with particular device.
RhosyncApi.list_client_docs("device_id","source_name")
params:
- DEVICE_ID :
- SOURCE NAME:
return:
this method will return nil if it fails
GET_DB_DOC_BY_TYPE
this method returns the content of a given document user and source name.
RhosyncApi.get_db_doc("user_id","source_name","type_doc")
params:
- USER ID :
- SOURCE NAME:
- TYPE DOC : such as md, md_size, md_copy, errors
return:
this method will return nil if it fails
SET_DB_DOC_BY_TYPE
this method set content of a given user id and source name
RhosyncApi.set_db_doc_by_type("user_id","source_name","data","type_doc")
params:
- USER ID :
- SOURCE NAME:
- DATA : Data should be a hash of hashes.
- TYPE DOC : such as md, md_size, md_copy, errors
return:
this method will return nil if it fails
- set_db_doc_by_type