Git Product home page Git Product logo

sdk-perl's Introduction

Mslm Perl SDK

The official Perl SDK for Mslm APIs.

Requirements

Perl version 5.006 or above.

Authentication

Mslm's APIs require an API key. If you don't have one, please read Authentication to understand how to get an API key before continuing.

Installation

Via CPAN or CPANMINUS

Mslm module can be installed using cpan or cpanm:

cpanm Mslm

Via source

If you'd like to install from source (not necessary for use in your application), download the source and run the following commands within the Mslm directory:

perl Makefile.PL
make
make test
make install

Usage

use Mslm;

my $api_key = "YOUR_API_KEY";
my $mslm = Mslm->new($api_key);

# Access EmailVerify functionality
my $sv_details = $mslm->email_verify->single_verify('[email protected]');

# Access OTP functionality. (OTP service is currently available for Pakistan only)
# Sending OTP
my $response = $mslm->otp->send({
	phone          => '03001234567',
	tmpl_sms       => 'Your verification code is: <otp>',
	token_len      => 6,
	expire_seconds => 60
});
# Verifying OTP token
my $verification_result = $mslm->otp->verify({
	phone   => '03001234567',
	token   => '123456',
	consume => \1
});

You can install and use sub-modules that are available under the Mslm module individually.

Using EmailVerify sub-module

use Mslm::EmailVerify;

my $api_key = "YOUR_API_KEY";
my $email_verifier = Mslm::EmailVerify->new($api_key);

# Single email verification
my $verification_result = $email_verifier->single_verify('[email protected]');

Using OTP sub-module

use Mslm::OTP;

my $api_key = "YOUR_API_KEY";
my $otp = Mslm::OTP->new($api_key);

# Sending OTP
my $response = $otp->send({
	phone          => '03001234567',
	tmpl_sms       => 'Your verification code is: <otp>',
	token_len      => 6,
	expire_seconds => 60
});

# Verifying OTP token
my $verification_result = $otp->verify({
	phone   => '1234567890',
	token   => '123456',
	consume => \1
});

Configuration

The new method of each client accepts an optional %opts parameter, which can be used to override the base_url, user_agent, timeout, and http_client; where http_client can only be a LWP::UserAgent.

  • Default base_url: 'https://mslm.io'
  • Default user_agent: 'mslm/perl/1.0'
  • Default request timeout: 120 seconds
  • Default http_client: LWP::UserAgent
$mslm = Mslm->new($api_key, (timeout => 180, base_url => "https://example.com"));

The single_verify method of EmailVerify sub-module, can accept an additional option; disable_url_encoding, that can be set to 1 (TRUE), if the email address you are providing is already URL encoded. URL encoding is enabled by default.

my $email_verifier = Mslm::EmailVerify->new($api_key);
my $sv_details = $mslm->email_verify->single_verify('[email protected]', (disable_url_encoding => '1'));

Methods set_base_url, set_http_client, set_user_agent, and set_api_key can also be used for configuration.

$mslm = Mslm->new($api_key);
$mslm->set_api_key("YOUR_NEW_API_KEY");

Additional Resources

See the official API Reference Documentation for details on each API's actual interface, which is implemented by this SDK.

Contributing

See CONTRIBUTING for more information.

Security

See Security Issue Notifications for more information.

License

This project is licensed under the MIT License.

About Mslm

At Mslm, we're all about making things better. Where others see norm, we see opportunity.

We build world-class solutions to the toughest problems. Excellence is a core value that defines our approach from top to bottom.

We're all about creating positive value for ourselves, our partners and our societies.

We do it by focusing on quality and the long-term, while intelligently maneuvering the complex realities of day-to-day business.

Our partners share our perspective, and we jointly produce truly world-class solutions to the toughest problems.

image

sdk-perl's People

Contributors

abu-usama avatar umanshahzad avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.