ecertic 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f474f1fb935efa9d8870e6e6ea6827216a8aa186f68f4953cf58debb9becc27f
4
+ data.tar.gz: 6789fc22f2fd40460ba1dc25ec1af6ba391d791f56010d10c604146b376d93ed
5
+ SHA512:
6
+ metadata.gz: ecd828b6c9b0d42a1b485ac04e7606c1ee0a4349478e26b01ae0deb60fee3eeb837ed685ee92fb1e83e442fd6175d18d27a6de3506c395407cb4cb94627b3880
7
+ data.tar.gz: 46f8de6fb07bcb79d7679f3c6c6a06af0931a25be685acf1a5c3aac3ce622de81dea7d596a11e0468bea6c9f1c41c852716294810a70c5ebb7d97f99e68a35aa
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .DS_Store
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,46 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.3
4
+
5
+ Layout/CaseIndentation:
6
+ EnforcedStyle: end
7
+
8
+ Layout/IndentFirstArrayElement:
9
+ EnforcedStyle: consistent
10
+
11
+ Layout/IndentFirstHashElement:
12
+ EnforcedStyle: consistent
13
+
14
+ Metrics/LineLength:
15
+ # Commonly used screens these days easily fit more than 80 characters.
16
+ Max: 120
17
+ Exclude:
18
+ - "spec/**/*.rb"
19
+
20
+ # [codesmell]
21
+ Metrics/BlockLength:
22
+ Enabled: false
23
+
24
+ Metrics/MethodLength:
25
+ Max: 50
26
+
27
+ Metrics/ModuleLength:
28
+ Enabled: false
29
+
30
+ Style/Documentation:
31
+ Enabled: false
32
+
33
+ Style/AccessModifierDeclarations:
34
+ EnforcedStyle: inline
35
+
36
+ Style/FrozenStringLiteralComment:
37
+ EnforcedStyle: always
38
+
39
+ Style/StringLiterals:
40
+ EnforcedStyle: double_quotes
41
+
42
+ Style/TrailingCommaInArrayLiteral:
43
+ EnforcedStyleForMultiline: consistent_comma
44
+
45
+ Style/TrailingCommaInHashLiteral:
46
+ EnforcedStyleForMultiline: consistent_comma
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.3
6
+ before_install: gem install bundler -v 2.0.2
7
+ notifications:
8
+ slack:
9
+ secure: faQfcCuUCq1psgiPZar9zajFU/C/o+Xs0CVOOqOQd/m43D4AvEeD/KEFnZEEjBW6ILzg9n7lf3AeE5MYwIkgTrieDKAEVQ1Rnl0qFJKwS9bjkEoqqrO2fGQJ8N/dTfA3BIsgrUgTZF3CoxqkIN1QKvtbSiWuao0ZHr4KnkBwA2P4m/G8CTMXzup4b2aX+B6P84UZgDMXdmeTNIuC/C7iXlpPCTcNaCO7EeB59IUP/WM6my4ynKpsa80wAz4HsALMh+oNRwE20EmYIK8L4ecn7PZitTeSZWuiPjWTHYrU1+05cM9tRQzP8r6FohRAfGTzUgC0cyMqxHN3uMwj4XMHE1hlnF6BP7BA5BbQSKkEIiwS8ao4k008nMYT0gplVZDxZ7lQpVOXVcIsEiPtYVJ2tayLhFS00H7HonppHwYhXTWnt2W4RHKjnkSiVj66/eBCaca9l59nP5oAxWvAVpa1lIZl2a/Gzv/mEDdCupIJmIXZiSz/sCDg5kQr/MhGdua3mniurCN1VIwpBGilO/hYSLoW0GNj5/bw3LLS1lVIaI4Q6Lm7dxQJKyayDVhDhhFBMZ79tUweZM9YFmsDE/8QWbCH6tZ/ZjubHi6PAgMAPgleSR5AxWPlCVP/YnBo1qpQOQ1qIRPmDlllgnefpG4kAfa/qSnvLfcLQW3AFJyGYEk=
data/CHANGELOG ADDED
@@ -0,0 +1 @@
1
+ #### Release 0.0.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at dev@devengo.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ecertic.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Devengo SL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Ecertic
2
+
3
+ Non-official Ruby client for Ecertic OTP API <https://docs.otpsecure.net/>. It provides the necessary scaffolding to easily upload a PDF file to Ecertic's API and request the delivery of an OTP to a given phone for its validation.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ecertic'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ gem install ecertic
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+
29
+ require "ecertic"
30
+
31
+ client = Ecertic::Client.new(apikey: "APIKEY", secret: "SECRET")
32
+
33
+ info = {
34
+ sandbox: true,
35
+ movil: "669010101",
36
+ smsusr: "smsusr",
37
+ smspwd: "smspwd",
38
+ pdf_files: [File.open("contract.pdf")],
39
+ }
40
+
41
+ request = client.otps.create(info)
42
+ # request.token => "d98509b2aa....3cff10a8b47"
43
+ # request.uuid => "rJwJnaKXS"
44
+ # In the sandbox environment you will get the OTP itself too
45
+ # request.otp => "147548"
46
+
47
+ status = client.otps.status(request.token)
48
+ # request.status => "SANDBOX"
49
+ # request.sandbox? => true
50
+ # request.sent? => false
51
+
52
+ validation = client.tokens.validate(request.token, request.otp)
53
+ # request.status => "OTP_OK"
54
+ # request.ok? => true
55
+ # request.message => "OTP CORRECTA"
56
+ ```
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests or if you prefer auto reloading specs run `bundle exec guard`. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ 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).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/devengoapp/ecertic-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
71
+
72
+ ## Code of Conduct
73
+
74
+ Everyone interacting in the Ecertic project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/devengoapp/ecertic-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ecertic"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/ecertic.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "ecertic/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.version = Ecertic::VERSION
9
+ spec.name = "ecertic"
10
+ spec.summary = "Non-official Ruby bindings for the Ecertic API"
11
+ spec.description = "Ecertic provides digital signature and KYC services."
12
+ spec.homepage = "https://www.ecertic.com/"
13
+ spec.authors = ["Devengo"]
14
+ spec.email = ["dev@devengo.com"]
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = ">= 2.3.0"
18
+
19
+ spec.metadata = {
20
+ "homepage_uri" => spec.homepage,
21
+ "bug_tracker_uri" => "https://github.com/devengoapp/ecertic-ruby/issues",
22
+ "changelog_uri" => "https://github.com/devengoapp/ecertic-ruby/blob/master/CHANGELOG.md",
23
+ "github_repo" => "ssh://github.com/devengoapp/ecertic-ruby",
24
+ "source_code_uri" => "https://github.com/devengoapp/ecertic-ruby",
25
+ }
26
+
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "bin"
31
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_runtime_dependency("faraday", "~> 0.13")
35
+ spec.add_runtime_dependency("faraday_middleware", "~> 0.13")
36
+ spec.add_runtime_dependency("net-http-persistent", "~> 3.0")
37
+
38
+ spec.add_development_dependency("bundler", "~> 2.0")
39
+ spec.add_development_dependency("rake", "~> 10.0")
40
+ spec.add_development_dependency("rspec", "~> 3.0")
41
+ spec.add_development_dependency("webmock", "~> 3.6")
42
+ spec.add_development_dependency("guard", "~> 2.15")
43
+ spec.add_development_dependency("guard-rspec", "~> 4.7")
44
+ end
data/lib/ecertic.rb ADDED
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+ require "logger"
6
+ require "base64"
7
+ require "json"
8
+
9
+ require "ecertic/version"
10
+ require "ecertic/api"
11
+
12
+ require "ecertic/resources/base"
13
+ require "ecertic/resources/document"
14
+ require "ecertic/resources/statusable"
15
+ require "ecertic/resources/otp/request"
16
+ require "ecertic/resources/otp/status"
17
+ require "ecertic/resources/token/instance"
18
+ require "ecertic/resources/token/validation"
19
+
20
+ require "ecertic/errors"
21
+ require "ecertic/default"
22
+ require "ecertic/callback"
23
+ require "ecertic/utils"
24
+ require "ecertic/response"
25
+ require "ecertic/client"
26
+
27
+ module Ecertic
28
+ @api_base = "https://api.otpsecure.net/"
29
+
30
+ @log_level = nil
31
+ @logger = nil
32
+
33
+ LEVEL_DEBUG = Logger::DEBUG
34
+ LEVEL_ERROR = Logger::ERROR
35
+ LEVEL_INFO = Logger::INFO
36
+
37
+ class << self
38
+ attr_accessor :api_base, :api_key, :secret
39
+ end
40
+
41
+ def self.log_level
42
+ @log_level
43
+ end
44
+
45
+ def self.log_level=(val)
46
+ # Support text values for easy log level definition from command line via export
47
+ val = case val
48
+ when "debug"
49
+ LEVEL_DEBUG
50
+ when "info"
51
+ LEVEL_INFO
52
+ else
53
+ val
54
+ end
55
+ if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
56
+ raise ArgumentError,
57
+ "log_level should only be set to `nil`, `debug` or `info`"
58
+ end
59
+ @log_level = val
60
+ end
61
+
62
+ def self.logger
63
+ @logger
64
+ end
65
+
66
+ def self.logger=(val)
67
+ @logger = val
68
+ end
69
+ end
70
+
71
+ Ecertic.log_level = ENV["ECERTIC_LOG"] unless ENV["ECERTIC_LOG"].nil?
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ecertic/api/service"
4
+ require "ecertic/api/documents_service"
5
+ require "ecertic/api/otps_service"
6
+ require "ecertic/api/tokens_service"
7
+
8
+ module Ecertic
9
+ module API
10
+ def otps
11
+ @services[:otps] ||= API::OTPsService.new(self)
12
+ end
13
+
14
+ def tokens
15
+ @services[:tokens] ||= API::TokensService.new(self)
16
+ end
17
+
18
+ def documents
19
+ @services[:documents] ||= API::DocumentsService.new(self)
20
+ end
21
+ end
22
+ end
23
+