Class: NedbankApi::AuthenticationsApi
Constant Summary
collapse
- API_PATHS =
{
request_token: 'nboauth/oauth20/token',
authorise: 'nboauth/oauth20/authorize'
}
Class Method Summary
collapse
Methods inherited from ApiWrapper
auth_headers, endpoint, idempotency_key, json_to_object
Class Method Details
.authorisation_url(request_body: {}) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/nedbank_api/authentications_api.rb', line 47
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
|
.request_token_heavy(request_body: {}) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/nedbank_api/authentications_api.rb', line 28
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
|
.request_token_light ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/nedbank_api/authentications_api.rb', line 9
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
|