securitytrails 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/securitytrails/client.rb +3 -2
- data/lib/securitytrails/response.rb +16 -1
- data/lib/securitytrails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44c325c548c7440852f81371215d2ed0c924138a6079d163a59b96a420cbf922
|
4
|
+
data.tar.gz: a5a154295f36ad0d411e3633eac96142d3066e11d2fd42282c76eb96602db42e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b2efa2c2f0e254f5b5736b7a2d96b0edbbaf20faceba31d289ae0675030e1e32855c40f1bc0c2787ce68e1517f4ad03d00ad2324a084f4bdb2af80ba496b344
|
7
|
+
data.tar.gz: b4707d84034420dc820d4a0cd9762d004187a133853bda53aa54b51e044c8033315112d9dee3a68a86b979acc3d1e3eb5a34c1f51f212000545f483db8b673da
|
@@ -10,6 +10,7 @@ module SecurityTrails
|
|
10
10
|
HOST = "api.securitytrails.com"
|
11
11
|
VERSION = 1
|
12
12
|
URL = "https://#{HOST}/v#{VERSION}"
|
13
|
+
API_KEY_HEADER = "apikey"
|
13
14
|
|
14
15
|
def initialize(api_key)
|
15
16
|
@api_key = api_key
|
@@ -48,19 +49,19 @@ module SecurityTrails
|
|
48
49
|
|
49
50
|
def get(path, params = {}, &block)
|
50
51
|
url = url_for(path)
|
51
|
-
params["apikey"] = api_key
|
52
52
|
url.query = URI.encode_www_form(params)
|
53
53
|
|
54
54
|
get = Net::HTTP::Get.new(url)
|
55
|
+
get.add_field(API_KEY_HEADER, api_key)
|
55
56
|
request(get, &block)
|
56
57
|
end
|
57
58
|
|
58
59
|
def post(path, params = {}, &block)
|
59
60
|
url = url_for(path)
|
60
|
-
url.query = "apikey=#{api_key}"
|
61
61
|
|
62
62
|
post = Net::HTTP::Post.new(url)
|
63
63
|
post.body = params.is_a?(Hash) ? params.to_json : params.to_s
|
64
|
+
post.add_field(API_KEY_HEADER, api_key)
|
64
65
|
request(post, &block)
|
65
66
|
end
|
66
67
|
end
|
@@ -3,5 +3,20 @@
|
|
3
3
|
require "ostruct"
|
4
4
|
|
5
5
|
module SecurityTrails
|
6
|
-
class Response < OpenStruct
|
6
|
+
class Response < OpenStruct
|
7
|
+
def openstruct_to_hash(object, hash = {})
|
8
|
+
object.each_pair do |key, value|
|
9
|
+
hash[key] = case value
|
10
|
+
when OpenStruct then openstruct_to_hash(value)
|
11
|
+
when Array then value.map { |v| openstruct_to_hash(v) }
|
12
|
+
else value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_h
|
19
|
+
openstruct_to_hash(self)
|
20
|
+
end
|
21
|
+
end
|
7
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: securitytrails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|