Class: Agms::ReportResponse
- Defined in:
- lib/agms/response/report_response.rb
Instance Method Summary collapse
-
#_parseReportResponse(xml) ⇒ Object
Parse transaction report response received from gateway.
- #getSafeId ⇒ Object
-
#initialize(response, op) ⇒ ReportResponse
constructor
A class representing AGMS Report Response objects.
- #toArray ⇒ Object
Methods inherited from Response
Constructor Details
#initialize(response, op) ⇒ ReportResponse
A class representing AGMS Report Response objects.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/agms/response/report_response.rb', line 5 def initialize(response, op) super(response, op) @response = nil @op = op arr = _parseReportResponse(response) if @op == 'TransactionAPI' @mapping = { :id => 'id', :transactionid => 'transaction_id', :transactiontype => 'transaction_type', :paymenttype => 'payment_type', :amount => 'amount', :orderdescription => 'order_description', :orderid => 'order_id', :ponumber => 'po_number', :tax => 'tax_amount', :shipping => 'shipping_amount', :tipamount => 'tip_amount', :ccnumber => 'cc_number', :ccexpdate => 'cc_exp_date', :checkname => 'ach_name', :checkaba => 'ach_routing_number', :checkaccount => 'ach_account_number', :accountholdertype => 'ach_business_or_personal', :accounttype => 'ach_checking_or_savings', :seccode => 'ach_sec_code', :safeaction => 'safe_action', :responsesafeid => 'safe_id', :clerkid => 'clerk_id', :firstname => 'first_name', :lastname => 'last_name', :company => 'company_name', :address1 => 'address', :address2 => 'address_2', :city => 'city', :state => 'state', :zip => 'zip', :country => 'country', :phone => 'phone', :fax => 'fax', :email => 'email', :website => 'website', :shippingfirstname => 'shipping_first_name', :shippinglastname => 'shipping_last_name', :shippingcompany => 'shipping_company_name', :shippingaddress1 => 'shipping_address', :shippingaddress2 => 'shipping_address_2', :shippingcity => 'shipping_city', :shippingstate => 'shipping_state', :shippingzip => 'shipping_zip', :shippingcountry => 'shipping_country', :shippingemail => 'shipping_email', :shippingphone => 'shipping_phone', :shippingfax => 'shipping_fax', :shippingcarrier => 'shipping_carrier', :trackingnumber => 'shipping_tracking', :ipaddress => 'ip_address', :customfield1 => 'custom_field_1', :customfield2 => 'custom_field_2', :customfield3 => 'custom_field_3', :customfield4 => 'custom_field_4', :customfield5 => 'custom_field_5', :customfield6 => 'custom_field_6', :customfield7 => 'custom_field_7', :customfield8 => 'custom_field_8', :customfield9 => 'custom_field_9', :customfield10 => 'custom_field_10', :customfield11 => 'custom_field_11', :customfield12 => 'custom_field_12', :customfield13 => 'custom_field_13', :customfield14 => 'custom_field_14', :customfield15 => 'custom_field_15', :customfield16 => 'custom_field_16', :customfield17 => 'custom_field_17', :customfield18 => 'custom_field_18', :customfield19 => 'custom_field_19', :customfield20 => 'custom_field_20', :receipttype => 'receipt_type', :responsestatuscode => 'response_code', :responsestatusmsg => 'response_message', :responsetransid => 'response_transaction_id', :responseauthcode => 'authorization_code', :transactiondate => 'transaction_date', :createdate => 'date_created', :moddate => 'date_last_modified', :createuser => 'created_by', :moduser => 'modified_by', :useragent => 'user_agent' } if arr @response = arr else @response = Array.new end elsif @op == 'QuerySAFE' if arr @response = arr else @response = Array.new end else raise InvalidRequestError, 'Invalid op in Response.' end end |
Instance Method Details
#_parseReportResponse(xml) ⇒ Object
Parse transaction report response received from gateway
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/agms/response/report_response.rb', line 128 def _parseReportResponse(xml) # Parse the response body doc = Nokogiri::XML(xml) # Remove the namespaces doc.remove_namespaces! response = {} # Extract the response data from the ProcessTransactionResult node doc.xpath("//transactions//transaction//*").each do |node| response[node.name] = node.children.text end return response end |
#getSafeId ⇒ Object
122 123 124 125 |
# File 'lib/agms/response/report_response.rb', line 122 def getSafeId response_array = toArray() return response_array['safe_id'] end |
#toArray ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/agms/response/report_response.rb', line 111 def toArray # Override toArray method to handle array response response = Array.new if @response @response.each do |result| response << mapResponse(result) end end return response end |