Esempio n. 1
0
def textSender():

    configuration = clicksend_client.Configuration()
    configuration.username = ''
    configuration.password = ''


    # create an instance of the API class
    api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))

    # If you want to explictly set from, add the key _from to the message.
    sms_message = SmsMessage(source="sdk",
                        body="Delivery Driver needed for Cake's Bakery. Contact at 214-557-4834",
                        to=""
                       )

    sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message])

    try:
        # Send sms message(s)
        api_response = api_instance.sms_send_post(sms_messages)
        print(api_response)
        return(jsonify(api_response))
    except ApiException as e:
        print("Exception when calling SMSApi->sms_send_post: %s\n" % e)
        return("error")
Esempio n. 2
0
    def setupClicksend(config):
        if "Notifications" in config:
            if "clicksendAPI_username" in config['Notifications']:
                configuration = clicksend_client.Configuration()
                configuration.username = config['Notifications'][
                    'clicksendAPI_username']
                configuration.password = config['Notifications'][
                    'clicksendAPI_password']
                self.notificationNumber = config['Notifications'][
                    'phonenumber']
                # create an instance of the API class
                self.smsAccountAPI = clicksend_client.AccountApi(
                    clicksend_client.ApiClient(configuration))
                try:
                    # Get account information
                    api_response = self.smsAccountAPI.account_get()
                    if "http_code': 200" not in api_response:
                        print("Invalid clicksend API response")
                        print(api_response)
                        self.smsAccountAPI = False
                    else:
                        self.smsAPI = clicksend_client.SMSApi(
                            clicksend_client.ApiClient(configuration))

                except ApiException as e:
                    print(
                        "Exception when calling AccountApi->account_get: %s\n"
                        % e)
                except Exception as err:
                    print("Eception when calling clicksend API")
                    print(err)
Esempio n. 3
0
    def __init__(self):
        print("Initializing Garage Door Monitor")
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.BEAM_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        #GPIO.add_event_detect(self.BEAM_PIN, GPIO.BOTH, callback=self.break_beam_callback)
        
        atexit.register(self.exitHandler)

        config = configparser.ConfigParser()
        config.read('settings.conf')


        # While there is no internet... run a continously loop.
        # THIS IS BLOCKING THE ENTIRE STATUS CHECK SCRIPT!
        noInternetCount = 0
        while not self.internet():
            print("No internet %s!!!" % noInternetCount)

            noInternetCount += 1
            time.sleep(5)

        # Configure HTTP basic authorization: BasicAuth
        username = config['Notifications']['clicksendAPI_username']
        password = config['Notifications']['clicksendAPI_password']
        notificationNumber = config['Notifications']['phonenumber']
        notificationNumber2 = config['Notifications']['benjaminWork']
        notificationNumber3 = config['Notifications']['annaCell']
        configuration = clicksend_client.Configuration()
        configuration.username = username
        configuration.password = password

        # create an instance of the API class
        self.api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))

        # If you want to explictly set from, add the key _from to the message.
        sms_message = SmsMessage(source="python",
                        body="Hey, the garage door has been open for five minutes.",
                        to=notificationNumber)
        sms_message2 = SmsMessage(source="python",
                        body="Hey, the garage door has been open for several minutes.",
                        to=notificationNumber2)

        sms_message3 = SmsMessage(source="python",
                        body="Hey, the garage door has been open for several minutes.",
                        to=notificationNumber3)

        self.sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message,sms_message2,sms_message3])


        garageDoorStatusThread = threading.Thread(target=self.doorStatusLoop)
        sendSMSThread = threading.Thread(target=self.sendSMS)


        garageDoorStatusThread.start()
        sendSMSThread.start()
Esempio n. 4
0
def send_fax(fax_number, the_file, config, country=None):
    if (hasattr(the_file, 'extension') and the_file.extension == 'pdf') or (hasattr(the_file, 'mimetype') and the_file.mimetype == 'application/pdf'):
        use_url = True
    else:
        use_url = False
    the_file.url_for(temporary=True, seconds=600)
    configuration = clicksend_client.Configuration()
    configuration.username = config['api username']
    configuration.password = config['api key']
    api_instance = clicksend_client.FAXApi(clicksend_client.ApiClient(configuration))
    fax_message_list = [FaxMessage(source="sdk", to=fax_number, _from=config['number'], country=country or config['country'], from_email=config['from email'])];
    if use_url:
        file_url = the_file.url_for(temporary=True, seconds=600)
    else:
        upload_file = clicksend_client.UploadFile(content=codecs.encode(the_file.slurp(auto_decode=False), 'base64'));
        try:
            api_response = api_instance.uploads_post(upload_file, 'fax')
        except ApiException as e:
            raise Exception("Exception when calling UploadApi->uploads_post: %s\n" % e)
        try:
            response = ast.literal_eval(api_response)
        except:
            logmessage(api_response)
            raise Exception("Exception when calling UploadApi->uploads_post: response could not be parsed: " + api_response)
        if response.get('http_code', 0) != 200:
            logmessage(api_response)
            raise Exception("Exception when calling UploadApi->uploads_post: response code not 200: " + api_response)
        if '_url' not in response:
            logmessage(api_response)
            raise Exception("Exception when calling UploadApi->uploads_post: url not returned " + api_response)
        file_url = response['_url']
    fax_message = clicksend_client.FaxMessageCollection(file_url=file_url, messages=fax_message_list)
    try:
        api_response = api_instance.fax_send_post(fax_message)
    except ApiException as e:
        raise Exception("Exception when calling FAXApi->fax_send_post: %s\n" % e)
    try:
        response = ast.literal_eval(api_response)
    except:
        logmessage(api_response)
        raise Exception("Exception when calling FAXApi->fax_send_post: response could not be parsed: " + api_response)
    if response.get('http_code', 0) != 200:
        logmessage(api_response)
        raise Exception("Exception when calling FAXApi->fax_send_post: response code not 200: " + api_response)
    try:
        message_id = response['data']['messages'][0]['message_id']
    except:
        raise Exception("Exception when calling FAXApi->fax_send_post: message_id not in response" + api_response)
    return response['data']['messages'][0]
Esempio n. 5
0
def api_clicksend(court_name, case_number, date_filed, plaintiff_name,
                  defendant_name, defendant_email):
    # https://developers.clicksend.com/docs/rest/v3/?python#ClickSend-v3-API-Transactional-Email

    # to get e-mail address from pipl API, need to upgrade pipl api key from social to business level (leave at social until turn on e-mail)

    # adapted from sample code:

    import clicksend_client
    from clicksend_client.rest import ApiException

    from clicksend_client import EmailRecipient
    from clicksend_client import EmailFrom
    from clicksend_client import Attachment

    configuration = clicksend_client.Configuration()

    from api_keys import configuration_username, configuration_password

    api_instance = clicksend_client.TransactionalEmailApi(
        clicksend_client.ApiClient(configuration))
    email_recipient = EmailRecipient(email=defendant_email,
                                     name=defendant_name)
    email_from = EmailFrom(email_address_id='6467', name='Hayden Barnes')
    email = clicksend_client.Email(
        to=[defendant_email],
        bcc=[email_recipient],  # send to storage e-mail account for arching
        _from=[email_from],
        subject="Legal Advertising: Lawsuit Filed In Muscogee County",
        body=
        "Court records show that a lawsuit was filed against [defendant_name] in Muscogee County, Georgia by [plaintiff_name_normalized] on [date_filed].\nIf you are the {{defendant_name_normalized}} named in this lawsuit and you are struggling to pay your bills we are here to help. We are bankruptcy lawyers dedicated to helping individuals and families experiencing temporary hardship regain their financial independence.\nAnyone can experience financial difficulties. Bankruptcy is designed to give those individuals and families a fresh start. Rather than waiting and worrying you can take your first steps to your financial freedom today.\nYou may be eligible to consolidate your debts into one lower monthly payment through a Chapter 13 reorganization. You may also be eligible to discharge your debts with a Chapter 7 bankruptcy. Both methods will stop creditors from calling, garnishing your wages, or taking your property.\nWe provide a free, no-obligation consultation to discuss your financial situation and whether bankruptcy is an option for you. Call us at 706.690.4471 day or night so we can schedule an appointment for you."
    )
    try:
        api_response = api_instance.email_send_post(email)
        dap_log_clicksend(LogLevel.DEBUG, str(api_response))
        # ! record clicksend api response to clicksend.log
    except ApiException as e:
        dap_log_clicksend(
            LogLevel.ERROR,
            "exception when calling TransactionalEmailApi->email_send_post: %s"
            % str(e))
        return 0
Esempio n. 6
0
from __future__ import print_function

import os
import re

import clicksend_client
from clicksend_client import SmsMessage, VoiceMessage
from clicksend_client.rest import ApiException
from clicksend_client import EmailRecipient
from clicksend_client import EmailFrom
from clicksend_client import Attachment

# Configure HTTP basic authorization: BasicAuth
configuration = clicksend_client.Configuration()
configuration.username = '******'
configuration.password = '******'


class Sendor:
    def send_invite_email(self, company, email, link, address):
        api_instance = clicksend_client.TransactionalEmailApi(clicksend_client.ApiClient(configuration))
        email_receipient = EmailRecipient(email=email, name='username')
        email_from = EmailFrom(email_address_id='14867', name='MEDD')
        attachment = Attachment(content='ZmlsZSBjb250ZW50cw==',
                              type='text/html',
                              filename='text.txt',
                              disposition='attachment',
                              content_id='292')
        # Email | Email model
Esempio n. 7
0
    def __init__(self, config, bgRun=True):
        self.config = config
        if "Elasticsearch" in config:
            esHost = config['Elasticsearch']['host']
            esUser = config['Elasticsearch']['username']
            esPass = config['Elasticsearch']['password']
            esPort = config['Elasticsearch']['port']
            self.es = Elasticsearch([esHost],
                                    http_auth=(esUser, esPass),
                                    ssl_show_warn=False,
                                    verify_certs=False,
                                    port=esPort)

        if "Notifications" in config:
            if "clicksendAPI_username" in config['Notifications']:
                configuration = clicksend_client.Configuration()
                configuration.username = config['Notifications'][
                    'clicksendAPI_username']
                configuration.password = config['Notifications'][
                    'clicksendAPI_password']
                self.notificationNumber = config['Notifications'][
                    'phonenumber']
                # create an instance of the API class
                self.smsAccountAPI = clicksend_client.AccountApi(
                    clicksend_client.ApiClient(configuration))
                try:
                    # Get account information
                    api_response = self.smsAccountAPI.account_get()
                    if "http_code': 200" not in api_response:
                        print("Invalid clicksend API response")
                        print(api_response)
                        self.smsAccountAPI = False
                    else:
                        self.smsAPI = clicksend_client.SMSApi(
                            clicksend_client.ApiClient(configuration))

                except ApiException as e:
                    print(
                        "Exception when calling AccountApi->account_get: %s\n"
                        % e)
                except Exception as err:
                    print("Eception when calling clicksend API")
                    print(err)

        if "Wemo" in config:
            if "AlwaysOn" in config['Wemo']:
                print("Loading always on devices")
                self.alwaysOnDevices = config['Wemo']['AlwaysOn'].split(",")

        if self.es:
            print("Connecting to ES")
            try:
                if not self.es.ping():
                    print(self.es.ping())
                    raise ConnectionError(
                        "Error connecting to Elasticsearch host: %s" % esHost)
            except Exception as err:
                print("Error connecting to ES")
        self.discovery()
        self.bgRun = bgRun

        if self.bgRun:
            self.bgUpdateThread = threading.Thread(target=self.update)
            self.bgUpdateThread.start()
 def __init__(self) -> None:
     configuration = clicksend_client.Configuration()
     configuration.username = self.USERNAME
     configuration.password = self.PASSWORD
     self.api_instance = clicksend_client.SMSApi(
         clicksend_client.ApiClient(configuration))