Class: Ebanc
- Inherits:
-
Object
- Object
- Ebanc
- Defined in:
- lib/ebanc.rb
Instance Method Summary collapse
- #api_version ⇒ Object
- #api_version=(value) ⇒ Object
- #create_customer(customer = {}) ⇒ Object
- #create_transaction(transaction = {}) ⇒ Object
- #create_transaction_from_customer(transaction = {}) ⇒ Object
- #customer(uuid) ⇒ Object
-
#customers ⇒ Object
Customers.
- #error ⇒ Object
-
#initialize(api_key, gateway_id) ⇒ Ebanc
constructor
A new instance of Ebanc.
- #server ⇒ Object
-
#server=(value) ⇒ Object
Class Getters and Setters.
- #transaction(uuid) ⇒ Object
-
#transactions ⇒ Object
Transactions.
- #update_customer(customer = {}) ⇒ Object
- #use_ssl ⇒ Object
- #use_ssl=(value) ⇒ Object
Constructor Details
#initialize(api_key, gateway_id) ⇒ Ebanc
Returns a new instance of Ebanc.
8 9 10 11 12 13 14 15 16 |
# File 'lib/ebanc.rb', line 8 def initialize(api_key, gateway_id) @api_key = api_key @api_version = 2 @gateway_id = gateway_id @server = 'https://' + gateway_id + '.ebanccorp.com' @ebanc_url = @server + '/api/v' + @api_version.to_s @use_ssl = true = '' end |
Instance Method Details
#api_version ⇒ Object
42 43 44 |
# File 'lib/ebanc.rb', line 42 def api_version @api_version end |
#api_version=(value) ⇒ Object
37 38 39 40 |
# File 'lib/ebanc.rb', line 37 def api_version=(value) @ebanc_url = @server + '/api/v' + value.to_s @api_version = value end |
#create_customer(customer = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ebanc.rb', line 65 def create_customer(customer = {}) if customer[:first_name] && customer[:last_name] && customer[:routing_number] && customer[:account_number] params = URI.encode_www_form([["first_name", customer[:first_name]], ["last_name", customer[:last_name]], ["routing_number", customer[:routing_number]], ["account_number", customer[:account_number]]]) customer = query_api(@ebanc_url + '/customers', 'post', params) if customer['base'] = customer['base'].first return false else return customer end else = 'Not all needed fields were included' return false end end |
#create_transaction(transaction = {}) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ebanc.rb', line 129 def create_transaction(transaction = {}) #if we are creating this transaction by passing in the information if transaction[:first_name] && transaction[:last_name] && transaction[:routing_number] && transaction[:account_number] && transaction[:amount] params = URI.encode_www_form([["first_name", transaction[:first_name]], ["last_name", transaction[:last_name]], ["routing_number", transaction[:routing_number]], ["account_number", transaction[:account_number]], ["amount", transaction[:amount]]]) if transaction[:category] params = params + '&' + URI.encode_www_form([["category", transaction[:category]]]) end if transaction[:memo] params = params + '&' + URI.encode_www_form([["memo", transaction[:memo]]]) end m_transation = query_api(@ebanc_url + '/transactions', 'post', params) if m_transation['base'] = m_transation['base'].first return false else return m_transation end else = 'Not all needed fields were included' return false end end |
#create_transaction_from_customer(transaction = {}) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/ebanc.rb', line 156 def create_transaction_from_customer(transaction = {}) #if we are creating this transaction by passing in the information if transaction[:customer_uuid] && transaction[:amount] params = URI.encode_www_form([["customer_uuid", transaction[:customer_uuid]], ["amount", transaction[:amount]]]) params = 'customer_uuid=' + transaction[:customer_uuid] + '&amount=' + transaction[:amount] if transaction[:category] params = params + '&' + URI.encode_www_form([["category", transaction[:category]]]) end if transaction[:memo] params = params + '&' + URI.encode_www_form([["memo", transaction[:memo]]]) end m_transation = query_api(@ebanc_url + '/transactions', 'post', params) if m_transation['base'] = m_transation['base'].first return false else return m_transation end else = 'Not all needed fields were included' return false end end |
#customer(uuid) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ebanc.rb', line 107 def customer(uuid) m_customer = query_api(@ebanc_url + '/customers/' + uuid) if m_customer.length == 0 = 'Customer not found' return false else return m_customer end end |
#customers ⇒ Object
Customers
55 56 57 58 59 60 61 62 63 |
# File 'lib/ebanc.rb', line 55 def customers m_customers = query_api(@ebanc_url + '/customers') if m_customers['customers'].length == 0 = 'No customers found' end m_customers['customers'] end |
#error ⇒ Object
46 47 48 |
# File 'lib/ebanc.rb', line 46 def error end |
#server ⇒ Object
25 26 27 |
# File 'lib/ebanc.rb', line 25 def server @server end |
#server=(value) ⇒ Object
Class Getters and Setters
20 21 22 23 |
# File 'lib/ebanc.rb', line 20 def server=(value) @ebanc_url = value + '/api/v' + @api_version.to_s @server = value end |
#transaction(uuid) ⇒ Object
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/ebanc.rb', line 184 def transaction(uuid) m_transaction = query_api(@ebanc_url + '/transactions/' + uuid) if m_transaction.length == 0 = 'Transaction not found' return false else return m_transaction end end |
#transactions ⇒ Object
Transactions
119 120 121 122 123 124 125 126 127 |
# File 'lib/ebanc.rb', line 119 def transactions m_transactions = query_api(@ebanc_url + '/transactions') if m_transactions['transactions'].length == 0 = 'No transactions found' end m_transactions['transactions'] end |
#update_customer(customer = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/ebanc.rb', line 83 def update_customer(customer = {}) if customer[:uuid] && customer[:first_name] && customer[:last_name] params = URI.encode_www_form([["first_name", customer[:first_name]], ["last_name", customer[:last_name]], ["routing_number", customer[:routing_number]], ["account_number", customer[:account_number]]]) if customer[:routing_number] params = params + '&' + URI.encode_www_form([["routing_number", customer[:routing_number]]]) end if customer[:account_number] params = params + '&' + URI.encode_www_form([["account_number", customer[:account_number]]]) end if customer(customer[:uuid]) customer = query_api(@ebanc_url + '/customers/' + customer[:uuid], 'patch', params) return customer else return false end else = 'Not all needed fields were included' return false end end |
#use_ssl ⇒ Object
33 34 35 |
# File 'lib/ebanc.rb', line 33 def use_ssl @use_ssl end |
#use_ssl=(value) ⇒ Object
29 30 31 |
# File 'lib/ebanc.rb', line 29 def use_ssl=(value) @use_ssl = value end |