mock-bandwidth 1.1.1 → 1.2.1

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: 989459f85a1c15c28e62e5e384bf2e3916a820bc2199ca664a92de1f8eeaecd7
4
- data.tar.gz: fca644ad717de699e1efc07378a2736f2006f8c310866534568b22f72657ce68
3
+ metadata.gz: 7f8655a3058743a8d413830fb6186354de556912c78410fc4e17242e13a7372c
4
+ data.tar.gz: 6e6574ae2b30987fed7e198bbc649af629784642c55256d13a2d84bfbcb5d37c
5
5
  SHA512:
6
- metadata.gz: 32cc04ecce4ed6a5bcffd2b3cd1de835dabb959312d0b972c70502f2305007b3750a7ec8a5041c367b2e4b9de1693f1b70cc7471a0b8127172becef64bd813d1
7
- data.tar.gz: 3d01d3a8fcae079ce7da0cd74ec786a00087e39be68d8a257e70512088352102b353da28d0fdb52985728e097917db8f0049996e235116444fb88265947a1d4d
6
+ metadata.gz: eeb5ee97dfb5103cfce82d68679a12a0936346aac7a4e8e457312f9900d5572637b7825b469d977c5d5b029ce97fd8c5f11577bcc6318f877fd2cafb247504b7
7
+ data.tar.gz: 8124f49d1abd0b3ae0679ce9ae582e640ae2934374c411f4a8c79f0abe56887e4e1fdb650f351d38d04e219b8cdcc941bf01a50b9b8ae52dd444dada6a8382ae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.2.1] - 2025-02-03
2
+ - Fix Scheduler perfomance
3
+
4
+ ## [1.2] - 2025-02-06
5
+ - Add disable_webhooks configuration
6
+ - Fix webhooks ErrorHandler
7
+
1
8
  ## [1.1.1] - 2025-02-03
2
9
  - Downgrade active-support to 5.2 for better compatibility
3
10
 
data/README.md CHANGED
@@ -51,6 +51,8 @@ end
51
51
 
52
52
  Mock::Bandwidth.configure do |config|
53
53
  config.webhook_message_status_url = "http://my-server.com/webhooks/bandwidth/messages_updates"
54
+ # optional
55
+ # config.disable_webhooks = true
54
56
  end
55
57
  ```
56
58
 
@@ -6,6 +6,8 @@ module Mock
6
6
  module MessagingV2
7
7
  class MessageCreate
8
8
  class << self
9
+ @@scheduler = Rufus::Scheduler.new
10
+
9
11
  def decorate(body, request)
10
12
  data = JSON.parse request.request_body
11
13
 
@@ -24,8 +26,7 @@ module Mock
24
26
  timestamp = (Time.now.to_f * 1000).to_i.to_s[0..12]
25
27
  random_part = SecureRandom.alphanumeric(15).downcase
26
28
  id = "#{timestamp}#{random_part}"
27
- scheduler = Rufus::Scheduler.new
28
- scheduler.in '2s' do
29
+ @@scheduler.in '2s' do
29
30
  begin
30
31
  Mock::Bandwidth::Webhooks::Messages.trigger(id, body)
31
32
  rescue => e
@@ -4,11 +4,15 @@ module Mock
4
4
  module Bandwidth
5
5
  module Util
6
6
  class Configuration
7
- attr_accessor :webhook_message_status_url
7
+ attr_accessor :webhook_message_status_url, :disable_webhooks
8
8
 
9
9
  def webhook_message_status_url=(value)
10
10
  @webhook_message_status_url = value
11
11
  end
12
+
13
+ def disable_webhooks=(value)
14
+ @disable_webhooks = value
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mock
4
4
  module Bandwidth
5
- VERSION = "1.1.1"
5
+ VERSION = "1.2.1"
6
6
  end
7
7
  end
@@ -5,6 +5,8 @@ module Mock
5
5
  module Webhooks
6
6
  class Messages < Base
7
7
  def self.trigger(id, body)
8
+ return if Mock::Bandwidth.disable_webhooks
9
+
8
10
  # Wait simulation from twilio
9
11
  sleep DELAY.sample
10
12
 
@@ -41,7 +43,7 @@ module Mock
41
43
  when 200..204
42
44
  response
43
45
  when 400..600
44
- raise Webhooks::RestError, Mock::Twilio::ErrorHandler.new(response).raise
46
+ raise Webhooks::RestError, Mock::Bandwidth::ErrorHandler.new(response).raise
45
47
  end
46
48
  end
47
49
  end
@@ -18,7 +18,7 @@ module Mock
18
18
  module Bandwidth
19
19
  extend SingleForwardable
20
20
 
21
- def_delegators :configuration, :webhook_message_status_url
21
+ def_delegators :configuration, :webhook_message_status_url, :disable_webhooks
22
22
 
23
23
  def self.configure(&block)
24
24
  yield configuration
@@ -28,6 +28,6 @@ module Mock
28
28
  @configuration ||= Util::Configuration.new
29
29
  end
30
30
 
31
- private_class_method :configuration
31
+ public_class_method :configuration
32
32
  end
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock-bandwidth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SchoolStatus Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-03 00:00:00.000000000 Z
11
+ date: 2025-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.1.6
135
+ rubygems_version: 3.5.12
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: This repository contains Mock::Bandwidth and Webhooks for Bandwidth's API.