# Path: libre/apps/origins/utils.py
# def recursive_asdict(d):
#     """Convert Suds object into serializable format."""
#     out = {}
#     for k, v in asdict(d).iteritems():
#         if hasattr(v, '__keylist__'):
#             out[k] = recursive_asdict(v)
#         elif isinstance(v, list):
#             out[k] = []
#             for item in v:
#                 if hasattr(item, '__keylist__'):
#                     out[k].append(recursive_asdict(item))
#                 else:
#                     out[k].append(item)
#         else:
#             out[k] = v
#     return out


from ast import literal_eval
from itertools import izip
from django.conf import settings
from django.db import models
from django.db import load_backend as django_load_backend
from django.utils.translation import ugettext_lazy as _
from model_utils.managers import InheritanceManager
from picklefield.fields import dbsafe_encode, dbsafe_decode
from suds.client import Client
from .literals import BACKEND_CHOICES, BACKEND_CLASSES
from .utils import recursive_asdict
import hashlib
import logging
import tempfile
import requests
        logger.debug('evaluated parameters: %s' % parameters)

        response = requests.get(self.url, params=parameters)

        logger.debug('response: %s' % response)

        return (item for item in response.json())

    class Meta:
        verbose_name = _('REST API origin')
        verbose_name_plural = _('REST API origins')


class OriginSOAPWebService(OriginURL):
    origin_type = _('SOAP webservice')

    endpoint = models.CharField(max_length=64, verbose_name=_('endpoint'), help_text=_('Endpoint, function or method to call.'))
    parameters = models.TextField(blank=True, verbose_name=_('parameters'))

    def get_binary_iterator(self):
        # We are a subclass of OriginURL which has a get_binary_iterator method, invalidate it
        raise AttributeError

    def get_non_binary_iterator(self):
        client = Client(self.url)
        if self.parameters:
            parameters = literal_eval(self.parameters)
        else:
            parameters = {}


# Path: libre/apps/origins/utils.py
# def recursive_asdict(d):
#     """Convert Suds object into serializable format."""
#     out = {}
#     for k, v in asdict(d).iteritems():
#         if hasattr(v, '__keylist__'):
#             out[k] = recursive_asdict(v)
#         elif isinstance(v, list):
#             out[k] = []
#             for item in v:
#                 if hasattr(item, '__keylist__'):
#                     out[k].append(recursive_asdict(item))
#                 else:
#                     out[k].append(item)
#         else:
#             out[k] = v
#     return out


# Path: libre/apps/origins/models.py
from ast import literal_eval
from itertools import izip
from django.conf import settings
from django.db import models
from django.db import load_backend as django_load_backend
from django.utils.translation import ugettext_lazy as _
from model_utils.managers import InheritanceManager
from picklefield.fields import dbsafe_encode, dbsafe_decode
from suds.client import Client
from .literals import BACKEND_CHOICES, BACKEND_CLASSES
from .utils import recursive_asdict
import hashlib
import logging
import tempfile
import requests

        logger.debug('evaluated parameters: %s' % parameters)

        response = requests.get(self.url, params=parameters)

        logger.debug('response: %s' % response)

        return (item for item in response.json())

    class Meta:
        verbose_name = _('REST API origin')
        verbose_name_plural = _('REST API origins')


class OriginSOAPWebService(OriginURL):
    origin_type = _('SOAP webservice')

    endpoint = models.CharField(max_length=64, verbose_name=_('endpoint'), help_text=_('Endpoint, function or method to call.'))
    parameters = models.TextField(blank=True, verbose_name=_('parameters'))

    def get_binary_iterator(self):
        # We are a subclass of OriginURL which has a get_binary_iterator method, invalidate it
        raise AttributeError

    def get_non_binary_iterator(self):
        client = Client(self.url)
        if self.parameters:
            parameters = literal_eval(self.parameters)
        else:
            parameters = {}


        return (recursive_asdict(item) for item in getattr(client.service, self.endpoint)(**parameters))