How to use the recurly.recurly.Recurly function in recurly

To help you get started, we’ve selected a few recurly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github recurly / recurly-client-python / recurly / recurly.py View on Github external
def parse_errors(self, xml):
        xml = Recurly.remove_white_space(xml)
        if not xml:
            return None
        
        er = Recurly.xml_to_dict(xml)
        ers = er['error']
        
        # Remove periods from all sentences that have them.
        self.errors = [e[:-1] if e[-1:] == '.' else e for e in ers]
        return '. '.join(self.errors) + '.'
github recurly / recurly-client-python / recurly / recurly.py View on Github external
def parse_errors(self, xml):
        xml = Recurly.remove_white_space(xml)
        if not xml:
            return None
        
        er = Recurly.xml_to_dict(xml)
        ers = er['error']
        
        # Remove periods from all sentences that have them.
        self.errors = [e[:-1] if e[-1:] == '.' else e for e in ers]
        return '. '.join(self.errors) + '.'
github recurly / recurly-client-python / recurly / recurly.py View on Github external
di[child.tagName]
                except KeyError:
                    # @todo This could be changed so that if the root type is an array,
                    # we automatically treat the resource as an array (eg. no checking 
                    # the element name)
                    if child.tagName in MULTIPLE and root_type in ['array', 'collection']:
                        di[child.tagName] = []
                    elif child.tagName in FORCED_MULTIPLE:
                        di[child.tagName] = []
                    else:
                        di[child.tagName] = None

                if di[child.tagName] is None:
                    di[child.tagName] = Recurly._parse_xml_doc(child)
                elif type(di[child.tagName]) is types.ListType:
                    di[child.tagName].append(Recurly._parse_xml_doc(child))
                
            child = child.nextSibling
        return di
github recurly / recurly-client-python / recurly / recurly.py View on Github external
    @staticmethod
    def dict_to_xml(trunk, data):
        doc = minidom.Document()
        root = doc.createElement(trunk)
        doc.appendChild(root)
        Recurly._build_xml_doc(doc, root, data)

        return doc.toxml(encoding='utf-8')
github recurly / recurly-client-python / recurly / recurly.py View on Github external
def __getattr__(self, k):
        try:
            return object.__getattr__(self, k)
        except AttributeError:
            return Recurly(self.username, self.password, self.subdomain, self.uri + '/' + k)
github recurly / recurly-client-python / recurly / recurly.py View on Github external
# Determine method with which to to request uri
        action = urili.pop()
        try:
            method = CRUD_METHODS[action]
        except KeyError:
            urili.append(action)
            method = 'GET'
        
        r = Recurly.singularize(urili[1])
        try:
            pk = PK[r]
        except KeyError:
            pk = 'id'
                
        model = Recurly.singularize(urili[-1])
                
        # If pk is set in arguments, place it in url instead
        uid = kwargs.pop(pk, False)
        if uid:
            urili.insert(2, uid)
        
        # Also, remove data from arguments and convert it to XML
        data = kwargs.pop('data', None)

        if data:
            data = Recurly.dict_to_xml(model, data)

        # Build argument list if necessary
        args = ''
        if kwargs:
            args = "?%s" % (urllib.urlencode(kwargs.items()))
github recurly / recurly-client-python / recurly / recurly.py View on Github external
pk = PK[r]
        except KeyError:
            pk = 'id'
                
        model = Recurly.singularize(urili[-1])
                
        # If pk is set in arguments, place it in url instead
        uid = kwargs.pop(pk, False)
        if uid:
            urili.insert(2, uid)
        
        # Also, remove data from arguments and convert it to XML
        data = kwargs.pop('data', None)

        if data:
            data = Recurly.dict_to_xml(model, data)

        # Build argument list if necessary
        args = ''
        if kwargs:
            args = "?%s" % (urllib.urlencode(kwargs.items()))
        
        # Build url from the pieces
        url = (URL % self.subdomain) + '/'.join(urili) + args
        
        # Build request with our new url, method, and data
        opener = urllib2.build_opener(urllib2.HTTPHandler)
        self._request = urllib2.Request(url=url, data=data)
        self._request.get_method = lambda: method
        self._request.add_header('Accept', 'application/xml')
        self._request.add_header('Content-Type', 'application/xml; charset=utf-8')
        self._request.add_header('User-Agent', 'Recurly Python Client (v' + __version__ + ')')