This repository has been archived by the owner on Feb 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from praekelt/feature/issue-1-create-basic-tran…
…sport-structure Create basic structure for WhatsApp transport
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |