示例#1
0
 def _build_instance_url(cls, sid):
     if not sid:
         return "/v1/accounts/me/"
     sid = util.utf8(sid)
     base = cls.class_url()
     extn = quote_plus(sid)
     return "%s/%s" % (base, extn)
示例#2
0
    def retrieve(self, id, **params):
        base = self.get('url')
        id = util.utf8(id)
        extn = quote_plus(id)
        url = "%s/%s" % (base, extn)

        return self.request('get', url, params)
示例#3
0
 def _build_instance_url(cls, sid):
     if not sid:
         return cls.class_url()
     base = cls.class_logs_url()
     sid = util.utf8(sid)
     extn = quote_plus(sid)
     if sid is not None:
         extn = extn + "/"
     return "%s/%s" % (base, extn)
示例#4
0
 def _build_instance_url(cls, sid):
     if not sid:
         return "/v1/accounts/customers/"
     base = "/v1/accounts/customer"
     sid = util.utf8(sid)
     extn = quote_plus(sid)
     if sid is not None:
         extn = extn + "/"
     return "%s/%s" % (base, extn)
示例#5
0
 def _build_instance_url(cls, sid):
     if not sid:
         return "/v1/plans/subscriptions/"
     base = cls.class_url()
     sid = util.utf8(sid)
     extn = quote_plus(sid)
     if sid is not None:
         extn = extn + "/"
     return "%s/%s" % (base, extn)
示例#6
0
    def delete(self, **params):
        base = '/v1/plans/un-subscribe'
        sid = self.get('subscription_id')
        sid = util.utf8(sid)
        extn = quote_plus(sid)
        if sid is not None:
            extn = extn + "/"
        url = "%s/%s" % (base, extn)

        self.refresh_from(self.request('delete', url, params))
        return self
示例#7
0
    def instance_url(self):
        id = self.get('id')

        if not isinstance(id, six.string_types):
            raise error.InvalidRequestError(
                'Could not determine which URL to request: %s instance '
                'has invalid ID: %r, %s. ID should be of type `str` (or'
                ' `unicode`)' % (type(self).__name__, id, type(id)), 'id')

        id = util.utf8(id)
        base = self.class_url()
        extn = quote_plus(id)
        if id is not None:
            extn = extn + "/"
        return "%s%s" % (base, extn)
 def nested_resource_url(cls, id, nested_id=None):
     url = "%s/%s/%s" % (cls.class_url(), quote_plus(id),
                         quote_plus(path))
     if nested_id is not None:
         url += "/%s" % quote_plus(nested_id)
     return url
示例#9
0
 def class_name(cls):
     if cls == APIResource:
         raise NotImplementedError(
             'APIResource is an abstract class.  You should perform '
             'actions on its subclasses (e.g. Charge, Customer)')
     return str(quote_plus(cls.__name__.lower()))