Skip to content
This repository has been archived by the owner on Feb 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1 from praekelt/feature/issue-1-create-basic-tran…
Browse files Browse the repository at this point in the history
…sport-structure

Create basic structure for WhatsApp transport
  • Loading branch information
Hannarst authored and Hannarst committed Jun 24, 2015
2 parents 590252b + dac833e commit 85311b7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions vxyowsup/whatsapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- test-case-name: vumi.transports.whatsapp.tests.test_whatsapp -*-
from twisted.internet import defer

from vumi.transports.base import Transport
from vumi.config import ConfigText
from vumi import log


class WhatsAppTransportConfig(Transport.CONFIG_CLASS):
extra_config = ConfigText('Some Config var', default='foo',
static=True)


class WhatsAppTransport(Transport):

CONFIG_CLASS = WhatsAppTransportConfig
transport_type = 'whatsapp'

def setup_transport(self):
config = self.get_static_config()
log.info('Transport starting with: %s' % (config.extra_config,))
return defer.succeed(1)

def teardown_transport(self):
return defer.succeed(1)

def handle_outbound_message(self, message):
# message is a vumi.message.TransportUserMessage
log.info('Sending %r' % (message.to_json(),))
if message['content'] == 'fail!':
return self.publish_nack(message['message_id'], 'failed')
return self.publish_ack(message['message_id'], 'remote-message-id')

0 comments on commit 85311b7

Please sign in to comment.