Project

tenios

0.0
Low commit activity in last 3 years
No release in over a year
A ruby wrapper for Tenios Call Control API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13
~> 3
 Project Readme

Tenios

Wraps Tenios Call Control blocks in ruby. Each accepted block has a corresponding object under Tenios::Blocks, currently these are:

  • Tenios::Blocks::Announcement
  • Tenios::Blocks::Bridge
  • Tenios::Blocks::CollectDigits
  • Tenios::Blocks::CollectSpeech
  • Tenios::Blocks::HangUp
  • Tenios::Blocks::RoutingPlan
  • Tenios::Blocks::Say

Each of these can be used as part of a Tenios::Blocks object, by using Tenios::Blocks#add.

Tenios::Blocks implements #as_json which returns a JSON-like hash (although with symbolised keys).

In rails you can pass the Tenios::Blocks object directly to render under the json: key.

require 'tenios'

class TeniosController < ApplicationController
  def redirect_to_number
    blocks = Tenios.blocks do |block|
      block.announce(announcement: 'redirect', standard: false)
      block.bridge(mode: Tenios::Blocks::Bridge::SEQUENTIAL) do |bridge|
        bridge.with_destination(Tenios::Blocks::Bridge::EXTERNAL_NUMBER, '+440123456789', 10)
      end
    end

    render json: blocks
  end
end

Else you can use any JSON serializer that can deal with a ruby Hash

require 'json'
require 'tenios'

announcement = Tenios::Blocks::Announcement.new(announcement: 'redirect', standard: false)
bridge =
  Tenios::Blocks::Bridge
  .new(mode: Tenios::Blocks::Bridge::SEQUENTIAL)
  .with_destination(Tenios::Blocks::Bridge::EXTERNAL_NUMBER, '+440123456789', 10)

Tenios::Blocks.new
.add(announcement)
.add(bridge)
.as_json
.yield_self { |hash| JSON.generate(hash) }

Installation

Add this line to your application's Gemfile:

gem 'tenios'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tenios

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/carwow/tenios-ruby.

License

The gem is available as open source under the terms of the MIT License.