Class: Agcod::CreateGiftCard
- Includes:
- OptionValidators
- Defined in:
- lib/agcod/create_gift_card.rb
Instance Attribute Summary collapse
-
#claim_code ⇒ Object
readonly
Returns the value of attribute claim_code.
-
#response_id ⇒ Object
readonly
Returns the value of attribute response_id.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Request
#action, #errors, #parameters, #request, #request_id, #response, #sent, #status, #timestamp, #xml_response
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CreateGiftCard
constructor
A new instance of CreateGiftCard.
- #process_response ⇒ Object
- #to_yaml(name) ⇒ Object
Methods included from OptionValidators
Methods inherited from Request
#request_url, #sign_string, #submit, #successful?
Constructor Details
#initialize(options = {}) ⇒ CreateGiftCard
Returns a new instance of CreateGiftCard.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/agcod/create_gift_card.rb', line 5 def initialize( = {}) @action = "CreateGiftCard" super validate_greater_than("value", 0) validate_length_of("request_id", {"max" => 19, "min" => 1}) #can't have a nonexistant or 0 value for the gift card @parameters["gcValue.amount"] = ["value"] @value = ["value"] #must have a unique identifier for the request @parameters["gcCreationRequestId"] = Agcod::Configuration.partner_id + ["request_id"].to_s @parameters["gcValue.currencyCode"] = ["currency_code"] || "USD" end |
Instance Attribute Details
#claim_code ⇒ Object (readonly)
Returns the value of attribute claim_code.
37 38 39 |
# File 'lib/agcod/create_gift_card.rb', line 37 def claim_code @claim_code end |
#response_id ⇒ Object (readonly)
Returns the value of attribute response_id.
37 38 39 |
# File 'lib/agcod/create_gift_card.rb', line 37 def response_id @response_id end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
37 38 39 |
# File 'lib/agcod/create_gift_card.rb', line 37 def value @value end |
Instance Method Details
#process_response ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/agcod/create_gift_card.rb', line 24 def process_response super if self.successful? @claim_code = self.xml_response.root.elements["gcClaimCode"].text @response_id = self.xml_response.root.elements["gcCreationResponseId"].text else attempt_retry unless @sent_retry if @sent_retry void_on_resend end end end |
#to_yaml(name) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/agcod/create_gift_card.rb', line 39 def to_yaml(name) {"response_id" => self.response_id, "request_id" => self.request_id, "claim_code" => self.claim_code, "value" => self.value, "timestamp" => self. }.to_yaml(name) end |