Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshjosh361 committed Oct 14, 2024
1 parent 7d855ce commit 2543ab7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 13 deletions.
1 change: 0 additions & 1 deletion notification-service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/joho/godotenv v1.5.1
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions notification-service/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+Licev
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
Expand Down
27 changes: 17 additions & 10 deletions notification-service/internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@ import (
"log"
"os"

"github.com/joho/godotenv"
"github.com/twilio/twilio-go"
twilioApi "github.com/twilio/twilio-go/rest/api/v2010"
)

// load env variables
func init() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
}
// func init() {
// err := godotenv.Load()
// if err != nil {
// log.Fatal("Error loading .env file")
// }
// }

type NotificationService struct {
twilioClient *twilio.RestClient
}

func NewNotificationService() *NotificationService {
accountSid := os.Getenv("Account_SID")
authToken := os.Getenv("Auth_Token")

if accountSid == "" || authToken == "" {
log.Fatal("Twilio credentials are missing")
}

client := twilio.NewRestClientWithParams(twilio.ClientParams{
Username: os.Getenv("Account_SID"),
Password: os.Getenv("Auth_Token"),
Username: accountSid,
Password: authToken,
})

return &NotificationService{
Expand All @@ -34,8 +40,9 @@ func NewNotificationService() *NotificationService {
}

func (ns *NotificationService) SendSMS(to string, body string) error {
phoneNumber := os.Getenv("PhoneNumber")
params := &twilioApi.CreateMessageParams{}
params.SetFrom(os.Getenv("PhoneNumber"))
params.SetFrom(phoneNumber)
params.SetBody(body)
params.SetTo(to)

Expand Down
61 changes: 61 additions & 0 deletions notification-service/keploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
path: ""
appId: 0
appName: notification-service
command: docker run -e Account_SID=AC9465c2cf339aa21ed06284dc8bcaf5aa -e Auth_Token=6a1e9ef25b72d52b3fde6e4052d8f0d6 -e PhoneNumber=+16202061107 -p 8084:8084 notification
templatize:
testSets: []
port: 0
dnsPort: 26789
proxyPort: 16789
debug: false
disableTele: false
disableANSI: false
containerName: ""
networkName: ""
buildDelay: 30
test:
selectedTests: {}
globalNoise:
global: {}
test-sets: {}
delay: 5
host: ""
port: 0
apiTimeout: 5
skipCoverage: false
coverageReportPath: ""
ignoreOrdering: true
mongoPassword: default@123
language: ""
removeUnusedMocks: false
fallBackOnMiss: false
jacocoAgentPath: ""
basePath: ""
mocking: true
ignoredTests: {}
disableLineCoverage: false
disableMockUpload: true
useLocalMock: false
updateTemplate: false
record:
filters: []
recordTimer: 0s
configPath: ""
bypassRules: []
generateGithubActions: false
keployContainer: keploy-v2
keployNetwork: keploy-network
cmdType: native
contract:
services: []
tests: []
path: ""
download: false
generate: false
driven: consumer
mappings:
servicesMapping: {}
self: ""
inCi: false

# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file.

0 comments on commit 2543ab7

Please sign in to comment.