示例#1
0
 def test_modules_init(self):
     api = Messente(urls="https://test.example.com")
     self.assertIsInstance(api.sms, SmsAPI)
     self.assertIsInstance(api.credit, CreditAPI)
     self.assertIsInstance(api.delivery, DeliveryAPI)
     self.assertIsInstance(api.pricing, PricingAPI)
     apis = [api.sms, api.credit, api.delivery, api.pricing]
     for item in apis:
         self.assertIsInstance(item, API)
     del api
示例#2
0
 def test_invalid_config_path(self):
     with self.assertRaises(ConfigurationError):
         Messente(ini_path="invalid-path.ini",
                  urls="https://test-messente.example.com")
示例#3
0
    sys.exit(1)

delay = 0
if len(sys.argv) == 4:
    delay = int(sys.argv[3])

sms_data = {
    "to": sys.argv[1],
    "text": sys.argv[2],
}

if delay:
    sms_data.update({"time_to_send": int(time.time()) + delay})

# process sms
api = Messente()

(ok, errors) = api.sms.validate(sms_data)

if ok:
    print("# Sending")
    response = api.sms.send(sms_data)
    sms_id = response.get_sms_id()
    print("Sent:", sms_id)

    print("# Delivery")
    response = api.delivery.get_dlr_response(sms_id)
    print("Delivery:", response.get_result())
    print("Delivery error message:", response.get_full_error_msg())

    print("# Cancellation")
示例#4
0
# -*- coding: utf-8 -*-

from messente.api.sms import Messente

api = Messente(username="******", password="******")
api.sms.send(dict(to="+XXXxxxxxxxxx", text="test"))
示例#5
0
# -*- coding: utf-8 -*-

from messente.api.sms import Messente

api = Messente(username="******", password="******")
response = api.sms.send(dict(to="+XXXxxxxxxxxx", text="test"))
sms_id = response.get_sms_id()
response = api.delivery.get_dlr_response(sms_id)
print(response.get_result())