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 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.



380
381
382
# File 'lib/google4r/checkout/shared.rb', line 380

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)



359
360
361
# File 'lib/google4r/checkout/shared.rb', line 359

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



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

def display_disposition
  @display_disposition
end

#email_deliveryObject

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



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

def email_delivery
  @email_delivery
end

#keyObject

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



375
376
377
# File 'lib/google4r/checkout/shared.rb', line 375

def key
  @key
end

#urlObject

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



378
379
380
# File 'lib/google4r/checkout/shared.rb', line 378

def url
  @url
end

Class Method Details

.create_from_element(element) ⇒ Object

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



385
386
387
388
389
390
391
392
393
# File 'lib/google4r/checkout/shared.rb', line 385

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