Class: Giact::Client
Instance Attribute Summary collapse
-
#company_id ⇒ Object
readonly
Returns the value of attribute company_id.
Instance Method Summary collapse
- #cancel_recurring(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#installments_payments(payment_request) ⇒ Giact::PaymentReply
Process installment payments.
-
#login ⇒ String
Return an authentication token.
- #recurring_checks(options = {}) ⇒ Object
-
#recurring_payments(payment_request) ⇒ Giact::PaymentReply
Process recurring payments.
- #search_transactions(options = {}) ⇒ Object
-
#single_payment(payment_request) ⇒ Giact::PaymentReply
Process a single payment.
-
#token ⇒ String
Returns current authentication token or calls login.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 |
# File 'lib/giact/client.rb', line 13 def initialize(={}) [:gateway] ||= 1 self.class.base_uri("https://gatewaydtx#{[:gateway]}.giact.com/RealTime/POST/RealTimeChecks.asmx") @company_id ||= Giact.company_id ||= [:company_id] @username ||= Giact.username ||= [:username] @password ||= Giact.password ||= [:password] end |
Instance Attribute Details
#company_id ⇒ Object (readonly)
Returns the value of attribute company_id.
6 7 8 |
# File 'lib/giact/client.rb', line 6 def company_id @company_id end |
Instance Method Details
#cancel_recurring(options = {}) ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'lib/giact/client.rb', line 107 def cancel_recurring(={}) path = "/CancelRecurringBy#{.keys.first.to_s.camelize.gsub(/Id$/, "ID")}" .merge!(:company_id => self.company_id, :token => self.token) .camelize_keys! response = self.class.post(path, :body => )['string'] Giact::CancelRecurringCheckList.from_response(response) end |
#installments_payments(payment_request) ⇒ Giact::PaymentReply
Process installment payments
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/giact/client.rb', line 79 def installments_payments(payment_request) payment_request.merge!(:company_id => self.company_id, :token => self.token) raise Giact::InvalidRequest.new(payment_request.errors.) if not payment_request.is_a?(Giact::InstallmentPaymentRequest) or not payment_request.valid? response = self.class.post("/InstallmentsPayments", :body => payment_request.to_request_hash) if reply = response['string'] Giact::PaymentReply.new(reply) else end end |
#login ⇒ String
Return an authentication token
26 27 28 29 30 31 32 33 34 |
# File 'lib/giact/client.rb', line 26 def login response = self.class.post("/Login", :body => {:companyID => @company_id, :un => @username, :pw => @password}) if auth_token = response['string'] @token = auth_token else raise Giact::Unauthorized.new(response.body) end end |
#recurring_checks(options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/giact/client.rb', line 94 def recurring_checks(={}) path = "/RecurringChecksBy#{.keys.first.to_s.camelize.gsub(/Id$/, "ID")}" .merge!(:company_id => self.company_id, :token => self.token) .camelize_keys! response = self.class.post(path, :body => )['string'] Giact::RecurringCheckList.from_response(response) end |
#recurring_payments(payment_request) ⇒ Giact::PaymentReply
Process recurring payments
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/giact/client.rb', line 63 def recurring_payments(payment_request) payment_request.merge!(:company_id => self.company_id, :token => self.token) raise Giact::InvalidRequest.new(payment_request.errors.) if not payment_request.is_a?(Giact::RecurringPaymentRequest) or not payment_request.valid? response = self.class.post("/RecurringPayments", :body => payment_request.to_request_hash) if reply = response['string'] Giact::PaymentReply.new(reply) else end end |
#search_transactions(options = {}) ⇒ Object
122 123 124 125 126 127 128 129 130 |
# File 'lib/giact/client.rb', line 122 def search_transactions(={}) path = "/TransactionsBy#{.keys.first.to_s.camelize.gsub(/Id$/, "ID")}" .merge!(:company_id => self.company_id, :token => self.token) .camelize_keys! response = self.class.post(path, :body => )['string'] Giact::TransactionResult.from_response(response) end |
#single_payment(payment_request) ⇒ Giact::PaymentReply
Process a single payment
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/giact/client.rb', line 47 def single_payment(payment_request) payment_request.merge!(:company_id => self.company_id, :token => self.token) raise Giact::InvalidRequest.new(payment_request.errors.) unless payment_request.valid? response = self.class.post("/SinglePayment", :body => payment_request.to_request_hash) if reply = response['string'] Giact::PaymentReply.new(reply) else raise response.body end end |
#token ⇒ String
Returns current authentication token or calls login
39 40 41 |
# File 'lib/giact/client.rb', line 39 def token @token ||= self.login end |