def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
    isArray = isinstance(params, list)
    request = (((('/api/' + api) + '/') + self.version) + '/')
    request += (path if isArray else self.implode_params(path, params))
    query = (params if isArray else self.omit(params, self.extract_params(path)))
    url = (self.implode_params(self.urls['api']['rest'], {'hostname': self.hostname}) + request)
    type = self.get_path_authentication_type(path)
    if (type == 'public'):
        if query:
            url += ('?' + self.urlencode(query))
    elif (type == 'private'):
        self.check_required_credentials()
        timestamp = self.iso8601(self.milliseconds())
        headers = {'OK-ACCESS-KEY': self.apiKey, 'OK-ACCESS-PASSPHRASE': self.password, 'OK-ACCESS-TIMESTAMP': timestamp}
        auth = ((timestamp + method) + request)
        if (method == 'GET'):
            if query:
                urlencodedQuery = ('?' + self.urlencode(query))
                url += urlencodedQuery
                auth += urlencodedQuery
        else:
            if (isArray or query):
                body = self.json(query)
                auth += body
            headers['Content-Type'] = 'application/json'
        signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256, 'base64')
        headers['OK-ACCESS-SIGN'] = signature
    return {'url': url, 'method': method, 'body': body, 'headers': headers}
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
    isArray = isinstance(params, list)
    request = (((('/api/' + api) + '/') + self.version) + '/')
    request += (path if isArray else self.implode_params(path, params))
    query = (params if isArray else self.omit(params, self.extract_params(path)))
    url = (self.implode_params(self.urls['api']['rest'], {'hostname': self.hostname}) + request)
    type = self.get_path_authentication_type(path)
    if (type == 'public'):
        if query:
            url += ('?' + self.urlencode(query))
    elif (type == 'private'):
        self.check_required_credentials()
        timestamp = self.iso8601(self.milliseconds())
        headers = {'OK-ACCESS-KEY': self.apiKey, 'OK-ACCESS-PASSPHRASE': self.password, 'OK-ACCESS-TIMESTAMP': timestamp}
        auth = ((timestamp + method) + request)
        if (method == 'GET'):
            if query:
                urlencodedQuery = ('?' + self.urlencode(query))
                url += urlencodedQuery
                auth += urlencodedQuery
        else:
            if (isArray or query):
                body = self.json(query)
                auth += body
            headers['Content-Type'] = 'application/json'
        signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256, 'base64')
        headers['OK-ACCESS-SIGN'] = signature
    return {'url': url, 'method': method, 'body': body, 'headers': headers}