Project

verifykit

0.0
No release in over a year
Ruby bindings for VerifyKit REST API. VerifyKit is a service that offers alternative channels alongside SMS for phone number verification and it enables your users to log in or sign up to your apps quickly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.0, >= 1.0.1
~> 3.1, >= 3.1.1
~> 1.7, >= 1.7.1
~> 2.7, >= 2.7.4
~> 2.6, >= 2.6.8
 Project Readme

Gem Version test rubocop Ruby Style Guide Ruby Version

VerifyKit

cover

The easiest and most complete unofficial VerifyKit API client for Ruby.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add verifykit

Or add the following line to the application's Gemfile:

gem 'verifykit', github: 'nejdetkadir/verifykit', branch: 'main'

If bundler is not being used to manage dependencies, install the gem by executing:

gem install verifykit

Usage

Configuration

# config/initializers/verifykit.rb

VerifyKit.configure do |config|
  # it's optional, you can set manually when you create a VerifyKit::Client instance too
  config.server_key = ENV.fetch('VERIFYKIT_SERVER_KEY')

  # it's optional, default is Logger.new(STDOUT)
  config.logger = Rails.logger

  # it's optional, default is false
  config.debug.enabled = true

  # it's optional, default is 'v1.0', you can set manually when you create a VerifyKit::Client instance too but VerifyKit doesn't support any other version yet, so don't change it
  config.api_version = 'v1.0'
end

# or

VerifyKit.config.server_key = ENV.fetch('VERIFYKIT_SERVER_KEY')
VerifyKit.config.logger = Rails.logger
VerifyKit.config.debug.enabled = true
VerifyKit.config.api_version = 'v1.0'

Client

# you can create a client instance with default configuration
client = VerifyKit::Client.new

# or you can create a client instance with custom configuration
client = VerifyKit::Client.new(server_key: 'your-server-key', api_version: 'v1.0')

Verification

VerifyKit supports two verification methods: sms and whatsapp.

SMS Verification

Send a verification code to the phone number like this:

client = VerifyKit::Client.new

params = { phoneNumber: '555 555 55 55', countryCode: 'TR' }
query = { lang: 'tr' } # optional, default is 'en'

result = client.sms.send(params) # or client.sms.send(params, query)

if result.success?
  success_response = result.success
  # success_response is a VerifyKit::Response::Success instance

  # do something
else
  error_response = result.failure
  # error_response is a VerifyKit::Response::Error instance

  # do something
end

Check the verification code like this:

client = VerifyKit::Client.new

params = { phoneNumber: '554 597 46 46',
           countryCode: 'TR',
           reference: 'reference code',
           code: 'verification code' }
query = { lang: 'tr' } # optional, default is 'en'

result = client.sms.check(params) # or client.sms.check(params, query)

if result.success?
  success_response = result.success
  # success_response is a VerifyKit::Response::Success instance

  # do something
else
  error_response = result.failure
  # error_response is a VerifyKit::Response::Error instance

  # do something
end

WhatsApp Verification

Send a verification code to the phone number like this:

client = VerifyKit::Client.new

params = { phoneNumber: '555 555 55 55', countryCode: 'TR' }
query = { lang: 'tr' } # optional, default is 'en'

result = client.whatsapp.send(params) # or client.whatsapp.send(params, query)

if result.success?
  success_response = result.success
  # success_response is a VerifyKit::Response::Success instance

  # do something
else
  error_response = result.failure
  # error_response is a VerifyKit::Response::Error instance

  # do something
end

Check the verification code like this:

client = VerifyKit::Client.new

params = { reference: 'reference code',
           code: 'verification code' }
query = { lang: 'tr' } # optional, default is 'en'

result = client.whatsapp.check(params) # or client.whatsapp.check(params, query)

if result.success?
  success_response = result.success
  # success_response is a VerifyKit::Response::Success instance

  # do something
else
  error_response = result.failure
  # error_response is a VerifyKit::Response::Error instance

  # do something
end

Response Objects

Development

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.

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 the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/nejdetkadir/verifykit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Verifykit project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.