isaca 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c38c95789f898eb26dcd03fc06bcff1926c8c58b
4
- data.tar.gz: 6d75fb5d7416ec8c914d6fdb4a3e3dd25a30f50e
3
+ metadata.gz: 673f78f81502f22ce8a21209d12a7962c60949e9
4
+ data.tar.gz: 696908574a010e26180f4f85530ed99820ccfb5b
5
5
  SHA512:
6
- metadata.gz: adf4b9e63ca46bd02322db1bace60dd34318fe3c153e6c61c525aa2565e01043170395fa05e85cfb4e119a44f3dded0e3b22a0850c915786d3dee1c6aef2bb8c
7
- data.tar.gz: 9b1ead55d0c97c50c2c7bdffb78c7bf5e4871d5f5f5d974a33ba9cccd15cf0745a3ec5f4566ff1b44730c184f6b9533b89114104ff733844f5b776fe81ecd4a8
6
+ metadata.gz: 26288e7fa7ea9811390a27e19d2f2e932cebc1d809b6d04613838d9b6d0a224e17fc97e58f5e49a865b59add6b58d52f36640f3cbefac0c6b961343b4108ecf3
7
+ data.tar.gz: 206e1394350fd730dacc42e493510d2bf76412e5d94017062f3261ffe05e3086cc3539be655bc75ff88252b713f0800b7437f9cae84c95768848fe32b3c5c1ec
data/.gitignore CHANGED
@@ -71,4 +71,6 @@ fabric.properties
71
71
  .idea/
72
72
 
73
73
 
74
- # End of https://www.gitignore.io/api/rubymine+all
74
+ # End of https://www.gitignore.io/api/rubymine+all
75
+
76
+ log/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isaca (0.1.6)
4
+ isaca (0.1.7)
5
5
  faraday (~> 0.14.0)
6
6
 
7
7
  GEM
data/lib/isaca/helpers.rb CHANGED
@@ -7,10 +7,6 @@ module ISACA
7
7
  (string_time.nil? || string_time.empty?) ? nil : DateTime.strptime(string_time, format)
8
8
  end
9
9
 
10
- def self.parse_json(string)
11
- JSON.parse(string)
12
- end
13
-
14
10
  def self.parse_boolean(string)
15
11
  string == 'True' ? true : false
16
12
  end
@@ -8,6 +8,8 @@ module ISACA
8
8
  attr_accessor :email
9
9
  attr_accessor :username
10
10
  attr_accessor :country
11
+ attr_accessor :privacy
12
+ attr_accessor :marketing
11
13
 
12
14
  def initialize(hash)
13
15
  @imis_id = hash['ID']
@@ -17,6 +19,22 @@ module ISACA
17
19
  @email = hash['Email']
18
20
  @username = hash['UserName']
19
21
  @country = hash['Country']
22
+
23
+ if hash['PRIVACY'] == '1'
24
+ @privacy = true
25
+ elsif hash['PRIVACY'] == '0'
26
+ @privacy = false
27
+ else
28
+ @privacy = nil
29
+ end
30
+
31
+ if hash['MARKETING'] == '1'
32
+ @marketing = true
33
+ elsif hash['MARKETING'] == '0'
34
+ @marketing = false
35
+ else
36
+ @marketing = nil
37
+ end
20
38
  end
21
39
  end
22
40
  end
@@ -8,7 +8,10 @@ module ISACA
8
8
  request.params['password'] = password
9
9
  end
10
10
 
11
- response.status == 200 ? ISACA::Model::AuthenticateUser.new(ISACA::Helpers.parse_json(response.body)) : nil
11
+ data = JSON.parse(response.body)
12
+ ISACA.logger.debug(data) if ISACA.configuration.debug
13
+
14
+ response.status == 200 ? ISACA::Model::AuthenticateUser.new(data) : nil
12
15
  end
13
16
  end
14
17
  end
@@ -7,7 +7,10 @@ module ISACA
7
7
  request.params['ID'] = id
8
8
  end
9
9
 
10
- response.status == 200 ? ISACA::Model::GetUserByID.new(ISACA::Helpers.parse_json(response.body)) : nil
10
+ data = JSON.parse(response.body)
11
+ ISACA.logger.debug(data) if ISACA.configuration.debug
12
+
13
+ response.status == 200 ? ISACA::Model::GetUserByID.new(data) : nil
11
14
  end
12
15
  end
13
16
  end
@@ -7,8 +7,10 @@ module ISACA
7
7
  request.params['token'] = token
8
8
  end
9
9
 
10
- data = JSON.parse(response.body, quirks_mode: true)
11
- response.status == 200 ? ISACA::Model::GetUserDetailsByToken.new(ISACA::Helpers.parse_json(data)) : nil
10
+ data = JSON.parse(JSON.parse(response.body, quirks_mode: true))
11
+ ISACA.logger.debug(data) if ISACA.configuration.debug
12
+
13
+ response.status == 200 ? ISACA::Model::GetUserDetailsByToken.new(data) : nil
12
14
  end
13
15
  end
14
16
  end
@@ -1,6 +1,19 @@
1
1
  module ISACA
2
2
  module Request
3
3
  module SubmitCPE
4
+ def self.get(imis_id, result, cpe)
5
+ response = ISACA::Request.get do |request|
6
+ request.path = request.path + '/SubmitCPE'
7
+ request.params['id'] = imis_id
8
+ request.params['result'] = result
9
+ request.params['cpe'] = cpe
10
+ end
11
+
12
+ data = JSON.parse(response.body)
13
+ ISACA.logger.debug(data) if ISACA.configuration.debug
14
+
15
+ response.status == 200 ? ISACA::Model::SubmitCPE.new(data) : nil
16
+ end
4
17
  end
5
18
  end
6
19
  end
data/lib/isaca/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ISACA
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/isaca.rb CHANGED
@@ -13,15 +13,26 @@ require 'isaca/models/get_user_details_by_token'
13
13
  require 'isaca/models/submit_cpe'
14
14
 
15
15
  require 'isaca/version'
16
+ require 'fileutils'
16
17
  require 'openssl'
18
+ require 'logger'
17
19
 
18
20
  module ISACA
19
21
  class << self
20
22
  attr_accessor :configuration
23
+ attr_accessor :logger
21
24
 
22
25
  def configuration
23
26
  @configuration ||= Configuration.new
24
27
  end
28
+
29
+ def logger
30
+ path = 'log/isaca.log'
31
+ dir = File.dirname(path)
32
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
33
+
34
+ @logger ||= Logger.new(path)
35
+ end
25
36
  end
26
37
 
27
38
  def self.configure
@@ -35,9 +46,12 @@ module ISACA
35
46
  attr_accessor :secret_pass
36
47
  attr_accessor :user_agent
37
48
  attr_accessor :verify_ssl
49
+ attr_writer :logger
50
+ attr_accessor :debug
38
51
 
39
52
  def initialize
40
53
  @verify_ssl = true
54
+ @debug = false
41
55
  end
42
56
 
43
57
  def secret_pass
@@ -72,6 +86,10 @@ module ISACA
72
86
 
73
87
  raise ConfigurationError.new(msg)
74
88
  end
89
+
90
+ def logger=(logger)
91
+ ISACA.logger = logger
92
+ end
75
93
  end
76
94
 
77
95
  class ConfigurationError < StandardError; 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: 0.1.6
4
+ version: 0.1.7
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-03-30 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday