(self, long_url, custom_code=None, description=None,
                owner=None, secret=None, expire_after=None)
return resp
Create the post payload for create short URL REST API.
        :param long_url:
        :param custom_code:
        :param description:
        :param owner:
        :param secret:
        :param expire_after:
        :return:
Create the post payload for create short URL REST API.
        :param long_url:
        :param custom_code:
        :param description:
        :param owner:
        :param secret:
        :param expire_after:
        :return:
Create the post payload for create short URL REST API . : param long_url : : param custom_code : : param description : : param owner : : param secret : : param expire_after : : return :
def shorten(self, long_url, custom_code=None, description=None,
                owner=None, secret=None, expire_after=None):
        """Create the post payload for create short URL REST API.
        :param long_url:
        :param custom_code:
        :param description:
        :param owner:
        :param secret:
        :param expire_after:
        :return:
        """
        url_path = '/api/shorten'
        payload = dict(long_url=long_url,
                       short_code=custom_code,
                       is_custom=custom_code is not None and custom_code != '',
                       description=description,
                       is_protected=secret is not None and secret != '',
                       expire_after=expire_after,
                       secret_key=secret,
                       owner=owner)
        r = self.call(url_path, data=payload, return_for_status=401)
        resp = r.json()
        if int(r.status_code) == 401:
            if resp['sub_status'] == 101:
                self.refresh_access_token()
                if self.header is None:
                    raise UnAuthorized('Please login again to continue')
                r = self.call(url_path, data=payload)
                resp = r.json()
        if resp.get('short_url'):
            resp['short_url'] = self.makeurl(self.HOSTNAME, resp['short_code'])
        return resp
def shorten ( self , long_url , custom_code = None , description = None , owner = None , secret = None , expire_after = None ) : url_path = '/api/shorten' payload = dict ( long_url = long_url , short_code = custom_code , is_custom = custom_code is not None and custom_code != '' , description = description , is_protected = secret is not None and secret != '' , expire_after = expire_after , secret_key = secret , owner = owner ) r = self . call ( url_path , data = payload , return_for_status = 401 ) resp = r . json ( ) if int ( r . status_code ) == 401 : if resp [ 'sub_status' ] == 101 : self . refresh_access_token ( ) if self . header is None : raise UnAuthorized ( 'Please login again to continue' ) r = self . call ( url_path , data = payload ) resp = r . json ( ) if resp . get ( 'short_url' ) : resp [ 'short_url' ] = self . makeurl ( self . HOSTNAME , resp [ 'short_code' ] ) return resp