Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby library for interacting with Livechat's REST API
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
Gemfile
Gemfile.lock
LICENSE
README.md

README.md

Livechat

A Ruby library for interacting with the Livechat REST API. It is heavily inspired by the Squall library written for the OnApp API (https://github.com/site5/squall).

Status:

Finished (with tests): None :(

Finished (need tests): operators, visitors, reports, status

Half Implemented: chats (needs pagination ability)

Not Implemented: skills, goals, skills, tracking_code, button_code

Configure:

    require 'livechat'

    Livechat.config do |c|
      c.base_uri 'https://api.livechatinc.com'
      c.username 'username@domain.com'
      c.password 'yourapikey'
    end

Livechat can load configuration from a yaml file:

    # .livechat.yml
    base_uri 'https://api.livechatinc.com'
    username 'username@domain.com'
    password 'yourapikey'

To load it (by default it assumes ~/.livechat.yml):

    Livechat.config_file(/[path]/[to]/.livechat.yml)

Usage:

Show current status:

    status = Livechat::Status.new
    pp status.show

Create a new operator:

    operator = Livechat::Operators.new
    operator.create(:login => 'operatoremail@domain.com', :password => 'password')

Show specific operator info:

    operator = Livechat::Operators.new
    pp operator.show(1093)

Update operator info (and change their current status):

    operator = Livechat::Operators.new
    operator.update(1093, :display_name => 'Graham', :name => 'Graham McMillan', :status => 'away')

List current visitors/chats:

    visitors = Livechat::Visitors.new
    pp visitors.list

Show only the visitors who are chatting with operators:

    visitors = Livechat::Visitors.new
    pp visitors.list(:only_chatting)

Responses

If the call you are making only returns a single item, a single hash will be returned:

operators = Livechat::Operators.new
pp operators.show(998)

{:id=>"998",
 :login=>"jdoe@domain.com",
 :name=>"John Doe",
 :display_name=>"John D.",
 :permission=>"normal",
 :status=>"offline",
 :email=>"jdoe@domain.com",
 :timezone=>"US/Eastern"}

For calls that return more than one element, you will receive an array of hashes for each element:

operators = Livechat::Operators.new
pp operators.list

[{:id=>"998",
 :login=>"jdoe@domain.com",
 :name=>"John doe",
 :display_name=>"John D.",
 :permission=>"normal",
 :status=>"offline"},
{:id=>"999",
 :login=>"tdurden@domain.com",
 :name=>"Tyler Durden",
 :display_name=>"Tyler D.",
 :permission=>"administrator",
 :status=>"online"}]

The one exception to the above is when fetching the status, which will simply return a string ("offline" or "online")

status = Livechat::Status.new
pp status.show

To enable HTTParty's debug mode:

Livechat::Base.debug_output

Known issues:

  1. Very early release -- no tests, so expect brokenness and changes.

Copyright

Copyright 2012 Graham McMillan. See LICENSE for details.

I have no affiliation with the company that creates Live Chat (http://www.livechatinc.com). All applicable trademarks and copyrights belong to them.

Something went wrong with that request. Please try again.