Repository: Stranger6667/postmarker

Issue:
Initialize inbound/outbound message in `get_details`
And probably rename method to ``get``

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=h1) Report
> Merging [#125](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=desc) into [master](https://codecov.io/gh/Stranger6667/postmarker/commit/604005f5a384995207ffb53e6de2b8f3fa2b38db?src=pr&el=desc) will **decrease** coverage by `0.12%`.
> The diff coverage is `87.5%`.

[![Impacted file tree graph](https://codecov.io/gh/Stranger6667/postmarker/pull/125/graphs/tree.svg?height=150&width=650&token=ntmpbnZMPl&src=pr)](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
- Coverage     100%   99.87%   -0.13%     
==========================================
  Files          20       20              
  Lines         788      790       +2     
  Branches       61       61              
==========================================
+ Hits          788      789       +1     
- Misses          0        1       +1
```


| [Impacted Files](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [postmarker/models/messages.py](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=tree#diff-cG9zdG1hcmtlci9tb2RlbHMvbWVzc2FnZXMucHk=) | `98.93% <87.5%> (-1.07%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=footer). Last update [604005f...8c2bf75](https://codecov.io/gh/Stranger6667/postmarker/pull/125?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Patch:
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 2ab7edc..208173f 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -11,6 +11,12 @@ Added
 
 - Short-circuit send of empty batches in `Django` backend. `#123`_
 
+Changed
+~~~~~~~
+
+- ``OutboundMessageManager.get_details`` and ``InboundMessageManager.get_details`` were methods were renamed to ``get``.
+  Now they returns ``OutboundMessage`` and ``InboundMessage`` instances respectively.
+
 `0.9.2`_ - 2017-03-29
 ---------------------
 
diff --git a/postmarker/models/messages.py b/postmarker/models/messages.py
index 6e946a0..361515f 100644
--- a/postmarker/models/messages.py
+++ b/postmarker/models/messages.py
@@ -35,8 +35,8 @@ class OpensManager(ModelManager):
 
 class BaseMessage(Model):
 
-    def get_details(self):
-        return self._manager.get_details(self.MessageID)
+    def get(self):
+        return self._manager.get(self.MessageID)
 
 
 class OutboundMessage(BaseMessage):
@@ -82,8 +82,9 @@ class OutboundMessageManager(SubModelManager):
         )
         return self.expand_responses(responses, 'Messages')
 
-    def get_details(self, id):
-        return self.call('GET', '/messages/outbound/%s/details' % id)
+    def get(self, id):
+        response = self.call('GET', '/messages/outbound/%s/details' % id)
+        return self._init_instance(response)
 
     def get_dump(self, id):
         return self.call('GET', '/messages/outbound/%s/dump' % id).get('Body')
@@ -169,8 +170,9 @@ class InboundMessageManager(ModelManager):
         )
         return self.expand_responses(responses, 'InboundMessages')
 
-    def get_details(self, id):
-        return self.call('GET', '/messages/inbound/%s/details' % id)
+    def get(self, id):
+        response = self.call('GET', '/messages/inbound/%s/details' % id)
+        return self._init_instance(response)
 
     def bypass(self, id):
         return self.call('PUT', '/messages/inbound/%s/bypass' % id)


Test patch:
diff --git a/tests/models/test_messages.py b/tests/models/test_messages.py
index 412296f..7910fb7 100644
--- a/tests/models/test_messages.py
+++ b/tests/models/test_messages.py
@@ -8,6 +8,8 @@ from postmarker.exceptions import ClientError
 from postmarker.models.base import ModelManager
 from postmarker.models.messages import Attachment, InboundMessage, Open, OutboundMessage
 
+from .._compat import patch
+
 
 CASSETTE_NAME = 'messages'
 
@@ -39,8 +41,8 @@ class TestOutboundMessages:
         assert isinstance(outbound_message, OutboundMessage)
         assert str(outbound_message) == 'Sent message to test@example.com'
 
-    def test_get_details(self, outbound_message):
-        assert outbound_message.get_details()['Body'] == 'Body example'
+    def test_get(self, outbound_message):
+        assert outbound_message.get().Body == 'Body example'
 
     def test_get_dump(self, outbound_message):
         assert outbound_message.get_dump() == 'Body example'
@@ -60,9 +62,10 @@ class TestInboundMessages:
         assert isinstance(inbound_message, InboundMessage)
         assert str(inbound_message) == 'Blocked message from test@example.com'
 
-    def test_get_details(self, inbound_message):
-        with not_found():
-            inbound_message.get_details()
+    def test_get(self, inbound_message):
+        with patch.object(inbound_message._manager, 'call', return_value=inbound_message.as_dict()):
+            instance = inbound_message.get()
+        assert isinstance(instance, InboundMessage)
 
     def test_bypass(self, inbound_message):
         with not_found('[701] This message was not found or cannot be bypassed.'):