velnod 0.1.3
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +8 -0
- data/lib/velnod/client.rb +57 -0
- data/lib/velnod/configuration.rb +26 -0
- data/lib/velnod/resources/check.rb +20 -0
- data/lib/velnod/version.rb +5 -0
- data/lib/velnod.rb +20 -0
- data/sig/velnod.rbs +4 -0
- data/velnod-0.1.0.gem +0 -0
- data/velnod-0.1.1.gem +0 -0
- data/velnod-0.1.2.gem +0 -0
- metadata +55 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 21680c98a0d0c31c80dd38da08e11ff1acaa5d86a037732bdc05014c750f177c
|
|
4
|
+
data.tar.gz: '0910b1ab17541b6a4787cdcfc1f81ed7ea2b3f7b1da9a6a9842e0510352c331d'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ea507b75a94f11687bc995f8a394250d472aff14864b8e7835e0b60ff9ef4d34fb83eb81f1fc33c3b75be0dcba01b1ea4bd55e67cb8c245ae590fcdfe3dcc52e
|
|
7
|
+
data.tar.gz: eeff55d5490f400d293de578909b6173c36a9f19ac451551d479e03622514929dc4bf5bf1c0d4af2c4941c9df390460d222621949abfb23340ee57c659bc84ad
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Samuenti
|
|
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,50 @@
|
|
|
1
|
+
# Velnod
|
|
2
|
+
|
|
3
|
+
Ruby client for the Velnod API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bundle add velnod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or add to your Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem "velnod"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
Set your API key as an environment variable:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
VELNOD_API_KEY=your_api_key
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
# Check an email
|
|
29
|
+
Velnod.check(email: "user@example.com")
|
|
30
|
+
|
|
31
|
+
# Check a domain
|
|
32
|
+
Velnod.check(domain: "example.com")
|
|
33
|
+
|
|
34
|
+
# Check a name
|
|
35
|
+
Velnod.check(name: "John Doe")
|
|
36
|
+
|
|
37
|
+
# Check multiple at once
|
|
38
|
+
Velnod.check(email: "user@example.com", domain: "example.com", name: "John Doe")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Returns a hash with the results:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
{
|
|
45
|
+
"allow" => true,
|
|
46
|
+
"email" => { "value" => "user@example.com", "risk" => "none" },
|
|
47
|
+
"domain" => { "value" => "example.com", "risk" => "none" }
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module Velnod
|
|
8
|
+
class Client
|
|
9
|
+
attr_reader :base_url, :api_key
|
|
10
|
+
|
|
11
|
+
def initialize(api_key:)
|
|
12
|
+
@base_url = "https://api.velnod.com"
|
|
13
|
+
@api_key = api_key
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def check
|
|
17
|
+
@check ||= Resources::Check.new(self)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def post(path, body = {})
|
|
21
|
+
uri = URI("#{@base_url}#{path}")
|
|
22
|
+
|
|
23
|
+
request = Net::HTTP::Post.new(uri)
|
|
24
|
+
request["Authorization"] = "Bearer #{@api_key}"
|
|
25
|
+
request["Content-Type"] = "application/json"
|
|
26
|
+
request.body = body.to_json
|
|
27
|
+
|
|
28
|
+
make_request(uri, request)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def make_request(uri, request)
|
|
34
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
35
|
+
response = http.request(request)
|
|
36
|
+
handle_response(response)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def handle_response(response)
|
|
41
|
+
case response.code.to_i
|
|
42
|
+
when 200..299
|
|
43
|
+
JSON.parse(response.body) if response.body && !response.body.empty?
|
|
44
|
+
when 400
|
|
45
|
+
raise Error, "Bad request: #{response.body}"
|
|
46
|
+
when 401
|
|
47
|
+
raise Error, "Unauthorized - invalid API key"
|
|
48
|
+
when 429
|
|
49
|
+
raise Error, "API limit reached"
|
|
50
|
+
when 404
|
|
51
|
+
raise Error, "Resource not found"
|
|
52
|
+
else
|
|
53
|
+
raise Error, "Request failed with status #{response.code}: #{response.body}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Velnod
|
|
4
|
+
class Configuration
|
|
5
|
+
attr_accessor :api_key
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@api_key = ENV["VELNOD_API_KEY"]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def configuration
|
|
14
|
+
@configuration ||= Configuration.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def configure
|
|
18
|
+
yield(configuration)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def reset_configuration!
|
|
22
|
+
@configuration = Configuration.new
|
|
23
|
+
@client = nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Velnod
|
|
4
|
+
module Resources
|
|
5
|
+
class Check
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call(email: nil, domain: nil, name: nil)
|
|
11
|
+
body = {}
|
|
12
|
+
body[:email] = email if email
|
|
13
|
+
body[:domain] = domain if domain
|
|
14
|
+
body[:name] = name if name
|
|
15
|
+
|
|
16
|
+
@client.post("/check", body)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/velnod.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "velnod/version"
|
|
4
|
+
require_relative "velnod/configuration"
|
|
5
|
+
require_relative "velnod/client"
|
|
6
|
+
require_relative "velnod/resources/check"
|
|
7
|
+
|
|
8
|
+
module Velnod
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
def client
|
|
13
|
+
@client ||= Client.new(api_key: configuration.api_key)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def check(email: nil, domain: nil, name: nil)
|
|
17
|
+
client.check.call(email: email, domain: domain, name: name)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/sig/velnod.rbs
ADDED
data/velnod-0.1.0.gem
ADDED
|
Binary file
|
data/velnod-0.1.1.gem
ADDED
|
Binary file
|
data/velnod-0.1.2.gem
ADDED
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: velnod
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- samuenti
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Simple Ruby client to check emails, domains, and names against the Velnod
|
|
13
|
+
API
|
|
14
|
+
email:
|
|
15
|
+
- development@samuenti.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- LICENSE.txt
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- lib/velnod.rb
|
|
24
|
+
- lib/velnod/client.rb
|
|
25
|
+
- lib/velnod/configuration.rb
|
|
26
|
+
- lib/velnod/resources/check.rb
|
|
27
|
+
- lib/velnod/version.rb
|
|
28
|
+
- sig/velnod.rbs
|
|
29
|
+
- velnod-0.1.0.gem
|
|
30
|
+
- velnod-0.1.1.gem
|
|
31
|
+
- velnod-0.1.2.gem
|
|
32
|
+
homepage: https://velnod.com
|
|
33
|
+
licenses:
|
|
34
|
+
- MIT
|
|
35
|
+
metadata:
|
|
36
|
+
allowed_push_host: https://rubygems.org
|
|
37
|
+
homepage_uri: https://velnod.com
|
|
38
|
+
rdoc_options: []
|
|
39
|
+
require_paths:
|
|
40
|
+
- lib
|
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 3.2.0
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
requirements: []
|
|
52
|
+
rubygems_version: 3.6.9
|
|
53
|
+
specification_version: 4
|
|
54
|
+
summary: Ruby client for the Velnod API
|
|
55
|
+
test_files: []
|