sinatra-hexacta 1.4.3 → 1.4.4

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
  SHA256:
3
- metadata.gz: fa4ce2599f3137734dcbc471ecd27592241b1043086c1671d10728d87432025b
4
- data.tar.gz: 7cd5851bd3d4e81788256f94c0372afd1dedf4a1cd7f597e4cb04a9bb007e14c
3
+ metadata.gz: 309f78d43f4e7447e920edaa8e90d36f4992e1cdc0fde8a40ee7ad8f0e17498a
4
+ data.tar.gz: 66e5d4cceb9b6bf3e1f83919bc2f0962827ef6fba83d459eec4aceea85ac6675
5
5
  SHA512:
6
- metadata.gz: 4d3c9b32037026c1235d80f0a2abd4bae7883c093fdc05192ed135cf75190ccc08696d1a556a8324db0d9fa38467e1a7c80a86fff3a043d5c80823d656efcfff
7
- data.tar.gz: e28adc2053545077db25b8c3b023c9aa4fc5dba671883b0f9fa1379e968972c6a43123336579e07539290efc5e57e8b88594bef2b09f0603147aaa9059e502a3
6
+ metadata.gz: 8c0c94b820a01db53ae1450f5dd014ca2d1541b6c9f2bb1a0f216e6579b64352ef59bfb2940e405e69a8ae7f19eef4b0f3e434d178a51d75cf3bfe75751b019e
7
+ data.tar.gz: 3536f3971f4cb17aa0674a496b98d33d2794a0dfe84bf5418ce88b8b4b9e65354d7a7784226b2bf3378cf9de4a775d9f72ef740280b4afc6c0d134c8f5e55e74
@@ -20,16 +20,32 @@ class MailSender
20
20
  http.start { |http| http.request(request) }
21
21
  end
22
22
 
23
+
23
24
  def _authorize_mail
24
25
  params = [ [ "grant_type", "password" ], [ "client_id", "MailApp" ], [ "client_secret", "MailAppPRD2018!" ] ]
25
- response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
26
+ retry_times = 0
27
+ begin
28
+ response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
29
+ rescue StandardError => bang
30
+ response = nil
31
+ end
32
+ until response.is_a?( Net::HTTPSuccess ) || retry_times > 10 do
33
+ begin
34
+ retry_times = retry_times + 1
35
+ sleep(retry_times)
36
+ response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
37
+ rescue StandardError => bang
38
+ end
39
+ end
26
40
  if( response.is_a?( Net::HTTPSuccess ) )
27
41
  token = JSON.parse(response.body)
28
42
  @access_token = token["access_token"]
29
43
  @refresh_token = token["refresh_token"]
30
44
  @expire = DateTime.parse(token[".expires"])
45
+ return true
31
46
  else
32
47
  NotificationSender.instance.send_error(nil,'Authorize mail failed',response.body)
48
+ return false
33
49
  end
34
50
  end
35
51
 
@@ -54,26 +70,34 @@ class MailSender
54
70
  end
55
71
 
56
72
  def _expired?
57
- expire.nil? || DateTime.now < expire
73
+ @expire.nil? || DateTime.now < @expire
58
74
  end
59
75
 
76
+
60
77
  def do_send(mail)
61
- begin
62
- if _expired?
63
- _authorize_mail
64
- end
78
+ authorized = _expired?? _authorize_mail : true
65
79
 
80
+ if authorized
66
81
  params = [ [ "ApplicationCode", 2009 ], [ "Name", mail.template ], [ "Subject", mail.subject ], [ "EmailAddress", mail.from ] ]
67
82
  params = params + _build_map_values(mail.values) + _build_to_map(mail.to)
68
83
 
69
- response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
70
-
84
+ retry_times = 0
85
+ begin
86
+ response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
87
+ rescue StandardError => bang
88
+ response = nil
89
+ end
90
+ until response.is_a?( Net::HTTPSuccess ) || retry_times > 10 do
91
+ begin
92
+ retry_times = retry_times + 1
93
+ sleep(retry_times)
94
+ response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
95
+ rescue StandardError => bang
96
+ end
97
+ end
71
98
  if( !response.is_a?( Net::HTTPSuccess ) )
72
99
  NotificationSender.instance.send_error(nil,'Send mail failed',response.body)
73
100
  end
74
- rescue StandardError => error
75
- message = error.backtrace.join(',');
76
- NotificationSender.instance.send_error(nil,"Mail send error",message)
77
101
  end
78
102
  end
79
103
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-hexacta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Zanger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-22 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sucker_punch