Class: Cantook::DownloadAPublication
- Defined in:
- lib/cantook/download_a_publication.rb
Instance Attribute Summary collapse
-
#customer_id ⇒ Object
RESPONSE CODES Code Content Description 200 url Chronodegradable download URL (expires after 1 minute).
-
#transaction_id ⇒ Object
RESPONSE CODES Code Content Description 200 url Chronodegradable download URL (expires after 1 minute).
-
#uname ⇒ Object
RESPONSE CODES Code Content Description 200 url Chronodegradable download URL (expires after 1 minute).
Attributes inherited from Base
#auth, #base_url, #currency, #format, #isbn, #organisation_id, #password, #platform, #query, #response, #sale_state, #username
Instance Method Summary collapse
-
#download_a_publication(params) ⇒ String
Example: base_hash = { username: Settings.cantook.username, password: Settings.cantook.password, platform: Settings.cantook.platform, organisation_id: Settings.cantook.organisation_id, sale_state: Settings.cantook.sale_state, format: ‘epub’, isbn: ‘123456789asdf’ } download_hash = { customer_id: ‘123’, transaction_id: ‘abc’, uname: ‘Foo Bar’ } cantook = Cantook::DownloadAPublication.new(base_hash) download_link = cantook.download_a_publication(download_hash) redirect_to download_link.
-
#request_url ⇒ String
The full url required for this request.
Methods inherited from Base
#initialize, #response_code, #response_hash
Constructor Details
This class inherits a constructor from Cantook::Base
Instance Attribute Details
#customer_id ⇒ Object
RESPONSE CODES Code Content Description 200 url Chronodegradable download URL (expires after 1 minute). Redirect user toward this URL. 400 missing_transaction_id You did not enter a transaction ID. 401 access_denied You do not have access to the resource. 404 not_found Your organisation could not be found.
25 26 27 |
# File 'lib/cantook/download_a_publication.rb', line 25 def customer_id @customer_id end |
#transaction_id ⇒ Object
RESPONSE CODES Code Content Description 200 url Chronodegradable download URL (expires after 1 minute). Redirect user toward this URL. 400 missing_transaction_id You did not enter a transaction ID. 401 access_denied You do not have access to the resource. 404 not_found Your organisation could not be found.
25 26 27 |
# File 'lib/cantook/download_a_publication.rb', line 25 def transaction_id @transaction_id end |
#uname ⇒ Object
RESPONSE CODES Code Content Description 200 url Chronodegradable download URL (expires after 1 minute). Redirect user toward this URL. 400 missing_transaction_id You did not enter a transaction ID. 401 access_denied You do not have access to the resource. 404 not_found Your organisation could not be found.
25 26 27 |
# File 'lib/cantook/download_a_publication.rb', line 25 def uname @uname end |
Instance Method Details
#download_a_publication(params) ⇒ String
Example: base_hash = { username: Settings.cantook.username, password: Settings.cantook.password, platform: Settings.cantook.platform, organisation_id: Settings.cantook.organisation_id, sale_state: Settings.cantook.sale_state, format: ‘epub’, isbn: ‘123456789asdf’ } download_hash = { customer_id: ‘123’, transaction_id: ‘abc’, uname: ‘Foo Bar’ } cantook = Cantook::DownloadAPublication.new(base_hash) download_link = cantook.download_a_publication(download_hash) redirect_to download_link
39 40 41 42 43 44 45 |
# File 'lib/cantook/download_a_publication.rb', line 39 def download_a_publication(params) self.customer_id = params[:customer_id] self.transaction_id = params[:transaction_id] self.uname = params[:uname] do_request response.parsed_response end |
#request_url ⇒ String
Returns The full url required for this request.
54 55 56 |
# File 'lib/cantook/download_a_publication.rb', line 54 def request_url base_url + "/customers/#{customer_id}/transactions/#{transaction_id}/publications/#{isbn}/download_links/#{format}" end |