mojesouhlasy 0.0.2

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: 4b94c670dee76e37008a0eee2873f827eb6ddee8
4
+ data.tar.gz: 34d16e7c4adadb223ce6bff52af23c1f471791f0
5
+ SHA512:
6
+ metadata.gz: ae4f60b82e05addbb48688b066c536ff7515b3518218e91b54247aef6a016ea05067a437d32a4ba1b147eae41aceb831106ad375d6e4b58dd2c2505bea9d8558
7
+ data.tar.gz: 865a3eb99151910c0a05b22a4209031d73a5c1928d38602ba6a059b0c7e1904262d9d3bbf4be2b40a554779326916d78ea9396d11fbc288411161e6549780dd5
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Mojesouhlasy.cz
2
+
3
+ ## Installation
4
+ Add this line to your application's Gemfile:
5
+
6
+ ```ruby
7
+ gem 'mojesouhlasy'
8
+ ```
9
+
10
+ ## Configuration
11
+
12
+ Create file in config/initializers/mojesouhlasy.rb with this content:
13
+
14
+ ```ruby
15
+ Mojesouhlasy::Core.config = {
16
+ endpoint: 'https://mojesouhlasy.cz',
17
+ api_token: '' #get this token at Mojesouhlasy.cz
18
+ }
19
+ ```
20
+
21
+ Or you can generate this config file by running ```rails g mojesouhlasy``` in console.
22
+
23
+
24
+ ## Using
25
+ ```ruby
26
+ Mojesouhlasy::Users.import(['email1@example.com', 'email2@example.com']) #imports users and send registration emails.
27
+ Mojesouhlasy::Users.anonymize('email@example.com') #anonymize user with email and sends email to him.
28
+ Mojesouhlasy::Users.is_anonymized('email@example.com') #check if user with this email is anonymized.
29
+ Mojesouhlasy::Users.anonymized #get all anonymized users.
30
+ Mojesouhlasy::Users.not_anonymized #get all not anonymized users.
31
+ Mojesouhlasy::Users.approved_for_purpose('purpose-id') #get all approved users for specific purpose.
32
+
33
+ Mojesouhlasy::Purposes.list #get all company's purposes.
34
+ ```
35
+
@@ -0,0 +1,12 @@
1
+ if defined?(Rails)
2
+
3
+ # Rails3 generator invoked with 'rails generate mojesouhlasy'
4
+ class MojesouhlasyGenerator < Rails::Generators::Base
5
+ source_root(File.expand_path(File.dirname(__FILE__) + "/../templates/mojesouhlasy"))
6
+ def copy_initializer
7
+
8
+ copy_file 'mojesouhlasy_template.rb', 'config/initializers/mojesouhlasy.rb'
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,26 @@
1
+ module Mojesouhlasy
2
+
3
+ require 'rest-client'
4
+ require 'mojesouhlasy/version'
5
+ require 'mojesouhlasy/engine' if defined?(::Rails)
6
+ require 'mojesouhlasy/users'
7
+ require 'mojesouhlasy/purposes'
8
+
9
+ class Core
10
+ @@config = {}
11
+ cattr_accessor :config
12
+
13
+ def initialize(opts = {})
14
+ @opts = opts
15
+ end
16
+
17
+ def self.endpoint
18
+ @@config[:endpoint].presence || 'https://mojesouhlasy.cz'
19
+ end
20
+
21
+ def self.headers
22
+ {'AUTH-TOKEN' => @@config[:api_token], accept: :json}
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,4 @@
1
+ module Mojesouhlasy
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module Mojesouhlasy
2
+ module Purposes
3
+
4
+ def self.list
5
+ parse(RestClient.get "#{Core.endpoint}/api/company/purposes", Core.headers)
6
+ end
7
+
8
+ private
9
+
10
+ def self.parse(request)
11
+ JSON.parse(request, symbolize_names: true)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ module Mojesouhlasy
2
+ module Users
3
+
4
+ def self.import(emails)
5
+ parse(RestClient.post "#{Core.endpoint}/api/company/users/import", {emails: emails}, Core.headers)
6
+ end
7
+
8
+ def self.anonymize(email)
9
+ parse(RestClient.get "#{Core.endpoint}/api/company/users/anonymize", Core.headers.merge!({params: {email: email}}))
10
+ end
11
+
12
+ def self.approved_for_purpose(purpose_id)
13
+ parse(RestClient.get "#{Core.endpoint}/api/company/purposes/#{purpose_id}/users", Core.headers)
14
+ end
15
+
16
+ def self.anonymized
17
+ parse(RestClient.get "#{Core.endpoint}/api/company/users/anonymized", Core.headers)
18
+ end
19
+
20
+ def self.is_anonymized(email)
21
+ parse(RestClient.get "#{Core.endpoint}/api/company/users/is_anonymized", Core.headers.merge!({params: {email: email}}))
22
+ end
23
+
24
+ def self.not_anonymized
25
+ parse(RestClient.get "#{Core.endpoint}/api/company/users/not_anonymized", Core.headers)
26
+ end
27
+
28
+ private
29
+
30
+ def self.parse(request)
31
+ JSON.parse(request, symbolize_names: true)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Mojesouhlasy
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,4 @@
1
+ Mojesouhlasy::Core.config = {
2
+ endpoint: 'https://mojesouhlasy.cz',
3
+ api_token: '' # get this token at Mojesouhlasy.cz
4
+ }
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mojesouhlasy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Richard Lapiš
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.7.3
27
+ description: Connection to mojesouhlasy.cz - GDPR consents application
28
+ email: richard.lapis@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - README.md
34
+ - lib/generators/mojesouhlasy_generator.rb
35
+ - lib/mojesouhlasy.rb
36
+ - lib/mojesouhlasy/engine.rb
37
+ - lib/mojesouhlasy/purposes.rb
38
+ - lib/mojesouhlasy/users.rb
39
+ - lib/mojesouhlasy/version.rb
40
+ - lib/templates/mojesouhlasy/mojesouhlasy_template.rb
41
+ homepage: https://railsformers.com
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.9.3
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.4.8
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Connection to mojesouhlasy.cz - GDPR consents application
65
+ test_files: []