kycaid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.drone.yml +27 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis-yml +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +68 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/kycaid.gemspec +35 -0
- data/lib/kycaid.rb +45 -0
- data/lib/kycaid/address.rb +30 -0
- data/lib/kycaid/applicant.rb +34 -0
- data/lib/kycaid/client.rb +62 -0
- data/lib/kycaid/configuration.rb +21 -0
- data/lib/kycaid/document.rb +67 -0
- data/lib/kycaid/file.rb +28 -0
- data/lib/kycaid/response.rb +32 -0
- data/lib/kycaid/verification.rb +32 -0
- data/lib/kycaid/version.rb +3 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 745164f9d1f5e40a02fd4e78dfa205895cdfe79cfc49d45724854d57c63614d7
|
4
|
+
data.tar.gz: 44786d6cea64b1d7936e93ffbc63ab4e3d0b05a2971cb7a920f6a884c4cc058e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 877880b180913660115721c50ca9f058750ef92c8b36b23d5d1afb13d2c8462d29fd618a85d494e2985d49ca3bc434ed2ef10ffa34da9bf31a3b24d6728253e9
|
7
|
+
data.tar.gz: 6db8b5e99d63d5ba21b95efb4934c945ab909c904c6caad9e0973cabcc7972783d93a044b842f641d36dfc09fb0b4099837d1cf40fbcaa06257eaf53e1ac7d7f
|
data/.drone.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
kind: pipeline
|
3
|
+
name: default
|
4
|
+
|
5
|
+
steps:
|
6
|
+
- name: Run rspec
|
7
|
+
image: ruby:2.6
|
8
|
+
commands:
|
9
|
+
- gem install bundler:2.1.4
|
10
|
+
- bundle install
|
11
|
+
- bundle exec rspec
|
12
|
+
|
13
|
+
- name: Release gems
|
14
|
+
image: ruby:2.6
|
15
|
+
environment:
|
16
|
+
GEM_CREDENTIALS:
|
17
|
+
from_secret: gem_credentials
|
18
|
+
commands:
|
19
|
+
- mkdir -p ~/.gem
|
20
|
+
- echo $GEM_CREDENTIALS | base64 -d > ~/.gem/credentials
|
21
|
+
- chmod 0600 ~/.gem/credentials
|
22
|
+
- gem build kycaid.gemspec
|
23
|
+
- gem push kycaid*.gem
|
24
|
+
|
25
|
+
trigger:
|
26
|
+
event:
|
27
|
+
- push
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis-yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kycaid (0.1.0)
|
5
|
+
faraday
|
6
|
+
json
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
coderay (1.1.2)
|
14
|
+
crack (0.4.3)
|
15
|
+
safe_yaml (~> 1.0.0)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
docile (1.3.2)
|
18
|
+
faraday (1.0.1)
|
19
|
+
multipart-post (>= 1.2, < 3)
|
20
|
+
hashdiff (1.0.1)
|
21
|
+
json (2.3.0)
|
22
|
+
method_source (1.0.0)
|
23
|
+
multipart-post (2.1.1)
|
24
|
+
pry (0.13.1)
|
25
|
+
coderay (~> 1.1)
|
26
|
+
method_source (~> 1.0)
|
27
|
+
public_suffix (4.0.5)
|
28
|
+
rake (13.0.1)
|
29
|
+
rspec (3.9.0)
|
30
|
+
rspec-core (~> 3.9.0)
|
31
|
+
rspec-expectations (~> 3.9.0)
|
32
|
+
rspec-mocks (~> 3.9.0)
|
33
|
+
rspec-core (3.9.1)
|
34
|
+
rspec-support (~> 3.9.1)
|
35
|
+
rspec-expectations (3.9.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.9.0)
|
38
|
+
rspec-mocks (3.9.1)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.9.0)
|
41
|
+
rspec-support (3.9.2)
|
42
|
+
safe_yaml (1.0.5)
|
43
|
+
simplecov (0.17.1)
|
44
|
+
docile (~> 1.1)
|
45
|
+
json (>= 1.8, < 3)
|
46
|
+
simplecov-html (~> 0.10.0)
|
47
|
+
simplecov-html (0.10.2)
|
48
|
+
vcr (5.1.0)
|
49
|
+
webmock (3.8.3)
|
50
|
+
addressable (>= 2.3.6)
|
51
|
+
crack (>= 0.3.2)
|
52
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bundler
|
59
|
+
kycaid!
|
60
|
+
pry
|
61
|
+
rake (~> 13.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
simplecov
|
64
|
+
vcr
|
65
|
+
webmock
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Ruby KYCAID
|
2
|
+
|
3
|
+
Ruby gem to interact with KYC provider https://www.kycaid.com/
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruby-kycaid'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ruby-kycaid
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Configure the gem using your issued KYCAID credentials in an initializer file. For example, in config/initializers/kycaid.rb:
|
24
|
+
|
25
|
+
```
|
26
|
+
KYCAID.configure do |config|
|
27
|
+
config.authorization_token = ENV['KYCAID_AUTHORIZATION_TOKEN']
|
28
|
+
config.sandbox_mode = ENV['KYCAID_SANDBOX_MODE']
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/openware/ruby-kycaid.
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kycaid"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/kycaid.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'lib/kycaid/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "kycaid"
|
5
|
+
spec.version = KYCAID::VERSION
|
6
|
+
spec.authors = ["Openware"]
|
7
|
+
spec.email = ["hello@openware.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Openware ruby library to interact with KYCAID.}
|
10
|
+
spec.description = %q{Support of core functionality of KYC provider}
|
11
|
+
spec.homepage = "https://www.openware.com/"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = "https://github.com/openware/kycaid"
|
16
|
+
spec.metadata["changelog_uri"] = "https://github.com/openware/kycaid/blob/master/CHANGELOG.md"
|
17
|
+
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "vcr"
|
29
|
+
spec.add_development_dependency "webmock"
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
spec.add_development_dependency "simplecov"
|
32
|
+
|
33
|
+
spec.add_dependency "faraday"
|
34
|
+
spec.add_dependency "json"
|
35
|
+
end
|
data/lib/kycaid.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "json"
|
3
|
+
require "ostruct"
|
4
|
+
|
5
|
+
require "kycaid/version"
|
6
|
+
require "kycaid/configuration"
|
7
|
+
require "kycaid/client"
|
8
|
+
require "kycaid/response"
|
9
|
+
require "kycaid/applicant"
|
10
|
+
require "kycaid/file"
|
11
|
+
require "kycaid/document"
|
12
|
+
require "kycaid/address"
|
13
|
+
require "kycaid/verification"
|
14
|
+
|
15
|
+
# KYCAID module contains wrappers around KYCAID API.
|
16
|
+
# See https://kycaid.com/
|
17
|
+
module KYCAID
|
18
|
+
|
19
|
+
# Error is generic error used in this gem.
|
20
|
+
# All defined errors are inherited from Error.
|
21
|
+
class Error < StandardError; end
|
22
|
+
|
23
|
+
# Unauthorized is raised when 403 status returned,
|
24
|
+
# when request is correct but refuses to authorize it.
|
25
|
+
# Check your token or contact KYCAID support.
|
26
|
+
class Unauthorized < Error; end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
attr_accessor :configuration
|
30
|
+
end
|
31
|
+
|
32
|
+
# Coinfigure allows to change gem preferences. Check Configuration for the list of options.
|
33
|
+
# ==== Example
|
34
|
+
#
|
35
|
+
# KYCAID.configure do |c|
|
36
|
+
# c.authorization_token = '1MAR3SP3CTABL3t0k3N'
|
37
|
+
# c.sandbox_mode = false
|
38
|
+
# c.api_endpoint = 'https://api.kycaid.com/'
|
39
|
+
# c.raise_errors = true
|
40
|
+
# end
|
41
|
+
def self.configure
|
42
|
+
self.configuration ||= Configuration.new
|
43
|
+
yield(configuration) if block_given?
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Address is wrapper for KYCAID Address endpoints.
|
3
|
+
class Address < Response
|
4
|
+
extend Client
|
5
|
+
|
6
|
+
# Creates new address, params is a Hash.
|
7
|
+
# * +:applicant_id+ - _required_ The applicant’s unique identificator that received in response of create an applicant.
|
8
|
+
# * +:type+ - _required_ The address type. Valid values are: +'REGISTERED', 'BUSINESS', 'ADDITIONAL'+.
|
9
|
+
# * +:country+ - The country of the applicants’s address. Example: GB (ISO 3166-2).
|
10
|
+
# * +:city+ - The city or town of the applicant’s address.
|
11
|
+
# * +:postal_code+ - The post or zip code of the applicant’s address.
|
12
|
+
# * +:full_address+ - The applicant’s full address.
|
13
|
+
#
|
14
|
+
# Returns Response object, conatining +address_id+.
|
15
|
+
def self.create(params)
|
16
|
+
response = KYCAID::Document.create(
|
17
|
+
{
|
18
|
+
front_file: params[:front_file],
|
19
|
+
applicant_id: params[:applicant_id],
|
20
|
+
type: 'ADDRESS_DOCUMENT'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
return response unless response.errors.nil?
|
24
|
+
|
25
|
+
protected_params = params.slice(:country, :city, :postal_code, :full_address, :applicant_id, :type)
|
26
|
+
|
27
|
+
respond(post("/addresses", protected_params))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Applicant is wrapper for KYCAID Applicants endpoints.
|
3
|
+
class Applicant < Response
|
4
|
+
extend Client
|
5
|
+
|
6
|
+
# Creates new applicant, params is a Hash.
|
7
|
+
# * +:type+ - _required_ The applicant type. Valid values are PERSON or COMPANY.
|
8
|
+
# * +:first_name+ - _required_ The applicant’s first name.
|
9
|
+
# * +:last_name+ - _required_ The applicant’s last name.
|
10
|
+
# * +:dob+ - _required_ The applicant’s day of birth date. (ISO 8601, YYYY-MM-DD).
|
11
|
+
# * +:residence_country+ - _required_ The applicant’s current nationality. Example: GB (ISO 3166-2).
|
12
|
+
# * +:email+ - _required_ The applicant’s email address.
|
13
|
+
# * +:phone+ - _required_ The phone number of applicant.
|
14
|
+
#
|
15
|
+
# Returns Response object, conatining +applicant_id+.
|
16
|
+
def self.create(params)
|
17
|
+
protected_params = params.slice(:type, :first_name, :last_name, :dob, :residence_country, :email, :phone)
|
18
|
+
respond(post("/applicants", protected_params))
|
19
|
+
end
|
20
|
+
|
21
|
+
# Send get request to retrieve applicant by his ID.
|
22
|
+
#
|
23
|
+
# Returns Response object, conatining:
|
24
|
+
# * +:applicant_id+
|
25
|
+
# * +:first_name+
|
26
|
+
# * +:last_name+
|
27
|
+
# * +:dob+
|
28
|
+
# * +:residence_country+
|
29
|
+
# * +:email+
|
30
|
+
def self.fetch(applicant_id)
|
31
|
+
respond(get("/applicants/#{applicant_id}"))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Client contins REST API and handles content type and injecting Authorization token.
|
3
|
+
module Client
|
4
|
+
# Returns Faraday connection with authorization header containing token.
|
5
|
+
def conn
|
6
|
+
@conn ||= Faraday.new(url: KYCAID.configuration.api_endpoint).tap do |faraday|
|
7
|
+
faraday.authorization("Token", KYCAID.configuration.authorization_token)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns Faraday connection for multipart data uploading with authorization header containing token.
|
12
|
+
def multipart_conn
|
13
|
+
@multipart_conn ||= Faraday.new(url: KYCAID.configuration.api_endpoint) do |faraday|
|
14
|
+
faraday.request :multipart
|
15
|
+
faraday.request :url_encoded
|
16
|
+
faraday.adapter Faraday.default_adapter
|
17
|
+
faraday.authorization("Token", KYCAID.configuration.authorization_token)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns true if sandbox mode is set.
|
22
|
+
def sandbox?
|
23
|
+
KYCAID.configuration.sandbox_mode
|
24
|
+
end
|
25
|
+
|
26
|
+
# Performs a get request, adds sandbox flag to request.
|
27
|
+
def get(url, options={})
|
28
|
+
conn.get(url, options.merge(sandbox: sandbox?))
|
29
|
+
end
|
30
|
+
|
31
|
+
# Performs a post request, adds sandbox flag to request.
|
32
|
+
def post(url, params={})
|
33
|
+
conn.post(url, params.merge(sandbox: sandbox?))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Performs a patch request, adds sandbox flag to request.
|
37
|
+
def patch(url, params={})
|
38
|
+
conn.patch(url, params.merge(sandbox: sandbox?))
|
39
|
+
end
|
40
|
+
|
41
|
+
# Performs a post request with multipart data, adds sandbox flag to request.
|
42
|
+
def file_post(url, params={})
|
43
|
+
multipart_conn.post(url, file_payload(params))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Performs a put request with multipart data, adds sandbox flag to request.
|
47
|
+
def file_put(url, params={})
|
48
|
+
multipart_conn.put(url, file_payload(params))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns multipart data body params.
|
52
|
+
def file_payload(params={})
|
53
|
+
file = Faraday::UploadIO.new(
|
54
|
+
params[:tempfile].path,
|
55
|
+
params[:content_type],
|
56
|
+
params[:original_filename]
|
57
|
+
)
|
58
|
+
payload = { :file => file }.merge(sandbox: sandbox?)
|
59
|
+
payload
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Configuration contains KYCAID gem preferences.
|
3
|
+
# * +:authorization_token+ - KYCAID acces token.
|
4
|
+
# * +:sandbox_mode+ - run requests in sandbox mode.
|
5
|
+
# * +:api_endpoint+ - KYCAID service endpoint.
|
6
|
+
# * +:raise_errors+ - if set to true, KYCAID errors (like unauthorized) will be raised, otherwise access errors by Response#errors.
|
7
|
+
class Configuration
|
8
|
+
attr_accessor :authorization_token
|
9
|
+
attr_accessor :sandbox_mode
|
10
|
+
attr_accessor :api_endpoint
|
11
|
+
attr_accessor :raise_errors
|
12
|
+
|
13
|
+
# Initizes configuration with default values.
|
14
|
+
def initialize
|
15
|
+
@authorization_token = "d9883415047de3439328df17b0310569669a"
|
16
|
+
@sandbox_mode = true
|
17
|
+
@api_endpoint = "https://api.kycaid.com/"
|
18
|
+
@raise_errors = false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Document is wrapper for KYCAID Documents endpoints.
|
3
|
+
class Document < Response
|
4
|
+
extend Client
|
5
|
+
|
6
|
+
# Creates +:front_file+ and +:back_file+ files (see File) and a document,referring to those files.
|
7
|
+
# * +:applicant_id+ - _required_ The applicant’s unique identificator that received in response of Applicant#create.
|
8
|
+
# * +:type+ - _required_ The document type. Valid values are: GOVERNMENT_ID, PASSPORT, DRIVERS_LICENSE, SELFIE_IMAGE,
|
9
|
+
# ADDRESS_DOCUMENT, FINANCIAL_DOCUMENT, TAX_ID_NUMBER, REGISTRATION_COMPANY, COMPANY_LEGAL_ADDRESS, AUTHORISED_PERSON,
|
10
|
+
# COMPANY_OWNERSHIP.
|
11
|
+
# * +:document_number+ - The unique number associated with document (e.g. passport number).
|
12
|
+
# * +:issue_date+ - The issue date of the document. (ISO 8601, YYYY-MM-DD).
|
13
|
+
# * +:expiry_date+ - The expiry date of the document. (ISO 8601, YYYY-MM-DD)
|
14
|
+
# * +:front_file+ - nested param to create a file.
|
15
|
+
# * +:back_file+ - nested param to create a file.
|
16
|
+
#
|
17
|
+
# Front file and Back file are a Hash:
|
18
|
+
# * +:tempfile+ - file to upload.
|
19
|
+
# * +:file_extension+ - file's extensions (f.e., .jpeg)
|
20
|
+
# * +:file_name+ - filename.
|
21
|
+
#
|
22
|
+
# Returns Response object, conatining +document_id+.
|
23
|
+
def self.create(params)
|
24
|
+
front_file_id = unless params[:front_file].nil?
|
25
|
+
front_file = file_params(params[:front_file])
|
26
|
+
return front_file unless front_file.errors.nil?
|
27
|
+
|
28
|
+
front_file.file_id
|
29
|
+
end
|
30
|
+
|
31
|
+
back_file_id = unless params[:back_file].nil?
|
32
|
+
back_file = file_params(params[:back_file])
|
33
|
+
return back_file unless back_file.errors.nil?
|
34
|
+
|
35
|
+
back_file.file_id
|
36
|
+
end
|
37
|
+
|
38
|
+
protected_params = params.slice(:applicant_id, :type, :document_number, :issue_date, :expiry_date)
|
39
|
+
.merge(front_side_id: front_file_id, back_side_id: back_file_id)
|
40
|
+
|
41
|
+
respond(post("/documents", protected_params.compact))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Update document, params is a Hash.
|
45
|
+
# * +:type+ - see #create
|
46
|
+
# * +:document_number+ - see #create
|
47
|
+
# * +:issue_date+ - see #create
|
48
|
+
# * +:expiry_date+ - see #create
|
49
|
+
# * +:front_side_id+ - new File ID to associate document with.
|
50
|
+
# * +:back_side_id+ - new File ID to associate document with.
|
51
|
+
# Returns Response object, conatining +document_id+.
|
52
|
+
def self.update(params)
|
53
|
+
protected_params = params.slice(:type, :document_number, :issue_date, :expiry_date, :front_side_id, :back_side_id)
|
54
|
+
respond(patch("/documents/#{params[:id]}", protected_params))
|
55
|
+
end
|
56
|
+
|
57
|
+
# A helper to create associated file before creating document.
|
58
|
+
# Return a File Response object.
|
59
|
+
def self.file_params(params)
|
60
|
+
KYCAID::File.create(
|
61
|
+
tempfile: params[:tempfile],
|
62
|
+
content_type: "image/#{params[:file_extension]}",
|
63
|
+
original_filename: params[:file_name]
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/kycaid/file.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# File is wrapper for KYCAID Files endpoints.
|
3
|
+
class File < Response
|
4
|
+
extend Client
|
5
|
+
|
6
|
+
# Creates new file.
|
7
|
+
# * +:tempfile+ - file to upload.
|
8
|
+
# * +:content_type+ - multipart data content type.
|
9
|
+
# * +:original_filename+ - filename.
|
10
|
+
#
|
11
|
+
# Returns Response object, conatining +file_id+.
|
12
|
+
def self.create(params)
|
13
|
+
respond(file_post("/files", params.slice(:tempfile, :content_type, :original_filename)))
|
14
|
+
end
|
15
|
+
|
16
|
+
# Updates a file.
|
17
|
+
# * +:file_id+ - file ID to update.
|
18
|
+
# * +:tempfile+ - file to upload.
|
19
|
+
# * +:content_type+ - multipart data content type.
|
20
|
+
# * +:original_filename+ - filename.
|
21
|
+
#
|
22
|
+
# Returns Response object, conatining +file_id+.
|
23
|
+
def self.update(params)
|
24
|
+
respond(file_put("/files/#{params[:file_id]}",
|
25
|
+
params.slice(:tempfile, :content_type, :original_filename)))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Response is an object to wrap parsed json response.
|
3
|
+
class Response < OpenStruct
|
4
|
+
def initialize(response)
|
5
|
+
super(response)
|
6
|
+
end
|
7
|
+
|
8
|
+
# * If response is not successful, set errors to array of detected errors.
|
9
|
+
# * If response is successful, errors in nil.
|
10
|
+
# * If raise_errors is set in configuration, will raise error if any.
|
11
|
+
def handle_error(err)
|
12
|
+
self.errors ||= []
|
13
|
+
self.errors << err
|
14
|
+
|
15
|
+
raise err if KYCAID.configuration.raise_errors
|
16
|
+
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
# Wraps JSON response into OpenStruct.
|
21
|
+
# Original response in stored in +raw_response+
|
22
|
+
def self.respond(response)
|
23
|
+
resp = new(JSON.parse(response.body))
|
24
|
+
resp.raw_response = response
|
25
|
+
|
26
|
+
resp.handle_error(Unauthorized.new(response.body)) if response.status == 403
|
27
|
+
resp.handle_error(Error.new(response.body)) unless response.success?
|
28
|
+
|
29
|
+
resp
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module KYCAID
|
2
|
+
# Verification is wrapper for KYCAID Verifications endpoints.
|
3
|
+
class Verification < Response
|
4
|
+
extend Client
|
5
|
+
|
6
|
+
# Create a verification.
|
7
|
+
# * +:applicant_id+ - _required_ The applicant unique identificator that received in response of Applicant#create.
|
8
|
+
# * +:types+ - _required_ The verification types. Valid values are: DOCUMENT, FACIAL, ADDRESS, AML, FINANCIAL, VIDEO, COMPANY.
|
9
|
+
# * +:callback_url+ - _required_ URL on which the result will come.
|
10
|
+
#
|
11
|
+
# See https://docs.kycaid.com/#create-a-verification for more info.
|
12
|
+
#
|
13
|
+
# Returns Response object, conatining +verification_id+.
|
14
|
+
def self.create(params)
|
15
|
+
protected_params = params.slice(:applicant_id, :types, :callback_url)
|
16
|
+
respond(post("/verifications", protected_params))
|
17
|
+
end
|
18
|
+
|
19
|
+
# Retrieve a verification by it's id.
|
20
|
+
#
|
21
|
+
# Returns Response object, conatining:
|
22
|
+
# * +:verification_id+ - The verification’s unique identificator.
|
23
|
+
# * +:status+ - Status of verification. Possible values: +unused+, +pending+, +completed+.
|
24
|
+
# * +:verified+ - Result of verification. Possible values: +true+ or +false+.
|
25
|
+
# * +:verifications+ - VerificationsList object.
|
26
|
+
#
|
27
|
+
# See https://docs.kycaid.com/#retrieve-a-verification for more info.
|
28
|
+
def self.fetch(verification_id)
|
29
|
+
respond(get("/verifications/#{verification_id}"))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kycaid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Openware
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: faraday
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: json
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Support of core functionality of KYC provider
|
140
|
+
email:
|
141
|
+
- hello@openware.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".drone.yml"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".travis-yml"
|
150
|
+
- Gemfile
|
151
|
+
- Gemfile.lock
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- bin/console
|
155
|
+
- bin/setup
|
156
|
+
- kycaid.gemspec
|
157
|
+
- lib/kycaid.rb
|
158
|
+
- lib/kycaid/address.rb
|
159
|
+
- lib/kycaid/applicant.rb
|
160
|
+
- lib/kycaid/client.rb
|
161
|
+
- lib/kycaid/configuration.rb
|
162
|
+
- lib/kycaid/document.rb
|
163
|
+
- lib/kycaid/file.rb
|
164
|
+
- lib/kycaid/response.rb
|
165
|
+
- lib/kycaid/verification.rb
|
166
|
+
- lib/kycaid/version.rb
|
167
|
+
homepage: https://www.openware.com/
|
168
|
+
licenses: []
|
169
|
+
metadata:
|
170
|
+
homepage_uri: https://www.openware.com/
|
171
|
+
source_code_uri: https://github.com/openware/kycaid
|
172
|
+
changelog_uri: https://github.com/openware/kycaid/blob/master/CHANGELOG.md
|
173
|
+
post_install_message:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 2.3.0
|
182
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
requirements: []
|
188
|
+
rubygems_version: 3.0.3
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: Openware ruby library to interact with KYCAID.
|
192
|
+
test_files: []
|