Class: Ccs::Downloader
- Inherits:
-
Object
- Object
- Ccs::Downloader
- Defined in:
- lib/ccs/downloader.rb
Overview
Downloads and decrypts the document at given URI with given access token. Decryption occurs using given passphrase.
Instance Method Summary collapse
-
#call ⇒ String|nil
Performs the download and decryption of document.
-
#initialize(uri, access_token, passphrase) ⇒ Downloader
constructor
Constructs a Downloader instance from a given URI, access token and passphrase.
Constructor Details
#initialize(uri, access_token, passphrase) ⇒ Downloader
Constructs a Downloader instance from a given URI, access token and passphrase.
19 20 21 22 23 |
# File 'lib/ccs/downloader.rb', line 19 def initialize(uri, access_token, passphrase) @uri = uri @access_token = access_token @passphrase = passphrase end |
Instance Method Details
#call ⇒ String|nil
Performs the download and decryption of document.
29 30 31 32 33 34 35 36 |
# File 'lib/ccs/downloader.rb', line 29 def call response = http.request(request) body = response.body return unless response.code.eql? '200' json = JSON.parse body Decrypter.new(@passphrase, json['encrypted_content']).call end |