Bizo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bizo/base.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'oauth'
2
+ require 'oauth/consumer'
3
+ require 'json'
4
+
5
+ module Bizo
6
+ class Base
7
+ def initialize(key, secret)
8
+ @key = key
9
+ @secret = secret
10
+ @consumer = OAuth::Consumer.new(@key, @secret, {
11
+ :site => API_URL,
12
+ :scheme => :query_string,
13
+ :http_method => :get
14
+ })
15
+ end
16
+
17
+ protected
18
+ def request(method, path, raw_params = {})
19
+ path_with_key = "#{path}?api_key=#{@key}"
20
+ url = raw_params.inject(path_with_key) { |path,(k,v)| path + "&#{k}=#{v}" }
21
+ full_path = URI.escape(url)
22
+ JSON.parse @consumer.request(method,full_path).body
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'digest/sha1'
3
+ require 'json'
4
+ module Bizo
5
+ module Classify < Base
6
+ def initialize(key,secret)
7
+ super(key,secret)
8
+ end
9
+
10
+ def self.classify(params = {})
11
+ email = params[:email]
12
+ params[:email] = Digest::SHA1.hexdigest(email.downcase) unless email.nil?
13
+ request :get, CLASSIFY_PATH, params
14
+ end
15
+
16
+ private
17
+ CLASSIFY_PATH = "/v1/classify.json"
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ require 'digest/sha1'
2
+
3
+ module Bizo
4
+ class Client < Base
5
+ def initialize(key,secret)
6
+ super(key,secret)
7
+ end
8
+
9
+ def classify(params = {})
10
+ email = params[:email]
11
+ params[:email] = Digest::SHA1.hexdigest(email.downcase) unless email.nil?
12
+ request :get, CLASSIFY_PATH, params
13
+ end
14
+
15
+ def profile
16
+ request :get, PROFILE_PATH
17
+ end
18
+
19
+ def account
20
+ request :get, ACCOUNT_PATH
21
+ end
22
+
23
+ def taxonomy
24
+ request :get, TAXONOMY_PATH
25
+ end
26
+
27
+ private
28
+ TAXONOMY_PATH = "/v1/taxonomy.json"
29
+ ACCOUNT_PATH = "/v1/account.json"
30
+ PROFILE_PATH = "/v1/profile.json"
31
+ CLASSIFY_PATH = "/v1/classify.json"
32
+ end
33
+ end
data/lib/bizo.rb ADDED
@@ -0,0 +1,7 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+ require 'bizo/base'
3
+ require 'bizo/client'
4
+
5
+ module Bizo
6
+ API_URL = "http://api.bizographics.com"
7
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Bizo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Joshua Carver
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-21 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: josh@bizo.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/bizo.rb
31
+ - lib/bizo/classify.rb
32
+ - lib/bizo/base.rb
33
+ - lib/bizo/client.rb
34
+ has_rdoc: false
35
+ homepage:
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: A simple wrapper around the Bizo API
66
+ test_files: []
67
+