alloy-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE +20 -0
  4. data/README.md +46 -0
  5. data/lib/alloy-api.rb +46 -0
  6. metadata +62 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6d37d96928f05bb171b47d67433c9699fc00c2752f83dfd8b1dd46b74553bdaa
4
+ data.tar.gz: 5f07aa536199716687e54ee7ae071f55adb655b87ea829738d7449857bb67df5
5
+ SHA512:
6
+ metadata.gz: 2114d90c96ce86a6fac6bfca74e956610b60f6a4aaabd4e6bf6c54c91fb2ab18aa131067d630e2db34af9a5a7bfb80c98ea494a6b216379af75fadc56c916b7b
7
+ data.tar.gz: 35ea77c8f8a19c604c1fbdb8a0b2851c0d2c46d522c1862fb65f04a36be5426853ddb55ba647e928297608c4b024b1624d3a8c5e7af563fd5fa77dedd158f1d3
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 / 2020-06-10
2
+
3
+ * Initial Release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright © 2020 Matthew Schultz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # Alloy API
2
+ A simple gem to wrap Alloy.co's API for doing KYC in ruby applications.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'alloy-api'
9
+ ```
10
+
11
+ And then execute:
12
+ ```bash
13
+ $ bundle
14
+ ```
15
+
16
+ Or install it yourself as:
17
+ ```bash
18
+ $ gem install alloy-api
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Start by requiring the api:
24
+
25
+ ```ruby
26
+ require 'alloy-api'
27
+ ```
28
+
29
+ Then set the token and secret for the workflow to use:
30
+
31
+ ```ruby
32
+ Alloy::Api.api_token = 'provided by the workflow'
33
+ Alloy::Api.api_secret = 'provided by the workflow'
34
+ ```
35
+
36
+ If using Rails, this can be done in either the environment files or an initializer, but remember not to include the raw keys in repositories!
37
+
38
+ Also, if using a sandbox, set the endpoint:
39
+
40
+ ```ruby
41
+ Alloy::Api.api_uri = 'https://sandbox.alloy.co/' # Be sure to include the trailing slash!
42
+ ```
43
+
44
+
45
+ ## License
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,46 @@
1
+ require 'httparty'
2
+ require 'base64'
3
+ require 'json'
4
+
5
+ module Alloy
6
+ class Api
7
+ @@api_uri = 'https://api.alloy.co/'
8
+ @@api_token = nil
9
+ @@api_secret = nil
10
+
11
+ def self.api_uri=(value)
12
+ @@api_uri = value
13
+ end
14
+
15
+ def self.api_token=(value)
16
+ @@api_token = value
17
+ end
18
+
19
+ def self.api_secret=(value)
20
+ @@api_secret = value
21
+ end
22
+
23
+ def self.method_missing(m, *args, &block)
24
+ options = args.any? ? args[0] : {}
25
+ method = options[:method] || "post"
26
+ uri = "#{@@api_uri}#{m}"
27
+ headers = {
28
+ "Content-Type" => "application/json",
29
+ "Authorization" => auth_param
30
+ }.merge(options[:headers].to_h)
31
+
32
+ JSON.parse(HTTParty.send(method, uri, {headers: headers, body: (options[:body] || {}).to_json}).body)
33
+ # TODO: Error handling
34
+ end
35
+
36
+ private
37
+
38
+ def self.auth_param
39
+ "Basic #{encoded}"
40
+ end
41
+
42
+ def self.encoded
43
+ Base64.strict_encode64 "#{@@api_token}:#{@@api_secret}"
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alloy-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Schultz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.0
27
+ description: " A wrapper for the Alloy.co API. Helps to build KYC policy support
28
+ into applications.\n"
29
+ email:
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - LICENSE
36
+ - README.md
37
+ - lib/alloy-api.rb
38
+ homepage: https://github.com/MatthewSchultz/alloy-api
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ source_code_uri: https://github.com/MatthewSchultz/alloy-api
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 1.9.0
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.0.3
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A wrapper for the Alloy.co API
62
+ test_files: []