15.2.150. camcops_server.cc_modules.cc_sms

camcops_server/cc_modules/cc_sms.py


Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.


Send SMS via supported backends

class camcops_server.cc_modules.cc_sms.ConsoleSmsBackend(config: Dict[str, Any])[source]

Debugging “backend” – just prints the message to the server console.

classmethod make_msg(recipient: str, message: str) str[source]

Returns the message sent to the console.

send_sms(recipient: str, message: str, sender: Optional[str] = None) None[source]

Send an SMS message.

Parameters
  • recipient – Recipient’s phone number, as a string.

  • message – Message contents.

  • sender – Sender’s phone number, if applicable.

class camcops_server.cc_modules.cc_sms.KapowSmsBackend(config: Dict[str, Any])[source]

Send SMS messages via Kapow.

__init__(config: Dict[str, Any]) None[source]
Parameters

config – Dictionary of parameters specific to the backend in use.

send_sms(recipient: str, message: str, sender: Optional[str] = None) None[source]

Send an SMS message.

Parameters
  • recipient – Recipient’s phone number, as a string.

  • message – Message contents.

  • sender – Sender’s phone number, if applicable.

exception camcops_server.cc_modules.cc_sms.MissingBackendException[source]

SMS backend not configured.

class camcops_server.cc_modules.cc_sms.SmsBackend(config: Dict[str, Any])[source]

Base class for sending SMS (text) messages.

__init__(config: Dict[str, Any]) None[source]
Parameters

config – Dictionary of parameters specific to the backend in use.

send_sms(recipient: str, message: str, sender: Optional[str] = None) None[source]

Send an SMS message.

Parameters
  • recipient – Recipient’s phone number, as a string.

  • message – Message contents.

  • sender – Sender’s phone number, if applicable.

class camcops_server.cc_modules.cc_sms.TwilioSmsBackend(config: Dict[str, Any])[source]

Send SMS messages via Twilio SMS.

__init__(config: Dict[str, Any]) None[source]
Parameters

config – Dictionary of parameters specific to the backend in use.

send_sms(recipient: str, message: str, sender: Optional[str] = None) None[source]

Send an SMS message.

Parameters
  • recipient – Recipient’s phone number, as a string.

  • message – Message contents.

  • sender – Sender’s phone number, if applicable.

camcops_server.cc_modules.cc_sms.get_sms_backend(label: str, config: Dict[str, Any]) camcops_server.cc_modules.cc_sms.SmsBackend[source]

Make an instance of an SMS backend by name, passing it appropriate backend-specific config options.

camcops_server.cc_modules.cc_sms.register_backend(name: str, backend_class: Type[camcops_server.cc_modules.cc_sms.SmsBackend]) None[source]

Internal function to register an SMS backend by name.

Parameters
  • name – Name of backend (e.g. as referred to in the config file).

  • backend_class – Appropriate subclass of SmsBackend.