1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

Updated SDKs

This commit is contained in:
eldadfux 2019-07-21 14:54:45 +03:00
parent 0e44a35215
commit 8d5e026773
19 changed files with 149 additions and 32 deletions

View file

@ -5,7 +5,7 @@ sdk
setKey('')
;
let promise = sdk.auth.logoutBySession('[USER_ID]');
let promise = sdk.auth.logoutBySession('[ID]');
promise.then(function (response) {
console.log(response);

View file

@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
"version": "v1.0.4",
"version": "v1.0.5",
"license": "BSD-3-Clause",
"main": "src/sdk.js",
"repository": {

View file

@ -132,7 +132,7 @@
globalParams.push({key: key, value: value});
};
addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.4');
addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.5');
addGlobalHeader('content-type', '');
/**
@ -546,15 +546,15 @@
* account sessions across all his different devices. When using the option id
* argument, only the session unique ID provider will be deleted.
*
* @param {string} userId
* @param {string} id
* @throws {Error}
* @return {Promise} */
logoutBySession: function(userId) {
if(userId === undefined) {
throw new Error('Missing required parameter: "userId"');
logoutBySession: function(id) {
if(id === undefined) {
throw new Error('Missing required parameter: "id"');
}
let path = '/auth/logout/{userId}'.replace(new RegExp('{userId}', 'g'), userId);
let path = '/auth/logout/{id}'.replace(new RegExp('{id}', 'g'), id);
return http
.delete(path, {'content-type': 'application/json'},
@ -932,6 +932,33 @@
});
},
/**
* Get image from and HTTP URL and crop to any size.
*
* Use this endpoint to fetch a remote image URL and crop it to any image size
* you want.
*
* @param {string} url
* @param {number} width
* @param {number} height
* @throws {Error}
* @return {Promise} */
getImage: function(url, width = 400, height = 400) {
if(url === undefined) {
throw new Error('Missing required parameter: "url"');
}
let path = '/avatars/image';
return http
.get(path, {'content-type': 'application/json'},
{
'url': url,
'width': width,
'height': height
});
},
/**
* Text to QR Generator
*

View file

@ -1,5 +1,5 @@
(function(window){window.Appwrite=function(){let config={endpoint:'https://appwrite.test/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(params.hasOwnProperty(p)){str.push(encodeURIComponent(p)+"="+encodeURIComponent(params[p]))}}
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.4');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.5');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
if(typeof path!=='string'){throw new Error('var path must be of type string')}
if(typeof headers!=='object'){throw new Error('var headers must be of type object')}
for(i=0;i<globalParams.length;i++){path=addParam(path,globalParams[i].key,globalParams[i].value)}
@ -19,8 +19,8 @@ if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPas
let path='/account/password';return http.patch(path,{'content-type':'application/json'},{'password':password,'old-password':oldPassword})},getPrefs:function(){let path='/account/prefs';return http.get(path,{'content-type':'application/json'},{})},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')}
let path='/account/prefs';return http.patch(path,{'content-type':'application/json'},{'prefs':prefs})},getSecurity:function(){let path='/account/security';return http.get(path,{'content-type':'application/json'},{})},getSessions:function(){let path='/account/sessions';return http.get(path,{'content-type':'application/json'},{})}};let auth={login:function(email,password,success='',failure=''){if(email===undefined){throw new Error('Missing required parameter: "email"')}
if(password===undefined){throw new Error('Missing required parameter: "password"')}
let path='/auth/login';return iframe('post',path,{project:config.project,'email':email,'password':password,'success':success,'failure':failure})},logout:function(){let path='/auth/logout';return http.delete(path,{'content-type':'application/json'},{})},logoutBySession:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
let path='/auth/logout/{userId}'.replace(new RegExp('{userId}','g'),userId);return http.delete(path,{'content-type':'application/json'},{})},recovery:function(email,redirect){if(email===undefined){throw new Error('Missing required parameter: "email"')}
let path='/auth/login';return iframe('post',path,{project:config.project,'email':email,'password':password,'success':success,'failure':failure})},logout:function(){let path='/auth/logout';return http.delete(path,{'content-type':'application/json'},{})},logoutBySession:function(id){if(id===undefined){throw new Error('Missing required parameter: "id"')}
let path='/auth/logout/{id}'.replace(new RegExp('{id}','g'),id);return http.delete(path,{'content-type':'application/json'},{})},recovery:function(email,redirect){if(email===undefined){throw new Error('Missing required parameter: "email"')}
if(redirect===undefined){throw new Error('Missing required parameter: "redirect"')}
let path='/auth/recovery';return http.post(path,{'content-type':'application/json'},{'email':email,'redirect':redirect})},recoveryReset:function(userId,token,passwordA,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
if(token===undefined){throw new Error('Missing required parameter: "token"')}
@ -40,7 +40,8 @@ let path='/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);retu
let path='/avatars/browsers/{code}'.replace(new RegExp('{code}','g'),code);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality})},getCreditCard:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/avatars/credit-cards/{code}'.replace(new RegExp('{code}','g'),code);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality})},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')}
let path='/avatars/favicon';return http.get(path,{'content-type':'application/json'},{'url':url})},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}
let path='/avatars/flags/{code}'.replace(new RegExp('{code}','g'),code);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality})},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')}
let path='/avatars/flags/{code}'.replace(new RegExp('{code}','g'),code);return http.get(path,{'content-type':'application/json'},{'width':width,'height':height,'quality':quality})},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')}
let path='/avatars/image';return http.get(path,{'content-type':'application/json'},{'url':url,'width':width,'height':height})},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')}
let path='/avatars/qr';return http.get(path,{'content-type':'application/json'},{'text':text,'size':size,'margin':margin,'download':download})}};let database={listCollections:function(search='',limit=25,offset=0,orderType='ASC'){let path='/database';return http.get(path,{'content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createCollection:function(name,read=[],write=[],rules=[]){if(name===undefined){throw new Error('Missing required parameter: "name"')}
let path='/database';return http.post(path,{'content-type':'application/json'},{'name':name,'read':read,'write':write,'rules':rules})},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.get(path,{'content-type':'application/json'},{'filters':filters,'offset':offset,'limit':limit,'order-field':orderField,'order-type':orderType,'order-cast':orderCast,'search':search,'first':first,'last':last})},createDocument:function(collectionId,data,read=[],write=[],parentDocument='',parentProperty='',parentPropertyType='assign'){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}

View file

@ -5,7 +5,7 @@ sdk
setKey('')
;
let promise = sdk.auth.logoutBySession('[USER_ID]');
let promise = sdk.auth.logoutBySession('[ID]');
promise.then(function (response) {
console.log(response);

View file

@ -7,7 +7,7 @@ class Client {
this.endpoint = 'https://appwrite.test/v1';
this.headers = {
'content-type': '',
'x-sdk-version': 'appwrite:nodejs:v1.0.16',
'x-sdk-version': 'appwrite:nodejs:v1.0.17',
};
this.selfSigned = false;
}

View file

@ -64,12 +64,12 @@ class Auth extends Service {
* account sessions across all his different devices. When using the option id
* argument, only the session unique ID provider will be deleted.
*
* @param string userId
* @param string id
* @throws Exception
* @return {}
*/
async logoutBySession(userId) {
let path = '/auth/logout/{userId}'.replace(new RegExp('{userId}', 'g'), userId);
async logoutBySession(id) {
let path = '/auth/logout/{id}'.replace(new RegExp('{id}', 'g'), id);
return await this.client.call('delete', path, {'content-type': 'application/json'},
{

View file

@ -98,6 +98,29 @@ class Avatars extends Service {
});
}
/**
* Get image from and HTTP URL and crop to any size.
*
* Use this endpoint to fetch a remote image URL and crop it to any image size
* you want.
*
* @param string url
* @param number width
* @param number height
* @throws Exception
* @return {}
*/
async getImage(url, width = 400, height = 400) {
let path = '/avatars/image';
return await this.client.call('get', path, {'content-type': 'application/json'},
{
'url': url,
'width': width,
'height': height
});
}
/**
* Text to QR Generator
*

View file

@ -2,7 +2,7 @@
"name": "node-appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
"version": "v1.0.16",
"version": "v1.0.17",
"license": "BSD-3-Clause",
"main": "index.js",
"repository": {

View file

@ -32,7 +32,7 @@ DELETE https://appwrite.test/v1/auth/logout
## Logout Specific Session
```http request
DELETE https://appwrite.test/v1/auth/logout/{userId}
DELETE https://appwrite.test/v1/auth/logout/{id}
```
** Use this endpoint to log out the currently logged in user from all his account sessions across all his different devices. When using the option id argument, only the session unique ID provider will be deleted. **
@ -41,7 +41,7 @@ DELETE https://appwrite.test/v1/auth/logout/{userId}
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| userId | string | **Required** User specific session unique ID number. if 0 delete all sessions. | |
| id | string | **Required** User specific session unique ID number. if 0 delete all sessions. | |
## Password Recovery

View file

@ -65,6 +65,22 @@ GET https://appwrite.test/v1/avatars/flags/{code}
| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100 | 100 |
| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100 | 100 |
## Get image from and HTTP URL and crop to any size.
```http request
GET https://appwrite.test/v1/avatars/image
```
** Use this endpoint to fetch a remote image URL and crop it to any image size you want. **
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| url | string | **Required** Image URL which you want to crop. | |
| width | integer | Resize preview image width, Pass an integer between 0 to 4000 | 400 |
| height | integer | Resize preview image height, Pass an integer between 0 to 4000 | 400 |
## Text to QR Generator
```http request

View file

@ -12,4 +12,4 @@ $client
$auth = new Auth($client);
$result = $auth->logoutBySession('[USER_ID]');
$result = $auth->logoutBySession('[ID]');

View file

@ -74,13 +74,13 @@ class Auth extends Service
* account sessions across all his different devices. When using the option id
* argument, only the session unique ID provider will be deleted.
*
* @param string $userId
* @param string $id
* @throws Exception
* @return array
*/
public function logoutBySession($userId)
public function logoutBySession($id)
{
$path = str_replace(['{userId}'], [$userId], '/auth/logout/{userId}');
$path = str_replace(['{id}'], [$id], '/auth/logout/{id}');
$params = [];

View file

@ -112,6 +112,31 @@ class Avatars extends Service
], $params);
}
/**
* Get image from and HTTP URL and crop to any size.
*
* Use this endpoint to fetch a remote image URL and crop it to any image size
* you want.
*
* @param string $url
* @param integer $width
* @param integer $height
* @throws Exception
* @return array
*/
public function getImage($url, $width = 400, $height = 400)
{
$path = str_replace([], [], '/avatars/image');
$params = [];
$params['url'] = $url;
$params['width'] = $width;
$params['height'] = $height;
return $this->client->call(Client::METHOD_GET, $path, [
], $params);
}
/**
* Text to QR Generator
*

View file

@ -25,12 +25,12 @@ class Auth(Service):
return self.client.call('delete', path, {
}, params)
def logout_by_session(self, user_id):
def logout_by_session(self, id):
"""Logout Specific Session"""
params = {}
path = '/auth/logout/{userId}'
path.replace('{userId}', user_id)
path = '/auth/logout/{id}'
path.replace('{id}', id)
return self.client.call('delete', path, {
}, params)

View file

@ -52,6 +52,18 @@ class Avatars(Service):
return self.client.call('get', path, {
}, params)
def get_image(self, url, width=400, height=400):
"""Get image from and HTTP URL and crop to any size."""
params = {}
path = '/avatars/image'
params['url'] = url
params['width'] = width
params['height'] = height
return self.client.call('get', path, {
}, params)
def get_q_r(self, text, size=400, margin=1, download=0):
"""Text to QR Generator"""

View file

@ -25,9 +25,9 @@ module Appwrite
}, params);
end
def logout_by_session(user_id:)
path = '/auth/logout/{userId}'
.gsub('{user_id}', user_id)
def logout_by_session(id:)
path = '/auth/logout/{id}'
.gsub('{id}', id)
params = {
}

View file

@ -54,6 +54,19 @@ module Appwrite
}, params);
end
def get_image(url:, width: 400, height: 400)
path = '/avatars/image'
params = {
'url': url,
'width': width,
'height': height
}
return @client.call('get', path, {
}, params);
end
def get_q_r(text:, size: 400, margin: 1, download: 0)
path = '/avatars/qr'

View file

@ -46,7 +46,7 @@ $cli
'gitUserName' => 'appwrite',
],
'js' => [
'version' => 'v1.0.4',
'version' => 'v1.0.5',
'result' => __DIR__ . '/../sdks/js/',
'gitURL' => 'https://github.com/appwrite/sdk-for-js.git',
'gitRepo' => 'git@github.com:appwrite/sdk-for-js.git',
@ -54,7 +54,7 @@ $cli
'gitUserName' => 'appwrite',
],
'node' => [
'version' => 'v1.0.16',
'version' => 'v1.0.17',
'result' => __DIR__ . '/../sdks/node/',
'gitURL' => 'https://github.com/appwrite/sdk-for-node.git',
'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git',