Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oksky-chat-api

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oksky-chat-api

  • 0.2.9
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Gem Version

Oksky::Chat::Api

About the OK SKY CHAT API

See the official API reference documentation for more information.

https://support.ok-sky.com

Installation

Add this line to your application's Gemfile:

gem 'oksky-chat-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install oksky-chat-api

Usage

# app.rb
require 'sinatra'
require 'oksky/chat'

def webhook_client
  @webhook_client ||= Oksky::Chat::WhClient.new
end

post '/callback' do
  body = request.body.read

  event = webhook_client.parse_events_from(body)
  case event
    when Oksky::Chat::Event::Message
      client = Oksky::Chat::Client.new { |config| 
        config.access_token = EVN['OKSKY_CHAT_ACCESS_TOKEN']
        config.endpoint = EVN['OKSKY_CHAT_ENDPOINT']
      }
      result = client.find("messages", event["id"], {}, false)
      p JSON.parse(result.body) if !result.nil? && result.kind_of?(Net::HTTPResponse) && !result.body.blank?
  end
 
  "OK"
end
GET Resource Object
client = Oksky::Chat::Client.new(
  access_token: "38d9b3ed60587820840857dfdf14561b", 
  endpoint: "http://127.0.0.1:3000/rapi/v1"
)
client.find("messages", 1) #=> Oksky::Chat::Object::MessagesResource
GET Resource Objects
client = Oksky::Chat::Client.new(
  access_token: "38d9b3ed60587820840857dfdf14561b", 
  endpoint: "http://127.0.0.1:3000/rapi/v1"
)
client.where("messages", {"filter[room_id]": 1}) #=> Array Oksky::Chat::Object::MessagesResource
CREATE Resource Object
client = Oksky::Chat::Client.new(
  access_token: "38d9b3ed60587820840857dfdf14561b", 
  endpoint: "http://127.0.0.1:3000/rapi/v1"
)
client.create("messages", {"data"=>{"type"=>"messages", "attributes"=>{"content"=>"test0001", "kind"=>"text", "settings"=>{}, "status"=>"", "info"=>"", "tags"=>[]}, "relationships"=>{"room"=>{"data"=>{"type"=>"rooms", "id"=>"369249"}}}}})
EDIT Resource Object
client = Oksky::Chat::Client.new(
  access_token: "38d9b3ed60587820840857dfdf14561b", 
  endpoint: "http://127.0.0.1:3000/rapi/v1"
)
client.edit("messages", 1, {"data"=>{"type"=>"messages", "attributes"=>{"content"=>"test0001", "kind"=>"text", "settings"=>{}, "status"=>"", "info"=>"", "tags"=>[]}, "relationships"=>{"room"=>{"data"=>{"type"=>"rooms", "id"=>"369249"}}}}})

License

Copyright (C) 2017 SOLAIRO, INC.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

FAQs

Package last updated on 11 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc