mock-twilio 1.4 → 1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b621eb4f194a009b3327c4a27d75fd6fc058e2d97d0fa47832e776910de3b4b9
|
4
|
+
data.tar.gz: 4657ed12e5856ba7c759d982e92451b23a72c808bbac6f25279e21d55fafbd0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a25a3b720bf598ff14a3c0de75f6c38666fb259003bb4d158fdd235d8d35788a837d0cce942f58fe1ad3030468a78372f22a1252a70b03888078b79f3ae2842
|
7
|
+
data.tar.gz: 77b999af450204792c58d1a9301d84aa83a7514c0f7f517d720761f712e41035248ff9ce89e14dadb39102c585c2069b893e625c6b1bb697369b841335cf1f41
|
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
|
@@ -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,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: '1.
|
4
|
+
version: '1.5'
|
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: 2024-
|
11
|
+
date: 2024-12-06 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
|
@@ -161,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
162
|
- !ruby/object:Gem::Version
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.4.19
|
165
166
|
signing_key:
|
166
167
|
specification_version: 4
|
167
168
|
summary: This repository contains Mock::Twilio::Client and Webhooks for Twilio's API.
|