Class: Google4R::Checkout::Item::DigitalContent

Inherits:
Object
  • Object
show all
Defined in:
lib/google4r/checkout/shared.rb

Overview

A DigitalContent item represents the information relating to online delivery of digital items

You should never initialize it directly but use Item#digital_content instead

See http://code.google.com/apis/checkout/developer/Google_Checkout_Digital_Delivery.html for information on Google Checkout's idea of digital content.

item.digital_content do |dc|
dc.optimistic!
dc.description = %{Here's some information on how to get your content}
end

Constant Summary collapse

OPTIMISTIC =

Constants for display-disposition

'OPTIMISTIC'
PESSIMISTIC =
'PESSIMISTIC'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDigitalContent

Returns a new instance of DigitalContent.



373
374
375
# File 'lib/google4r/checkout/shared.rb', line 373

def initialize
  @display_disposition = PESSIMISTIC
end

Instance Attribute Details

#descriptionObject

A description of how the user should access the digital content after completing the order (string, required for description-based delivery, otherwise optional)



352
353
354
# File 'lib/google4r/checkout/shared.rb', line 352

def description
  @description
end

#display_dispositionObject

Either 'OPTIMISTIC' or 'PESSIMISTIC'. If OPTIMISTIC, then Google will display instructions for accessing the digital content as soon as the buyer confirms the order. Optional, but default is PESSIMISTIC



357
358
359
# File 'lib/google4r/checkout/shared.rb', line 357

def display_disposition
  @display_disposition
end

#email_deliveryObject

A boolean identifying whether email delivery is used for this item.



365
366
367
# File 'lib/google4r/checkout/shared.rb', line 365

def email_delivery
  @email_delivery
end

#keyObject

A key required by the user to access this digital content after completing the order (string, optional)



368
369
370
# File 'lib/google4r/checkout/shared.rb', line 368

def key
  @key
end

#urlObject

A URL required by the user to access this digital content after completing the order (string, optional)



371
372
373
# File 'lib/google4r/checkout/shared.rb', line 371

def url
  @url
end

Class Method Details

.create_from_element(element) ⇒ Object

Creates a new DigitalContent object from a REXML::Element object



378
379
380
381
382
383
384
385
386
# File 'lib/google4r/checkout/shared.rb', line 378

def self.create_from_element(element)
  result = DigitalContent.new
  result.description = element.elements['description'].text rescue nil
  result.display_disposition = element.elements['display-disposition'].text rescue nil
  result.email_delivery = element.elements['email-delivery'].text rescue nil # TODO need to convert to boolean?
  result.key = element.elements['key'].text rescue nil
  result.url = element.elements['url'].text rescue nil
  return result
end