mock-twilio 1.4 → 1.5.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/mock/twilio/decorators/api_2010/available_phone_numbers_local.rb +53 -0
- data/lib/mock/twilio/decorators/api_2010/calls.rb +3 -2
- data/lib/mock/twilio/decorators/api_2010/messages.rb +3 -2
- data/lib/mock/twilio/decorators/customer_profiles_v1/customer_profile_update.rb +3 -2
- data/lib/mock/twilio/schemas/api_2010.rb +8 -0
- data/lib/mock/twilio/schemas/brands_registrations_a2p.rb +3 -2
- data/lib/mock/twilio/util/generator.rb +18 -1
- data/lib/mock/twilio/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52bffd4c72fd567629419247ab70a105749bdc6ecb1949a90c6283d7a7f7605
|
4
|
+
data.tar.gz: 29b1ea83b4e2e031c9d667eb855291e0ff5c559efc4d8138cff9fd21628b1f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce53334c3db48402acd11ae664af553dd2bdbc6e14f961c7e581dbfa36280d1fa73c7809af595965d0eef3ffdbcedb75c797c057c0e91a57469ca523daad6dc
|
7
|
+
data.tar.gz: 12a531d4ec3ed53e3047bb2ff9b9fae4115246c30c9694e511298f979fda663191249a0190a949c434395573f7c7f5352a77aee845b00a7750acd1efa37140a6
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mock
|
4
|
+
module Twilio
|
5
|
+
module Decorators
|
6
|
+
module Api2010
|
7
|
+
class AvailablePhoneNumbersLocal
|
8
|
+
class << self
|
9
|
+
include Mock::Twilio::Generator
|
10
|
+
|
11
|
+
PAGES_KEYS = [
|
12
|
+
"end",
|
13
|
+
"first_page_uri",
|
14
|
+
"next_page_uri",
|
15
|
+
"last_page_uri",
|
16
|
+
"page",
|
17
|
+
"page_size",
|
18
|
+
"previous_page_uri",
|
19
|
+
"total",
|
20
|
+
"num_pages",
|
21
|
+
"start",
|
22
|
+
"uri"
|
23
|
+
].freeze
|
24
|
+
|
25
|
+
def decorate(body, request)
|
26
|
+
PAGES_KEYS.each do |key|
|
27
|
+
body.delete(key) if body.key?(key)
|
28
|
+
end
|
29
|
+
|
30
|
+
body["available_phone_numbers"].each do |number|
|
31
|
+
number["address_requirements"] = "none"
|
32
|
+
number["friendly_name"] = friendly_number_generator
|
33
|
+
number["iso_country"] = "US"
|
34
|
+
number["lata"] = rand(100..999).to_s
|
35
|
+
number["latitude"] = random_latitude.to_s
|
36
|
+
number["longitude"] = random_longitude.to_s
|
37
|
+
number["locality"] = "Hilo"
|
38
|
+
number["postal_code"] = rand(10000..99999).to_s
|
39
|
+
number["rate_center"] = "HILO"
|
40
|
+
number["region"] = "HI"
|
41
|
+
number["phone_number"] = phone_number_generator
|
42
|
+
end
|
43
|
+
|
44
|
+
body["uri"] = "/2010-04-01/Accounts/#{::Twilio.account_sid}/AvailablePhoneNumbers/US/Local.json"
|
45
|
+
|
46
|
+
body
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -5,6 +5,8 @@ module Mock
|
|
5
5
|
module Decorators
|
6
6
|
module Api2010
|
7
7
|
class Calls
|
8
|
+
@@scheduler = Rufus::Scheduler.new
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def decorate(body, request)
|
10
12
|
body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
|
@@ -26,8 +28,7 @@ module Mock
|
|
26
28
|
def call_sid(body, request)
|
27
29
|
prefix = "CA"
|
28
30
|
sid = prefix + SecureRandom.hex(16)
|
29
|
-
scheduler
|
30
|
-
scheduler.in '2s' do
|
31
|
+
@@scheduler.in '2s' do
|
31
32
|
conference_uuid = request.data["Url"].split("conference_uuid=").last
|
32
33
|
begin
|
33
34
|
response = Mock::Twilio::Webhooks::CallStatusUpdates.trigger(sid, conference_uuid, 'unknown', 'ringing')
|
@@ -5,6 +5,8 @@ module Mock
|
|
5
5
|
module Decorators
|
6
6
|
module Api2010
|
7
7
|
class Messages
|
8
|
+
@@scheduler = Rufus::Scheduler.new
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def decorate(body, request)
|
10
12
|
body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
|
@@ -34,9 +36,8 @@ module Mock
|
|
34
36
|
def message_sid(body, request)
|
35
37
|
prefix = request.data["MediaUrl"] ? "MM" : "SM"
|
36
38
|
sid = prefix + SecureRandom.hex(16)
|
37
|
-
scheduler = Rufus::Scheduler.new
|
38
39
|
callback_url = request.data["StatusCallback"] if request.data["StatusCallback"]
|
39
|
-
scheduler.in '2s' do
|
40
|
+
@@scheduler.in '2s' do
|
40
41
|
begin
|
41
42
|
response = Mock::Twilio::Webhooks::Messages.trigger(sid, callback_url)
|
42
43
|
|
@@ -5,6 +5,8 @@ module Mock
|
|
5
5
|
module Decorators
|
6
6
|
module CustomerProfilesV1
|
7
7
|
class CustomerProfileUpdate
|
8
|
+
@@scheduler = Rufus::Scheduler.new
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def decorate(body, request)
|
10
12
|
body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
|
@@ -21,8 +23,7 @@ module Mock
|
|
21
23
|
def parse_customer_profile_sid(body, request)
|
22
24
|
uri = URI(request.url)
|
23
25
|
customer_profile_sid = uri.path.split('/')[3].split('.').first
|
24
|
-
scheduler
|
25
|
-
scheduler.in '2s' do
|
26
|
+
@@scheduler.in '2s' do
|
26
27
|
begin
|
27
28
|
response = Mock::Twilio::Webhooks::CustomerProfiles.trigger(customer_profile_sid, "in-review")
|
28
29
|
|
@@ -6,6 +6,7 @@ require_relative "../decorators/api_2010/conferences_participants_update"
|
|
6
6
|
require_relative "../decorators/api_2010/conferences_participants_create"
|
7
7
|
require_relative "../decorators/api_2010/addresses"
|
8
8
|
require_relative "../decorators/api_2010/incoming_phone_numbers"
|
9
|
+
require_relative "../decorators/api_2010/available_phone_numbers_local"
|
9
10
|
|
10
11
|
module Mock
|
11
12
|
module Twilio
|
@@ -19,6 +20,7 @@ module Mock
|
|
19
20
|
conferences_participants_create: Mock::Twilio::Decorators::Api2010::ConferencesParticipantsCreate,
|
20
21
|
addresses: Mock::Twilio::Decorators::Api2010::Addresses,
|
21
22
|
incoming_phone_numbers: Mock::Twilio::Decorators::Api2010::IncomingPhoneNumbers,
|
23
|
+
available_phone_numbers_local: Mock::Twilio::Decorators::Api2010::AvailablePhoneNumbersLocal
|
22
24
|
}
|
23
25
|
|
24
26
|
PAGES_KEYS = [
|
@@ -50,7 +52,13 @@ module Mock
|
|
50
52
|
when %r{\/2010-04-01/Accounts/[A-Za-z0-9]+/Addresses.json}
|
51
53
|
RESOURCES[:addresses].decorate(body, request)
|
52
54
|
when %r{\/2010-04-01/Accounts/[A-Za-z0-9]+/IncomingPhoneNumbers/[A-Za-z0-9]+.json}
|
55
|
+
# Update
|
53
56
|
RESOURCES[:incoming_phone_numbers].decorate(body, request)
|
57
|
+
when %r{\/2010-04-01/Accounts/[A-Za-z0-9]+/IncomingPhoneNumbers.json}
|
58
|
+
# Create
|
59
|
+
RESOURCES[:incoming_phone_numbers].decorate(body, request)
|
60
|
+
when %r{\/2010-04-01/Accounts/[A-Za-z0-9]+/AvailablePhoneNumbers/[A-Z]+/Local.json}
|
61
|
+
RESOURCES[:available_phone_numbers_local].decorate(body, request)
|
54
62
|
end
|
55
63
|
end
|
56
64
|
end
|
@@ -4,6 +4,8 @@ module Mock
|
|
4
4
|
module Twilio
|
5
5
|
module Schemas
|
6
6
|
class BrandsRegistrationsA2p
|
7
|
+
@@scheduler = Rufus::Scheduler.new
|
8
|
+
|
7
9
|
class << self
|
8
10
|
def for(body, request)
|
9
11
|
body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
|
@@ -32,8 +34,7 @@ module Mock
|
|
32
34
|
def brand_sid(body)
|
33
35
|
prefix = "BN"
|
34
36
|
sid = prefix + SecureRandom.hex(16)
|
35
|
-
scheduler
|
36
|
-
scheduler.in '2s' do
|
37
|
+
@@scheduler.in '2s' do
|
37
38
|
response = Mock::Twilio::Webhooks::Brands.trigger(sid, "unverified")
|
38
39
|
response = if response.status == 200
|
39
40
|
Mock::Twilio::Webhooks::Brands.trigger(sid, "verified")
|
@@ -4,7 +4,11 @@ module Mock
|
|
4
4
|
module Twilio
|
5
5
|
module Generator
|
6
6
|
def phone_number_generator
|
7
|
-
"+1" + rand(
|
7
|
+
"+1" + rand(1000000000..9999999999).to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
def friendly_number_generator
|
11
|
+
"(#{rand(100..999)}) #{rand(100..999)}-#{rand(1000..9999)}"
|
8
12
|
end
|
9
13
|
|
10
14
|
def random_phone_number_sid
|
@@ -35,8 +39,21 @@ module Mock
|
|
35
39
|
random_sid_prefixed_by "RA"
|
36
40
|
end
|
37
41
|
|
42
|
+
def random_longitude
|
43
|
+
rand(MIN_LONGITUDE..MAX_LONGITUDE)
|
44
|
+
end
|
45
|
+
|
46
|
+
def random_latitude
|
47
|
+
rand(MIN_LATITUDE..MAX_LATITUDE)
|
48
|
+
end
|
49
|
+
|
38
50
|
private
|
39
51
|
|
52
|
+
MIN_LATITUDE = -90.0
|
53
|
+
MAX_LATITUDE = 90.0
|
54
|
+
MIN_LONGITUDE = -180.0
|
55
|
+
MAX_LONGITUDE = 180.0
|
56
|
+
|
40
57
|
def random_sid_prefixed_by(prefix)
|
41
58
|
"#{prefix}#{SecureRandom.hex(16)}"
|
42
59
|
end
|
data/lib/mock/twilio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mock-twilio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.5.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:
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/mock/twilio/client.rb
|
96
96
|
- lib/mock/twilio/decorator.rb
|
97
97
|
- lib/mock/twilio/decorators/api_2010/addresses.rb
|
98
|
+
- lib/mock/twilio/decorators/api_2010/available_phone_numbers_local.rb
|
98
99
|
- lib/mock/twilio/decorators/api_2010/calls.rb
|
99
100
|
- lib/mock/twilio/decorators/api_2010/conferences_participants_create.rb
|
100
101
|
- lib/mock/twilio/decorators/api_2010/conferences_participants_update.rb
|