agilibox 1.0.14 → 1.0.15

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: 2a1aedfde807ff11e7230b83d1c65305f4abe9b6
4
- data.tar.gz: ec2ff7c3c3bc68c383b3ba4887a4c0f006c80a61
3
+ metadata.gz: 6ed08a7d086225ae4abf9cac6f5f7a2e4e9250f0
4
+ data.tar.gz: c2c2fb53c41d945c973f0938f2809209090b02f4
5
5
  SHA512:
6
- metadata.gz: 95781e7dba7620ecdcd196a15b0788618b70d401391163e7443d3576e522f560fd62d5fcc39d1a6f8be8aea4b468569d3c498926770b4ffd30cd6e63e7d6dc9d
7
- data.tar.gz: 830a06fca765d269ba0445df621d04d5f0fbf73783e138567c8254e0ee63ad76f51fa95d3e4c875c3dea247db6767347fe84e4322283751fe7144188fdaf1420
6
+ metadata.gz: ca24f0844a6aca0e1abcac9db9d11a1620dc132034afa8aa8c737eb90b177f169cf1dfaef242e286bc7d1890f433ef23f257787d1bc2e232081ad82c288c57f5
7
+ data.tar.gz: 1bc57502c9ba25e4645ba42135967b258df0be8a30ff3f2f4460399056fcffdd0774a41b7d2cb46b993ade48b8d21f832b617122de0e2e81dcb45e8038c21f63
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 1.0.15
6
+
7
+ - `ApiControllerConcern#render_json_error` improvements
8
+ - Add Agilibox::Service object
9
+ - Fix SMS AmazonSNS strategy bug
10
+ - Fix time period filter
11
+
5
12
  ## 1.0.14
6
13
 
7
14
  - Sorting helper improvements
@@ -12,16 +12,18 @@ module Agilibox::ApiControllerConcern
12
12
  render options.merge(json: json)
13
13
  end
14
14
 
15
- def render_json_error(message_or_object, options = {})
16
- if message_or_object.is_a?(ActiveRecord::Base)
17
- message = message_or_object.errors.full_messages.join(", ")
15
+ def render_json_error(any_object, options = {})
16
+ if any_object.is_a?(ActiveRecord::Base)
17
+ json = {error: any_object.errors.full_messages.join(", ")}
18
+ elsif any_object.is_a?(String)
19
+ json = {error: any_object}
18
20
  else
19
- message = message_or_object
21
+ json = any_object
20
22
  end
21
23
 
22
24
  options[:status] ||= :unprocessable_entity
23
25
 
24
- render_json({error: message}, options)
26
+ render_json(json, options)
25
27
  end
26
28
 
27
29
  def render_not_found
@@ -1,5 +1,7 @@
1
1
  class Agilibox::SmallData::FilterStrategyByTimePeriod < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value) # rubocop:disable Metrics/MethodLength
3
+ value = value.to_s
4
+
3
5
  if value == "today"
4
6
  a = Time.zone.now.beginning_of_day
5
7
  b = Time.zone.now.end_of_day
@@ -28,10 +30,10 @@ class Agilibox::SmallData::FilterStrategyByTimePeriod < ::Agilibox::SmallData::F
28
30
  return query
29
31
  end
30
32
 
31
- criteria = "#{query.model.table_name}.#{key}"
33
+ column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
32
34
 
33
35
  query
34
- .where("#{criteria} >= ?", a.to_date)
35
- .where("#{criteria} <= ?", b.to_date)
36
+ .where("DATE(#{column}) >= ?", a.to_date)
37
+ .where("DATE(#{column}) <= ?", b.to_date)
36
38
  end
37
39
  end
@@ -0,0 +1,20 @@
1
+ module Agilibox::InitializeWith
2
+ extend ActiveSupport::Concern
3
+
4
+ class_methods do
5
+ def initialize_with(*attrs)
6
+ attr_reader(*attrs)
7
+
8
+ define_method(:initialize) do |*args|
9
+ if attrs.length != args.length
10
+ message = "wrong number of arguments (given #{args.length}, expected #{attrs.length})"
11
+ raise ArgumentError, message
12
+ end
13
+
14
+ attrs.length.times do |i|
15
+ instance_variable_set("@#{attrs[i]}", args[i])
16
+ end
17
+ end
18
+ end
19
+ end # class_methods
20
+ end
@@ -0,0 +1,11 @@
1
+ class Agilibox::Service
2
+ include Agilibox::InitializeWith
3
+
4
+ def self.call(*args)
5
+ new(*args).call
6
+ end
7
+
8
+ def call(*)
9
+ raise NotImplementedError
10
+ end
11
+ end
@@ -1,18 +1,18 @@
1
1
  class Agilibox::SMS::Strategies::AmazonSNS < Agilibox::SMS::Strategies::Base
2
2
  class << self
3
- attr_writer :region
3
+ attr_writer :sns_region
4
4
 
5
5
  def sns_region
6
6
  @sns_region ||= (ENV["SNS_REGION"] || ENV["AWS_REGION"])
7
7
  end
8
8
 
9
- attr_writer :access_key_id
9
+ attr_writer :sns_access_key_id
10
10
 
11
11
  def sns_access_key_id
12
12
  @sns_access_key_id ||= (ENV["SNS_ACCESS_KEY_ID"] || ENV["AWS_ACCESS_KEY_ID"])
13
13
  end
14
14
 
15
- attr_writer :secret_access_key
15
+ attr_writer :sns_secret_access_key
16
16
 
17
17
  def sns_secret_access_key
18
18
  @sns_secret_access_key ||= (ENV["SNS_SECRET_ACCESS_KEY"] || ENV["AWS_SECRET_ACCESS_KEY"])
@@ -1,3 +1,3 @@
1
- ENV["RAILS_ROOT"] ||= File.expand_path("../../../spec/dummy", __FILE__)
1
+ ENV["RAILS_ROOT"] ||= File.expand_path("../../spec/dummy", __dir__)
2
2
  require "cucumber/rails"
3
3
  require "agilibox/cucumber_config"
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.0.14"
2
+ VERSION = "1.0.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilibox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-07 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -102,6 +102,7 @@ files:
102
102
  - app/helpers/agilibox/sorting_helper.rb
103
103
  - app/helpers/agilibox/text_helper.rb
104
104
  - app/helpers/h.rb
105
+ - app/libs/agilibox/initialize_with.rb
105
106
  - app/libs/agilibox/mini_model_serializer/serialize.rb
106
107
  - app/libs/agilibox/mini_model_serializer/serializer.rb
107
108
  - app/libs/agilibox/phone_number_sanitizer.rb
@@ -117,6 +118,7 @@ files:
117
118
  - app/serializers/agilibox/serializers.rb
118
119
  - app/serializers/agilibox/serializers/base.rb
119
120
  - app/serializers/agilibox/serializers/xlsx.rb
121
+ - app/services/agilibox/service.rb
120
122
  - app/sms/agilibox/sms.rb
121
123
  - app/sms/agilibox/sms/application_sms.rb
122
124
  - app/sms/agilibox/sms/strategies/amazon_sns.rb