Sha256: 517e0e407256c7e5d895a2e9d4c7e18d0c05ec6316d836932d5913213eeb2af7
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
module NedbankApi class AuthenticationsApi < ApiWrapper class << self API_PATHS = { request_token: 'nboauth/oauth20/token', authorise: 'nboauth/oauth20/authorize' } def request_token_light http = Http.new(url: endpoint(API_PATHS[:request_token])) response = http.post( body: URI.encode_www_form({ client_id: NedbankApi.configuration.client_id, client_secret: NedbankApi.configuration.client_secret, grant_type: 'client_credentials', scope: 'tpp_client_credential' }) ) intent_token = Models::IntentToken.new(JSON.parse(response.body, object_class: OpenStruct)) NedbankApi.intent_token = intent_token return intent_token end def request_token_heavy(request_body: {}) http = Http.new(url: endpoint(API_PATHS[:request_token])) response = http.post( body: URI.encode_www_form({ client_id: NedbankApi.configuration.client_id, client_secret: NedbankApi.configuration.client_secret, redirect_uri: NedbankApi.configuration.oauth_redirect_url, grant_type: 'authorization_code', }.merge(request_body)) ) intent_token = Models::IntentToken.new(JSON.parse(response.body, object_class: OpenStruct)) NedbankApi.intent_token = intent_token return intent_token end def authorisation_url(request_body: {}) url = endpoint(API_PATHS[:authorise]) body = URI.encode_www_form({ client_id: NedbankApi.configuration.client_id, redirect_uri: NedbankApi.configuration.oauth_redirect_url, response_type: 'code', scope: 'payments', itype: 'payments' }.merge(request_body)) return "#{url}?#{body}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nedbank_api-0.2.5 | lib/nedbank_api/authentications_api.rb |