# Path: invoiced/util.py
# def build_objects(_class, objects):
# def convert_to_object(_class, values):
# def uri_encode(params):
# def _url_encode(value):
# def _flatten_params(params, parent_key=None):
# def _flatten_params_array(value, calculated_key):


import unittest
import invoiced
from invoiced import util

    def test_build_objects(self):
        customers = [
            {'id': 100},
            {'id': 101}
        ]

        objects = util.build_objects(self.client.Customer, customers)
        self.assertEqual(2, len(objects))
        self.assertIsInstance(objects[0], invoiced.Customer)
        self.assertIsInstance(objects[1], invoiced.Customer)
        self.assertEqual(objects[0].id, 100)
        self.assertEqual(objects[1].id, 101)

    def test_uri_encode(self):
        params = {
            "test": "property",
            "filter": {
                "levels": "work",
                "nesting": {
                    "works": True
                }
            },
            "array": [
                "should",
                {"also": True},
                ["work"]
            ]
        }


# Path: invoiced/util.py
# def build_objects(_class, objects):
# def convert_to_object(_class, values):
# def uri_encode(params):
# def _url_encode(value):
# def _flatten_params(params, parent_key=None):
# def _flatten_params_array(value, calculated_key):


# Path: invoiced/test/test_util.py
import unittest
import invoiced
from invoiced import util


    def test_build_objects(self):
        customers = [
            {'id': 100},
            {'id': 101}
        ]

        objects = util.build_objects(self.client.Customer, customers)
        self.assertEqual(2, len(objects))
        self.assertIsInstance(objects[0], invoiced.Customer)
        self.assertIsInstance(objects[1], invoiced.Customer)
        self.assertEqual(objects[0].id, 100)
        self.assertEqual(objects[1].id, 101)

    def test_uri_encode(self):
        params = {
            "test": "property",
            "filter": {
                "levels": "work",
                "nesting": {
                    "works": True
                }
            },
            "array": [
                "should",
                {"also": True},
                ["work"]
            ]
        }


        encoded = util.uri_encode(params)