Class: AppleNews::Security
- Inherits:
-
Object
- Object
- AppleNews::Security
- Defined in:
- lib/apple-news/security.rb
Instance Attribute Summary collapse
-
#content_body ⇒ Object
Returns the value of attribute content_body.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#method ⇒ Object
Returns the value of attribute method.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #authorization ⇒ Object
-
#initialize(method, url, config = AppleNews.config) ⇒ Security
constructor
A new instance of Security.
Constructor Details
#initialize(method, url, config = AppleNews.config) ⇒ Security
Returns a new instance of Security.
8 9 10 11 12 13 14 15 |
# File 'lib/apple-news/security.rb', line 8 def initialize(method, url, config = AppleNews.config) @method = method.upcase @url = url @config = config @date = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ") @content_type = nil @content_body = nil end |
Instance Attribute Details
#content_body ⇒ Object
Returns the value of attribute content_body.
6 7 8 |
# File 'lib/apple-news/security.rb', line 6 def content_body @content_body end |
#content_type ⇒ Object
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/apple-news/security.rb', line 6 def content_type @content_type end |
#method ⇒ Object
Returns the value of attribute method.
6 7 8 |
# File 'lib/apple-news/security.rb', line 6 def method @method end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/apple-news/security.rb', line 6 def url @url end |
Instance Method Details
#authorization ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/apple-news/security.rb', line 17 def if @method == 'POST' && (@content_type.nil? || @content_body.nil?) raise "POST requests require the content type and body to be included in the signature generation" end "HHMAC; key=#{@config.api_key_id}; signature=#{signature}; date=#{@date}" end |