LiveChat API Ruby Client
Install
Via rubygems.org:
$ gem install livechat_client
To build and install the development branch yourself from the latest source:
$ git clone git@github.com:cxz/livechat_client.git
$ cd livechat_client
$ git checkout -b develop
$ rake gem
$ gem install pkg/livechat_client-{version}
Connection
Basic Auth over HTTPS is used to authenticate API requests.
require "livechat"
@livechat = LiveChat::REST::Client.new do |config|
config[:login] = "joe@example.com"
config[:api_key] = ""
endList all agents
@livechat.agents.list # all agents
@livechat.agents.each {|a| ..code.. } # iterate over requested agentsGet a single agent details
@livechat.agents('john.doe@mycompany.com')Create a new agent
@livechat.agents.create do |a|
a[:login] = @alice_id
a[:name] = 'Alice'
endUpdate an agent
@livechat.agents(@jane_id).update do |a|
a[:job_title] = 'Tester'
a[:status] = 'not accepting chats'
endReset an API key
@livechat.agents('john.doe@mycompany.com').reset_api_keyRemove an agent
@livechat.agents('john.doe@mycompany.com').deleteList all canned responses
@livechat.canned_responses.listGet a single canned response
@livechat.canned_responses(3151)Create a new canned response
@livechat.canned_responses.create do |r|
r[:text] = 'Have a great day, goodbye.'
r[:tags] = ['cu', 'bye']
endUpdate a canned response
@livechat.canned_responses(3151).update do |r|
r[:tags] = ['bye']
endRemove a canned response
@livechat.canned_responses(3151).deleteGet list of chats
@livechat.chats.listGet single chat
@livechat.chats('MH022RD0K5')Send chat transcript to e-mail
@livechat.chats('MH022RD0K5').send_transcript(:to => 'john.doe@mycompany.com')List all goals
@livechat.goals.listGet a single goal details
@livechat.goals(1181)Mark goal as successful
@livechat.goals(1181).mark_as_successful(:visitor_id => 1)Add a new goal
@livechat.goals.create do |goal|
goal[:name] = 'new goal'
goal[:type] = 'url'
endUpdate a goal
@livechat.goals(2231).update do |goal|
goal[:name] = 'updated goal'
endRemove a goal
@livechat.goals(2231).deleteList all groups
@livechat.groups.listGet a single group details
@livechat.groups(2)Create a new group
@livechat.groups.create do |goal|
group[:name] = 'Human Resources'
group[:agents] = ['jenny.doe@mycompany.com', 'john.doe@mycompany.com']
endUpdate a group
@livechat.groups(3).update do |goal|
group[:name] = 'Quality Assurance'
group[:agents] = ['jane.doe@mycompany.com']
endRemove a group
@livechat.groups(4).deleteGet dashboard data
@livechat.reports.dashboardGet dashboard data for agent
@livechat.reports.dashboard(:agent => 'john.doe@mycompany.com')Get dashboard data for group
@livechat.reports.dashboard(:group => 1)Get chats report
@livechat.reports.chats(:date_from => '2013-01-01')Get ratings report
@livechat.reports.ratings(:group => 1)Get ratings ranking
@livechat.reports.ratings_ranking(:group => 1)Get queued visitors report
@livechat.reports.queued_visitors(:date_from => '2013-01-01')Get queue waiting times report
@livechat.reports.queued_visitors_waiting_times(:date_from => '2013-01-01')Get availability report
@livechat.reports.availabilityGet chatting time report
@livechat.reports.chatting_timeGet goals report
@livechat.reports.goalsGet status
@livechat.status(:group => 0)List all visitors
@livechat.visitors.listList only chatting visitors
@livechat.visitors.chattingAdd custom visitor details
@livechat.visitors('S1352647457.ac951bfe2e').add_details do |detail|
detail[:license_id] = '12345'
detail[:token] = '26132406c42c96ba61ed42689b70f719'
detail[:id] = 'my-app'
detail[:fields] = [{:name => 'Age', :value => 36}]
endContributing
Ways you can help:
- report bugs
- writing/fixing documentation
- writing code (refactoring, strengthening areas that are weak, catching typos)
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so we don't break it in a future version unintentionally.
- Commit
- Send a pull request. Bonus points for topic branches.
MIT License
Copyright (c) 2013 Alexandre Maia
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.