isaca 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -6
- data/isaca.gemspec +1 -1
- data/lib/isaca/attribute_error.rb +1 -1
- data/lib/isaca/configuration_error.rb +1 -1
- data/lib/isaca/connection_error.rb +1 -1
- data/lib/isaca/helpers.rb +1 -1
- data/lib/isaca/models/authenticate_user.rb +2 -2
- data/lib/isaca/models/countries.rb +2 -2
- data/lib/isaca/models/get_user_by_id.rb +5 -5
- data/lib/isaca/models/get_user_details_by_token.rb +3 -3
- data/lib/isaca/partner_key_error.rb +1 -1
- data/lib/isaca/requests/authenticate_user.rb +5 -5
- data/lib/isaca/requests/countries.rb +5 -5
- data/lib/isaca/requests/explicit_countries.rb +5 -5
- data/lib/isaca/requests/get_user_by_id.rb +4 -4
- data/lib/isaca/requests/get_user_details_by_token.rb +5 -5
- data/lib/isaca/requests/log_out.rb +3 -3
- data/lib/isaca/requests/report_consent.rb +2 -2
- data/lib/isaca/requests/request.rb +11 -11
- data/lib/isaca/service_error.rb +1 -1
- data/lib/isaca/session_error.rb +1 -1
- data/lib/isaca/version.rb +2 -2
- data/lib/isaca.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5731ab5c9f6520fdd6f707e6494742a012ca5cb9
|
4
|
+
data.tar.gz: 007ca4c7926f16168ce0c722e34f03e27766de90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baad6f6779e27c7452349d938023ae012a7b8015c62584866c824f42250cb81e0e45cf35f952d3ae07dbfc85e852080acf8ccd90b923cc32f076258c2a9fa424
|
7
|
+
data.tar.gz: e5a0df3b4085533b375d268cee2f8d04e99dc00fe3150a933ccfc9addcfc58c107580c70bc34c52e7e15bd2411c7e458265bb830b7b4302b4a606bb0f9e8316b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,22 +24,22 @@ Refer to the full documentation on how to use this library. Consider the followi
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
# Log the user in and get back a session token
|
27
|
-
session =
|
27
|
+
session = Isaca::Request::AuthenticateUser.get('username', 'password')
|
28
28
|
|
29
29
|
# Get user information of the current user
|
30
|
-
user =
|
30
|
+
user = Isaca::Request::GetUserDetailsByToken.get(session.value)
|
31
31
|
|
32
32
|
# Destroy a user session
|
33
|
-
|
33
|
+
Isaca::Request::LogOut.get(session.value)
|
34
34
|
```
|
35
35
|
|
36
36
|
## Configuration
|
37
37
|
|
38
|
-
Configuration of this library is fairly easy -- you just need to use the `
|
38
|
+
Configuration of this library is fairly easy -- you just need to use the `Isaca.configure` block. Consider the following
|
39
39
|
example:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
|
42
|
+
Isaca.configure do |config|
|
43
43
|
config.url = 'https://partnerapi.isaca.org:8443/ISACAServices/Service1.svc'
|
44
44
|
config.secret_pass = '1234567890ABCDEFGHI'
|
45
45
|
config.user_agent = 'my_application'
|
@@ -49,7 +49,7 @@ end
|
|
49
49
|
|
50
50
|
## Rails Integration
|
51
51
|
|
52
|
-
For Ruby on Rails applications, consider the `isaca-rails` engine which utilizes this library. `
|
52
|
+
For Ruby on Rails applications, consider the `isaca-rails` engine which utilizes this library. `Isaca::Rails` is intended
|
53
53
|
to give you a jump start on your ISACA integrated Rails applications.
|
54
54
|
|
55
55
|
## Contributing
|
data/isaca.gemspec
CHANGED
data/lib/isaca/helpers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Model
|
3
|
-
# Class that is used as an object representation of the response from {
|
3
|
+
# Class that is used as an object representation of the response from {Isaca::Request::AuthenticateUser}.
|
4
4
|
class AuthenticateUser
|
5
5
|
attr_reader :error
|
6
6
|
# @!attribute error
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Model
|
3
|
-
# Class that is used as an object representation of the response from {
|
3
|
+
# Class that is used as an object representation of the response from {Isaca::Request::Countries} and {Isaca::Request::ExplicitCountries}.
|
4
4
|
class Countries
|
5
5
|
attr_reader :countries
|
6
6
|
# @!attribute countries
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Model
|
3
|
-
# Class is used as an object representation of the response from {
|
3
|
+
# Class is used as an object representation of the response from {Isaca::Request::GetUserByID}.
|
4
4
|
class GetUserByID
|
5
5
|
attr_reader :active_member
|
6
6
|
# @!attribute active_member
|
@@ -24,9 +24,9 @@ module ISACA
|
|
24
24
|
# @option params [String] :MemberType
|
25
25
|
# @option params [String] :iMISID
|
26
26
|
def initialize(params)
|
27
|
-
@active_member =
|
28
|
-
@expiration_date =
|
29
|
-
@member_type =
|
27
|
+
@active_member = Isaca::Helpers.parse_boolean(params[:ActiveMember])
|
28
|
+
@expiration_date = Isaca::Helpers.strptime(params[:ExpirationDate])
|
29
|
+
@member_type = Isaca::Helpers.normalize_member_type(params[:MemberType])
|
30
30
|
|
31
31
|
if params[:iMISID].to_s.strip.empty?
|
32
32
|
raise ServiceError.new('User with given IMIS ID not found')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# An object representation of the GetUserDetailsByToken endpoint
|
2
|
-
module
|
2
|
+
module Isaca
|
3
3
|
module Model
|
4
|
-
# Class is used as an object representation of the response from {
|
4
|
+
# Class is used as an object representation of the response from {Isaca::Request::GetUserDetailsByToken}.
|
5
5
|
class GetUserDetailsByToken
|
6
6
|
attr_reader :imis_id
|
7
7
|
# @!attribute imis_id
|
@@ -50,7 +50,7 @@ module ISACA
|
|
50
50
|
# @option params [String] :PRIVACY
|
51
51
|
# @option params [String] :MARKETING
|
52
52
|
#
|
53
|
-
# @raise [
|
53
|
+
# @raise [Isaca::ServiceError] Raises error if IMIS ID is not present.
|
54
54
|
def initialize(params)
|
55
55
|
if params[:ID].to_s.strip.empty?
|
56
56
|
raise ServiceError.new('User with given IMIS ID not found')
|
@@ -1,16 +1,16 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
# Class used to create user sessions.
|
4
4
|
class AuthenticateUser
|
5
5
|
# Method used to generate a session token.
|
6
6
|
#
|
7
|
-
# @raise [
|
7
|
+
# @raise [Isaca::SessionError] Raised if the returned session is invalid.
|
8
8
|
#
|
9
|
-
# @return [
|
9
|
+
# @return [Isaca::Model::AuthenticateUser] An object representation of the response.
|
10
10
|
def self.get(username, password)
|
11
11
|
response = self.send_request(username, password)
|
12
12
|
|
13
|
-
model =
|
13
|
+
model = Isaca::Model::AuthenticateUser.new(JSON.parse(response.body, {symbolize_names: true}))
|
14
14
|
raise SessionError.new(model.value) unless model.is_valid?
|
15
15
|
|
16
16
|
model
|
@@ -24,7 +24,7 @@ module ISACA
|
|
24
24
|
#
|
25
25
|
# @return [Faraday::Response]
|
26
26
|
def self.send_request(username, password)
|
27
|
-
|
27
|
+
Isaca::Request.get do |request|
|
28
28
|
request.path = request.path + '/AuthenticateUser'
|
29
29
|
request.params['username'] = username
|
30
30
|
request.params['password'] = password
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
# Class used to fetch countries recognized by ISACA.
|
4
4
|
module Countries
|
5
5
|
# Method used to fetch all countries.
|
6
6
|
#
|
7
|
-
# @return [
|
7
|
+
# @return [Isaca::Model::Countries] An object representation of the response.
|
8
8
|
def self.get
|
9
9
|
response = self.send_request
|
10
|
-
|
10
|
+
Isaca::Model::Countries.new(JSON.parse(response.body, symbolize_names: true))
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
@@ -16,8 +16,8 @@ module ISACA
|
|
16
16
|
#
|
17
17
|
# @return [Faraday::Response]
|
18
18
|
def self.send_request
|
19
|
-
|
20
|
-
uri = URI(
|
19
|
+
Isaca::Request.get do |request|
|
20
|
+
uri = URI(Isaca.configuration.url)
|
21
21
|
request.path = "#{uri.scheme}://#{uri.hostname}:#{uri.port}/isacaservices/countries.json"
|
22
22
|
end
|
23
23
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
# Class used to fetch the explicit countries recognized by ISACA. Explicit countries are countries that require
|
4
4
|
# consent for marketing.
|
5
5
|
module ExplicitCountries
|
6
6
|
# Method used to fetch all of the ExplicitCountries.
|
7
7
|
#
|
8
|
-
# @return [
|
8
|
+
# @return [Isaca::Model::Countries] An object representation of the response.
|
9
9
|
def self.get
|
10
10
|
response = self.send_request
|
11
|
-
|
11
|
+
Isaca::Model::Countries.new(JSON.parse(response.body, symbolize_names: true))
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -17,8 +17,8 @@ module ISACA
|
|
17
17
|
#
|
18
18
|
# @return [Faraday::Response]
|
19
19
|
def self.send_request
|
20
|
-
|
21
|
-
uri = URI(
|
20
|
+
Isaca::Request.get do |request|
|
21
|
+
uri = URI(Isaca.configuration.url)
|
22
22
|
request.path = "#{uri.scheme}://#{uri.hostname}:#{uri.port}/isacaservices/explicitcountries.json"
|
23
23
|
end
|
24
24
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
# Class used to fetch an ISACA user by their IMIS ID.
|
4
4
|
module GetUserByID
|
@@ -6,10 +6,10 @@ module ISACA
|
|
6
6
|
#
|
7
7
|
# @param [String] id The IMIS ID of the requested user.
|
8
8
|
#
|
9
|
-
# @return [
|
9
|
+
# @return [Isaca::Model::GetUserByID] An object representation of the response.
|
10
10
|
def self.get(id)
|
11
11
|
response = self.send_request(id)
|
12
|
-
|
12
|
+
Isaca::Model::GetUserByID.new(JSON.parse(response.body, symbolize_names: true))
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -20,7 +20,7 @@ module ISACA
|
|
20
20
|
#
|
21
21
|
# @return [Faraday::Response]
|
22
22
|
def self.send_request(id)
|
23
|
-
|
23
|
+
Isaca::Request.get do |request|
|
24
24
|
request.path = request.path + '/GetUserByID'
|
25
25
|
request.params['ID'] = id
|
26
26
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
class GetUserDetailsByToken
|
4
4
|
# Method used to get user information by token
|
5
5
|
#
|
6
6
|
# @param token [String] The user's session token
|
7
7
|
#
|
8
|
-
# @raise [
|
8
|
+
# @raise [Isaca::AttributeError] Raised if the returned IMIS ID is nil or the ID key is missing
|
9
9
|
#
|
10
|
-
# @return [
|
10
|
+
# @return [Isaca::Model::GetUserDetailsByToken] An object representation of the response
|
11
11
|
def self.get(token)
|
12
12
|
response = self.send_request(token)
|
13
13
|
|
14
14
|
data = JSON.parse(JSON.parse(response.body, quirks_mode: true), {symbolize_names: true})
|
15
|
-
|
15
|
+
Isaca::Model::GetUserDetailsByToken.new(data)
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -22,7 +22,7 @@ module ISACA
|
|
22
22
|
#
|
23
23
|
# @return [Faraday::Response]
|
24
24
|
def self.send_request(token)
|
25
|
-
|
25
|
+
Isaca::Request.get do |request|
|
26
26
|
request.path = request.path + '/GetUserDetailsByToken'
|
27
27
|
request.params['token'] = token
|
28
28
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
module LogOut
|
4
4
|
# Method used to destroy a user session
|
5
5
|
#
|
6
6
|
# @param token [String] Session token to be destroyed
|
7
7
|
#
|
8
|
-
# @raise [
|
8
|
+
# @raise [Isaca::ServiceError] An error is raised if this ever fails. See [Isaca::Request]
|
9
9
|
#
|
10
10
|
# @return [Faraday::Response] Returns a response object
|
11
11
|
def self.get(token)
|
@@ -20,7 +20,7 @@ module ISACA
|
|
20
20
|
#
|
21
21
|
# @return [Faraday::Response] Returns a response object
|
22
22
|
def self.send_request(token)
|
23
|
-
|
23
|
+
Isaca::Request.get do |request|
|
24
24
|
request.path = request.path + '/LogOut'
|
25
25
|
request.params['token'] = token
|
26
26
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Isaca
|
2
2
|
module Request
|
3
3
|
module ReportConsent
|
4
4
|
# Method used to report marketing consent and acceptance of the privacy policy. ISACA assumes that when you
|
@@ -28,7 +28,7 @@ module ISACA
|
|
28
28
|
#
|
29
29
|
# @return [Faraday::Response] Returns a response object
|
30
30
|
def self.send_request(imis_id, options={})
|
31
|
-
|
31
|
+
Isaca::Request.get do |request|
|
32
32
|
request.path = request.path + '/ReportConsent'
|
33
33
|
request.params['MarketingConsent'] = options[:marketing]
|
34
34
|
request.params['iMISID'] = imis_id
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Isaca
|
4
4
|
module Request
|
5
5
|
# Generic GET request used to build REST calls
|
6
6
|
#
|
7
|
-
# @raise [
|
8
|
-
# @raise [
|
9
|
-
# @raise [
|
7
|
+
# @raise [Isaca::ServiceError] Raised because server returned a 400 response code. Bad request.
|
8
|
+
# @raise [Isaca::PartnerKey] The partner has provided an invalid API Key.
|
9
|
+
# @raise [Isaca::ServiceError] Raised because the server returned a 500 response code. Server error.
|
10
10
|
#
|
11
11
|
# @return [Faraday::Response] Returns a Faraday Response object
|
12
12
|
def self.get # :yields: [Faraday::Request] Yields a request object.
|
13
|
-
conn = Faraday.new(url:
|
14
|
-
conn.ssl.verify_mode = OpenSSL::SSL::VERIFY_NONE unless
|
13
|
+
conn = Faraday.new(url: Isaca.configuration.url)
|
14
|
+
conn.ssl.verify_mode = OpenSSL::SSL::VERIFY_NONE unless Isaca.configuration.verify_ssl
|
15
15
|
|
16
16
|
response = conn.get do |request|
|
17
17
|
set_default_request_options(request)
|
18
18
|
yield(request) if block_given?
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
Isaca.logger.debug("\n" + response.inspect + "\n") if Isaca.configuration.debug
|
22
22
|
response.success? ? response : raise_response_error(response)
|
23
23
|
end
|
24
24
|
|
@@ -26,7 +26,7 @@ module ISACA
|
|
26
26
|
|
27
27
|
# Testing Request#get is difficult so this method was created for easier testing and stubbing
|
28
28
|
#
|
29
|
-
# @raise [
|
29
|
+
# @raise [Isaca::ServiceError] Raises a type of service error depending on status code
|
30
30
|
#
|
31
31
|
# @param response [Faraday::Response] Accepts a response object
|
32
32
|
def self.raise_response_error(response)
|
@@ -48,11 +48,11 @@ module ISACA
|
|
48
48
|
#
|
49
49
|
# @param request [Faraday::Request] The request to which the headers are applied
|
50
50
|
def self.set_default_request_options(request)
|
51
|
-
uri = URI(
|
51
|
+
uri = URI(Isaca.configuration.url)
|
52
52
|
request.path = uri.path
|
53
53
|
request.headers['Content-Type'] = 'application/json'
|
54
|
-
request.headers['User-Agent'] =
|
55
|
-
request.params['secPass'] =
|
54
|
+
request.headers['User-Agent'] = Isaca.configuration.user_agent
|
55
|
+
request.params['secPass'] = Isaca.configuration.secret_pass
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/lib/isaca/service_error.rb
CHANGED
data/lib/isaca/session_error.rb
CHANGED
data/lib/isaca/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "1.0
|
1
|
+
module Isaca
|
2
|
+
VERSION = "1.1.0"
|
3
3
|
end
|
data/lib/isaca.rb
CHANGED
@@ -31,11 +31,11 @@ require 'openssl'
|
|
31
31
|
require 'logger'
|
32
32
|
|
33
33
|
# Library intended to help ease the implementation of ISACA web services.
|
34
|
-
module
|
34
|
+
module Isaca
|
35
35
|
class << self
|
36
36
|
attr_accessor :configuration
|
37
37
|
# @!attribute configuration
|
38
|
-
# @return [
|
38
|
+
# @return [Isaca::Configuration] Object used to configure the library.
|
39
39
|
|
40
40
|
attr_accessor :logger
|
41
41
|
# @!attribute logger
|
@@ -43,14 +43,14 @@ module ISACA
|
|
43
43
|
|
44
44
|
# Method used to fetch the configuration object.
|
45
45
|
#
|
46
|
-
# @return [
|
46
|
+
# @return [Isaca::Configuration]
|
47
47
|
def configuration
|
48
48
|
@configuration ||= Configuration.new
|
49
49
|
end
|
50
50
|
|
51
51
|
# Method used to reset the ISACA configuration. Primarily used for testing.
|
52
52
|
#
|
53
|
-
# @return [
|
53
|
+
# @return [Isaca::Configuration]
|
54
54
|
def reset
|
55
55
|
@configuration = Configuration.new
|
56
56
|
end
|
@@ -69,10 +69,10 @@ module ISACA
|
|
69
69
|
|
70
70
|
# Configuration block used to configure the library.
|
71
71
|
#
|
72
|
-
# @yield [
|
72
|
+
# @yield [Isaca::Configuration]
|
73
73
|
#
|
74
74
|
# @example An example configuration
|
75
|
-
#
|
75
|
+
# Isaca.configure do |config|
|
76
76
|
# config.url = 'https://partnerapi.isaca.org:8443/ISACAServices/Service1.svc'
|
77
77
|
# config.secret_pass = '1234567890ABCDEFGHI'
|
78
78
|
# config.user_agent = 'my_application'
|
@@ -117,7 +117,7 @@ module ISACA
|
|
117
117
|
|
118
118
|
# Returns the secret_pass attribute value
|
119
119
|
#
|
120
|
-
# @raise [
|
120
|
+
# @raise [Isaca::ConfigurationError] Raises if secret pass was not configured.
|
121
121
|
#
|
122
122
|
# @return [String]
|
123
123
|
def secret_pass
|
@@ -125,7 +125,7 @@ module ISACA
|
|
125
125
|
@secret_pass
|
126
126
|
else
|
127
127
|
msg = 'Missing SecretPass configuration. The ISACA Partners API requires an assigned SecretPass.'
|
128
|
-
msg << ' Example:
|
128
|
+
msg << ' Example: Isaca.configure {|config| config.secret_pass = "MyPass"}'
|
129
129
|
|
130
130
|
raise ConfigurationError.new(msg)
|
131
131
|
end
|
@@ -133,7 +133,7 @@ module ISACA
|
|
133
133
|
|
134
134
|
# Returns the url attribute value
|
135
135
|
#
|
136
|
-
# @raise [
|
136
|
+
# @raise [Isaca::ConfigurationError] Raises if url was not configured.
|
137
137
|
#
|
138
138
|
# @return [String]
|
139
139
|
def url
|
@@ -141,7 +141,7 @@ module ISACA
|
|
141
141
|
@url
|
142
142
|
else
|
143
143
|
msg = 'Missing URL configuration. The ISACA Partners API requires an endpoint URL.'
|
144
|
-
msg << ' Example:
|
144
|
+
msg << ' Example: Isaca.configure {|config| config.url = "https://partnerapi.isaca.org:8443/ISACAServices/Service1.svc"}'
|
145
145
|
|
146
146
|
raise ConfigurationError.new(msg)
|
147
147
|
end
|
@@ -149,7 +149,7 @@ module ISACA
|
|
149
149
|
|
150
150
|
# Returns the user_agent attribute value
|
151
151
|
#
|
152
|
-
# @raise [
|
152
|
+
# @raise [Isaca::ConfigurationError] Raises if user agent was not configured.
|
153
153
|
#
|
154
154
|
# @return [String]
|
155
155
|
def user_agent
|
@@ -157,7 +157,7 @@ module ISACA
|
|
157
157
|
@user_agent
|
158
158
|
else
|
159
159
|
msg = 'Missing User-Agent configuration. The ISACA Partners API requires a predefined User-Agent.'
|
160
|
-
msg << ' Example:
|
160
|
+
msg << ' Example: Isaca.configure {|config| config.user_agent = "MyApplication"}'
|
161
161
|
|
162
162
|
raise ConfigurationError.new(msg)
|
163
163
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isaca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Orahood
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|