hooks

class naz.hooks.BaseHook[source]

Bases: abc.ABC

Interface that must be implemented to satisfy naz’s hooks. User implementations should inherit this class and implement the to_smsc and from_smsc methods with the type signatures shown.

A hook is class with methods that are called just before sending data to SMSC and just after receiving data from SMSC.

abstract async from_smsc(smpp_command, log_id, hook_metadata, status, pdu)[source]

called after receiving data from SMSC.

Parameters
  • smpp_command (str) – any one of the SMSC commands eg submit_sm_resp

  • log_id (str) – an ID that a user’s application had previously supplied to naz to track/correlate different messages.

  • hook_metadata (str) – a string that a user’s application had previously supplied to naz that it may want to be correlated with the log_id.

  • status (state.CommandStatus) – the state of request/response from SMSC.

  • pdu (bytes) – the full PDU as received from SMSC

Return type

None

abstract async to_smsc(smpp_command, log_id, hook_metadata, pdu)[source]

called before sending data to SMSC.

Parameters
  • smpp_command (str) – any one of the SMSC commands eg submit_sm

  • log_id (str) – an ID that a user’s application had previously supplied to naz to track/correlate different messages.

  • hook_metadata (str) – a string that a user’s application had previously supplied to naz that it may want to be correlated with the log_id.

  • pdu (bytes) – the full PDU as sent to SMSC

Return type

None

class naz.hooks.SimpleHook(logger=None)[source]

Bases: naz.hooks.BaseHook

This is an implementation of BaseHook. When this class is called by naz, it just logs the request or response.

__init__(logger=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Return type

None

async from_smsc(smpp_command, log_id, hook_metadata, status, pdu)[source]

called after receiving data from SMSC.

Parameters
  • smpp_command (str) – any one of the SMSC commands eg submit_sm_resp

  • log_id (str) – an ID that a user’s application had previously supplied to naz to track/correlate different messages.

  • hook_metadata (str) – a string that a user’s application had previously supplied to naz that it may want to be correlated with the log_id.

  • status (state.CommandStatus) – the state of request/response from SMSC.

  • pdu (bytes) – the full PDU as received from SMSC

Return type

None

async to_smsc(smpp_command, log_id, hook_metadata, pdu)[source]

called before sending data to SMSC.

Parameters
  • smpp_command (str) – any one of the SMSC commands eg submit_sm

  • log_id (str) – an ID that a user’s application had previously supplied to naz to track/correlate different messages.

  • hook_metadata (str) – a string that a user’s application had previously supplied to naz that it may want to be correlated with the log_id.

  • pdu (bytes) – the full PDU as sent to SMSC

Return type

None