nymeria 1.0.0 → 2.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 +4 -4
- data/lib/nymeria.rb +85 -42
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 831385d14e60144b9cbbb1dd31f6f024d6d4b5f326c222846b9f467a8da65bef
|
|
4
|
+
data.tar.gz: 4931a2288cc5bd690472cbb12c55ef108b18a54024206a846569f4b1b592efa2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c95a242aa3b1e2bf0c140b1c8119e21667eff9557b56a50a1ef6e5de39192b36a2dbbff865715f6044fd0da0d0f6fdf1de1149d896c4f648ba923bf673b069f
|
|
7
|
+
data.tar.gz: e30815b814a66486ddcc2fb895c0c68f90bc6b269d695ff611a65f66deac35dcc1b8572ad4d030dd8d7738e7cd4c151644de27adc3216a4f15ab2ed33211e884
|
data/lib/nymeria.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'json'
|
|
|
4
4
|
require 'net/http'
|
|
5
5
|
|
|
6
6
|
BASE_URL = 'https://www.nymeria.io/api/v3'
|
|
7
|
-
USER_AGENT = 'nymeria.rb/
|
|
7
|
+
USER_AGENT = 'nymeria.rb/2.0'
|
|
8
8
|
|
|
9
9
|
# Nymeria is our primary module namespace.
|
|
10
10
|
module Nymeria
|
|
@@ -19,6 +19,10 @@ module Nymeria
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def self.authenticated?
|
|
23
|
+
self.check_authentication.success?
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
def self.check_authentication
|
|
23
27
|
uri = URI("#{BASE_URL}/check-authentication")
|
|
24
28
|
req = request(Net::HTTP::Post.new(uri))
|
|
@@ -65,53 +69,92 @@ module Nymeria
|
|
|
65
69
|
)
|
|
66
70
|
end
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
# Accepts one or more hashes with any of the following: { url: '', identifier: '', email: '', custom: { ... } }
|
|
73
|
+
def self.enrich(*args)
|
|
74
|
+
if args.nil? || !args.is_a?(Array)
|
|
75
|
+
return OpenStruct.new(
|
|
76
|
+
success?: false,
|
|
77
|
+
error: "Invalid parameter detected. Requires one or more hashes with any of the following keys; :url, ;identifier or :email."
|
|
78
|
+
)
|
|
75
79
|
end
|
|
76
80
|
|
|
77
|
-
|
|
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)
|
|
81
|
+
valid_keys = [:url, :identifier, :email, :custom]
|
|
94
82
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
valid_args = args.select do |arg|
|
|
84
|
+
arg.is_a?(Hash) && valid_keys.any? { |k| arg.keys.include?(k) }
|
|
85
|
+
end
|
|
98
86
|
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
if valid_args.length == 0
|
|
88
|
+
return OpenStruct.new(
|
|
89
|
+
success?: false,
|
|
90
|
+
error: "Invalid parameter detected. Requires one or more hashes with any of the following keys; :url, ;identifier or :email."
|
|
91
|
+
)
|
|
101
92
|
end
|
|
102
93
|
|
|
103
|
-
|
|
94
|
+
# Clean the args; remove any unsupported keys.
|
|
95
|
+
valid_args.each do |arg|
|
|
96
|
+
arg.keys.each do |key|
|
|
97
|
+
arg.delete(key) unless valid_keys.include?(key)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
104
100
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
if valid_args.length == 1
|
|
102
|
+
#
|
|
103
|
+
# Single Enrichment
|
|
104
|
+
#
|
|
105
|
+
begin
|
|
106
|
+
arg = valid_args.first
|
|
107
|
+
|
|
108
|
+
uri = URI("#{BASE_URL}/enrich")
|
|
109
|
+
req = request(Net::HTTP::Post.new(uri))
|
|
110
|
+
req.body = JSON.dump(arg)
|
|
111
|
+
|
|
112
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
113
|
+
http.request(req)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
response = JSON.parse(res.body)
|
|
117
|
+
|
|
118
|
+
return OpenStruct.new(
|
|
119
|
+
success?: response['status'] == 'success',
|
|
120
|
+
error: response['error'],
|
|
121
|
+
usage: OpenStruct.new(response['usage']),
|
|
122
|
+
data: OpenStruct.new(response['data'])
|
|
123
|
+
)
|
|
124
|
+
rescue => e
|
|
125
|
+
return OpenStruct.new(
|
|
126
|
+
success?: false,
|
|
127
|
+
error: "#{e}"
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
else
|
|
131
|
+
#
|
|
132
|
+
# Bulk Enrichment
|
|
133
|
+
#
|
|
134
|
+
begin
|
|
135
|
+
uri = URI("#{BASE_URL}/bulk-enrich")
|
|
136
|
+
req = request(Net::HTTP::Post.new(uri))
|
|
137
|
+
req.body = JSON.dump({ people: args })
|
|
138
|
+
|
|
139
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
140
|
+
http.request(req)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
response = JSON.parse(res.body)
|
|
144
|
+
|
|
145
|
+
# Use an open struct here?
|
|
146
|
+
OpenStruct.new(
|
|
147
|
+
success?: response['status'] == 'success',
|
|
148
|
+
error: response['error'],
|
|
149
|
+
usage: OpenStruct.new(response['usage']),
|
|
150
|
+
data: response.fetch('data', []).map { |data| OpenStruct.new(data) }
|
|
151
|
+
)
|
|
152
|
+
rescue => e
|
|
153
|
+
OpenStruct.new(
|
|
154
|
+
success?: false,
|
|
155
|
+
error: "#{e}"
|
|
156
|
+
)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
116
159
|
end
|
|
117
160
|
end
|
metadata
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nymeria
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nymeria, LLC
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Nymeria enables people to easily discover and connect with people. This
|
|
14
14
|
gem is a light weight wrapper around Nymeria's API. With this gem you can easily
|
|
15
15
|
interact with the API to find and verify people's contact information.
|
|
16
|
-
email:
|
|
16
|
+
email: dev@nymeria.io
|
|
17
17
|
executables: []
|
|
18
18
|
extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
|
@@ -23,7 +23,7 @@ homepage: https://www.nymeria.io
|
|
|
23
23
|
licenses:
|
|
24
24
|
- MIT
|
|
25
25
|
metadata: {}
|
|
26
|
-
post_install_message:
|
|
26
|
+
post_install_message:
|
|
27
27
|
rdoc_options: []
|
|
28
28
|
require_paths:
|
|
29
29
|
- lib
|
|
@@ -38,8 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0'
|
|
40
40
|
requirements: []
|
|
41
|
-
rubygems_version: 3.
|
|
42
|
-
signing_key:
|
|
41
|
+
rubygems_version: 3.2.26
|
|
42
|
+
signing_key:
|
|
43
43
|
specification_version: 4
|
|
44
44
|
summary: Easily interact with Nymeria's API to find and verify people's contact information.
|
|
45
45
|
test_files: []
|