code: def wrapped_resource(response):
      
      # decode response text, assuming utf-8 if unset
      response_content = response.content.decode(response.encoding or 'utf-8')
  
      try:
          content = json.loads(response_content)
      except ValueError:
          # not JSON
          content = response_content
      if isinstance(content, list):
          result = ResourceList(content)
      else:
          result = Resource(content)
          if hasattr(result, 'collection'):
              result.collection = ResourceList(result.collection)
      result.raw_data = response_content
  
      for attr in ('encoding', 'url', 'status_code', 'reason'):
          setattr(result, attr, getattr(response, attr))
  
      return result
docs: Return a response wrapped in the appropriate wrapper type.
  
      Lists will be returned as a ```ResourceList``` instance,
      dicts will be returned as a ```Resource``` instance.