appwrite 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c7cc7220b584ed2aa2de4566719da27e15d93954fb87c176ce13244ed8f81d1
4
- data.tar.gz: 3ed457ef4e2b6aa12815dd24d05c88af9efb4de8c75a96a59282cc48d7401435
3
+ metadata.gz: '08e68904b5658a70b0d6ec2824ad112522deb02b41bc16f2f4c1dd687480c58f'
4
+ data.tar.gz: c242643369feb6e65e78c95d31fe6d396f8476353544f6e3eb321eebaa865ad3
5
5
  SHA512:
6
- metadata.gz: 640bff5c0d47f33d6c74e9d0435904ba577b643e47ca42c1f3d0df3de9feff5c5422ae012e77fd368703148688fb683e9c3c7d697538a0581bcebe0484cc4c4d
7
- data.tar.gz: 9f8996b0f98c5b427be850d72538fc97cea37f78efa3bcae4538f69437a7f5a39fd1786d100341ed48c56b0840762f42d3ee447a3faaf28aa0b437aae5e2c116
6
+ metadata.gz: 0c616cf3ca5980cb81723a07d9dabfacf3060262984a181cb13ae1b30abfe6367775a6a59bd1a3ee78c8fa9f609f6c6690bf9d9cce2b382b5aac8a3ec654a07e
7
+ data.tar.gz: e63834b15e6cdeb33d7279c3710d0bf47f3d33ad6fd2a475adf63d9dcb6c9b794e42a936ae66046f1ca1a6e9c855bbb1831c6523c0e60719e599c83a400348d2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,24 @@
1
+ # Appwrite SDK for Ruby
2
+
3
+ ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1)
4
+ ![Version](https://img.shields.io/badge/api%20version-0.2.0-blue.svg?v=1)
5
+
6
+ **WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).**
7
+
8
+ 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)
9
+
10
+
11
+
12
+ ![Appwrite](https://appwrite.io/images/github.png)
13
+
14
+ ## Installation
15
+
16
+ To install via [Gem](https://rubygems.org/):
17
+
18
+ ```bash
19
+ gem install appwrite --save
20
+ ```
21
+
22
+ ## License
23
+
24
+ Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
@@ -0,0 +1,11 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'appwrite'
4
+ s.version = '1.0.3'
5
+ s.summary = "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)"
6
+ s.author = 'Appwrite Team'
7
+ s.homepage = 'https://appwrite.io/support'
8
+ s.email = 'team@appwrite.io'
9
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
10
+
11
+ end
@@ -0,0 +1,14 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+ require_relative 'appwrite/client'
5
+ require_relative 'appwrite/service'
6
+ require_relative 'appwrite/services/account'
7
+ require_relative 'appwrite/services/auth'
8
+ require_relative 'appwrite/services/avatars'
9
+ require_relative 'appwrite/services/database'
10
+ require_relative 'appwrite/services/locale'
11
+ require_relative 'appwrite/services/projects'
12
+ require_relative 'appwrite/services/storage'
13
+ require_relative 'appwrite/services/teams'
14
+ require_relative 'appwrite/services/users'
@@ -0,0 +1,93 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module Appwrite
6
+ class Client
7
+
8
+ METHOD_GET = 'get'
9
+ METHOD_POST = 'post'
10
+ METHOD_PUT = 'put'
11
+ METHOD_PATCH = 'patch'
12
+ METHOD_DELETE = 'delete'
13
+ METHOD_HEAD = 'head'
14
+ METHOD_OPTIONS = 'options'
15
+ METHOD_CONNECT = 'connect'
16
+ METHOD_TRACE = 'trace'
17
+
18
+ def initialize()
19
+ @headers = {
20
+ 'content-type' => '',
21
+ 'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION,
22
+ 'x-sdk-version' => 'appwrite:ruby:1.0.3'
23
+ }
24
+ @endpoint = 'https://appwrite.io/v1';
25
+ end
26
+
27
+ def set_project(value)
28
+ add_header('x-appwrite-project', value)
29
+
30
+ return self
31
+ end
32
+
33
+ def set_key(value)
34
+ add_header('x-appwrite-key', value)
35
+
36
+ return self
37
+ end
38
+
39
+ def set_locale(value)
40
+ add_header('x-appwrite-locale', value)
41
+
42
+ return self
43
+ end
44
+
45
+ def set_mode(value)
46
+ add_header('x-appwrite-mode', value)
47
+
48
+ return self
49
+ end
50
+
51
+ def set_endpoint(endpoint)
52
+ @endpoint = endpoint
53
+
54
+ return self
55
+ end
56
+
57
+ def add_header(key, value)
58
+ @headers[key.downcase] = value.downcase
59
+
60
+ return self
61
+ end
62
+
63
+ def call(method, path = '', headers = {}, params = {})
64
+ uri = URI.parse(@endpoint + path + ((method == METHOD_GET) ? '?' + URI.encode_www_form(params) : ''))
65
+ http = Net::HTTP.new(uri.host, uri.port)
66
+ http.use_ssl = (uri.scheme == 'https')
67
+ payload = ''
68
+
69
+ headers = @headers.merge(headers)
70
+
71
+ if (method != METHOD_GET)
72
+ case headers['content-type'][0, headers['content-type'].index(';') || headers['content-type'].length]
73
+ when 'application/json'
74
+ payload = params.to_json
75
+ else
76
+ payload = URI.encode_www_form(params)
77
+ end
78
+ end
79
+
80
+ begin
81
+ response = http.send_request(method.upcase, uri.request_uri, payload, headers)
82
+ rescue => error
83
+ raise 'Request Failed: ' + error.message
84
+ end
85
+
86
+ return JSON.parse(response.body);
87
+ end
88
+
89
+ protected
90
+
91
+ private
92
+ end
93
+ end
@@ -0,0 +1,12 @@
1
+ module Appwrite
2
+ class Service
3
+
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ protected
9
+
10
+ private
11
+ end
12
+ end
@@ -0,0 +1,114 @@
1
+ module Appwrite
2
+ class Account < Service
3
+
4
+ def get()
5
+ path = '/account'
6
+
7
+ params = {
8
+ }
9
+
10
+ return @client.call('get', path, {
11
+ 'content-type' => 'application/json',
12
+ }, params);
13
+ end
14
+
15
+ def delete()
16
+ path = '/account'
17
+
18
+ params = {
19
+ }
20
+
21
+ return @client.call('delete', path, {
22
+ 'content-type' => 'application/json',
23
+ }, params);
24
+ end
25
+
26
+ def update_email(email:, password:)
27
+ path = '/account/email'
28
+
29
+ params = {
30
+ 'email': email,
31
+ 'password': password
32
+ }
33
+
34
+ return @client.call('patch', path, {
35
+ 'content-type' => 'application/json',
36
+ }, params);
37
+ end
38
+
39
+ def update_name(name:)
40
+ path = '/account/name'
41
+
42
+ params = {
43
+ 'name': name
44
+ }
45
+
46
+ return @client.call('patch', path, {
47
+ 'content-type' => 'application/json',
48
+ }, params);
49
+ end
50
+
51
+ def update_password(password:, old_password:)
52
+ path = '/account/password'
53
+
54
+ params = {
55
+ 'password': password,
56
+ 'old-password': old_password
57
+ }
58
+
59
+ return @client.call('patch', path, {
60
+ 'content-type' => 'application/json',
61
+ }, params);
62
+ end
63
+
64
+ def get_prefs()
65
+ path = '/account/prefs'
66
+
67
+ params = {
68
+ }
69
+
70
+ return @client.call('get', path, {
71
+ 'content-type' => 'application/json',
72
+ }, params);
73
+ end
74
+
75
+ def update_prefs(prefs:)
76
+ path = '/account/prefs'
77
+
78
+ params = {
79
+ 'prefs': prefs
80
+ }
81
+
82
+ return @client.call('patch', path, {
83
+ 'content-type' => 'application/json',
84
+ }, params);
85
+ end
86
+
87
+ def get_security()
88
+ path = '/account/security'
89
+
90
+ params = {
91
+ }
92
+
93
+ return @client.call('get', path, {
94
+ 'content-type' => 'application/json',
95
+ }, params);
96
+ end
97
+
98
+ def get_sessions()
99
+ path = '/account/sessions'
100
+
101
+ params = {
102
+ }
103
+
104
+ return @client.call('get', path, {
105
+ 'content-type' => 'application/json',
106
+ }, params);
107
+ end
108
+
109
+
110
+ protected
111
+
112
+ private
113
+ end
114
+ end
@@ -0,0 +1,131 @@
1
+ module Appwrite
2
+ class Auth < Service
3
+
4
+ def login(email:, password:, success: '', failure: '')
5
+ path = '/auth/login'
6
+
7
+ params = {
8
+ 'email': email,
9
+ 'password': password,
10
+ 'success': success,
11
+ 'failure': failure
12
+ }
13
+
14
+ return @client.call('post', path, {
15
+ 'content-type' => 'application/json',
16
+ }, params);
17
+ end
18
+
19
+ def logout()
20
+ path = '/auth/logout'
21
+
22
+ params = {
23
+ }
24
+
25
+ return @client.call('delete', path, {
26
+ 'content-type' => 'application/json',
27
+ }, params);
28
+ end
29
+
30
+ def logout_by_session(id:)
31
+ path = '/auth/logout/{id}'
32
+ .gsub('{id}', id)
33
+
34
+ params = {
35
+ }
36
+
37
+ return @client.call('delete', path, {
38
+ 'content-type' => 'application/json',
39
+ }, params);
40
+ end
41
+
42
+ def oauth(provider:, success:, failure:)
43
+ path = '/auth/oauth/{provider}'
44
+ .gsub('{provider}', provider)
45
+
46
+ params = {
47
+ 'success': success,
48
+ 'failure': failure
49
+ }
50
+
51
+ return @client.call('get', path, {
52
+ 'content-type' => 'application/json',
53
+ }, params);
54
+ end
55
+
56
+ def recovery(email:, reset:)
57
+ path = '/auth/recovery'
58
+
59
+ params = {
60
+ 'email': email,
61
+ 'reset': reset
62
+ }
63
+
64
+ return @client.call('post', path, {
65
+ 'content-type' => 'application/json',
66
+ }, params);
67
+ end
68
+
69
+ def recovery_reset(user_id:, token:, password_a:, password_b:)
70
+ path = '/auth/recovery/reset'
71
+
72
+ params = {
73
+ 'userId': user_id,
74
+ 'token': token,
75
+ 'password-a': password_a,
76
+ 'password-b': password_b
77
+ }
78
+
79
+ return @client.call('put', path, {
80
+ 'content-type' => 'application/json',
81
+ }, params);
82
+ end
83
+
84
+ def register(email:, password:, confirm:, success: '', failure: '', name: '')
85
+ path = '/auth/register'
86
+
87
+ params = {
88
+ 'email': email,
89
+ 'password': password,
90
+ 'confirm': confirm,
91
+ 'success': success,
92
+ 'failure': failure,
93
+ 'name': name
94
+ }
95
+
96
+ return @client.call('post', path, {
97
+ 'content-type' => 'application/json',
98
+ }, params);
99
+ end
100
+
101
+ def confirm(user_id:, token:)
102
+ path = '/auth/register/confirm'
103
+
104
+ params = {
105
+ 'userId': user_id,
106
+ 'token': token
107
+ }
108
+
109
+ return @client.call('post', path, {
110
+ 'content-type' => 'application/json',
111
+ }, params);
112
+ end
113
+
114
+ def confirm_resend(confirm:)
115
+ path = '/auth/register/confirm/resend'
116
+
117
+ params = {
118
+ 'confirm': confirm
119
+ }
120
+
121
+ return @client.call('post', path, {
122
+ 'content-type' => 'application/json',
123
+ }, params);
124
+ end
125
+
126
+
127
+ protected
128
+
129
+ private
130
+ end
131
+ end
@@ -0,0 +1,95 @@
1
+ module Appwrite
2
+ class Avatars < Service
3
+
4
+ def get_browser(code:, width: 100, height: 100, quality: 100)
5
+ path = '/avatars/browsers/{code}'
6
+ .gsub('{code}', code)
7
+
8
+ params = {
9
+ 'width': width,
10
+ 'height': height,
11
+ 'quality': quality
12
+ }
13
+
14
+ return @client.call('get', path, {
15
+ 'content-type' => 'application/json',
16
+ }, params);
17
+ end
18
+
19
+ def get_credit_card(code:, width: 100, height: 100, quality: 100)
20
+ path = '/avatars/credit-cards/{code}'
21
+ .gsub('{code}', code)
22
+
23
+ params = {
24
+ 'width': width,
25
+ 'height': height,
26
+ 'quality': quality
27
+ }
28
+
29
+ return @client.call('get', path, {
30
+ 'content-type' => 'application/json',
31
+ }, params);
32
+ end
33
+
34
+ def get_favicon(url:)
35
+ path = '/avatars/favicon'
36
+
37
+ params = {
38
+ 'url': url
39
+ }
40
+
41
+ return @client.call('get', path, {
42
+ 'content-type' => 'application/json',
43
+ }, params);
44
+ end
45
+
46
+ def get_flag(code:, width: 100, height: 100, quality: 100)
47
+ path = '/avatars/flags/{code}'
48
+ .gsub('{code}', code)
49
+
50
+ params = {
51
+ 'width': width,
52
+ 'height': height,
53
+ 'quality': quality
54
+ }
55
+
56
+ return @client.call('get', path, {
57
+ 'content-type' => 'application/json',
58
+ }, params);
59
+ end
60
+
61
+ def get_image(url:, width: 400, height: 400)
62
+ path = '/avatars/image'
63
+
64
+ params = {
65
+ 'url': url,
66
+ 'width': width,
67
+ 'height': height
68
+ }
69
+
70
+ return @client.call('get', path, {
71
+ 'content-type' => 'application/json',
72
+ }, params);
73
+ end
74
+
75
+ def get_q_r(text:, size: 400, margin: 1, download: 0)
76
+ path = '/avatars/qr'
77
+
78
+ params = {
79
+ 'text': text,
80
+ 'size': size,
81
+ 'margin': margin,
82
+ 'download': download
83
+ }
84
+
85
+ return @client.call('get', path, {
86
+ 'content-type' => 'application/json',
87
+ }, params);
88
+ end
89
+
90
+
91
+ protected
92
+
93
+ private
94
+ end
95
+ end