mints 0.0.8 → 0.0.13
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 +4 -4
- data/Gemfile +2 -1
- data/{Readme.md → README.md} +5 -5
- data/lib/client.rb +43 -9
- data/lib/contact.rb +0 -0
- data/lib/generators/mints_config.yml.erb +23 -0
- data/lib/generators/mints_contact_controller.rb +0 -0
- data/lib/generators/mints_files_generator.rb +1 -1
- data/lib/generators/mints_public_controller.rb +0 -0
- data/lib/generators/mints_user_controller.rb +0 -0
- data/lib/mints.rb +1 -0
- data/lib/mints/controllers/admin_base_controller.rb +3 -2
- data/lib/mints/controllers/base_api_controller.rb +53 -0
- data/lib/mints/controllers/base_controller.rb +4 -3
- data/lib/mints/controllers/contact_api_controller.rb +61 -9
- data/lib/mints/controllers/public_api_controller.rb +58 -9
- data/lib/mints/controllers/user_api_controller.rb +56 -9
- data/lib/pub.rb +4 -4
- data/lib/user.rb +0 -0
- metadata +25 -4
- data/lib/generators/mints_config.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c41c7087845ab6006184ede917cacbd44060204251bf3ca22feba75c3a259833
|
4
|
+
data.tar.gz: 5e9ad370733cb076c6000d5127d979b9727c7c103e56a79095ff881de0249a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5b4e5709e9852e34bf9411cc158d75faf35204bd897625106748ed27d00f7217b16fbb844abc28ec935b83dd6ade6ca7708330280d61de6969ca3a498b7425
|
7
|
+
data.tar.gz: 265637b717d062e3c0474b3ad5d1275f7c3329568a4fcc6b181f6198cddd5ef325583cdaa3827c6e6ff752b24b458316c9dda6f068946142577101c16ea3bff3
|
data/Gemfile
CHANGED
data/{Readme.md → README.md}
RENAMED
@@ -30,7 +30,7 @@ con.login(email, password)
|
|
30
30
|
con.get_contacts
|
31
31
|
```
|
32
32
|
## Generate mints files
|
33
|
-
This command will generate the mints_config.yml file, API controlles and routes to have available the mints endpoints
|
33
|
+
This command will generate the mints_config.yml.erb file, API controlles and routes to have available the mints endpoints
|
34
34
|
```bash
|
35
35
|
rails generate mints_files
|
36
36
|
```
|
@@ -46,8 +46,8 @@ This heritance will make the following class variables available:
|
|
46
46
|
|
47
47
|
| Variable | Description |
|
48
48
|
| --- | :---: |
|
49
|
-
| @host | Host defined in mints_config.yml file |
|
50
|
-
| @api_key | API key defined in mints_config.yml file |
|
49
|
+
| @host | Host defined in mints_config.yml.erb file |
|
50
|
+
| @api_key | API key defined in mints_config.yml.erb file |
|
51
51
|
| @mints_pub | An already instanced public client |
|
52
52
|
| @contact_token | A token used by mints to identify the contact |
|
53
53
|
| @visit_id | An identifier of the visit registered |
|
@@ -73,8 +73,8 @@ end
|
|
73
73
|
This heritance will make the following class variables available:
|
74
74
|
| Variable | Description |
|
75
75
|
| --- | :---: |
|
76
|
-
| @host | Host defined in mints_config.yml file |
|
77
|
-
| @api_key | API key defined in mints_config.yml file |
|
76
|
+
| @host | Host defined in mints_config.yml.erb file |
|
77
|
+
| @api_key | API key defined in mints_config.yml.erb file |
|
78
78
|
| @mints_user | An already instanced user client (not usable until call the user login method) |
|
79
79
|
|
80
80
|
And the following controller methods:
|
data/lib/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "httparty"
|
2
2
|
require "json"
|
3
3
|
require "addressable"
|
4
|
+
require "redis"
|
4
5
|
module Mints
|
5
6
|
class Client
|
6
7
|
attr_reader :host
|
@@ -24,10 +25,42 @@ module Mints
|
|
24
25
|
uri = Addressable::URI.new
|
25
26
|
uri.query_values = options
|
26
27
|
end
|
27
|
-
|
28
|
+
|
28
29
|
full_url = "#{@host}#{base_url}#{url}#{uri}"
|
30
|
+
response = nil
|
29
31
|
if action === 'get'
|
32
|
+
|
33
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
34
|
+
config = YAML.load template.result(binding)
|
35
|
+
url_need_cache = false
|
36
|
+
result_from_cache = false
|
37
|
+
time = 0
|
38
|
+
|
39
|
+
if config['redis_cache']['use_cache']
|
40
|
+
config['redis_cache']['groups'].each do |group|
|
41
|
+
group['urls'].each do |url|
|
42
|
+
if full_url.match url
|
43
|
+
time = group['time']
|
44
|
+
url_need_cache = true
|
45
|
+
@redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1)
|
46
|
+
if @redis_server.get(full_url)
|
47
|
+
response = @redis_server.get(full_url)
|
48
|
+
result_from_cache = true
|
49
|
+
else
|
50
|
+
response = self.send("#{@scope}_#{action}", "#{full_url}")
|
51
|
+
@redis_server.setex(full_url,time,response)
|
52
|
+
end
|
53
|
+
break
|
54
|
+
end
|
55
|
+
end
|
56
|
+
break if url_need_cache
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
if !url_need_cache
|
30
61
|
response = self.send("#{@scope}_#{action}", "#{full_url}")
|
62
|
+
end
|
63
|
+
|
31
64
|
elsif action === 'create' or action === 'post'
|
32
65
|
action = 'post'
|
33
66
|
response = self.send("#{@scope}_#{action}", "#{full_url}", data)
|
@@ -35,14 +68,15 @@ module Mints
|
|
35
68
|
action = 'put'
|
36
69
|
response = self.send("#{@scope}_#{action}", "#{full_url}", data)
|
37
70
|
end
|
38
|
-
if
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
71
|
+
if result_from_cache
|
72
|
+
return parsed_response = JSON.parse(response)
|
73
|
+
else
|
74
|
+
if (response.response.code == "404")
|
75
|
+
raise 'NotFoundError'
|
76
|
+
end
|
77
|
+
parsed_response = JSON.parse(response.body)
|
78
|
+
return parsed_response
|
79
|
+
end
|
46
80
|
end
|
47
81
|
|
48
82
|
def method_missing(name, *args, &block)
|
data/lib/contact.rb
CHANGED
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Mints connection configuration
|
2
|
+
mints:
|
3
|
+
host: http://your_host_goes_here.com
|
4
|
+
api_key: your_mints_api_key_goes_here
|
5
|
+
mints_slug: slug_id #save id and token in redis
|
6
|
+
user_email: mints_user_email
|
7
|
+
user_password: mints_user_password
|
8
|
+
redis_cache:
|
9
|
+
use_cache: boolean_value_to_enable_and_disable_cache
|
10
|
+
redis_host: your_redis_server_host
|
11
|
+
redis_port: your_redis_server_port
|
12
|
+
redis_db: your_redis_database
|
13
|
+
groups:
|
14
|
+
- urls:
|
15
|
+
- group_of_urls
|
16
|
+
time: time_that_will_be_applied_to_urls_in_seconds
|
17
|
+
sdk:
|
18
|
+
debug: false
|
19
|
+
cookies_iframe:
|
20
|
+
activated: boolean_value_to_enable_and_disable_cookies_iframe
|
21
|
+
expire_time: expire_time_of_cookies_iframe_in_hours
|
22
|
+
hosts:
|
23
|
+
- array_of_host_to_send_cookies
|
File without changes
|
@@ -2,7 +2,7 @@ class MintsFilesGenerator < Rails::Generators::Base
|
|
2
2
|
source_root(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
include Rails::Generators::Actions
|
4
4
|
def create_mints_files
|
5
|
-
copy_file 'mints_config.yml', 'mints_config.yml'
|
5
|
+
copy_file 'mints_config.yml.erb', 'mints_config.yml.erb'
|
6
6
|
copy_file 'mints_user_controller.rb', './app/controllers/api/mints_user_controller.rb'
|
7
7
|
copy_file 'mints_contact_controller.rb', './app/controllers/api/v1/mints_contact_controller.rb'
|
8
8
|
copy_file 'mints_public_controller.rb', './app/controllers/api/v1/mints_public_controller.rb'
|
File without changes
|
File without changes
|
data/lib/mints.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative "./pub.rb"
|
|
2
2
|
require_relative "./contact.rb"
|
3
3
|
require_relative "./user.rb"
|
4
4
|
require_relative "./mints/controllers/base_controller.rb"
|
5
|
+
require_relative "./mints/controllers/base_api_controller.rb"
|
5
6
|
require_relative "./mints/controllers/admin_base_controller.rb"
|
6
7
|
require_relative "./mints/controllers/public_api_controller.rb"
|
7
8
|
require_relative "./mints/controllers/contact_api_controller.rb"
|
@@ -41,8 +41,9 @@ module Mints
|
|
41
41
|
# === Set Mints user client.
|
42
42
|
# Initialize the public client and set the user token
|
43
43
|
def set_mints_user_client
|
44
|
-
if File.exists?("#{Rails.root}/mints_config.yml")
|
45
|
-
|
44
|
+
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
45
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
46
|
+
config = YAML.load template.result(binding)
|
46
47
|
@host = config["mints"]["host"]
|
47
48
|
@api_key = config["mints"]["api_key"]
|
48
49
|
@debug = config["sdk"]["debug"] ? config["sdk"]["debug"] : false
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Mints
|
2
|
+
class BaseApiController < ActionController::Base
|
3
|
+
before_action :set_mints_pub_client
|
4
|
+
|
5
|
+
##
|
6
|
+
# === Mints Contact Login.
|
7
|
+
# Starts a contact session in mints.cloud and set a session cookie
|
8
|
+
def mints_contact_login(email, password)
|
9
|
+
# Login in mints
|
10
|
+
response = @mints_contact.login(email, password)
|
11
|
+
# Get session token from response
|
12
|
+
session_token = response['session_token']
|
13
|
+
id_token = response['contact']['id_token']
|
14
|
+
# Set a permanent cookie with the session token
|
15
|
+
cookies.permanent[:mints_contact_session_token] = session_token
|
16
|
+
cookies.permanent[:mints_contact_id] = id_token
|
17
|
+
@contact_token = id_token
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# === Mints Contact Logout.
|
22
|
+
# Destroy session from mints.cloud and delete local session cookie
|
23
|
+
def mints_contact_logout
|
24
|
+
# Logout from mints
|
25
|
+
@mints_contact.logout
|
26
|
+
# Delete local cookie
|
27
|
+
cookies.delete(:mints_contact_session_token)
|
28
|
+
cookies.delete(:mints_contact_id)
|
29
|
+
@contact_token = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
##
|
35
|
+
# === Set mints pub.
|
36
|
+
# Initialize the public client and set the contact token
|
37
|
+
def set_mints_pub_client
|
38
|
+
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
39
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
40
|
+
config = YAML.load template.result(binding)
|
41
|
+
@host = config["mints"]["host"]
|
42
|
+
@api_key = config["mints"]["api_key"]
|
43
|
+
@debug = config["sdk"]["debug"] ? config["sdk"]["debug"] : false
|
44
|
+
else
|
45
|
+
raise 'MintsBadCredentialsError'
|
46
|
+
end
|
47
|
+
# Initialize mints pub client, credentials taken from mints_config.yml.erb file
|
48
|
+
@mints_pub = Mints::Pub.new(@host, @api_key, nil, @debug)
|
49
|
+
# Set contact token from cookie
|
50
|
+
@mints_pub.client.session_token = @contact_token
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -59,15 +59,16 @@ module Mints
|
|
59
59
|
# === Set mints pub.
|
60
60
|
# Initialize the public client and set the contact token
|
61
61
|
def set_mints_pub_client
|
62
|
-
if File.exists?("#{Rails.root}/mints_config.yml")
|
63
|
-
|
62
|
+
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
63
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
64
|
+
config = YAML.load template.result(binding)
|
64
65
|
@host = config["mints"]["host"]
|
65
66
|
@api_key = config["mints"]["api_key"]
|
66
67
|
@debug = config["sdk"]["debug"] ? config["sdk"]["debug"] : false
|
67
68
|
else
|
68
69
|
raise 'MintsBadCredentialsError'
|
69
70
|
end
|
70
|
-
# Initialize mints pub client, credentials taken from mints_config.yml file
|
71
|
+
# Initialize mints pub client, credentials taken from mints_config.yml.erb file
|
71
72
|
@mints_pub = Mints::Pub.new(@host, @api_key, nil, @debug)
|
72
73
|
# Set contact token from cookie
|
73
74
|
@mints_pub.client.session_token = @contact_token
|
@@ -14,16 +14,64 @@ module Mints
|
|
14
14
|
'Content-Type'=> 'application/json',
|
15
15
|
'Accept'=> 'application/json'
|
16
16
|
}
|
17
|
+
# Set contact token id as header
|
18
|
+
if cookies[:mints_contact_id]
|
19
|
+
headers['ContactToken'] = cookies[:mints_contact_id]
|
20
|
+
end
|
21
|
+
# Set contact session token as header
|
17
22
|
if cookies[:mints_contact_session_token]
|
18
23
|
session_token = cookies[:mints_contact_session_token]
|
19
24
|
headers["Authorization"] = "Bearer #{session_token}"
|
20
25
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
|
27
|
+
url_need_cache = false
|
28
|
+
result_from_cache = false
|
29
|
+
time = 0
|
30
|
+
full_url = request.original_url
|
31
|
+
|
32
|
+
if request.method == "GET"
|
33
|
+
if @use_cache
|
34
|
+
@redis_config['groups'].each do |group|
|
35
|
+
group['urls'].each do |url|
|
36
|
+
if full_url.match url
|
37
|
+
time = group['time']
|
38
|
+
url_need_cache = true
|
39
|
+
break
|
40
|
+
end
|
41
|
+
end
|
42
|
+
break if url_need_cache
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if url_need_cache
|
48
|
+
if @redis_server.get(full_url)
|
49
|
+
response = @redis_server.get(full_url)
|
50
|
+
result_from_cache = true
|
51
|
+
render json: response
|
52
|
+
else
|
53
|
+
reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
|
54
|
+
# Request succeded!
|
55
|
+
config.on_response do |code, response|
|
56
|
+
@redis_server.setex(full_url,time,response.body)
|
57
|
+
end
|
58
|
+
# Request failed!
|
59
|
+
config.on_missing do |code, response|
|
60
|
+
# We got a 404!
|
61
|
+
if code == 404
|
62
|
+
raise ActionController::RoutingError.new('Not Found')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
else
|
68
|
+
reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
|
69
|
+
# Request failed!
|
70
|
+
config.on_missing do |code, response|
|
71
|
+
# We got a 404!
|
72
|
+
if code == 404
|
73
|
+
raise ActionController::RoutingError.new('Not Found')
|
74
|
+
end
|
27
75
|
end
|
28
76
|
end
|
29
77
|
end
|
@@ -32,10 +80,14 @@ module Mints
|
|
32
80
|
private
|
33
81
|
|
34
82
|
def set_config_variables
|
35
|
-
if File.exists?("#{Rails.root}/mints_config.yml")
|
36
|
-
|
83
|
+
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
84
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
85
|
+
config = YAML.load template.result(binding)
|
37
86
|
@host = config["mints"]["host"]
|
38
|
-
@api_key = config["mints"]["api_key"]
|
87
|
+
@api_key = config["mints"]["api_key"]
|
88
|
+
@redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1) if config['redis_cache']['use_cache']
|
89
|
+
@redis_config = config['redis_cache']
|
90
|
+
@use_cache = config['redis_cache']['use_cache']
|
39
91
|
end
|
40
92
|
end
|
41
93
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'reverse_proxy/controller'
|
2
2
|
require 'reverse_proxy/client'
|
3
|
+
require 'redis'
|
3
4
|
module Mints
|
4
5
|
class PublicAPIController < ActionController::API
|
5
6
|
include ReverseProxy::Controller
|
@@ -12,24 +13,72 @@ module Mints
|
|
12
13
|
'Content-Type'=> 'application/json',
|
13
14
|
'Accept'=> 'application/json'
|
14
15
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
|
17
|
+
url_need_cache = false
|
18
|
+
result_from_cache = false
|
19
|
+
time = 0
|
20
|
+
full_url = request.original_url
|
21
|
+
|
22
|
+
if request.method == "GET"
|
23
|
+
if @use_cache
|
24
|
+
@redis_config['groups'].each do |group|
|
25
|
+
group['urls'].each do |url|
|
26
|
+
if full_url.match url
|
27
|
+
time = group['time']
|
28
|
+
url_need_cache = true
|
29
|
+
break
|
30
|
+
end
|
31
|
+
end
|
32
|
+
break if url_need_cache
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if url_need_cache
|
38
|
+
if @redis_server.get(full_url)
|
39
|
+
response = @redis_server.get(full_url)
|
40
|
+
result_from_cache = true
|
41
|
+
render json: response
|
42
|
+
else
|
43
|
+
reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
|
44
|
+
# Request succeded!
|
45
|
+
config.on_response do |code, response|
|
46
|
+
@redis_server.setex(full_url,time,response.body)
|
47
|
+
end
|
48
|
+
# Request failed!
|
49
|
+
config.on_missing do |code, response|
|
50
|
+
# We got a 404!
|
51
|
+
if code == 404
|
52
|
+
raise ActionController::RoutingError.new('Not Found')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
|
59
|
+
# Request failed!
|
60
|
+
config.on_missing do |code, response|
|
61
|
+
# We got a 404!
|
62
|
+
if code == 404
|
63
|
+
raise ActionController::RoutingError.new('Not Found')
|
64
|
+
end
|
21
65
|
end
|
22
66
|
end
|
23
67
|
end
|
68
|
+
|
24
69
|
end
|
25
70
|
|
26
71
|
private
|
27
72
|
|
28
73
|
def set_config_variables
|
29
|
-
if File.exists?("#{Rails.root}/mints_config.yml")
|
30
|
-
|
74
|
+
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
75
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
76
|
+
config = YAML.load template.result(binding)
|
31
77
|
@host = config["mints"]["host"]
|
32
|
-
@api_key = config["mints"]["api_key"]
|
78
|
+
@api_key = config["mints"]["api_key"]
|
79
|
+
@redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1) if config['redis_cache']['use_cache']
|
80
|
+
@redis_config = config['redis_cache']
|
81
|
+
@use_cache = config['redis_cache']['use_cache']
|
33
82
|
end
|
34
83
|
end
|
35
84
|
end
|
@@ -14,16 +14,59 @@ module Mints
|
|
14
14
|
'Content-Type'=> 'application/json',
|
15
15
|
'Accept'=> 'application/json'
|
16
16
|
}
|
17
|
-
if cookies[:
|
17
|
+
if cookies[:mints_user_session_token]
|
18
18
|
session_token = cookies[:mints_user_session_token]
|
19
19
|
headers["Authorization"] = "Bearer #{session_token}"
|
20
20
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
|
22
|
+
url_need_cache = false
|
23
|
+
result_from_cache = false
|
24
|
+
time = 0
|
25
|
+
full_url = request.original_url
|
26
|
+
|
27
|
+
if request.method == "GET"
|
28
|
+
if url_need_cache
|
29
|
+
@redis_config['groups'].each do |group|
|
30
|
+
group['urls'].each do |url|
|
31
|
+
if full_url.match url
|
32
|
+
time = group['time']
|
33
|
+
url_need_cache = true
|
34
|
+
break
|
35
|
+
end
|
36
|
+
end
|
37
|
+
break if url_need_cache
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if url_need_cache
|
43
|
+
if @redis_server.get(full_url)
|
44
|
+
response = @redis_server.get(full_url)
|
45
|
+
result_from_cache = true
|
46
|
+
render json: response
|
47
|
+
else
|
48
|
+
reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
|
49
|
+
# Request succeded!
|
50
|
+
config.on_response do |code, response|
|
51
|
+
@redis_server.setex(full_url,time,response.body)
|
52
|
+
end
|
53
|
+
# Request failed!
|
54
|
+
config.on_missing do |code, response|
|
55
|
+
# We got a 404!
|
56
|
+
if code == 404
|
57
|
+
raise ActionController::RoutingError.new('Not Found')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
else
|
63
|
+
reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
|
64
|
+
# Request failed!
|
65
|
+
config.on_missing do |code, response|
|
66
|
+
# We got a 404!
|
67
|
+
if code == 404
|
68
|
+
raise ActionController::RoutingError.new('Not Found')
|
69
|
+
end
|
27
70
|
end
|
28
71
|
end
|
29
72
|
end
|
@@ -32,10 +75,14 @@ module Mints
|
|
32
75
|
private
|
33
76
|
|
34
77
|
def set_config_variables
|
35
|
-
if File.exists?("#{Rails.root}/mints_config.yml")
|
36
|
-
|
78
|
+
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
79
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
80
|
+
config = YAML.load template.result(binding)
|
37
81
|
@host = config["mints"]["host"]
|
38
82
|
@api_key = config["mints"]["api_key"]
|
83
|
+
@redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1) if config['redis_cache']['use_cache']
|
84
|
+
@redis_config = config['redis_cache']
|
85
|
+
@use_cache = config['redis_cache']['use_cache'] if config['redis_cache']['use_cache']
|
39
86
|
end
|
40
87
|
end
|
41
88
|
end
|
data/lib/pub.rb
CHANGED
@@ -7,7 +7,7 @@ module Mints
|
|
7
7
|
# == Usage example
|
8
8
|
# Initialize
|
9
9
|
# pub = Mints::Pub.new(mints_url, api_key)
|
10
|
-
# or if host and api_key are provided by mints_config.yml
|
10
|
+
# or if host and api_key are provided by mints_config.yml.erb
|
11
11
|
# pub = Mints::Pub.new
|
12
12
|
# Call any function
|
13
13
|
# pub.get_products
|
@@ -42,8 +42,8 @@ module Mints
|
|
42
42
|
# * +contact_token+ - [String] Cookie 'mints_contact_id' value (mints_contact_token)
|
43
43
|
# ==== Return
|
44
44
|
# Returns a Client object
|
45
|
-
def initialize(host, api_key, contact_token = nil, debug = false)
|
46
|
-
@client = Mints::Client.new(host, api_key, contact_token, debug)
|
45
|
+
def initialize(host, api_key, contact_token = nil, debug = false)
|
46
|
+
@client = Mints::Client.new(host, api_key, 'public', contact_token, debug)
|
47
47
|
end
|
48
48
|
|
49
49
|
##
|
@@ -178,7 +178,7 @@ module Mints
|
|
178
178
|
# ==== Parameters
|
179
179
|
# * +data+ - [Hash] Data to be submited
|
180
180
|
def submit_form(data)
|
181
|
-
return @client.raw("post", "/forms/
|
181
|
+
return @client.raw("post", "/content/forms/submit", nil, data)
|
182
182
|
end
|
183
183
|
|
184
184
|
##
|
data/lib/user.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mints
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Gomez Garcia, Omar Mora, Luis Payan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.18.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: redis
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 4.2.2
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 4.2.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 4.2.2
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 4.2.2
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: addressable
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,16 +117,17 @@ extensions: []
|
|
97
117
|
extra_rdoc_files: []
|
98
118
|
files:
|
99
119
|
- Gemfile
|
100
|
-
-
|
120
|
+
- README.md
|
101
121
|
- lib/client.rb
|
102
122
|
- lib/contact.rb
|
103
|
-
- lib/generators/mints_config.yml
|
123
|
+
- lib/generators/mints_config.yml.erb
|
104
124
|
- lib/generators/mints_contact_controller.rb
|
105
125
|
- lib/generators/mints_files_generator.rb
|
106
126
|
- lib/generators/mints_public_controller.rb
|
107
127
|
- lib/generators/mints_user_controller.rb
|
108
128
|
- lib/mints.rb
|
109
129
|
- lib/mints/controllers/admin_base_controller.rb
|
130
|
+
- lib/mints/controllers/base_api_controller.rb
|
110
131
|
- lib/mints/controllers/base_controller.rb
|
111
132
|
- lib/mints/controllers/contact_api_controller.rb
|
112
133
|
- lib/mints/controllers/public_api_controller.rb
|