isaca 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c79b6131b4c6157136bd4ee0da2d828811e855e
4
+ data.tar.gz: 8f1e32c1be7081b7c250c452d2b7465c6d6dd75e
5
+ SHA512:
6
+ metadata.gz: b54111fbf23e79ce113d7afdde65e74342da606a07c46806c76be3bf63061f613468bf7b80ed3d36801b0468a7322ecdc9b57ab3c2817dc3f9f47ffac209801c
7
+ data.tar.gz: 145b745da17457f61f8397933645af658c4b933dcab4fdb8a4e77adf5d9e69af58407b3ed603edc0b695c9daa06fd7495aef460c947f8696831ae9371eae9872
data/.gitignore ADDED
@@ -0,0 +1,74 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+
11
+ # Created by https://www.gitignore.io/api/rubymine+all
12
+
13
+ ### RubyMine+all ###
14
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
15
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
16
+
17
+ # User-specific stuff:
18
+ .idea/**/workspace.xml
19
+ .idea/**/tasks.xml
20
+ .idea/dictionaries
21
+
22
+ # Sensitive or high-churn files:
23
+ .idea/**/dataSources/
24
+ .idea/**/dataSources.ids
25
+ .idea/**/dataSources.xml
26
+ .idea/**/dataSources.local.xml
27
+ .idea/**/sqlDataSources.xml
28
+ .idea/**/dynamic.xml
29
+ .idea/**/uiDesigner.xml
30
+
31
+ # Gradle:
32
+ .idea/**/gradle.xml
33
+ .idea/**/libraries
34
+
35
+ # CMake
36
+ cmake-build-debug/
37
+
38
+ # Mongo Explorer plugin:
39
+ .idea/**/mongoSettings.xml
40
+
41
+ ## File-based project format:
42
+ *.iws
43
+
44
+ ## Plugin-specific files:
45
+
46
+ # IntelliJ
47
+ /out/
48
+
49
+ # mpeltonen/sbt-idea plugin
50
+ .idea_modules/
51
+
52
+ # JIRA plugin
53
+ atlassian-ide-plugin.xml
54
+
55
+ # Cursive Clojure plugin
56
+ .idea/replstate.xml
57
+
58
+ # Ruby plugin and RubyMine
59
+ /.rakeTasks
60
+
61
+ # Crashlytics plugin (for Android Studio and IntelliJ)
62
+ com_crashlytics_export_strings.xml
63
+ crashlytics.properties
64
+ crashlytics-build.properties
65
+ fabric.properties
66
+
67
+ ### RubyMine+all Patch ###
68
+ # Ignores the whole idea folder
69
+ # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
70
+
71
+ .idea/
72
+
73
+
74
+ # End of https://www.gitignore.io/api/rubymine+all
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in isaca.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ isaca (0.1.0)
5
+ faraday (~> 0.14.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (0.14.0)
11
+ multipart-post (>= 1.2, < 3)
12
+ minitest (5.10.3)
13
+ multipart-post (2.0.0)
14
+ rake (10.4.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 1.16)
21
+ isaca!
22
+ minitest (~> 5.0)
23
+ rake (~> 10.0)
24
+
25
+ BUNDLED WITH
26
+ 1.16.0
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Isaca
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/isaca`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'isaca'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install isaca
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/isaca.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "isaca"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/isaca.gemspec ADDED
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "isaca/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "isaca"
8
+ spec.version = ISACA::VERSION
9
+ spec.authors = ["Matt Orahood"]
10
+ spec.email = ["morahood@gmail.com"]
11
+
12
+ spec.summary = 'A wrapper for the ISACA Partners API'
13
+ spec.description = 'A wrapper for the ISACA Partners API'
14
+ spec.homepage = ""
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "faraday", "~> 0.14.0"
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'date'
2
+ require 'json'
3
+
4
+ module ISACA
5
+ module Helpers
6
+ def self.strptime(string_time, format='%m/%d/%Y %I:%M:%S %p')
7
+ (string_time.nil? || string_time.empty?) ? nil : DateTime.strptime(string_time, format)
8
+ end
9
+
10
+ def self.parse_json(string)
11
+ JSON.parse(string)
12
+ end
13
+
14
+ def self.parse_boolean(string)
15
+ string == 'True' ? true : false
16
+ end
17
+
18
+ def self.normalize_member_type(type)
19
+ case type
20
+ when 'COMP' then :member
21
+ when 'LIFE' then :member
22
+ when 'STUM' then :student
23
+ when 'PENS' then :student
24
+ when 'RG1' then :member
25
+ when 'RG2' then :member
26
+ when 'RETM' then :member
27
+ when 'UADV' then :member
28
+ when 'MEM' then :member
29
+ when 'PEND' then :member
30
+ when 'PENRG' then :member
31
+ when 'EMPL' then :member
32
+ else :non_member
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,21 @@
1
+ module ISACA
2
+ module Model
3
+ class AuthenticateUser
4
+ attr_accessor :error
5
+ attr_accessor :error_code
6
+ attr_accessor :is_valid
7
+ attr_accessor :value
8
+
9
+ def initialize(hash)
10
+ @error = hash['Error']
11
+ @error_code = hash['ErrorCode']
12
+ @is_valid = ISACA::Helpers.parse_boolean(hash['IsValid'])
13
+ @value = hash['Value']
14
+ end
15
+
16
+ def is_valid?
17
+ is_valid
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module ISACA
2
+ module Model
3
+ class GetUserByID
4
+ attr_accessor :active_member
5
+ attr_accessor :expiration_date
6
+ attr_accessor :member_type
7
+ attr_accessor :imis_id
8
+
9
+ def initialize(hash)
10
+ @active_member = ISACA::Helpers.parse_boolean(hash['ActiveMember'])
11
+ @expiration_date = ISACA::Helpers.strptime(hash['ExpirationDate'])
12
+ @member_type = ISACA::Helpers.normalize_member_type(hash['MemberType'])
13
+ @imis_id = hash['iMISID']
14
+ end
15
+
16
+ def active_member?
17
+ active_member
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module ISACA
2
+ module Model
3
+ class GetUserDetailsByToken
4
+ attr_accessor :imis_id
5
+ attr_accessor :enterprise_id
6
+ attr_accessor :name
7
+ attr_accessor :email
8
+
9
+ def initialize(hash)
10
+ @imis_id = hash['ID']
11
+ @enterprise_id = hash['Ent_ID']
12
+ @name = hash['Name']
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ module ISACA
2
+ module Model
3
+ class LogOut
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module ISACA
2
+ module Model
3
+ class SubmitCPE
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ module ISACA
2
+ module Request
3
+ module AuthenticateUser
4
+ def self.get(username, password)
5
+ response = ISACA::Request.get do |request|
6
+ request.path = request.path + '/AuthenticateUser'
7
+ request.params['username'] = username
8
+ request.params['password'] = password
9
+ end
10
+
11
+ puts response.inspect
12
+
13
+ response.status == 200 ? ISACA::Model::AuthenticateUser.new(ISACA::Helpers.parse_json(response.body)) : nil
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module ISACA
2
+ module Request
3
+ module GetUserByID
4
+ def self.get(id)
5
+ response = ISACA::Request.get do |request|
6
+ request.path = request.path + '/GetUserByID'
7
+ request.params['ID'] = id
8
+ end
9
+
10
+ response.status == 200 ? ISACA::Model::GetUserByID.new(ISACA::Helpers.parse_json(response.body)) : nil
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+
17
+
@@ -0,0 +1,14 @@
1
+ module ISACA
2
+ module Request
3
+ module GetUserDetailsByToken
4
+ def self.get(token)
5
+ response = ISACA::Request.get do |request|
6
+ request.path = request.path + '/GetUserDetailsByToken'
7
+ request.params['token'] = token
8
+ end
9
+
10
+ response.status == 200 ? ISACA::Model::GetUserDetailsByToken.new(ISACA::Helpers.parse_json(response.body)) : nil
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ module ISACA
2
+ module Request
3
+ module LogOut
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,37 @@
1
+ require 'faraday'
2
+
3
+ module ISACA
4
+ module Request
5
+ def self.get
6
+ conn = Faraday.new(url: ISACA.configuration.url)
7
+ conn.ssl.verify_mode = OpenSSL::SSL::VERIFY_NONE unless ISACA.configuration.verify_ssl
8
+
9
+ conn.get do |request|
10
+ set_default_request_options(request)
11
+ yield(request)
12
+ end
13
+ end
14
+
15
+ def self.post
16
+ conn = Faraday.new(url: ISACA.configuration.url)
17
+ conn.ssl.verify_mode = OpenSSL::SSL::VERIFY_NONE unless ISACA.configuration.verify_ssl
18
+
19
+ conn.post do |request|
20
+ set_default_request_options(request)
21
+ yield(request)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def self.set_default_request_options(request)
28
+ uri = URI(ISACA.configuration.url)
29
+ request.path = uri.path
30
+ request.headers['Content-Type'] = 'application/json'
31
+ request.headers['User-Agent'] = ISACA.configuration.user_agent
32
+ request.params['secPass'] = ISACA.configuration.secret_pass
33
+ end
34
+ end
35
+ end
36
+
37
+ Faraday::Response
@@ -0,0 +1,6 @@
1
+ module ISACA
2
+ module Request
3
+ module SubmitCPE
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module ISACA
2
+ VERSION = "0.1.1"
3
+ end
data/lib/isaca.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'isaca/helpers'
2
+
3
+ require 'isaca/requests/request'
4
+ require 'isaca/requests/authenticate_user'
5
+ require 'isaca/requests/get_user_by_id'
6
+ require 'isaca/requests/get_user_details_by_token'
7
+ require 'isaca/requests/submit_cpe'
8
+ require 'isaca/requests/log_out'
9
+
10
+ require 'isaca/models/authenticate_user'
11
+ require 'isaca/models/get_user_by_id'
12
+ require 'isaca/models/get_user_details_by_token'
13
+ require 'isaca/models/submit_cpe'
14
+ require 'isaca/models/log_out'
15
+
16
+ require 'isaca/version'
17
+ require 'openssl'
18
+
19
+ module ISACA
20
+ class << self
21
+ attr_accessor :configuration
22
+
23
+ def configuration
24
+ @configuration ||= Configuration.new
25
+ end
26
+ end
27
+
28
+ def self.configure
29
+ self.configuration ||= Configuration.new
30
+ yield(configuration)
31
+ self.configuration
32
+ end
33
+
34
+ class Configuration
35
+ attr_accessor :url
36
+ attr_accessor :secret_pass
37
+ attr_accessor :user_agent
38
+ attr_accessor :verify_ssl
39
+
40
+ def initialize
41
+ @verify_ssl = true
42
+ end
43
+
44
+ def secret_pass
45
+ if @secret_pass
46
+ @secret_pass
47
+ else
48
+ msg = 'Missing SecretPass configuration. The ISACA Partners API requires an assigned SecretPass.'
49
+ msg << ' Example: ISACA.configure {|config| config.secret_pass = "MyPass"}'
50
+
51
+ raise ConfigurationError.new(msg)
52
+ end
53
+ end
54
+
55
+ def url
56
+ if @url
57
+ @url
58
+ else
59
+ msg = 'Missing URL configuration. The ISACA Partners API requires an endpoint URL.'
60
+ msg << ' Example: ISACA.configure {|config| config.url = "https://partnerapi.isaca.org:8443/ISACAServices/Service1.svc"}'
61
+
62
+ raise ConfigurationError.new(msg)
63
+ end
64
+ end
65
+ end
66
+
67
+ def user_agent
68
+ if @user_agent
69
+ @user_agent
70
+ else
71
+ msg = 'Missing User-Agent configuration. The ISACA Partners API requires a predefined User-Agent.'
72
+ msg << ' Example: ISACA.configure {|config| config.user_agent = "MyApplication"}'
73
+
74
+ raise ConfigurationError.new(msg)
75
+ end
76
+ end
77
+
78
+ class ConfigurationError < StandardError; end
79
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isaca
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Orahood
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description: A wrapper for the ISACA Partners API
70
+ email:
71
+ - morahood@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - isaca.gemspec
85
+ - lib/isaca.rb
86
+ - lib/isaca/helpers.rb
87
+ - lib/isaca/models/authenticate_user.rb
88
+ - lib/isaca/models/get_user_by_id.rb
89
+ - lib/isaca/models/get_user_details_by_token.rb
90
+ - lib/isaca/models/log_out.rb
91
+ - lib/isaca/models/submit_cpe.rb
92
+ - lib/isaca/requests/authenticate_user.rb
93
+ - lib/isaca/requests/get_user_by_id.rb
94
+ - lib/isaca/requests/get_user_details_by_token.rb
95
+ - lib/isaca/requests/log_out.rb
96
+ - lib/isaca/requests/request.rb
97
+ - lib/isaca/requests/submit_cpe.rb
98
+ - lib/isaca/version.rb
99
+ homepage: ''
100
+ licenses: []
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.6.14
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: A wrapper for the ISACA Partners API
122
+ test_files: []