Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 15 commits
  • 16 files changed
  • 0 commit comments
  • 5 contributors
View
1  .gitignore
@@ -15,3 +15,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
+.rvmrc
View
4 README.md
@@ -5,7 +5,9 @@ The supportbee.com CLI gem
=======
# Supportbee
-TODO: Write a gem description
+Its command line interface for - http://supportbee.com/
+
+Checkout API as here - http://developer.supportbee.com/
## Installation
View
4 Rakefile
@@ -4,6 +4,10 @@ require "bundler/gem_tasks"
require 'rake'
require 'rake/testtask'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new('spec')
+task :default => :spec
+
Rake::TestTask.new do |t|
t.pattern = 'spec/**/*_spec.rb'
end
View
52 bin/supportbee
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+
+lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
+
+require 'optparse'
+require 'supportbee'
+
+# This hash will hold all of the options
+# parsed from the command-line by
+# OptionParser.
+options = {}
+
+optparse = OptionParser.new do|opts|
+ # Set a banner, displayed at the top
+ # of the help screen.
+ opts.banner = "Usage: supportbee [object] [options] "
+
+ # Define the options, and what they do
+ options[:verbose] = false
+ opts.on( '-v', '--verbose', 'Output more information' ) do
+ options[:verbose] = true
+ end
+
+ options[:logfile] = nil
+ opts.on( '-l', '--logfile FILE', 'Write log to FILE' ) do|file|
+ options[:logfile] = file
+ end
+
+ # This displays the help screen, all programs are
+ # assumed to have this option.
+ opts.on( '-h', '--help', 'Display this screen' ) do
+ puts opts
+ exit
+ end
+end
+
+# Parse the command-line. Remember there are two forms
+# of the parse method. The 'parse' method simply parses
+# ARGV, while the 'parse!' method parses ARGV and removes
+# any options found there, as well as any parameters for
+# the options. What's left is the list of files to resize.
+optparse.parse!
+
+begin
+ cmd = ARGV.shift.strip
+rescue NoMethodError
+ puts optparse
+end
+
+Supportbee::Base.call(cmd, options) if cmd and !cmd.include?('-')
+
View
32 lib/supportbee.rb
@@ -1,12 +1,22 @@
require "supportbee/version"
+require "supportbee/auth"
+require "supportbee/tickets"
require 'httparty'
require 'json'
+require 'supportbee/ticket'
+require 'supportbee/agent'
+require 'supportbee/label'
module Supportbee
class Base
include HTTParty
+ include Supportbee::Ticket
+ include Supportbee::Agent
+ include Supportbee::Label
+ include Supportbee::Auth
- def initialize(company, auth_token)
+ def initialize
+ company, auth_token = authenticate
self.class.base_uri "https://#{company}.supportbee.com"
self.class.default_params :auth_token => auth_token
end
@@ -17,12 +27,20 @@ def tickets(options={})
raise "Invalid Options: #{invalid_keys.join(', ')}" unless invalid_keys.empty?
- self.class.default_params.merge!(options)
-
- response = self.class.get("/tickets.json")
- result = JSON.parse(response.body)
- result['tickets'].map do |ticket|
- {ticket['id'] => ticket['subject']}
+ #
+ # this method will receive command line methods and
+ # options and will pass it on accordingly
+ def self.call(cmd, options)
+ self.new.send(cmd, options)
+ end
+
+ #It's takes ticket,agent,label get as parameter and call appropriate module
+ #TODO need to finalize parameters
+ def self.run cmd
+ supportbee = Supportbee::Base.new("josh", "4rP9QFdmxNUyyK-saK7H")
+
+ if cmd == "tickets"
+ supportbee.tickets
end
end
end
View
5 lib/supportbee/agent.rb
@@ -0,0 +1,5 @@
+module Supportbee
+ module Agent
+
+ end
+end
View
0  lib/supportbee/attachments.rb
No changes.
View
15 lib/supportbee/auth.rb
@@ -0,0 +1,15 @@
+module Supportbee
+ module Auth
+ def self.authenticate
+ p 'Please enter Company Name : '
+ company_name = gets.chomp
+ p 'Please enter Authentication Token :'
+ token = gets.chomp
+ puts %x[mkdir ~/.supportbee] if !File.exists?(File.expand_path('~/.supportbee'))
+ f = File.new(File.expand_path("~/.supportbee/credentials"), 'w')
+ f.write("company: #{company_name}")
+ f.write("token:#{token}")
+ [ company_name, token]
+ end
+ end
+end
View
5 lib/supportbee/label.rb
@@ -0,0 +1,5 @@
+module Supportbee
+ module Label
+
+ end
+end
View
0  lib/supportbee/lables.rb
No changes.
View
0  lib/supportbee/snippets.rb
No changes.
View
18 lib/supportbee/ticket.rb
@@ -0,0 +1,18 @@
+ module Supportbee
+ module Ticket
+ def tickets(options={})
+ valid_keys = [:per_page, :page, :spam, :trash, :replies, :max_replies, :assigned_user, :assigned_group, :starred, :label, :since, :until]
+ invalid_keys = options.keys - valid_keys
+
+ raise "Invalid Options: #{invalid_keys.join(', ')}" unless invalid_keys.empty?
+
+ self.class.default_params.merge!(options)
+
+ response = self.class.get("/tickets.json")
+ result = JSON.parse(response.body)
+ result['tickets'].map do |ticket|
+ {ticket['id'] => ticket['subject']}
+ end
+ end
+ end
+ end
View
15 lib/supportbee/tickets.rb
@@ -0,0 +1,15 @@
+
+class Supportbee::Base
+ class Tickets
+
+ class << self
+ # TODO : to be implemented
+ # start removing this method first.
+ def method_missing(method, argv)
+ puts 'Not Implemented yet.'
+ end
+ end
+
+ end
+
+end
View
0  lib/supportbee/users.rb
No changes.
View
0  lib/supportbee/webhooks.rb
No changes.
View
9 supportbee.rb
@@ -0,0 +1,9 @@
+#! /usr/bin/env ruby
+
+lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
+
+require 'supportbee'
+
+Supportbee::Base.run 'tickets'
+

No commit comments for this range

Something went wrong with that request. Please try again.