Class: NoradBeacon::HttpPayload
- Inherits:
-
Object
- Object
- NoradBeacon::HttpPayload
- Defined in:
- lib/norad_beacon/http_payload.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #add(obj) ⇒ Object
- #compute_signature ⇒ Object
-
#initialize(url = nil) ⇒ HttpPayload
constructor
A new instance of HttpPayload.
- #payload ⇒ Object
Constructor Details
#initialize(url = nil) ⇒ HttpPayload
Returns a new instance of HttpPayload.
10 11 12 13 |
# File 'lib/norad_beacon/http_payload.rb', line 10 def initialize(url = nil) @data = {} @url = url || url_from_env end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/norad_beacon/http_payload.rb', line 8 def url @url end |
Instance Method Details
#add(obj) ⇒ Object
15 16 17 |
# File 'lib/norad_beacon/http_payload.rb', line 15 def add(obj) @data.merge!(obj.to_h) end |
#compute_signature ⇒ Object
23 24 25 |
# File 'lib/norad_beacon/http_payload.rb', line 23 def compute_signature OpenSSL::HMAC.hexdigest('sha256', ENV['NORAD_SECRET'], payload) end |
#payload ⇒ Object
19 20 21 |
# File 'lib/norad_beacon/http_payload.rb', line 19 def payload @payload ||= @data.merge(timestamp: Time.now.to_i).to_json end |