Code Monkey home page Code Monkey logo

layer-ruby's Introduction

Ruby Client for Layer

Build Status Gem Version Yard Docs

Ruby client for the Layer Platform API and Layer Client REST API.

Installation

Add this line to your application's Gemfile:

gem 'layer-ruby', require: 'layer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install layer-ruby

Usage

Please refer to the Layer Platform API documentation and Layer Client REST API documentation for details about the required payloads and responses.

Configuration

To use the Layer Platform API, you need your Layer APP ID as well as a Layer Platform API Token. The gem reads both values from the LAYER_APP_ID and LAYER_PLATFORM_TOKEN environment variables. Alternatively you can specify the values by configuring the Layer::Client like this:

Layer::Client.configure do |config|
  config.app_id = 'YOUR_APP_ID_HERE'
  config.token = 'YOUR_PLATFORM_TOKEN_HERE'
end

Using the gem with multiple applications at once

It's possible to create a new instance of Layer::Client::Platform and passing both the app id and the token to the initializer:

platform_client = Layer::Client::Platform.new('YOUR_APP_ID_HERE', 'YOUR_PLATFORM_TOKEN_HERE')

The client will not use any global configuration. You can pass the client as a second parameter to any operations (create, find) described above.

Using the Layer Client REST API

To use the Layer Client REST API, you need a way to generate identitiy tokens. You might want to use the layer-identity_token gem for that. Using this gem, you can create a new client using the REST API like this:

client = Layer::Client.authenticate { |nonce| Layer::IdentityToken.new('user_id_here', nonce) }

Afterwards, pass the client as an additional argument to the resource's methods:

# Finds all conversations of the authenticated user
Layer::Conversation.all(client)

Documentation

Please refer to the full documentation for details on how to use Announcements, Block Lists, Conversations, Messages, Rich Content, and WebHooks.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/benedikt/layer-ruby. 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.

Related Work

Check out the layer-identity_token gem to generate authentication tokens for the Layer SDK.

layer-ruby's People

Contributors

benedikt avatar curbsaleem avatar we5 avatar wiseleyb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.