def session_url(path, options=None): options = options or {} if api.default().mode == "live": path = util.join_url("https://www.paypal.com", path) else: path = util.join_url("https://www.sandbox.paypal.com", path) return util.join_url_params(path, options)
def post(cls, action, options=None, headers=None): url = util.join_url(endpoint(), action) body = util.urlencode(options or {}) headers = util.merge_dict({ 'User-Agent': cls.user_agent, 'Content-Type': 'application/x-www-form-urlencoded'}, headers or {}) data = api.default().http_call(url, 'POST', data=body, headers=headers) return cls(data)
def post(cls, action, options=None, headers=None): url = util.join_url(endpoint(), action) body = util.urlencode(options or {}) headers = util.merge_dict({ 'User-Agent': cls.user_agent, 'Content-Type': 'application/x-www-form-urlencoded'}, headers or {}) data = api.default().http_call(url, 'POST', data=body, headers=headers) return cls(data)
def post(self, name, attributes = {}, klass = Resource): url = util.join_url(self.path, str(self['id']), name) if not isinstance(attributes, Resource): attributes = Resource(attributes) new_attributes = api.default().post(url, attributes.to_dict(), attributes.http_headers()) if isinstance(klass, Resource): klass.error = None klass.merge(new_attributes) return self.success() else: return klass(new_attributes)
def post(self, name, attributes={}, cls=Resource): url = util.join_url(self.path, str(self['id']), name) if not isinstance(attributes, Resource): attributes = Resource(attributes) new_attributes = api.default().post(url, attributes.to_dict(), attributes.http_headers()) if isinstance(cls, Resource): cls.error = None cls.merge(new_attributes) return self.success() else: return cls(new_attributes)
def session_url(path, options=None): if api.default().mode == "live": path = util.join_url("https://www.paypal.com", path) else: path = util.join_url("https://www.sandbox.paypal.com", path) return util.join_url_params(path, options or {})
def endpoint(): return api.default().options.get("openid_endpoint", "https://api.paypal.com/")
def client_id(): return api.default().options.get("openid_client_id", api.default().client_id)
def client_id(): return api.default().options.get("openid_client_id", api.default().client_id)
def redirect_uri(): return api.default().options.get("openid_redirect_uri")
def find(klass, resource_id): url = util.join_url(klass.path, str(resource_id)) return klass(api.default().get(url))
def delete(self): url = util.join_url(self.path, str(self['id'])) new_attributes = api.default().delete(url) self.error = None self.merge(new_attributes) return self.success()
def create(self): new_attributes = api.default().post(self.path, self.to_dict(), self.http_headers()) self.error = None self.merge(new_attributes) return self.success()
def all(klass, params=None): if params == None: url = klass.path else: url = util.join_url_params(klass.path, params) return klass.list_class(api.default().get(url))
def find(klass, resource_id): url = util.join_url(klass.path, str(resource_id)) return klass(api.default().get(url))
def endpoint(): return api.default().options.get("openid_endpoint", api.default().endpoint)
def client_secret(): return api.default().options.get("openid_client_secret", api.default().client_secret)
def find(cls, resource_id): url = util.join_url(cls.path, str(resource_id)) return cls(api.default().get(url))
def endpoint(): return api.default().options.get("openid_endpoint", "https://api.paypal.com/")
def all(cls, params=None): if params is None: url = cls.path else: url = util.join_url_params(cls.path, params) return cls.list_class(api.default().get(url))
def redirect_uri(): return api.default().options.get("openid_redirect_uri")
def create(self): new_attributes = api.default().post(self.path, self.to_dict(), self.http_headers()) self.error = None self.merge(new_attributes) return self.success()
def endpoint(): return api.default().options.get("openid_endpoint", api.default().endpoint)
def delete(self): url = util.join_url(self.path, str(self['id'])) new_attributes = api.default().delete(url) self.error = None self.merge(new_attributes) return self.success()
def client_secret(): return api.default().options.get("openid_client_secret", api.default().client_secret)
def all(klass, params = None): if params == None: url = klass.path else: url = util.join_url_params(klass.path, params) return klass.list_class(api.default().get(url))