示例#1
0
    def triggered_send(self, args):
        sendTrig = FuelSDK.ET_TriggeredSend()
        sendTrig.auth_stub = self.client
        sendTrig.props = {"CustomerKey": args.customer_key}
        if args.attribute_file is None:
            attributes = {}
        else:
            attributes = json.loads(args.attribute_file.read())

        sendTrig.subscribers = [{
            "EmailAddress": args.email,
            "SubscriberKey": args.subscriber_key,
        }]
        sendTrig.attributes = [{
            "Name": key,
            "Value": val
        } for key, val in attributes.items()]
        sendResponse = sendTrig.send()
        print(
            json.dumps([{
                "StatusCode":
                result.StatusCode,
                "StatusMessage":
                result.StatusMessage,
                "OrdinalID":
                result.OrdinalID,
                "NewID":
                result.NewID,
                "ErrorCode":
                result.ErrorCode if hasattr(result, "ErrorCode") else None,
            } for result in sendResponse.results]))
示例#2
0
    def retrieve_triggeredsend(self, args):
        """
        retrive a triggered send with customer key.

        :param string customer_key: data extension's customer key
        :return: data extension's name array.
        """
        getTS = FuelSDK.ET_TriggeredSend()
        getTS.auth_stub = self.client
        getTS.props = [
            "CustomerKey", "Name", "TriggeredSendStatus", "ObjectID"
        ]
        getTS.search_filter = {
            'Property': 'CustomerKey',
            'SimpleOperator': 'equals',
            'Value': args.customer_key
        }
        getResponse = getTS.get()

        for result in getResponse.results:
            return result.ObjectID
        return ""