-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring SMS credentials to be multi-tenant and persisted in database
- Loading branch information
Jim Van Fleet
committed
Nov 21, 2017
1 parent
060dccf
commit 64cedd9
Showing
21 changed files
with
131 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,5 +192,8 @@ DEPENDENCIES | |
unicorn | ||
webmock | ||
|
||
RUBY VERSION | ||
ruby 2.2.3p173 | ||
|
||
BUNDLED WITH | ||
1.10.6 | ||
1.15.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Citygram::Models | ||
class SmsCredentials < Sequel::Model | ||
dataset_module do | ||
end | ||
|
||
def validate | ||
super | ||
validates_presence [:from_number, :account_sid, :auth_token] | ||
validates_unique :account_sid | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Citygram | ||
module SmsSender | ||
|
||
def send_sms(subscription, body) | ||
Citygram::App.logger.info("Sending SMS via #{subscription.credential_name}") | ||
Citygram::Services::Channels::SMS.sms( | ||
subscription.account_sid, | ||
subscription.auth_token, { | ||
from: subscription.from_number, | ||
to: subscription.phone_number, | ||
body: body | ||
}) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Sequel.migration do | ||
up do | ||
create_table :sms_credentials do | ||
primary_key :id | ||
String :credential_name | ||
String :from_number | ||
String :account_sid | ||
String :auth_token | ||
DateTime :updated_at | ||
DateTime :created_at | ||
end | ||
end | ||
|
||
down do | ||
drop_table :sms_credentials | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Sequel.migration do | ||
up do | ||
alter_table(:publishers) do | ||
add_foreign_key :sms_credentials_id, :sms_credentials | ||
end | ||
end | ||
|
||
down do | ||
alter_table(:publishers) do | ||
drop_foreign_key :sms_credentials_id | ||
end | ||
end | ||
end |
Oops, something went wrong.