This is a ruby library for InstaMsg Rest api.
Add instamsg-ruby to your Gemfile, and then run bundle install
gem 'instamsg-ruby'
or install via gem
gem install instamsg-ruby
After registering at https://platform.instamsg.io/signup configure your app with the security credentials. You can find instamsg starting quick guide here. (http://instamsg.io/docs/quick-start)
For add instamsg in your app add require 'instamsg'
in your controller or helper.
instamsg = Instamsg::Client.new({ :host => 'platform.instamsg.io', :port => 443, :bearer_token => "gt0AF51x7wxHFUNX44FPYCWPRhU5icDrPKA02GKR22jwt6jkrnTC3TZbTjs", :key=> '5cf46a16-cde6-4ece-9005-0c6f26fa71a0', :secret=> '468a08a5-5e18-4aa6-8692-c367bcbf3944' })
Where key and secret is your registerd app key and secret. For getting bearer(access) token you have to authenticate first. This client have all the functionality provided by InstaMsg api.
create an Instamsg account and follow these steps to get your client_id
& client_auth_token
.
Currently we are supporting only one grant type. Path for getting your bearer token "oauth2/token" and grant_type is "client_credentials"
instamsg.authenticate(path,params)
Example :
Request is :
instamsg.authenticate("/oauth2/token",{:grant_type => "client_credentials"})
Response is :
{ "access_token": "gt0AF51x7wxHFUNX44FPYCWPRhU5icDrPKA02GKR22jwt6jkrnTC3TZbTjs", "token_type": "bearer", "expires_in": 31536000000 }
You can get, post, put and delete your resources. We are supporting sync and async request both.
instamsg.get(path,params)
instamsg.post(path,params)
instamsg.put(path,params)
instamsg.delete(path,params)
instamsg.get_async(path,params)
instamsg.post_async(path,params)
instamsg.put_async(path,params)
For detailed InstaMsg Rest api methods you can visit. (http://instamsg.io/docs/api)
You can get files list from a connected client. You can upload and download files to a connected client. <\br> File operations are sync operations.
Download all file
instamsg.get("/api/beta/tenants/tenant_id/clients/client_id}/files", params)
Upload a file
instamsg.put_file("/api/beta/tenants/tenant_id/clients/client_id}/files", {:file => file_path})
Download a file
instamsg.get_file("/api/beta/tenants/tenant_id/clients/client_id}/files/file_name", params)
This gives you a hhttp file url in response. And then you can download this file from that url.
You can find all client api methods here. (http://instamsg.io/docs/client)
begin
instamsg.get(path,params)
rescue Instamsg::Error => e
(Instamsg::AuthenticationError, Instamsg::HTTPError, or Instamsg::Error)
end