mslm 1.1.1 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41b686bbd85c4ce37661def8101efae9671d96be609a718b37327697a451170c
4
- data.tar.gz: 52248f56276e5a739508f3821beccfe24fc30417ce3204d9746b7cde9e0da0b1
3
+ metadata.gz: ef29e7107da0fc04c7853ede27bb2a9ddd1c5dfb31cb9551a00844f0dfa0f702
4
+ data.tar.gz: 7cdccfd1a89b0d6f6031eb1175c2c3b5f088ea64ac55985a7ab1f635039c413b
5
5
  SHA512:
6
- metadata.gz: '099a57333a62f81e0b4e9b584d70bbc9a1e70d80c07eea7fd0eecf252e4e9bf973716271c830c3206b4f1dcec16c64f5fdcec2a05f024dc5ef813ae796cb9154'
7
- data.tar.gz: 6f25385e96fcda51408c7928c72fa8f073a3976b534b250475db63642b1ba0f79e14bbe24a5d7de434cf7ae85a8cc962eb85fab91866777ea19eb2f176957e66
6
+ metadata.gz: 668881352faa56001656c49981ffa973c3dc00d36c532011fef21eaa6961d6c2a9a1db2628b3eaecc702f35515be9e71b45316dbaa792a4313decc2977efe1c4
7
+ data.tar.gz: 70d04cacb05f8762e2cf1abbfaab5aa21fd9594de3ff196bb0000780517438d31701386cda1b401806d4e9f99e04fa0130ea0df68697f8944d7e09c3293d482b
data/.gitignore ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in mslm.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/README.md CHANGED
@@ -69,7 +69,7 @@ otp_send_req = {
69
69
  otp_send_resp = otp.send_otp(otp_send_req)
70
70
 
71
71
  otp_verify_req = {
72
- "phone" => "+923004242293",
72
+ "phone" => "+921123454456",
73
73
  "token" => "Recieved Token",
74
74
  "consume" => true,
75
75
  }
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "mslm"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "irb"
11
+ 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/lib/mslm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mslm
4
- VERSION = "1.1.1"
4
+ VERSION = "2.1.1"
5
5
  end
data/lib/mslm.rb CHANGED
@@ -1,14 +1,13 @@
1
-
2
- require_relative "mslm/email_verification"
3
- require_relative "mslm/otp"
4
- require_relative "mslm/version"
1
+ require_relative './mslm/email_verify'
2
+ # require_relative './mslm/otp'
5
3
 
6
4
  module Mslm
7
5
  class << self
8
- attr_accessor :api_key
6
+ attr_reader :email_verify, :otp
9
7
 
10
- def init(api_key = nil)
11
- @api_key = api_key
8
+ def initialize(api_key)
9
+ @email_verify = EmailVerify.new(api_key)
10
+ # @otp = Otp.new(api_key)
12
11
  end
13
12
  end
14
13
  end
data/mslm.gemspec CHANGED
@@ -20,10 +20,20 @@ Gem::Specification.new do |spec|
20
20
  spec.metadata["changelog_uri"] = "https://github.com/mslmio/sdk-ruby/blob/main/CHANGELOG.md"
21
21
 
22
22
 
23
+ excluded_files = [
24
+ "lib/mslm/constants/constants.rb",
25
+ "lib/mslm/email_verification.rb",
26
+ "sig/mslm.rbs",
27
+ "test/email_verification_test.rb",
28
+ "CODE_OF_CONDUCT.md"
29
+ ]
30
+
31
+
23
32
  spec.files = Dir.chdir(__dir__) do
24
33
  `git ls-files -z`.split("\x0").reject do |f|
25
34
  (File.expand_path(f) == __FILE__) ||
26
35
  f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
36
+ excluded_files.include?(f)
27
37
  end
28
38
  end
29
39
  spec.bindir = "exe"
@@ -0,0 +1,40 @@
1
+
2
+
3
+ require 'minitest/autorun'
4
+ require_relative '../lib/mslm/otp'
5
+
6
+ class OtpTest < Minitest::Test
7
+ def setup
8
+ @otp= Mslm::Otp::Otp_send_verify.new
9
+
10
+ end
11
+
12
+ def test_valid_otp_send
13
+ c = Mslm.init("YOUR_API_KEY")
14
+ expected_response = {
15
+ "code" => 1000,
16
+ "msg"=> "Successfully sent SMS."
17
+ }
18
+ phone_number = "+92334455112"
19
+ otp_send_req = {
20
+ "phone" => phone_number,
21
+ "tmpl_sms" => "Your verification code is {112233}",
22
+ "token_len" => 6,
23
+ "expire_seconds" => 300
24
+ }
25
+ response = @otp.send_otp(otp_send_req)
26
+ assert_equal expected_response, response
27
+ end
28
+
29
+ def test_valid_otp_verification
30
+ phone_number = "+92334455112"
31
+ otp_verify_req = {
32
+ "phone" => phone_number,
33
+ "token" => "123456", # Replace with actual OTP received
34
+ "consume" => true
35
+ }
36
+ response = @otp.verify(otp_verify_req)
37
+ assert_equal "expected_response", response
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mslm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sahal Abdullah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RubyGem offering email verification and OTP (One-Time Password) generation
14
14
  and verification capabilities. Seamlessly integrate email verification and OTP functionality
@@ -19,19 +19,20 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - ".gitignore"
22
23
  - CHANGELOG.md
23
- - CODE_OF_CONDUCT.md
24
24
  - CONTRIBUTING.md
25
+ - Gemfile
25
26
  - LICENSE
26
27
  - README.md
27
28
  - Rakefile
29
+ - bin/console
30
+ - bin/setup
28
31
  - lib/mslm.rb
29
- - lib/mslm/constants/constants.rb
30
- - lib/mslm/email_verification.rb
31
32
  - lib/mslm/otp.rb
32
33
  - lib/mslm/version.rb
33
34
  - mslm.gemspec
34
- - sig/mslm.rbs
35
+ - test/otp_verification_test.rb
35
36
  homepage: https://github.com/mslmio/sdk-ruby
36
37
  licenses:
37
38
  - MIT
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sahalzai111@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
@@ -1,48 +0,0 @@
1
-
2
- require 'uri'
3
- require 'net/http'
4
- require 'json'
5
-
6
- module Mslm
7
- module Constants
8
- BASE_URL = 'https://mslm.io/'.freeze
9
-
10
- def self.prepare_url(path, query_params, opts)
11
- url = path.dup
12
- url << '?' << URI.encode_www_form(query_params) unless query_params.empty?
13
- url
14
- end
15
-
16
- def self.req_and_resp(_method, _url, _data, _opts)
17
- uri = URI.parse(_url)
18
- http = Net::HTTP.new(uri.host, uri.port)
19
- http.use_ssl = true if uri.scheme == 'https'
20
-
21
- if _method == 'POST'
22
- request = Net::HTTP::Post.new(uri.request_uri)
23
- request.body = _data.to_json
24
- request.content_type = 'application/json'
25
- elsif _method == 'GET'
26
- request = Net::HTTP::Get.new(uri.request_uri)
27
-
28
- else
29
- return "Unsupported HTTP method: #{_method}"
30
- end
31
-
32
- response_data = http.request(request)
33
-
34
- if _method == 'POST' and response_data.code.to_i == 200
35
- json_response = JSON.parse(response_data.body)
36
- return json_response
37
-
38
- elsif response_data.code.to_i == 200
39
- json_response = JSON.parse(response_data.body)
40
- response = [json_response["email"],json_response["username"],json_response["domain"],json_response["malformed"],json_response["suggestion"],json_response["status"],json_response["has_mailbox"],json_response["accept_all"],json_response["disposable"],json_response["free"],json_response["role"],json_response['mx']]
41
-
42
- return response
43
- else
44
- return "HTTP #{response_data.code}: #{response_data.message}"
45
- end
46
- end
47
- end
48
- end
@@ -1,36 +0,0 @@
1
-
2
- require_relative '../mslm'
3
- require_relative './constants/constants'
4
-
5
- module Mslm
6
- module EmailVerification
7
- include Constants
8
-
9
- class SingleVerifyReqOpts
10
- attr_accessor :disable_url_encode
11
- attr_accessor :api_key
12
- end
13
- class SingleVerifyEmail
14
-
15
- def single_verify(email_addr, opts = nil)
16
- opt = SingleVerifyReqOpts.new
17
- opt = opts.last unless opts.nil? || opts.empty?
18
- opt.disable_url_encode = true if opt.disable_url_encode.nil?
19
-
20
- email_addr = URI.encode_www_form_component(email_addr) unless opt.disable_url_encode
21
-
22
- qp = { 'email' => email_addr }
23
- if Mslm.api_key || opt.api_key
24
- api_key = opt.api_key || Mslm.api_key
25
- qp['apikey'] = api_key
26
- end
27
-
28
- t_url = Mslm::Constants.prepare_url(Mslm::EmailVerification::BASE_URL + 'api/sv/v1', qp, opt)
29
-
30
-
31
- sv_resp = Mslm::Constants.req_and_resp('GET', t_url, nil, opt)
32
- return sv_resp
33
- end
34
- end
35
- end
36
- end
data/sig/mslm.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Mslm
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end