Class: Cantook::SaleOfAPublication
- Defined in:
- lib/cantook/sale_of_a_publication.rb
Instance Attribute Summary collapse
-
#aggregator ⇒ Object
TEST BOOKS Title: test-1.
-
#cost ⇒ Object
TEST BOOKS Title: test-1.
-
#country ⇒ Object
TEST BOOKS Title: test-1.
-
#credit_card_prefix ⇒ Object
TEST BOOKS Title: test-1.
-
#customer_id ⇒ Object
TEST BOOKS Title: test-1.
-
#protection ⇒ Object
TEST BOOKS Title: test-1.
-
#sale_state ⇒ Object
TEST BOOKS Title: test-1.
-
#transaction_id ⇒ Object
TEST BOOKS Title: test-1.
-
#uname ⇒ Object
TEST BOOKS Title: test-1.
Attributes inherited from Base
#auth, #base_url, #currency, #format, #isbn, #organisation_id, #password, #platform, #query, #response, #username
Instance Method Summary collapse
-
#request_url ⇒ String
The full url required for this request.
-
#sale_of_a_publication(params) ⇒ True, False
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’ } sale_hash = { cost: ‘999’, customer_id: ‘123’, transaction_id: ‘abc’, protection: ‘acs4’ } cantook = Cantook::SaleOfAPublication.new(base_hash) if cantook.sale_of_a_publication(sale_hash) puts “mais oui” else puts “mais non” end.
Methods inherited from Base
#initialize, #response_code, #response_hash
Constructor Details
This class inherits a constructor from Cantook::Base
Instance Attribute Details
#aggregator ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def aggregator @aggregator end |
#cost ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def cost @cost end |
#country ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def country @country end |
#credit_card_prefix ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def credit_card_prefix @credit_card_prefix end |
#customer_id ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def customer_id @customer_id end |
#protection ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def protection @protection end |
#sale_state ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def sale_state @sale_state end |
#transaction_id ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def transaction_id @transaction_id end |
#uname ⇒ Object
TEST BOOKS Title: test-1. PDF format: 9990000000001 ePub format: 9991000000001 protection: watermark (“protection=watermark”) cost: $0, 0 euro (“cost=0”) Title: test-2. PDF format: 9990000000002 ePub format: 9991000000002 protection: ACS4 (“protection=acs4”) cost: $1.00, 1.00 euro (“cost=100”) Title: test-3. PDF format: 9990000000003 ePub format: 9991000000003 protection : ACS4 (“protection=acs4”) cost: $0, 0 euro (“cost=0”)
49 50 51 |
# File 'lib/cantook/sale_of_a_publication.rb', line 49 def uname @uname end |
Instance Method Details
#request_url ⇒ String
Returns The full url required for this request.
92 93 94 |
# File 'lib/cantook/sale_of_a_publication.rb', line 92 def request_url base_url + "/publications/#{isbn}/sales" end |
#sale_of_a_publication(params) ⇒ True, False
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’ } sale_hash = { cost: ‘999’, customer_id: ‘123’, transaction_id: ‘abc’, protection: ‘acs4’ } cantook = Cantook::SaleOfAPublication.new(base_hash) if cantook.sale_of_a_publication(sale_hash)
puts "mais oui"
else
puts "mais non"
end
76 77 78 79 80 81 82 83 |
# File 'lib/cantook/sale_of_a_publication.rb', line 76 def sale_of_a_publication(params) self.cost = params[:cost] self.protection = params[:protection] self.customer_id = params[:customer_id] self.transaction_id = params[:transaction_id] do_request response.code == 201 end |