twilio_base 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +82 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +142 -0
- data/Rakefile +12 -0
- data/app/controllers/twilio_base/base_controller.rb +32 -0
- data/app/models/twilio_base/global_config.rb +5 -0
- data/app/services/twilio_base/api_key.rb +15 -0
- data/app/services/twilio_base/application.rb +29 -0
- data/app/services/twilio_base/clients.rb +37 -0
- data/app/services/twilio_base/phone_number.rb +40 -0
- data/app/services/twilio_base/protocols/voice/base.rb +65 -0
- data/app/services/twilio_base/protocols/voice/pstn.rb +13 -0
- data/app/services/twilio_base/protocols/voice/sip.rb +48 -0
- data/app/services/twilio_base/protocols/voice.rb +24 -0
- data/app/services/twilio_base/request_verification_service.rb +21 -0
- data/app/services/twilio_base/routers/voice/base.rb +44 -0
- data/app/services/twilio_base/routers/voice/default.rb +24 -0
- data/app/services/twilio_base/routers/voice/direct_dial.rb +10 -0
- data/app/services/twilio_base/routers/voice/task_router.rb +34 -0
- data/app/services/twilio_base/sync/service.rb +18 -0
- data/app/services/twilio_base/task_router/activity.rb +49 -0
- data/app/services/twilio_base/task_router/base.rb +17 -0
- data/app/services/twilio_base/task_router/task.rb +33 -0
- data/app/services/twilio_base/task_router/task_queue.rb +40 -0
- data/app/services/twilio_base/task_router/worker.rb +27 -0
- data/app/services/twilio_base/task_router/workflow.rb +22 -0
- data/app/services/twilio_base/task_router/workspace.rb +51 -0
- data/bin/console +8 -0
- data/bin/rails +14 -0
- data/bin/setup +6 -0
- data/circle.yml +36 -0
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20171214105252_create_twilio_base_global_configs.rb +18 -0
- data/lib/twilio_base/engine.rb +7 -0
- data/lib/twilio_base/helpers/protocols.rb +12 -0
- data/lib/twilio_base/version.rb +5 -0
- data/lib/twilio_base.rb +11 -0
- data/spec/factories/channel_sid.rb +7 -0
- data/spec/factories/chat_member_id.rb +7 -0
- data/spec/factories/global_config/activity_sid.rb +7 -0
- data/spec/factories/global_config/api_key_secret.rb +7 -0
- data/spec/factories/global_config/api_key_sid.rb +7 -0
- data/spec/factories/global_config/application_sid.rb +7 -0
- data/spec/factories/global_config/chat_service_sid.rb +7 -0
- data/spec/factories/global_config/conference_sid.rb +7 -0
- data/spec/factories/global_config/message_sid.rb +7 -0
- data/spec/factories/global_config/phone_number.rb +7 -0
- data/spec/factories/global_config/recording_sid.rb +7 -0
- data/spec/factories/global_config/sync_service_sid.rb +7 -0
- data/spec/factories/global_config/task_sid.rb +7 -0
- data/spec/factories/global_config/voice_call_sid.rb +7 -0
- data/spec/factories/global_config/worker_sid.rb +7 -0
- data/spec/factories/global_config/workflow_sid.rb +7 -0
- data/spec/factories/global_config/workspace_sid.rb +7 -0
- data/spec/factories/global_configs.rb +28 -0
- data/spec/lib/twilio_base/helpers/protocols_spec.rb +49 -0
- data/spec/services/twilio_base/api_key_spec.rb +17 -0
- data/spec/services/twilio_base/application_spec.rb +31 -0
- data/spec/services/twilio_base/phone_number_spec.rb +49 -0
- data/spec/services/twilio_base/protocols/voice/base_spec.rb +134 -0
- data/spec/services/twilio_base/protocols/voice/pstn_spec.rb +13 -0
- data/spec/services/twilio_base/protocols/voice/sip_spec.rb +104 -0
- data/spec/services/twilio_base/protocols/voice_spec.rb +48 -0
- data/spec/services/twilio_base/request_verification_service_spec.rb +105 -0
- data/spec/services/twilio_base/routers/voice/base_spec.rb +91 -0
- data/spec/services/twilio_base/routers/voice/default_spec.rb +59 -0
- data/spec/services/twilio_base/routers/voice/task_router_spec.rb +63 -0
- data/spec/services/twilio_base/sync/service.rb +25 -0
- data/spec/services/twilio_base/task_router/activity_spec.rb +68 -0
- data/spec/services/twilio_base/task_router/task_queue_spec.rb +114 -0
- data/spec/services/twilio_base/task_router/worker_spec.rb +49 -0
- data/spec/services/twilio_base/task_router/workflow_spec.rb +37 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/support/factory_bot.rb +9 -0
- data/spec/support/shared_contexts/global_config.rb +6 -0
- data/spec/support/shared_contexts/twilio_controller.rb +7 -0
- data/spec/support/twilio_base/fake/api_key.rb +26 -0
- data/spec/support/twilio_base/fake/application.rb +59 -0
- data/spec/support/twilio_base/fake/available_phone_number.rb +29 -0
- data/spec/support/twilio_base/fake/chat/channel.rb +63 -0
- data/spec/support/twilio_base/fake/chat/client.rb +40 -0
- data/spec/support/twilio_base/fake/chat/member.rb +27 -0
- data/spec/support/twilio_base/fake/chat/message.rb +47 -0
- data/spec/support/twilio_base/fake/chat/service.rb +52 -0
- data/spec/support/twilio_base/fake/clients/rest.rb +84 -0
- data/spec/support/twilio_base/fake/clients/sms.rb +27 -0
- data/spec/support/twilio_base/fake/conference.rb +48 -0
- data/spec/support/twilio_base/fake/flex_flow.rb +36 -0
- data/spec/support/twilio_base/fake/helpers.rb +38 -0
- data/spec/support/twilio_base/fake/incoming_phone_number.rb +46 -0
- data/spec/support/twilio_base/fake/lookup/client.rb +29 -0
- data/spec/support/twilio_base/fake/lookup/phone_number.rb +34 -0
- data/spec/support/twilio_base/fake/notify/binding.rb +41 -0
- data/spec/support/twilio_base/fake/notify/notification.rb +40 -0
- data/spec/support/twilio_base/fake/notify/segment_membership.rb +17 -0
- data/spec/support/twilio_base/fake/notify/user.rb +30 -0
- data/spec/support/twilio_base/fake/notify/v1.rb +33 -0
- data/spec/support/twilio_base/fake/proxy.rb +30 -0
- data/spec/support/twilio_base/fake/recording.rb +44 -0
- data/spec/support/twilio_base/fake/sync/client.rb +17 -0
- data/spec/support/twilio_base/fake/sync/service.rb +78 -0
- data/spec/support/twilio_base/fake/sync/services/document.rb +50 -0
- data/spec/support/twilio_base/fake/sync/services/list.rb +50 -0
- data/spec/support/twilio_base/fake/sync/services/lists/item.rb +48 -0
- data/spec/support/twilio_base/fake/sync/services/map.rb +50 -0
- data/spec/support/twilio_base/fake/sync/services/maps/item.rb +54 -0
- data/spec/support/twilio_base/fake/task_router/activity.rb +34 -0
- data/spec/support/twilio_base/fake/task_router/channel.rb +40 -0
- data/spec/support/twilio_base/fake/task_router/client.rb +31 -0
- data/spec/support/twilio_base/fake/task_router/statistic.rb +38 -0
- data/spec/support/twilio_base/fake/task_router/task.rb +80 -0
- data/spec/support/twilio_base/fake/task_router/task_queue.rb +46 -0
- data/spec/support/twilio_base/fake/task_router/worker.rb +64 -0
- data/spec/support/twilio_base/fake/task_router/workflow.rb +54 -0
- data/spec/support/twilio_base/fake/task_router/workspace.rb +83 -0
- data/spec/support/twilio_base/fake/voice_call.rb +54 -0
- data/spec/support/twilio_base/responses/twiml.rb +29 -0
- data/spec/twilio_base_dummy/.gitignore +21 -0
- data/spec/twilio_base_dummy/Rakefile +5 -0
- data/spec/twilio_base_dummy/app/assets/config/manifest.js +0 -0
- data/spec/twilio_base_dummy/app/channels/application_cable/channel.rb +6 -0
- data/spec/twilio_base_dummy/app/channels/application_cable/connection.rb +6 -0
- data/spec/twilio_base_dummy/app/controllers/application_controller.rb +5 -0
- data/spec/twilio_base_dummy/app/controllers/concerns/.keep +0 -0
- data/spec/twilio_base_dummy/app/helpers/application_helper.rb +4 -0
- data/spec/twilio_base_dummy/bin/bundle +5 -0
- data/spec/twilio_base_dummy/bin/rails +11 -0
- data/spec/twilio_base_dummy/bin/rake +11 -0
- data/spec/twilio_base_dummy/bin/setup +36 -0
- data/spec/twilio_base_dummy/bin/spring +18 -0
- data/spec/twilio_base_dummy/bin/update +31 -0
- data/spec/twilio_base_dummy/config/application.rb +13 -0
- data/spec/twilio_base_dummy/config/boot.rb +7 -0
- data/spec/twilio_base_dummy/config/cable.yml +5 -0
- data/spec/twilio_base_dummy/config/database.example.yml +13 -0
- data/spec/twilio_base_dummy/config/environment.rb +5 -0
- data/spec/twilio_base_dummy/config/environments/development.rb +28 -0
- data/spec/twilio_base_dummy/config/environments/test.rb +17 -0
- data/spec/twilio_base_dummy/config/initializers/application_controller_renderer.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/assets.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/filter_parameter_logging.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/inflections.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/mime_types.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/new_framework_defaults.rb +9 -0
- data/spec/twilio_base_dummy/config/initializers/session_store.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/wrap_parameters.rb +5 -0
- data/spec/twilio_base_dummy/config/locales/en.yml +23 -0
- data/spec/twilio_base_dummy/config/puma.rb +7 -0
- data/spec/twilio_base_dummy/config/routes.rb +5 -0
- data/spec/twilio_base_dummy/config/secrets.yml +10 -0
- data/spec/twilio_base_dummy/config/spring.rb +8 -0
- data/spec/twilio_base_dummy/config.ru +7 -0
- data/spec/twilio_base_dummy/db/schema.rb +31 -0
- data/spec/twilio_base_dummy/db/seeds.rb +1 -0
- data/spec/twilio_base_dummy/lib/assets/.keep +0 -0
- data/spec/twilio_base_dummy/lib/tasks/.keep +0 -0
- data/spec/twilio_base_dummy/log/.keep +0 -0
- data/spec/twilio_base_dummy/public/404.html +67 -0
- data/spec/twilio_base_dummy/public/422.html +67 -0
- data/spec/twilio_base_dummy/public/500.html +66 -0
- data/spec/twilio_base_dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/twilio_base_dummy/public/apple-touch-icon.png +0 -0
- data/spec/twilio_base_dummy/public/favicon.ico +0 -0
- data/spec/twilio_base_dummy/public/robots.txt +5 -0
- data/spec/twilio_base_dummy/tmp/.keep +0 -0
- data/spec/twilio_base_dummy/vendor/assets/javascripts/.keep +0 -0
- data/spec/twilio_base_dummy/vendor/assets/stylesheets/.keep +0 -0
- data/spec/twilio_base_spec.rb +7 -0
- data/twilio_base.gemspec +45 -0
- metadata +580 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Chat
|
6
|
+
class Client
|
7
|
+
cattr_accessor :members, :messages
|
8
|
+
self.members = []
|
9
|
+
self.messages = []
|
10
|
+
|
11
|
+
def initialize(_account_sid, _auth_token); end
|
12
|
+
|
13
|
+
def chat
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def v2
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def services(service_sid = nil)
|
22
|
+
TwilioBase::Fake::Chat::Service.new(service_sid)
|
23
|
+
end
|
24
|
+
|
25
|
+
def channels(channel_id = nil)
|
26
|
+
TwilioBase::Fake::Chat::Channel.new(channel_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_task(sender_number:, receiving_number:, claim_id:)
|
30
|
+
TwilioBase::Fake::TaskRouter::Task.new
|
31
|
+
.create(attributes: {
|
32
|
+
sender_number: sender_number,
|
33
|
+
receiving_number: receiving_number,
|
34
|
+
claim_id: claim_id
|
35
|
+
})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Chat
|
6
|
+
class Member
|
7
|
+
Member = Struct.new(:attributes) do
|
8
|
+
def identity
|
9
|
+
JSON.parse(attributes)['identity']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
cattr_accessor :members
|
14
|
+
self.members = []
|
15
|
+
|
16
|
+
def create(attributes)
|
17
|
+
self.class.members << Member.new(attributes)
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def list
|
22
|
+
members
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Chat
|
6
|
+
class Message
|
7
|
+
Message = Struct.new(:attributes) do
|
8
|
+
def sid
|
9
|
+
@sid ||= Time.now.to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
def created_at
|
13
|
+
Time.now
|
14
|
+
end
|
15
|
+
|
16
|
+
def date_created
|
17
|
+
2.days.ago
|
18
|
+
end
|
19
|
+
|
20
|
+
def body
|
21
|
+
attributes[:body]
|
22
|
+
end
|
23
|
+
|
24
|
+
def from
|
25
|
+
attributes[:from]
|
26
|
+
end
|
27
|
+
|
28
|
+
def to
|
29
|
+
attributes[:to]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
cattr_accessor :messages
|
34
|
+
self.messages = []
|
35
|
+
|
36
|
+
def create(attributes)
|
37
|
+
self.class.messages << Message.new(attributes)
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def list
|
42
|
+
self.class.messages
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Chat
|
6
|
+
class Service
|
7
|
+
Service = Struct.new(:friendly_name) do
|
8
|
+
attr_accessor :webhook_filters, :post_webhook_url
|
9
|
+
|
10
|
+
def sid
|
11
|
+
@sid ||= TwilioBase::GlobalConfig.first&.chat_service_sid ||
|
12
|
+
FactoryBot.generate(:chat_service_sid)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(post_webhook_url:, webhook_filters: nil)
|
16
|
+
self.post_webhook_url = post_webhook_url
|
17
|
+
self.webhook_filters = webhook_filters if webhook_filters
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
cattr_accessor :services
|
22
|
+
self.services = []
|
23
|
+
|
24
|
+
def initialize(service_sid = nil)
|
25
|
+
self.service_sid = service_sid
|
26
|
+
end
|
27
|
+
|
28
|
+
def create(friendly_name:)
|
29
|
+
service = Service.new(friendly_name)
|
30
|
+
self.class.services << service
|
31
|
+
service
|
32
|
+
end
|
33
|
+
|
34
|
+
def channels(channel_id = nil)
|
35
|
+
TwilioBase::Fake::Chat::Channel.new(channel_id)
|
36
|
+
end
|
37
|
+
|
38
|
+
def fetch
|
39
|
+
services.detect { |service| service.sid == service_sid }
|
40
|
+
end
|
41
|
+
|
42
|
+
def list
|
43
|
+
services
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
attr_accessor :service_sid
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Clients
|
6
|
+
class Rest
|
7
|
+
Message = Struct.new(:from, :to, :body)
|
8
|
+
|
9
|
+
cattr_accessor :messages
|
10
|
+
self.messages = []
|
11
|
+
|
12
|
+
def initialize(_account_sid = nil, _auth_token = nil); end
|
13
|
+
|
14
|
+
def messages
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(from:, to:, body:)
|
19
|
+
self.class.messages << Message.new(from, to, body)
|
20
|
+
end
|
21
|
+
|
22
|
+
def taskrouter
|
23
|
+
TwilioBase::Fake::TaskRouter::Client.new(nil, nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
def calls(sid = nil)
|
27
|
+
TwilioBase::Fake::VoiceCall.new(sid)
|
28
|
+
end
|
29
|
+
|
30
|
+
def chat
|
31
|
+
TwilioBase::Fake::Chat::Client.new(nil, nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
def conferences(conference_sid = nil)
|
35
|
+
TwilioBase::Fake::Conference.new(conference_sid)
|
36
|
+
end
|
37
|
+
|
38
|
+
def flex_flow
|
39
|
+
TwilioBase::Fake::FlexFlow.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def new_keys
|
43
|
+
TwilioBase::Fake::ApiKey.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def proxy
|
47
|
+
TwilioBase::Fake::Proxy.new
|
48
|
+
end
|
49
|
+
|
50
|
+
def applications(sid = nil)
|
51
|
+
TwilioBase::Fake::Application.new(sid)
|
52
|
+
end
|
53
|
+
|
54
|
+
def available_phone_numbers(country_code)
|
55
|
+
TwilioBase::Fake::AvailablePhoneNumber.new(country_code)
|
56
|
+
end
|
57
|
+
|
58
|
+
def incoming_phone_numbers
|
59
|
+
TwilioBase::Fake::IncomingPhoneNumber.new
|
60
|
+
end
|
61
|
+
|
62
|
+
def lookups
|
63
|
+
TwilioBase::Fake::Lookup::Client.new(nil, nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
def sync
|
67
|
+
TwilioBase::Fake::Sync::Client.new
|
68
|
+
end
|
69
|
+
|
70
|
+
def services(sid = nil)
|
71
|
+
TwilioBase::Fake::Notify::V1.new(sid)
|
72
|
+
end
|
73
|
+
|
74
|
+
def method_missing(_name)
|
75
|
+
self || super
|
76
|
+
end
|
77
|
+
|
78
|
+
def respond_to_missing?(method_name)
|
79
|
+
super
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Clients
|
6
|
+
class Sms
|
7
|
+
Message = Struct.new(:from, :to, :body)
|
8
|
+
|
9
|
+
cattr_accessor :messages
|
10
|
+
self.messages = []
|
11
|
+
|
12
|
+
def messages
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(from:, to:, body:)
|
17
|
+
self.class.messages << Message.new(from, to, body)
|
18
|
+
self.class.messages.last
|
19
|
+
end
|
20
|
+
|
21
|
+
def list(_attributes = {})
|
22
|
+
self.class.messages
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
class Conference
|
6
|
+
Conference = Struct.new(:attributes) do
|
7
|
+
def sid
|
8
|
+
@sid ||= FactoryBot.generate(:conference_sid)
|
9
|
+
end
|
10
|
+
|
11
|
+
def status
|
12
|
+
attributes[:status]
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(attributes)
|
16
|
+
self.attributes = attributes
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
cattr_accessor :conferences, :sid
|
21
|
+
self.conferences = []
|
22
|
+
|
23
|
+
def initialize(sid = nil)
|
24
|
+
self.sid = sid
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(args = {})
|
28
|
+
conference = Conference.new(args)
|
29
|
+
conferences << conference
|
30
|
+
conference
|
31
|
+
end
|
32
|
+
|
33
|
+
def participants(sid = nil)
|
34
|
+
TwilioBase::Fake::VoiceCall.new(sid)
|
35
|
+
end
|
36
|
+
|
37
|
+
def list(attributes = {})
|
38
|
+
conferences.select do |conference|
|
39
|
+
conference.attributes.slice(*attributes.keys) == attributes
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def fetch
|
44
|
+
conferences.detect { |conference| conference.sid == sid }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
class FlexFlow
|
6
|
+
FlexFlow = Struct.new(:attributes) do
|
7
|
+
def channel_type
|
8
|
+
attributes[:channel_type]
|
9
|
+
end
|
10
|
+
|
11
|
+
def contact_identity
|
12
|
+
attributes[:contact_identity]
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(update_attributes)
|
16
|
+
attributes.merge(update_attributes)
|
17
|
+
|
18
|
+
self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
cattr_accessor :flex_flows
|
23
|
+
self.flex_flows = []
|
24
|
+
|
25
|
+
def create(args = {})
|
26
|
+
flex_flow = FlexFlow.new(args)
|
27
|
+
flex_flows << flex_flow
|
28
|
+
flex_flow
|
29
|
+
end
|
30
|
+
|
31
|
+
def list
|
32
|
+
flex_flows
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Helpers
|
6
|
+
def clean_cache
|
7
|
+
TwilioBase::Fake::ApiKey.keys = []
|
8
|
+
TwilioBase::Fake::Application.applications = []
|
9
|
+
TwilioBase::Fake::AvailablePhoneNumber.phone_numbers = []
|
10
|
+
TwilioBase::Fake::Chat::Channel.channels = []
|
11
|
+
TwilioBase::Fake::Chat::Member.members = []
|
12
|
+
TwilioBase::Fake::Chat::Message.messages = []
|
13
|
+
TwilioBase::Fake::Chat::Service.services = []
|
14
|
+
TwilioBase::Fake::Clients::Rest.messages = []
|
15
|
+
TwilioBase::Fake::Clients::Sms.messages = []
|
16
|
+
TwilioBase::Fake::FlexFlow.flex_flows = []
|
17
|
+
TwilioBase::Fake::IncomingPhoneNumber.phone_numbers = []
|
18
|
+
TwilioBase::Fake::Notify::Binding.bindings = []
|
19
|
+
TwilioBase::Fake::Notify::SegmentMembership.memberships = []
|
20
|
+
TwilioBase::Fake::Notify::User.users = []
|
21
|
+
TwilioBase::Fake::Notify::V1.all_notifications = []
|
22
|
+
TwilioBase::Fake::Proxy.proxies = []
|
23
|
+
TwilioBase::Fake::Sync::Services::Document.documents = []
|
24
|
+
TwilioBase::Fake::Sync::Services::List.lists = []
|
25
|
+
TwilioBase::Fake::Sync::Services::Map.maps = []
|
26
|
+
TwilioBase::Fake::TaskRouter::Activity.activities = []
|
27
|
+
TwilioBase::Fake::TaskRouter::Channel.channels = []
|
28
|
+
TwilioBase::Fake::TaskRouter::Task.tasks = []
|
29
|
+
TwilioBase::Fake::TaskRouter::TaskQueue.task_queues = []
|
30
|
+
TwilioBase::Fake::TaskRouter::Worker.workers = []
|
31
|
+
TwilioBase::Fake::TaskRouter::Workflow.workflows = []
|
32
|
+
TwilioBase::Fake::TaskRouter::Workspace.workspaces = []
|
33
|
+
TwilioBase::Fake::VoiceCall.calls = []
|
34
|
+
end
|
35
|
+
module_function :clean_cache
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
class IncomingPhoneNumber
|
6
|
+
PhoneNumber = Struct.new(:phone_number) do
|
7
|
+
attr_accessor :attributes
|
8
|
+
|
9
|
+
def update(attributes)
|
10
|
+
self.attributes = attributes
|
11
|
+
end
|
12
|
+
|
13
|
+
def sms_application_sid
|
14
|
+
attributes[:sms_application_sid]
|
15
|
+
end
|
16
|
+
|
17
|
+
def voice_application_sid
|
18
|
+
attributes[:voice_application_sid]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
cattr_accessor :phone_numbers
|
23
|
+
self.phone_numbers = []
|
24
|
+
|
25
|
+
def phone_numbers
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def create(phone_number:)
|
30
|
+
new_phone_number = PhoneNumber.new(phone_number)
|
31
|
+
self.class.phone_numbers << new_phone_number
|
32
|
+
new_phone_number
|
33
|
+
end
|
34
|
+
|
35
|
+
def list(phone_number: nil)
|
36
|
+
if phone_number.present?
|
37
|
+
self.class.phone_numbers.select do |pn|
|
38
|
+
pn.phone_number == phone_number
|
39
|
+
end
|
40
|
+
else
|
41
|
+
self.class.phone_numbers
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Lookup
|
6
|
+
class Client
|
7
|
+
class RestError < StandardError
|
8
|
+
def code
|
9
|
+
20_404
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(_account_sid, _auth_token); end
|
14
|
+
|
15
|
+
def v1
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def phone_numbers(phone_number = nil)
|
20
|
+
if phone_number.to_s.length < 10
|
21
|
+
raise RestError, '[HTTP 404] 20404 : Unable to fetch record'
|
22
|
+
end
|
23
|
+
|
24
|
+
TwilioBase::Fake::Lookup::PhoneNumber.new(phone_number)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Lookup
|
6
|
+
class PhoneNumber
|
7
|
+
PhoneNumberInstance = Struct.new(
|
8
|
+
:attributes,
|
9
|
+
:phone_number,
|
10
|
+
:national_format,
|
11
|
+
:caller_name,
|
12
|
+
:carrier,
|
13
|
+
:country_code
|
14
|
+
) do
|
15
|
+
def carrier
|
16
|
+
{
|
17
|
+
'type' => 'mobile'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :phone_number
|
23
|
+
|
24
|
+
def initialize(phone_number)
|
25
|
+
self.phone_number = phone_number
|
26
|
+
end
|
27
|
+
|
28
|
+
def fetch(attributes = {})
|
29
|
+
PhoneNumberInstance.new(attributes, phone_number)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Notify
|
6
|
+
class Binding
|
7
|
+
attr_accessor :sid
|
8
|
+
cattr_accessor :bindings
|
9
|
+
BindingObject = Struct.new(
|
10
|
+
:address,
|
11
|
+
:binding_type,
|
12
|
+
:identity,
|
13
|
+
:tag,
|
14
|
+
:sid
|
15
|
+
)
|
16
|
+
|
17
|
+
self.bindings = []
|
18
|
+
|
19
|
+
def initialize(sid = nil)
|
20
|
+
self.sid = sid
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(attributes)
|
24
|
+
attributes[:sid] = SecureRandom.hex(16)
|
25
|
+
object = BindingObject.new(*attributes.values)
|
26
|
+
bindings << object
|
27
|
+
TwilioBase::Fake::Notify::User.users << object
|
28
|
+
object
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete
|
32
|
+
bindings.delete_if { |binding| binding.sid == sid }
|
33
|
+
end
|
34
|
+
|
35
|
+
def list(*)
|
36
|
+
bindings
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Notify
|
6
|
+
class Notification
|
7
|
+
attr_accessor :sid
|
8
|
+
|
9
|
+
NotificationInstance = Struct.new(
|
10
|
+
:account_sid,
|
11
|
+
:action,
|
12
|
+
:alexa,
|
13
|
+
:apn,
|
14
|
+
:body,
|
15
|
+
:data,
|
16
|
+
:date_created,
|
17
|
+
:facebook_messenger,
|
18
|
+
:fcm,
|
19
|
+
:gcm,
|
20
|
+
:identities,
|
21
|
+
:priority,
|
22
|
+
:segments,
|
23
|
+
:service_sid,
|
24
|
+
:sid,
|
25
|
+
:sms,
|
26
|
+
:sound,
|
27
|
+
:tags,
|
28
|
+
:title,
|
29
|
+
:ttl
|
30
|
+
)
|
31
|
+
|
32
|
+
def initialize(_attributes = {})
|
33
|
+
NotificationInstance.new(
|
34
|
+
sid: SecureRandom.hex(16)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Notify
|
6
|
+
class SegmentMembership
|
7
|
+
cattr_accessor :memberships
|
8
|
+
|
9
|
+
self.memberships = []
|
10
|
+
|
11
|
+
def create(attributes)
|
12
|
+
memberships << attributes
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Notify
|
6
|
+
class User
|
7
|
+
attr_accessor :identity
|
8
|
+
cattr_accessor :users
|
9
|
+
|
10
|
+
self.users = []
|
11
|
+
|
12
|
+
def initialize(identity = nil)
|
13
|
+
self.identity = identity
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(attributes)
|
17
|
+
users << attributes.merge(sid: SecureRandom.hex(16))
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete
|
21
|
+
users.delete_if { |user| user.address == identity }
|
22
|
+
end
|
23
|
+
|
24
|
+
def segment_memberships
|
25
|
+
TwilioBase::Fake::Notify::SegmentMembership.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Fake
|
5
|
+
module Notify
|
6
|
+
class V1
|
7
|
+
cattr_accessor :all_notifications
|
8
|
+
|
9
|
+
self.all_notifications = []
|
10
|
+
|
11
|
+
def initialize(_notify_service_sid = nil); end
|
12
|
+
|
13
|
+
def notifications
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(attributes)
|
18
|
+
all_notifications << attributes
|
19
|
+
|
20
|
+
TwilioBase::Fake::Notify::Notification.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def bindings(sid = nil)
|
24
|
+
TwilioBase::Fake::Notify::Binding.new(sid)
|
25
|
+
end
|
26
|
+
|
27
|
+
def users(sid = nil)
|
28
|
+
TwilioBase::Fake::Notify::User.new(sid)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|