Example #1
0
 def merge_response(self, response):
     try:
         api_response = response['APIResponse']
         super(Resource, self).__setattr__('version',
                                           api_response['@version'])
         super(Resource, self).__setattr__(
             '__header__', utils.to_pythonic_dict(api_response['Header']))
         self.merge(api_response['Body'] or {})
     except KeyError:
         raise ValueError('XML document was not in the expected format')
 def merge_response(self, response):
     try:
         api_response = response['APIResponse']
         super(Resource, self).__setattr__(
             'version', api_response['@version'])
         super(Resource, self).__setattr__(
             '__header__', utils.to_pythonic_dict(api_response['Header']))
         self.merge(api_response['Body'] or {})
     except KeyError:
         raise ValueError('XML document was not in the expected format')
    def create_from_response(cls, response):
        """
        Instantiate a new :py:class:`altapay.Resource` object from
        a response.

        :arg response: a response of type :samp:`dict`. The response most
            conform to the AltaPay response format, which means it must carry
            four keys called :samp:`@version`, :samp:`APIResponse`,
            :samp:`Header` and :samp:`Body`.

        :rtype: a new version object of type
            :py:class:`altapay.Resource`.
        """
        try:
            api_response = response['APIResponse']
            header = utils.to_pythonic_dict(api_response['Header'])
            body = api_response['Body']
            return cls(
                version=api_response['@version'], header=header, body=body)
        except KeyError:
            raise ValueError('XML document was not in expected format')
Example #4
0
    def create_from_response(cls, response):
        """
        Instantiate a new :py:class:`altapay.Resource` object from
        a response.

        :arg response: a response of type :samp:`dict`. The response most
            conform to the AltaPay response format, which means it must carry
            four keys called :samp:`@version`, :samp:`APIResponse`,
            :samp:`Header` and :samp:`Body`.

        :rtype: a new version object of type
            :py:class:`altapay.Resource`.
        """
        try:
            api_response = response['APIResponse']
            header = utils.to_pythonic_dict(api_response['Header'])
            body = api_response['Body']
            return cls(version=api_response['@version'],
                       header=header,
                       body=body)
        except KeyError:
            raise ValueError('XML document was not in expected format')
Example #5
0
 def merge(self, attributes):
     for key, value in attributes.items():
         setattr(
             self, utils.to_pythonic_name(key),
             utils.to_pythonic_dict(value)
             if isinstance(value, dict) else value)
 def merge(self, attributes):
     for key, value in attributes.items():
         setattr(
             self, utils.to_pythonic_name(key),
             utils.to_pythonic_dict(value)
             if isinstance(value, dict) else value)