stelapoint 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/stelapoint.rb +43 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6ef204fbe3b98e2238831d60ca1517af7a46ec2
4
+ data.tar.gz: 6b2ced2a0327e7f887c9c75a52ddc40996a6398b
5
+ SHA512:
6
+ metadata.gz: 754efeca0a311124287d03adc2511bd8571872574d3157ae918e656a1872b98db344a1fcebf6d2e8bd11c815d071c1e355b220169e6b4c070d3edbae4d09c655
7
+ data.tar.gz: cd3b0db405f151859dd1dc635f5a5b50d7067368bdd5581c89f153f38f414d81d3dadc488c73de848adf58339d226794bfc2eb97ea636b1e844c8e5896b973a0
data/lib/stelapoint.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ class Stelapoint
5
+ class StelapointError < StandardError
6
+ end
7
+ class StelapointAuthenticationError < StandardError
8
+ end
9
+
10
+ include HTTParty
11
+ base_uri "https://api.stelapoint.com/v1/"
12
+
13
+ def initialize(api_key)
14
+ @auth = {:username => api_key, :password => 'x'}
15
+ end
16
+
17
+ def search(names)
18
+ response = post("/search", names)
19
+ case response.code
20
+ when 200
21
+ return response.parsed_response[0]
22
+ when 401
23
+ raise StelapointAuthenticationError, "Invalid API Key"
24
+ when 500
25
+ raise StelapointError, "There was an error with your input or the stelapoint API"
26
+ end
27
+
28
+ return response
29
+ end
30
+
31
+ private
32
+
33
+ # Internal: Fire POST HTTP request.
34
+ # We only need POST right now
35
+ def post(path, params, auth=nil)
36
+ request(:post, path, :body => params.to_json, :basic_auth => @auth)
37
+ end
38
+
39
+ # Internal: Does the actual requests.
40
+ def request(method, path, params)
41
+ self.class.send(method, path, params)
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stelapoint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stelapoint
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Stelapoint sanctions API wrapper
14
+ email: jake@stelapoint.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/stelapoint.rb
20
+ homepage: http://stelapoint.com
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.2.2
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Stelapoint sanctions API wrapper
43
+ test_files: []