Repository: omise/omise-python

Issue:
Can't access a metadata object
The metadata properly appears when getting an object via `curl`

But accessing metadata via omise client got an error 

```
>>> transfer = omise.Transfer.retrieve(transfer_id)
>>> transfer.metadata
*** AttributeError: object
```

Discussion:

Patch:
diff --git a/omise/__init__.py b/omise/__init__.py
index 3ab88f0..bce6517 100644
--- a/omise/__init__.py
+++ b/omise/__init__.py
@@ -103,7 +103,7 @@ def _as_object(data):
     if isinstance(data, list):
         return [_as_object(i) for i in data]
     elif isinstance(data, dict):
-        class_ = _get_class_for(data['object'])
+        class_ = _get_class_for(data.get('object'))
         if not class_:
             class_ = Base
         return class_.from_data(data)


Test patch:
diff --git a/omise/test/test_charge.py b/omise/test/test_charge.py
index dcfc727..5a3dc68 100644
--- a/omise/test/test_charge.py
+++ b/omise/test/test_charge.py
@@ -268,6 +268,9 @@ class ChargeTest(_ResourceMixin, unittest.TestCase):
             "amount": 100000,
             "currency": "thb",
             "description": "Order-384",
+            "metadata": {
+                "order_id": "384"
+            },
             "capture": false,
             "authorized": true,
             "reversed": false,
@@ -314,6 +317,7 @@ class ChargeTest(_ResourceMixin, unittest.TestCase):
         self.assertEqual(charge.amount, 100000)
         self.assertEqual(charge.currency, 'thb')
         self.assertEqual(charge.description, 'Order-384')
+        self.assertEqual(charge.metadata.order_id, '384')
         self.assertEqual(charge.ip, '127.0.0.1')
         self.assertEqual(charge.card.id, 'card_test')
         self.assertEqual(charge.card.last_digits, '4242')
diff --git a/omise/test/test_transfer.py b/omise/test/test_transfer.py
index 75fd328..b66f6b8 100644
--- a/omise/test/test_transfer.py
+++ b/omise/test/test_transfer.py
@@ -74,6 +74,9 @@ class TransferTest(_ResourceMixin, unittest.TestCase):
             "paid": false,
             "amount": 100000,
             "currency": "thb",
+            "metadata": {
+                "recipient_name": "Somchai"
+            },
             "failure_code": null,
             "failure_message": null,
             "transaction": null,
@@ -87,6 +90,7 @@ class TransferTest(_ResourceMixin, unittest.TestCase):
         self.assertFalse(transfer.paid)
         self.assertEqual(transfer.id, 'trsf_test')
         self.assertEqual(transfer.amount, 100000)
+        self.assertEqual(transfer.metadata.recipient_name, 'Somchai')
         self.assertEqual(transfer.transaction, None)
         self.assertRequest(api_call, 'https://api.omise.co/transfers/trsf_test')