MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / AddPhone

Method AddPhone

api/pkg/services/phone_api_key_service.go:172–195  ·  view source on GitHub ↗

AddPhone adds a phone to the phone API key

(ctx context.Context, userID entities.UserID, phoneAPIKeyID uuid.UUID, phoneID uuid.UUID)

Source from the content-addressed store, hash-verified

170
171// AddPhone adds a phone to the phone API key
172func (service *PhoneAPIKeyService) AddPhone(ctx context.Context, userID entities.UserID, phoneAPIKeyID uuid.UUID, phoneID uuid.UUID) error {
173 ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)
174 defer span.End()
175
176 phone, err := service.phoneRepository.LoadByID(ctx, userID, phoneID)
177 if err != nil {
178 msg := fmt.Sprintf("cannot load [%T] with ID [%s] for user [%s]", &entities.Phone{}, phoneID, userID.String())
179 return stacktrace.Propagate(err, msg)
180 }
181
182 phoneAPIKey, err := service.repository.Load(ctx, userID, phoneAPIKeyID)
183 if err != nil {
184 msg := fmt.Sprintf("cannot load [%T] with ID [%s] for user [%s]", &entities.PhoneAPIKey{}, phoneAPIKeyID, userID.String())
185 return stacktrace.Propagate(err, msg)
186 }
187
188 if err = service.repository.AddPhone(ctx, phoneAPIKey, phone); err != nil {
189 msg := fmt.Sprintf("cannot add [%T] with ID [%s] to phone API key with ID [%s] for user [%s]", phone, phone.ID, phoneAPIKey.ID, userID)
190 return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
191 }
192
193 ctxLogger.Info(fmt.Sprintf("added [%T] with ID [%s] to [%T] with ID [%s] for user ID [%s]", phone, phone.ID, phoneAPIKey, phoneAPIKeyID, userID))
194 return nil
195}
196
197func (service *PhoneAPIKeyService) generateRandomBytes(n int) ([]byte, error) {
198 b := make([]byte, n)

Callers

nothing calls this directly

Calls 7

StartWithLoggerMethod · 0.65
LoadByIDMethod · 0.65
LoadMethod · 0.65
AddPhoneMethod · 0.65
WrapErrorSpanMethod · 0.65
InfoMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected