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,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Routers
|
5
|
+
module Voice
|
6
|
+
module Default
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def init(protocol:, routing_method: nil)
|
10
|
+
routing_method ||= ENV.fetch('ROUTING_METHOD')
|
11
|
+
|
12
|
+
klass = {
|
13
|
+
'direct_dial' => TwilioBase::Routers::Voice::DirectDial,
|
14
|
+
'task_router' => TwilioBase::Routers::Voice::TaskRouter
|
15
|
+
}.fetch(routing_method, TwilioBase::Routers::Voice::DirectDial)
|
16
|
+
|
17
|
+
klass.new(
|
18
|
+
protocol: protocol
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Routers
|
5
|
+
module Voice
|
6
|
+
class TaskRouter < Base
|
7
|
+
def route
|
8
|
+
yield_response = yield if block_given?
|
9
|
+
(yield_response || voice_response).enqueue(enqueue_params) do |e|
|
10
|
+
e.task task_attributes
|
11
|
+
end.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def enqueue_params
|
17
|
+
{
|
18
|
+
action: protocol.action_url,
|
19
|
+
wait_url: protocol.wait_url,
|
20
|
+
workflow_sid: workflow_sid
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def task_attributes
|
25
|
+
{ outbound_contact_uri: protocol.endpoint }
|
26
|
+
end
|
27
|
+
|
28
|
+
def workflow_sid
|
29
|
+
@workflow_sid ||= TwilioBase::GlobalConfig.first.workflow_sid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module Sync
|
5
|
+
class Service
|
6
|
+
DEFAULT_FRIENDLY_NAME = 'Default Sync Service'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
include TwilioBase::Clients
|
10
|
+
|
11
|
+
def create(name: nil)
|
12
|
+
friendly_name = name || DEFAULT_FRIENDLY_NAME
|
13
|
+
rest_client.sync.v1.services.create(friendly_name: friendly_name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module TaskRouter
|
5
|
+
class Activity < Base
|
6
|
+
AVAILABLE_ACTIVITY_NAME = 'Available'
|
7
|
+
ASSIGNMENT_ACTIVITY_NAME = 'Busy'
|
8
|
+
IDLE_ACTIVITY_NAME = 'Idle'
|
9
|
+
OFFLINE_ACTIVITY_NAME = 'Offline'
|
10
|
+
RESERVATION_ACTIVITY_NAME = 'Reserved'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def available
|
14
|
+
list.detect do |activity|
|
15
|
+
activity.friendly_name == AVAILABLE_ACTIVITY_NAME
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def busy
|
20
|
+
list.detect do |activity|
|
21
|
+
activity.friendly_name == ASSIGNMENT_ACTIVITY_NAME
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def idle
|
26
|
+
list.detect do |activity|
|
27
|
+
activity.friendly_name == IDLE_ACTIVITY_NAME
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def list
|
32
|
+
workspace.activities.list
|
33
|
+
end
|
34
|
+
|
35
|
+
def offline
|
36
|
+
list.detect do |activity|
|
37
|
+
activity.friendly_name == OFFLINE_ACTIVITY_NAME
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def reserved
|
42
|
+
list.detect do |activity|
|
43
|
+
activity.friendly_name == RESERVATION_ACTIVITY_NAME
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module TaskRouter
|
5
|
+
class Base
|
6
|
+
class << self
|
7
|
+
include TwilioBase::Clients
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def workspace
|
12
|
+
rest_client.taskrouter.workspaces(workspace_sid)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module TaskRouter
|
5
|
+
class Task < Base
|
6
|
+
class << self
|
7
|
+
def create(task_attributes:, **options)
|
8
|
+
workspace.tasks.create(
|
9
|
+
attributes: task_attributes.to_json,
|
10
|
+
workflow_sid: workflow_sid,
|
11
|
+
**options
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(sid)
|
16
|
+
workspace.tasks(sid).fetch
|
17
|
+
end
|
18
|
+
|
19
|
+
def where(attributes)
|
20
|
+
workspace.tasks.list(
|
21
|
+
evaluate_task_attributes: evaluable_attributes(attributes)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def evaluable_attributes(attributes)
|
28
|
+
attributes.map { |k, v| "#{k} == '#{v}'" }.join(' AND ')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module TaskRouter
|
5
|
+
class TaskQueue
|
6
|
+
class << self
|
7
|
+
def find_or_create_by(workspace:, friendly_name:, target_workers: nil)
|
8
|
+
attributes = {
|
9
|
+
workspace: workspace,
|
10
|
+
friendly_name: friendly_name,
|
11
|
+
target_workers: target_workers
|
12
|
+
}.to_a
|
13
|
+
|
14
|
+
find_by(attributes[0..1].to_h) || create(attributes.to_h)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_by(workspace:, friendly_name:)
|
18
|
+
workspace.task_queues.list(friendly_name: friendly_name).first
|
19
|
+
end
|
20
|
+
|
21
|
+
def create(workspace:, friendly_name:, target_workers:)
|
22
|
+
workspace.task_queues.create(
|
23
|
+
assignment_activity_sid: assignment_activity_sid(workspace),
|
24
|
+
friendly_name: friendly_name,
|
25
|
+
reservation_activity_sid: reservation_activity_sid(workspace),
|
26
|
+
target_workers: target_workers
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def assignment_activity_sid(workspace)
|
31
|
+
workspace.activities.list(friendly_name: 'Busy').first.sid
|
32
|
+
end
|
33
|
+
|
34
|
+
def reservation_activity_sid(workspace)
|
35
|
+
workspace.activities.list(friendly_name: 'Reserved').first.sid
|
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 TaskRouter
|
5
|
+
class Worker < Base
|
6
|
+
class << self
|
7
|
+
def create(name:, attributes:)
|
8
|
+
workspace.workers.create(
|
9
|
+
friendly_name: name,
|
10
|
+
activity_sid: idle_activity.sid,
|
11
|
+
attributes: attributes.to_json
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(worker_sid)
|
16
|
+
workspace.workers(worker_sid).fetch
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def idle_activity
|
22
|
+
TwilioBase::TaskRouter::Activity.idle
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module TaskRouter
|
5
|
+
class Workflow
|
6
|
+
class << self
|
7
|
+
include Rails.application.routes.url_helpers
|
8
|
+
include TwilioBase::Clients
|
9
|
+
|
10
|
+
def create(workspace:, attributes:)
|
11
|
+
workspace.workflows.create(
|
12
|
+
attributes
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_accessor :params
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
module TaskRouter
|
5
|
+
class Workspace
|
6
|
+
class << self
|
7
|
+
include TwilioBase::Clients
|
8
|
+
|
9
|
+
DEFAULT_TEMPLATE = 'FIFO'
|
10
|
+
REQUIRED_EVENTS = %w[
|
11
|
+
task.canceled
|
12
|
+
task.completed
|
13
|
+
task.updated
|
14
|
+
workflow.timeout
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
def create(friendly_name:)
|
18
|
+
workspace_client.create(
|
19
|
+
event_callback_url: event_callback_url,
|
20
|
+
events_filter: events,
|
21
|
+
friendly_name: friendly_name,
|
22
|
+
multi_task_enabled: true,
|
23
|
+
template: DEFAULT_TEMPLATE
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def find(sid)
|
28
|
+
workspace_client(sid)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def event_callback_url
|
34
|
+
TwilioBase::Engine.routes.url_helpers.task_router_callbacks_url
|
35
|
+
end
|
36
|
+
|
37
|
+
def workspace_client(sid = nil)
|
38
|
+
if sid
|
39
|
+
rest_client.taskrouter.v1.workspaces(sid)
|
40
|
+
else
|
41
|
+
rest_client.taskrouter.v1.workspaces
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def events
|
46
|
+
REQUIRED_EVENTS.join(',')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/bin/console
ADDED
data/bin/rails
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
5
|
+
ENGINE_PATH = File.expand_path(
|
6
|
+
'../lib/twilio_base/engine', __dir__
|
7
|
+
)
|
8
|
+
|
9
|
+
# Set up gems listed in the Gemfile.
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
11
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
12
|
+
|
13
|
+
require 'rails/all'
|
14
|
+
require 'rails/engine/commands'
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.5.1-node-browsers
|
6
|
+
environment:
|
7
|
+
PGHOST: 127.0.0.1
|
8
|
+
PGUSER: twilio_base
|
9
|
+
RAILS_ENV: test
|
10
|
+
- image: postgres:9.5
|
11
|
+
environment:
|
12
|
+
POSTGRES_USER: twilio_base
|
13
|
+
POSTGRES_DB: twilio_base_test
|
14
|
+
POSTGRES_PASSWORD: ""
|
15
|
+
steps:
|
16
|
+
- checkout
|
17
|
+
- run: bundle install
|
18
|
+
- run: cp spec/twilio_base_dummy/config/database.example.yml spec/twilio_base_dummy/config/database.yml
|
19
|
+
- run: bundle exec rake db:setup
|
20
|
+
- run:
|
21
|
+
name: Parallel RSpec
|
22
|
+
command: bundle exec rspec spec/
|
23
|
+
- run:
|
24
|
+
name: Rubocop
|
25
|
+
command: bundle exec rubocop
|
26
|
+
- run:
|
27
|
+
name: Publish gem to gemfury
|
28
|
+
command: |
|
29
|
+
if [ "${CIRCLE_BRANCH}" == "master" ]
|
30
|
+
then
|
31
|
+
gem install gemfury
|
32
|
+
gem build twilio_base.gemspec
|
33
|
+
fury push $(ls | grep twilio_base-) --as=dvelp --api-token=$BUNDLE_GEM__FURY__IO
|
34
|
+
else
|
35
|
+
echo "Publishing to gemfury allowed only for master branch"
|
36
|
+
fi
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateTwilioBaseGlobalConfigs < ActiveRecord::Migration[5.0]
|
4
|
+
def change
|
5
|
+
create_table :twilio_base_global_configs do |t|
|
6
|
+
t.string :api_key_secret
|
7
|
+
t.string :api_key_sid
|
8
|
+
t.string :application_sid
|
9
|
+
t.string :chat_service_sid
|
10
|
+
t.string :phone_number
|
11
|
+
t.string :sync_service_sid
|
12
|
+
t.string :workflow_sid
|
13
|
+
t.string :workspace_sid
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/twilio_base.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TwilioBase
|
4
|
+
FactoryBot.define do
|
5
|
+
factory :global_config, class: TwilioBase::GlobalConfig do
|
6
|
+
api_key_sid
|
7
|
+
api_key_secret
|
8
|
+
application_sid
|
9
|
+
chat_service_sid
|
10
|
+
phone_number
|
11
|
+
sync_service_sid
|
12
|
+
workflow_sid
|
13
|
+
workspace_sid
|
14
|
+
end
|
15
|
+
|
16
|
+
trait :empty do
|
17
|
+
api_key_sid { nil }
|
18
|
+
api_key_secret { nil }
|
19
|
+
application_sid { nil }
|
20
|
+
chat_service_sid { nil }
|
21
|
+
message_sid { nil }
|
22
|
+
phone_number { nil }
|
23
|
+
sync_service_sid { nil }
|
24
|
+
workflow_sid { nil }
|
25
|
+
workspace_sid { nil }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|