nymeria 1.0.0
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/lib/nymeria.rb +117 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0da433cf7627b6ce7836303ebe5ce5e09f60c1557001f133bb0e63bb1c2e3519
|
|
4
|
+
data.tar.gz: c552fdc10fbb0435a3432aaf9449597af12993921100eee3fde8dbe89ba782c1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a5dca76b156fea1b15cd8184ab9d50adcba5b1bc3bbce0185e40b49f5177a1a3d069b49bcf088b9cbc7b5de7326706991aa65e10eeec887c86f619af34e00d18
|
|
7
|
+
data.tar.gz: 0f389958290b388d7d9653d5ea95912b1f7ac1e8641bc4430cf6bff591b5f819eae7e9e48127154341d5a508c4d286499ab62f7c893edc6a0ffc48eb35854554
|
data/lib/nymeria.rb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
|
|
6
|
+
BASE_URL = 'https://www.nymeria.io/api/v3'
|
|
7
|
+
USER_AGENT = 'nymeria.rb/1.0'
|
|
8
|
+
|
|
9
|
+
# Nymeria is our primary module namespace.
|
|
10
|
+
module Nymeria
|
|
11
|
+
class << self
|
|
12
|
+
attr_accessor :api_key
|
|
13
|
+
|
|
14
|
+
def request(req)
|
|
15
|
+
req['Content-Type'] = 'application/json'
|
|
16
|
+
req['X-Api-Key'] = api_key
|
|
17
|
+
req['User-Agent'] = USER_AGENT
|
|
18
|
+
req
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.check_authentication
|
|
23
|
+
uri = URI("#{BASE_URL}/check-authentication")
|
|
24
|
+
req = request(Net::HTTP::Post.new(uri))
|
|
25
|
+
|
|
26
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
27
|
+
http.request(req)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
response = JSON.parse(res.body)
|
|
31
|
+
|
|
32
|
+
# Use an open struct here?
|
|
33
|
+
OpenStruct.new(
|
|
34
|
+
success?: response['status'] == 'success',
|
|
35
|
+
error: response['developer_message']
|
|
36
|
+
)
|
|
37
|
+
rescue => e
|
|
38
|
+
OpenStruct.new(
|
|
39
|
+
success?: false,
|
|
40
|
+
error: "#{e}"
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.verify(email)
|
|
45
|
+
uri = URI("#{BASE_URL}/verify")
|
|
46
|
+
req = request(Net::HTTP::Post.new(uri))
|
|
47
|
+
req.body = JSON.dump({ email: email })
|
|
48
|
+
|
|
49
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
50
|
+
http.request(req)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
response = JSON.parse(res.body)
|
|
54
|
+
|
|
55
|
+
# Use an open struct here?
|
|
56
|
+
OpenStruct.new(
|
|
57
|
+
success?: response['status'] == 'success',
|
|
58
|
+
usage: OpenStruct.new(response['usage']),
|
|
59
|
+
data: OpenStruct.new(response['data'])
|
|
60
|
+
)
|
|
61
|
+
rescue => e
|
|
62
|
+
OpenStruct.new(
|
|
63
|
+
success?: false,
|
|
64
|
+
error: "#{e}"
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.enrich(url, identifier = '')
|
|
69
|
+
uri = URI("#{BASE_URL}/enrich")
|
|
70
|
+
req = request(Net::HTTP::Post.new(uri))
|
|
71
|
+
req.body = JSON.dump({ url: url, identifier: identifier })
|
|
72
|
+
|
|
73
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
74
|
+
http.request(req)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
response = JSON.parse(res.body)
|
|
78
|
+
|
|
79
|
+
# Use an open struct here?
|
|
80
|
+
OpenStruct.new(
|
|
81
|
+
success?: response['status'] == 'success',
|
|
82
|
+
usage: OpenStruct.new(response['usage']),
|
|
83
|
+
data: OpenStruct.new(response['data'])
|
|
84
|
+
)
|
|
85
|
+
rescue => e
|
|
86
|
+
OpenStruct.new(
|
|
87
|
+
success?: false,
|
|
88
|
+
error: "#{e}"
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def self.bulk_enrich(people)
|
|
93
|
+
people = [people] unless people.is_a?(Array)
|
|
94
|
+
|
|
95
|
+
uri = URI("#{BASE_URL}/bulk-enrich")
|
|
96
|
+
req = request(Net::HTTP::Post.new(uri))
|
|
97
|
+
req.body = JSON.dump({ people: people })
|
|
98
|
+
|
|
99
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
100
|
+
http.request(req)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
response = JSON.parse(res.body)
|
|
104
|
+
|
|
105
|
+
# Use an open struct here?
|
|
106
|
+
OpenStruct.new(
|
|
107
|
+
success?: response['status'] == 'success',
|
|
108
|
+
usage: OpenStruct.new(response['usage']),
|
|
109
|
+
data: response.fetch('data', []).map { |data| OpenStruct.new(data) }
|
|
110
|
+
)
|
|
111
|
+
rescue => e
|
|
112
|
+
OpenStruct.new(
|
|
113
|
+
success?: false,
|
|
114
|
+
error: "#{e}"
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nymeria
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nymeria, LLC
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Nymeria enables people to easily discover and connect with people. This
|
|
14
|
+
gem is a light weight wrapper around Nymeria's API. With this gem you can easily
|
|
15
|
+
interact with the API to find and verify people's contact information.
|
|
16
|
+
email: rubygems@nymeria.io
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- lib/nymeria.rb
|
|
22
|
+
homepage: https://www.nymeria.io
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubygems_version: 3.1.4
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Easily interact with Nymeria's API to find and verify people's contact information.
|
|
45
|
+
test_files: []
|