Skip to content

Commit 5c58476

Browse files
author
Charles Gruenwald
committed
[misc] bunch of random updates.
Summary: [misc] token_for_code to be consistent with ruby-bindings. [readme] Fix small typo. [files] Get support for sending and retrieving files. [misc] Examples + linting. [examples] Update the examles. Test Plan: review the code. Reviewers: bengotow, khamidou Reviewed By: khamidou Differential Revision: https://review.inboxapp.com/D371
1 parent 48acf1e commit 5c58476

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

inbox/models.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ def star(self):
112112
def unstar(self):
113113
self.update_tags([], ['starred'])
114114

115+
def create_reply(self):
116+
d = self.drafts.create()
117+
d.reply_to_thread = self.id
118+
d.subject = self.subject
119+
return d
120+
115121

116122
# This is a dummy class that allows us to use the create_resource function
117123
# and pass in a 'Send' object that will translate into a 'send' endpoint.
@@ -123,10 +129,10 @@ def __init__(self, api, namespace):
123129

124130

125131
class Draft(Message):
126-
attrs = Message.attrs + ["state", "reply_to_thread"]
132+
attrs = Message.attrs + ["state", "reply_to_thread", "version"]
127133
collection_name = 'drafts'
128134

129-
def __init__(self, api, namespace):
135+
def __init__(self, api, namespace, reply_to_thread=None):
130136
Message.__init__(self, api, namespace)
131137
InboxAPIObject.__init__(self, Thread, api, namespace)
132138
# We should probably move to using 'file_ids' instead of 'files'
@@ -144,7 +150,11 @@ def send(self):
144150
if not self.id:
145151
self.save()
146152

147-
self.api._create_resource(self.namespace, Send, {'draft_id': self.id})
153+
d_params = {'draft_id': self.id, 'version': self.version}
154+
if hasattr(self, 'reply_to_thread'):
155+
d_params['reply_to_thread'] = self.reply_to_thread
156+
157+
self.api._create_resource(self.namespace, Send, d_params)
148158

149159

150160
class File(InboxAPIObject):

0 commit comments

Comments
 (0)