|
1 | | -# coding=utf-8 |
2 | | -# |
3 | | -# Copyright 2013 keyes.ie |
4 | | -# |
5 | | -# License: http://jkeyes.mit-license.org/ |
6 | | -# |
7 | | -""" Note module. |
| 1 | +from intercom.user import Resource |
| 2 | +from intercom.api_operations.find import Find |
8 | 3 |
|
9 | | ->>> from intercom import Intercom |
10 | | ->>> Intercom.app_id = 'dummy-app-id' |
11 | | ->>> Intercom.api_key = 'dummy-api-key' |
12 | | ->>> from intercom import Note |
| 4 | +class Note(Resource, Find): |
| 5 | + pass |
13 | 6 |
|
14 | | -""" |
15 | | - |
16 | | -from . import Intercom |
17 | | -from . import from_timestamp_property |
18 | | -from . import to_timestamp_property |
19 | | -from .user import User |
20 | | -from .user import UserId |
21 | | - |
22 | | - |
23 | | -class Note(UserId): |
24 | | - """ A note on a User. """ |
25 | | - |
26 | | - @classmethod |
27 | | - def create(cls, user_id=None, email=None, body=None): |
28 | | - """ Create a Note. |
29 | | -
|
30 | | - >>> note = Note.create(email="somebody@example.com", |
31 | | - ... body="This is a note.") |
32 | | - >>> note.created_at.year |
33 | | - 2011 |
34 | | - >>> note.html |
35 | | - u'<p>This is a note</p>' |
36 | | -
|
37 | | - """ |
38 | | - resp = Intercom.create_note(user_id=user_id, email=email, body=body) |
39 | | - return cls(resp) |
40 | | - |
41 | | - def save(self): |
42 | | - """ Create a Note from this objects properties: |
43 | | -
|
44 | | - >>> note = Note() |
45 | | - >>> note.email = "somebody@example.com" |
46 | | - >>> note.body = "This is a note." |
47 | | - >>> note.save() |
48 | | - >>> note.html |
49 | | - u'<p>This is a note</p>' |
50 | | -
|
51 | | - """ |
52 | | - resp = Intercom.create_note( |
53 | | - user_id=self.user_id, email=self.email, body=self.body) |
54 | | - self.update(resp) |
55 | | - |
56 | | - @property |
57 | | - def body(self): |
58 | | - """ The body of the note. """ |
59 | | - return dict.get(self, 'body', None) |
60 | | - |
61 | | - @body.setter |
62 | | - def body(self, body): |
63 | | - """ Set the note body. """ |
64 | | - self['body'] = body |
65 | | - |
66 | | - @property |
67 | | - def html(self): |
68 | | - """ Get the html of the note – set by an API response. """ |
69 | | - return dict.get(self, 'html', None) |
70 | | - |
71 | | - @property |
72 | | - @from_timestamp_property |
73 | | - def created_at(self): |
74 | | - """ Returns the datetime this note was created – set by an |
75 | | - API response. """ |
76 | | - return dict.get(self, 'created_at', None) |
77 | | - |
78 | | - @created_at.setter |
79 | | - @to_timestamp_property |
80 | | - def created_at(self, created_at): |
81 | | - """ Set the datetime this note was created. """ |
82 | | - self['created_at'] = created_at |
83 | | - |
84 | | - @property |
85 | | - def user(self): |
86 | | - """ Get the noted user – set by an API response. """ |
87 | | - data = dict.get(self, 'user', None) |
88 | | - if data: |
89 | | - return User(**data) |
0 commit comments