aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2014-06-08 11:37:36 -0400
committerTeddy Wing2014-06-08 11:37:36 -0400
commitf1a17c22776c6affd5fd48d5dd519510f5907431 (patch)
treed450e82ef30b4ec8e4ad578b7081256b8c715cec
parent1e1b10e6da171d2f72d910a3af043794b632ae64 (diff)
parent8806e3a676d2fbe1397b0079318ca279851e476e (diff)
downloadsellevate-f1a17c22776c6affd5fd48d5dd519510f5907431.tar.bz2
Merge branch 'feature/contextio-messages' into develop
-rw-r--r--app.rb7
-rw-r--r--fancy_bear/contextio.rb2
-rw-r--r--fancy_bear/contextio/auth.rb6
-rw-r--r--fancy_bear/contextio/base.rb13
-rw-r--r--fancy_bear/contextio/label.rb37
5 files changed, 60 insertions, 5 deletions
diff --git a/app.rb b/app.rb
index 3564523..4101e10 100644
--- a/app.rb
+++ b/app.rb
@@ -29,4 +29,11 @@ class App < Sinatra::Base
get '/auth-callback' do
erb :auth_callback
end
+
+ get '/initialise-labels' do
+ contextio = FancyBear::ContextIO::Label.new('sellevate.hack@gmail.com')
+ contextio.create_defaults
+
+ redirect to('/')
+ end
end
diff --git a/fancy_bear/contextio.rb b/fancy_bear/contextio.rb
index 88fc988..a7198e1 100644
--- a/fancy_bear/contextio.rb
+++ b/fancy_bear/contextio.rb
@@ -1,5 +1,7 @@
require_relative 'contextio/config'
+require_relative 'contextio/base'
require_relative 'contextio/auth'
+require_relative 'contextio/label'
module FancyBear
module ContextIO
diff --git a/fancy_bear/contextio/auth.rb b/fancy_bear/contextio/auth.rb
index 174648a..1288b6d 100644
--- a/fancy_bear/contextio/auth.rb
+++ b/fancy_bear/contextio/auth.rb
@@ -3,11 +3,7 @@ require 'contextio'
module FancyBear
module ContextIO
- class Auth
- def initialize
- @contextio = ::ContextIO.new(API_KEY, API_SECRET)
- end
-
+ class Auth < Base
def connect(callback_url)
connection_token = @contextio.connect_tokens.create(callback_url)
connection_token.browser_redirect_url
diff --git a/fancy_bear/contextio/base.rb b/fancy_bear/contextio/base.rb
new file mode 100644
index 0000000..84473d1
--- /dev/null
+++ b/fancy_bear/contextio/base.rb
@@ -0,0 +1,13 @@
+require 'contextio'
+
+module FancyBear
+ module ContextIO
+
+ class Base
+ def initialize
+ @contextio = ::ContextIO.new(API_KEY, API_SECRET)
+ end
+ end
+
+ end
+end
diff --git a/fancy_bear/contextio/label.rb b/fancy_bear/contextio/label.rb
new file mode 100644
index 0000000..fb5a33a
--- /dev/null
+++ b/fancy_bear/contextio/label.rb
@@ -0,0 +1,37 @@
+require 'contextio'
+
+module FancyBear
+ module ContextIO
+
+ class Label < Base
+ def initialize(email)
+ super()
+
+ @account = @contextio.accounts.where(:email => email).first
+ @labels = []
+ @defaults = ['[FancyBear]/Low', '[FancyBear]/Medium', '[FancyBear]/High']
+ end
+
+ def all
+ return if not @labels.empty?
+
+ @account.sources.first.folders.each do |f|
+ @labels << f.name
+ end
+ @labels
+ end
+
+ def create_defaults
+ all()
+ @labels.each do |l|
+ return if @defaults.include?(l)
+ end
+
+ @defaults.each do |l|
+ system "contextio-put-folder.py '#{@account.id}' '#{l}'"
+ end
+ end
+ end
+
+ end
+end