Skip to content

Reference

smsdrop.smsdrop.Client dataclass

Main module class that make the requests to the smsdrop api.

Parameters:

Name Type Description Default
email str

The email address of your smsdrop account, defaults to [None]

required
password str

Your smsdrop account password

required
context Optional[str]

Root url of the api

required
storage Optional[BaseStorage]

A storage object that will be use to store the api token

required
logger Optioanl[logging.Logger]

A logger instance with your own config

required

Exceptions:

Type Description
BadCredentialsError

If the password or/and email your provided are incorrect

launch_campaign(self, campaign)

Send a request to the api to launch a new campaign from the smsdrop.CampaignIn instance provided

Note that the campaign is always created even if an exception is raised, the instance your provide is updated with the response from the api. For example campaign.id will always be available even the campaign is not launched, it is always created except if there are some validation errors, you can use client.retry(campaign.id) to retry after you

Parameters:

Name Type Description Default
campaign CampaignCreate

An instance of the class smsdrop.CampaignIn

required

Exceptions:

Type Description
InsufficientSmsError

If the number of sms available on your account is insufficient to launch the campaign

ValidationError

if the campaign data you provided is not valid

ServerError

If the server if failing for some obscure reasons

read_campaign(self, id)

Get a campaign data based on an id

Parameters:

Name Type Description Default
id str

The cmapign id

required

Returns:

Type Description
Optional[smsdrop.models.Campaign]

An instance of smsdrop.CampaignIn

read_campaigns(self, skip=0, limit=100)

Get mutliple campaigns from the api

Parameters:

Name Type Description Default
skip int

starting index

0
limit int

The maximum amount of element to get

100

Returns:

Type Description
List[smsdrop.models.Campaign]

read_me(self)

Get your profile informations

Returns:

Type Description
User

An instance of the smsdrop.User class

Exceptions:

Type Description
ServerError

If the server if failing for some obscure reasons

read_subscription(self)

Get your subsctiption informations

Returns:

Type Description
Subscription

An instance of the smsdrop.Subscription class

Exceptions:

Type Description
ServerError

If the server if failing for some obscure reasons

retry_campaign(self, id)

Retry a campaign if it was not launch due to insufficient sms on the user account

Parameters:

Name Type Description Default
id str

The id of your campaign

required

Exceptions:

Type Description
ServerError

If the server if failing for some obscure reasons

send_message(self, message, sender, phone, dispatch_date=None)

Send a simple message to a single recipient.

This is just a convenient helper to send sms to a unique recipient, internally it work exactly as a campaign and create a new campaign.

Parameters:

Name Type Description Default
message str

The content of your message

required
sender str

The sender that will be displayed on the recipient phone

required
phone str

The recipient's phone number, Ex: +229XXXXXXXX

required
dispatch_date Optional[datetime.datetime]

The date you want the message to be sent

None

Returns:

Type Description
Campaign

An instance of the class py:class::smsdrop.Campaign

Exceptions:

Type Description
ValidationError

if some of the data you provided are not valid

ServerError

If the server if failing for some obscure reasons

InsufficientSmsError

If the number of sms available on your account is insufficient to send the message

smsdrop.models.CampaignCreate dataclass

Data class use to create a new campaign.

Parameters:

Name Type Description Default
title str

A title intended to help you identify this campaign, a random name will be generated if you do not provide one.

required
message str

The content of your message

required
message_type MessageType

The message type, the possible values are MessageType.PLAIN_TEXT, MessageType.UNICODE, MessageType.FLASH_MESSAGE

required
sender str

The sender name that will be displayed on the recipient's phone.

required
defer_until Optional[datetime.datetime]

The launch date of your campaign. It is recommended to specify your timezone infos in order to avoid surprises.

required
defer_by Optional[int]

The number of seconds the launch will be postponed.

required
recipient_list List[str]

The list of users the message will be sent to. Ex ["phone1", "phone2"]. The phone number format is '{code}{local_number}' , Ex: +22963588213, the "+" at the beginning is optional.

required

When you create an instance of this class, the only validation that is made is to check if you set both defer_by and defer_until which is not allowed. You campaign data is really only validate when the request is made to the check, so be sure to sanitize your data.