iro/offer/smstrade.py
changeset 310 352850d4fb4b
parent 307 6acae4210716
child 312 42fd5075a5d1
--- a/iro/offer/smstrade.py	Sat Jul 27 13:36:51 2019 +0200
+++ b/iro/offer/smstrade.py	Sat Jul 27 13:37:23 2019 +0200
@@ -1,19 +1,19 @@
 # -*- coding: utf-8 -*-
 
 # Copyright (c) 2012 netzguerilla.net <iro@netzguerilla.net>
-# 
+#
 # This file is part of Iro.
-# 
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy of
 # this software and associated documentation files (the "Software"), to deal in
 # the Software without restriction, including without limitation the rights to use,
 # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
 # #Software, and to permit persons to whom the Software is furnished to do so,
 # subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -57,7 +57,7 @@
         ExternalException.__init__(self)
         self.status = status
         self.str_=str(status)
-    
+
     def __str__(self):
         return "%s\n%s"%(ExternalException.__str__(self),self.str_)
 
@@ -66,7 +66,7 @@
     """Class that represents the output of one smstrade request."""
     def __init__(self,code, exID=None, costs=Decimal("0.0"), count=0):
         self.code = code
-        
+
         self.exID = exID
         try:
             self.costs = Decimal(costs)
@@ -76,11 +76,11 @@
             else:
                 raise
         self.count = int(count)
-     
+
     def __str__(self):
         if self.code in statusCodes.keys():
             return "%i: %s"%(self.code, statusCodes[self.code])
-        
+
         return "%i: unknown statuscode."%self.code
 
     def __int__(self):
@@ -104,14 +104,14 @@
            }
     '''dict for standrd values of the smstrade api, it is used to get the right values to the API.'''
 
-    def __init__(self, name):       
+    def __init__(self, name):
         self.url = "https://gateway.smstrade.de"
         options =[("key", Option(lambda x,y:x,long="smstrade Gateway Key https://login.smstrade.de/index.php?gateway", must=True)),]
         Provider.__init__(self, name, {"sms":["basic","economy","gold","direct"]},options)
 
     def send(self, route, recipient, sms):
         """send one SMS to recipient via route
-        
+
         :param string route: A valid route ``["basic", "economy", "gold", "direct"]``
         :param `iro.telnumber.Telnumber` recipient: Mobilenumber of recipient
         :param `iro.model.message.SMS` sms: the sms to send
@@ -125,7 +125,7 @@
 
         if recipient.land != '49' and route == "basic":
             raise RejectRecipient(recipient)
-        
+
         to ='00'+recipient.land+recipient.number
 
         s = self.__send(route, to, sms)
@@ -138,31 +138,31 @@
             raise SmstradeException(s)
 
     def __send(self, route, to, sms):
-        """ This is the main function to request to the sms service.    
+        """ This is the main function to request to the sms service.
 
         :param string route: A valid route ``["basic", "economy", "gold", "direct"]
         :param string recipient: Mobilenumber of recipient
         :param `iro.model.message.sms` sms: the sms to send
         :return: a :class:`.StatusCode` object
         """
-        
+
         #logger.debug('smstrade._send(%s,%s,%s)'%( route, to, sms))
         parameters= {"key": self.key,
                 "route": route,
                 "to": to,
                 "message": sms.content,
-                "charset":"utf-8", 
+                "charset":"utf-8",
                 "debug": self.testmode,
                 "message_id":True,
                 "count":True,
                 "cost":True,
                 }
-        
+
         doubleChar="€[]{}|\\^~"    #these charactar need two GSM Chars
 
         if sms.from_ is not None:
             parameters["from"] = sms.from_
-       
+
         length=len(sms.content)
         for s in doubleChar:
             length += sms.content.count(s)