Class: Figo::Session
Overview
Represents a user-bound connection to the figo Connect API and allows access to the user’s data.
Instance Method Summary collapse
-
#initialize(access_token, fingerprints = $valid_fingerprints, api_endpoint = $api_endpoint) ⇒ Session
constructor
Create session object with access token.
-
#query_api(path, data = nil, method = "GET") ⇒ Hash
Helper method for making a REST request.
-
#query_api_object(type, path, data = nil, method = "GET", array_name = nil) ⇒ Object
:nodoc:.
Methods included from Figo
#account_sort_order, #accounts, #add_account, #add_notification, #add_payment, #cancel_task, #create_process, #create_user, #credential_login, #delete_transaction, #find_bank, #get_account, #get_account_balance, #get_account_standing_orders, #get_bank, #get_notification, #get_payment, #get_payment_proposals, #get_securities, #get_security, #get_standing_order, #get_standing_orders, #get_supported_payment_services, #get_sync_url, #get_task_state, #get_transaction, #login_url, #modify_account, #modify_account_balance, #modify_bank, #modify_notification, #modify_payment, #modify_securities, #modify_security, #modify_transaction, #modify_transactions, #modify_user, #notifications, #obtain_access_token, #payments, #remove_account, #remove_bank_pin, #remove_notification, #remove_payment, #remove_user, #resend_verification, #revoke_token, #start_process, #start_task, #submit_payment, #sync_url, #transactions, #user
Constructor Details
#initialize(access_token, fingerprints = $valid_fingerprints, api_endpoint = $api_endpoint) ⇒ Session
Create session object with access token.
122 123 124 125 126 |
# File 'lib/figo.rb', line 122 def initialize(access_token, fingerprints = $valid_fingerprints, api_endpoint = $api_endpoint) @access_token = access_token @https = HTTPS.new("figo-#{access_token}", nil, fingerprints) @api_endpoint = api_endpoint end |
Instance Method Details
#query_api(path, data = nil, method = "GET") ⇒ Hash
Helper method for making a REST request.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/figo.rb', line 134 def query_api(path, data=nil, method="GET") # :nodoc: uri = URI("https://#{@api_endpoint}#{path}") # Setup HTTP request. request = case method when "POST" Net::HTTP::Post.new(path) when "PUT" Net::HTTP::Put.new(path) when "DELETE" Net::HTTP::Delete.new(path) else Net::HTTP::Get.new(path) end request["Authorization"] = "Bearer #{@access_token}" request["Accept"] = "application/json" request["Content-Type"] = "application/json" request["User-Agent"] = "figo-ruby/1.3.1" request.body = JSON.generate(data) unless data.nil? # Send HTTP request. response = @https.request(uri, request) # Evaluate HTTP response. return nil if response.nil? return nil if response.body.nil? return response.body == "" ? nil : JSON.parse(response.body) end |
#query_api_object(type, path, data = nil, method = "GET", array_name = nil) ⇒ Object
:nodoc:
165 166 167 168 169 170 |
# File 'lib/figo.rb', line 165 def query_api_object(type, path, data=nil, method="GET", array_name=nil) # :nodoc: response = query_api path, data, method return nil if response.nil? return type.new(self, response) if array_name.nil? return response[array_name].map {|entry| type.new(self, entry)} end |