Class: CloudApp::GiftCard
Overview
An ActiveResource-like interface through which to interract with CloudApp gift cards.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#effective_at ⇒ Object
readonly
Returns the value of attribute effective_at.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#months ⇒ Object
readonly
Returns the value of attribute months.
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
-
#redeemed_at ⇒ Object
readonly
Returns the value of attribute redeemed_at.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Attributes inherited from Base
Class Method Summary collapse
-
.find(code) ⇒ CloudApp::GiftCard
Get the details of an unredeemed gift card.
-
.redeem(code) ⇒ CloudApp::GiftCard
Apply a gift card to the authenticated account.
Instance Method Summary collapse
-
#redeem ⇒ CloudApp::GiftCard
Apply the gift card to the authenticated account.
Methods inherited from Base
authenticate, bad_response, #initialize
Constructor Details
This class inherits a constructor from CloudApp::Base
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def code @code end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def created_at @created_at end |
#effective_at ⇒ Object (readonly)
Returns the value of attribute effective_at.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def effective_at @effective_at end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def expires_at @expires_at end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def href @href end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def id @id end |
#months ⇒ Object (readonly)
Returns the value of attribute months.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def months @months end |
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def plan @plan end |
#redeemed_at ⇒ Object (readonly)
Returns the value of attribute redeemed_at.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def redeemed_at @redeemed_at end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
42 43 44 |
# File 'lib/cloudapp/gift_card.rb', line 42 def updated_at @updated_at end |
Class Method Details
.find(code) ⇒ CloudApp::GiftCard
Get the details of an unredeemed gift card.
Requires authentication.
26 27 28 29 |
# File 'lib/cloudapp/gift_card.rb', line 26 def self.find(code) res = get "/gift_cards/#{code}", :digest_auth => @@auth res.ok? ? GiftCard.new(res) : bad_response(res) end |
.redeem(code) ⇒ CloudApp::GiftCard
Apply a gift card to the authenticated account.
Requires authentication.
37 38 39 40 |
# File 'lib/cloudapp/gift_card.rb', line 37 def self.redeem(code) res = put "/gift_cards/#{code}", {:body => {}, :digest_auth => @@auth} res.ok? ? GiftCard.new(res) : bad_response(res) end |
Instance Method Details
#redeem ⇒ CloudApp::GiftCard
Apply the gift card to the authenticated account.
48 49 50 |
# File 'lib/cloudapp/gift_card.rb', line 48 def redeem self.class.redeem code end |