norad_beacon 0.1.5 → 0.1.6
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/norad_beacon/api.rb +28 -7
- data/lib/norad_beacon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99ae90cc58a883071e41492b8446da7d1130a6e0
|
|
4
|
+
data.tar.gz: 8ec70cfcde36e46f8529ef566f41e60d51983402
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47e67ee1bc409641a34b17818c982e605a28b77f258895e4e4de5350c2771b6246a9dcc80ad5c3c88c8fe2c5dc0ea71e774b11fff0f0538f5056a456296e5b8d
|
|
7
|
+
data.tar.gz: a209abe48d4e7114b02dad759413cf520f456a7b769b14b610652d69a769da7069dabe7fa856562fd2c258b1f7f149b3529bb58dfd1d9af5d21d540d4e34fc74
|
data/lib/norad_beacon/api.rb
CHANGED
|
@@ -26,14 +26,35 @@ module NoradBeacon
|
|
|
26
26
|
private
|
|
27
27
|
|
|
28
28
|
def http_req(http_payload, verb)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
httpparty_response = send(verb, @norad_root + http_payload.url, http_req_options(http_payload))
|
|
30
|
+
error_msg = unsuccessful_http_response_msg(httpparty_response)
|
|
31
|
+
puts error_msg if error_msg
|
|
32
|
+
httpparty_response
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def unsuccessful_http_response_msg(httpparty_response)
|
|
36
|
+
code = httpparty_response.response.code
|
|
37
|
+
msg = httpparty_response.response.message
|
|
38
|
+
heading = '[Beacon] Non-200 response received from API:'
|
|
39
|
+
|
|
40
|
+
return nil unless display_http_error?(code, msg)
|
|
41
|
+
return "#{heading} #{code}" if msg.nil? && code
|
|
42
|
+
return "#{heading} #{msg.strip}" if code.nil? && msg
|
|
43
|
+
"#{heading} #{msg.strip}. (#{code})"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def display_http_error?(code, msg)
|
|
47
|
+
code.to_s != '200' && (code || msg)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def http_req_options(http_payload)
|
|
51
|
+
{
|
|
34
52
|
body: http_payload.payload,
|
|
35
|
-
headers: {
|
|
36
|
-
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type' => 'application/json',
|
|
55
|
+
'NORAD-SIGNATURE' => http_payload.compute_signature
|
|
56
|
+
}
|
|
57
|
+
}
|
|
37
58
|
end
|
|
38
59
|
end
|
|
39
60
|
end
|
data/lib/norad_beacon/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: norad_beacon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Blake Hitchcock
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: exe
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2018-01-22 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: httparty
|