bmc 1.3.2 → 1.3.5
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/CHANGELOG.md +9 -0
- data/app/filters/bmc/filter/by_key_value.rb +2 -0
- data/app/filters/bmc/filter/by_key_values.rb +3 -0
- data/app/helpers/bmc/form_helper.rb +5 -5
- data/app/libs/bmc/mini_model_serializer/serialize.rb +1 -1
- data/app/libs/bmc/mini_model_serializer/serializer.rb +1 -1
- data/app/serializers/bmc/serializers/xlsx.rb +5 -7
- data/app/sms/bmc/sms/delivery_error.rb +2 -0
- data/app/sms/bmc/sms/strategies/sendinblue.rb +41 -0
- data/lib/bmc/active_model_custom_error_messages.rb +1 -3
- data/lib/bmc/config.rb +3 -3
- data/lib/bmc/form_back_url.rb +1 -1
- data/lib/bmc/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c240f97e32a79aa89f2d8bbf57797dda66cfb566d63063a498e97e4e051dfa4
|
4
|
+
data.tar.gz: 127af8319136aef6611037276a6d29564938d7109e9914711db36aaecf4fded4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb20dae217a52ec5733b9d4e5e237099f455fc5003020d1c70d5e4de3aa09bf476e2d63b8cf31e2fd61110a490a010a669872bbef44e6da470caf4ee9e8703eb
|
7
|
+
data.tar.gz: da49b6d35eef688c3d6109df347de1d926cd48576c819849fff85db770b63f2f0dcaaed25276bf302bed1701747e61c11c0a02b92599b8fa9b053280f3d31b93
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Next version
|
4
4
|
|
5
|
+
## 1.3.5
|
6
|
+
- Add Sendinblue SMS strategy
|
7
|
+
|
8
|
+
## v1.3.4
|
9
|
+
- Add `all` support to filters `ByKeyValue` and `ByKeyValues`
|
10
|
+
|
11
|
+
## v1.3.3
|
12
|
+
- Add `only:` support to `hidden_inputs_for_get_form` helper
|
13
|
+
|
5
14
|
## v1.3.2
|
6
15
|
- Add `bs_button_to` helper
|
7
16
|
|
@@ -5,17 +5,17 @@ module BMC::FormHelper
|
|
5
5
|
# Does not work if display:none
|
6
6
|
def form_hidden_submit
|
7
7
|
css = "position:absolute;top:-9999px;left:-9999px;opacity:0;height:0;width:0;visibility: hidden"
|
8
|
-
tag(
|
8
|
+
tag.input(type: "submit", class: "hidden-submit", style: css)
|
9
9
|
end
|
10
10
|
|
11
11
|
def search_form(action: request.fullpath)
|
12
12
|
render "bmc/search/form", action: action
|
13
13
|
end
|
14
14
|
|
15
|
-
def hidden_inputs_for_get_form(url, except:
|
16
|
-
query_values = Addressable::URI.parse(url).query_values.to_h
|
17
|
-
|
18
|
-
|
15
|
+
def hidden_inputs_for_get_form(url, except: nil, only: nil)
|
16
|
+
query_values = Addressable::URI.parse(url).query_values.to_h.with_indifferent_access
|
17
|
+
query_values.except!(*except) if except
|
18
|
+
query_values.select! { only.map(&:to_sym).include?(_1.to_sym) } if only
|
19
19
|
|
20
20
|
return if query_values.empty?
|
21
21
|
|
@@ -8,7 +8,7 @@ class BMC::MiniModelSerializer::Serialize
|
|
8
8
|
|
9
9
|
def call
|
10
10
|
if object.is_a?(Hash)
|
11
|
-
object.
|
11
|
+
object.to_h { |k, v| [k.to_s, serialize(v)] }
|
12
12
|
elsif object.is_a?(Enumerable)
|
13
13
|
object.map { |e| serialize(e) }
|
14
14
|
elsif (serializer = "#{object.class}Serializer".safe_constantize)
|
@@ -11,9 +11,7 @@ class BMC::Serializers::XLSX < BMC::Serializers::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def render_file(file_path)
|
14
|
-
File.
|
15
|
-
f.write(render_inline)
|
16
|
-
end
|
14
|
+
File.binwrite(file_path, render_inline)
|
17
15
|
end
|
18
16
|
|
19
17
|
private
|
@@ -25,14 +23,14 @@ class BMC::Serializers::XLSX < BMC::Serializers::Base
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def date_range_styles(row)
|
28
|
-
row.each_index.select { row[_1].is_a?(Date) }.map do
|
29
|
-
{range: {rows: :all, columns:
|
26
|
+
row.each_index.select { row[_1].is_a?(Date) }.map do |col|
|
27
|
+
{range: {rows: :all, columns: col}, styles: {format_code: "dd/mm/yyyy"}}
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
def time_range_styles(row)
|
34
|
-
row.each_index.select { row[_1].is_a?(Time) }.map do
|
35
|
-
{range: {rows: :all, columns:
|
32
|
+
row.each_index.select { row[_1].is_a?(Time) }.map do |col|
|
33
|
+
{range: {rows: :all, columns: col}, styles: {format_code: "dd/mm/yyyy hh:mm:ss"}}
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class BMC::SMS::Strategies::Sendinblue
|
2
|
+
URL = "https://api.sendinblue.com/v3/transactionalSMS/sms"
|
3
|
+
|
4
|
+
DeliveryError = Class.new(BMC::SMS::DeliveryError)
|
5
|
+
|
6
|
+
attr_reader :api_key
|
7
|
+
|
8
|
+
def initialize(api_key: ENV["SENDINBLUE_API_KEY"])
|
9
|
+
@api_key = api_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(data)
|
13
|
+
response = HTTP.request(:post, URL, headers: request_headers, json: request_body(data))
|
14
|
+
|
15
|
+
unless response.code.to_s.start_with?("2")
|
16
|
+
raise DeliveryError, "Invalid response: #{response.code} / #{response.body}"
|
17
|
+
end
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def request_headers
|
25
|
+
{
|
26
|
+
:content_type => "application/json",
|
27
|
+
:api_key => api_key,
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def request_body(data)
|
32
|
+
from = data[:from] || BMC::SMS.default_from
|
33
|
+
|
34
|
+
{
|
35
|
+
:type => "transactional",
|
36
|
+
:sender => from,
|
37
|
+
:recipient => data[:to],
|
38
|
+
:content => data[:body],
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
data/lib/bmc/config.rb
CHANGED
@@ -5,7 +5,7 @@ class << BMC
|
|
5
5
|
@parent_controller ||= [
|
6
6
|
"ApplicationController",
|
7
7
|
"ActionController::Base",
|
8
|
-
].
|
8
|
+
].filter_map(&:safe_constantize).first
|
9
9
|
end
|
10
10
|
|
11
11
|
attr_writer :parent_job
|
@@ -14,7 +14,7 @@ class << BMC
|
|
14
14
|
@parent_job ||= [
|
15
15
|
"ApplicationJob",
|
16
16
|
"ActiveJob::Base",
|
17
|
-
].
|
17
|
+
].filter_map(&:safe_constantize).first
|
18
18
|
end
|
19
19
|
|
20
20
|
attr_writer :parent_mailer
|
@@ -23,6 +23,6 @@ class << BMC
|
|
23
23
|
@parent_mailer ||= [
|
24
24
|
"ApplicationMailer",
|
25
25
|
"ActionMailer::Base",
|
26
|
-
].
|
26
|
+
].filter_map(&:safe_constantize).first
|
27
27
|
end
|
28
28
|
end
|
data/lib/bmc/form_back_url.rb
CHANGED
data/lib/bmc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit MARTIN-CHAVE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -172,8 +172,10 @@ files:
|
|
172
172
|
- app/sms/bmc/sms.rb
|
173
173
|
- app/sms/bmc/sms/application_sms.rb
|
174
174
|
- app/sms/bmc/sms/deliver_job.rb
|
175
|
+
- app/sms/bmc/sms/delivery_error.rb
|
175
176
|
- app/sms/bmc/sms/message.rb
|
176
177
|
- app/sms/bmc/sms/strategies/amazon.rb
|
178
|
+
- app/sms/bmc/sms/strategies/sendinblue.rb
|
177
179
|
- app/sms/bmc/sms/strategies/test.rb
|
178
180
|
- app/sorters/bmc/sorter.rb
|
179
181
|
- app/views/bmc/search/_form.html.slim
|