Skip to content

Commit

Permalink
Upgraded to support Appwrite 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
eldadfux committed May 19, 2021
1 parent 6310c67 commit 33273d3
Show file tree
Hide file tree
Showing 37 changed files with 609 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
api_key: $RUBYGEMS_TOKEN
gem: appwrite
on:
tags: true
tags: true
75 changes: 72 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Appwrite Ruby SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.7.0-blue.svg?v=1)
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 0.7.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).**
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).**

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
Expand All @@ -19,6 +21,73 @@ To install via [Gem](https://rubygems.org/):
gem install appwrite --save
```


## Getting Started

### Init your SDK
Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section.

```ruby
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint
.set_project(ENV["APPWRITE_PROJECT"]) # Your project ID
.set_key(ENV["APPWRITE_SECRET"]) # Your secret API key
.setSelfSigned() # Use only on dev mode with a self-signed SSL cert
;
```

### Make Your First Request
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

```ruby
users = Appwrite::Users.new(client);

result = users.create(email: '[email protected]', password: 'password');
```

### Full Example
```ruby
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint
.set_project(ENV["APPWRITE_PROJECT"]) # Your project ID
.set_key(ENV["APPWRITE_SECRET"]) # Your secret API key
.setSelfSigned() # Use only on dev mode with a self-signed SSL cert
;

users = Appwrite::Users.new(client);

result = users.create(email: '[email protected]', password: 'password');
```

### Error Handling
The Appwrite Ruby SDK raises `Appwrite::Exception` object with `message`, `code` and `response` properties. You can handle any errors by catching `Appwrite::Exception` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.

```ruby
users = Appwrite::Users.new(client);

begin
result = users.create(email: '[email protected]', password: 'password');
rescue Appwrite::Exception => error
puts error.message
end
```

### Learn more
You can use followng resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)
- 🚂 [Appwrite Ruby Playground](https://github.com/appwrite/playground-for-ruby)


## Contribution

This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
Expand Down
4 changes: 2 additions & 2 deletions appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Gem::Specification.new do |s|

s.name = 'appwrite'
s.version = '2.0.2'
s.version = '2.1.0'
s.summary = "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API"
s.author = 'Appwrite Team'
s.homepage = 'https://appwrite.io/support'
s.email = '[email protected]'
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)

end
end
15 changes: 15 additions & 0 deletions docs/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.create_recovery(email: '[email protected]', url: 'https://example.com');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/create-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.create_verification(url: 'https://example.com');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/delete-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.delete_session(session_id: '[SESSION_ID]');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.delete_sessions();

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.delete();

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/get-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.get_logs();

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.get_prefs();

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/get-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.get_sessions();

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.get();

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/update-email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.update_email(email: '[email protected]', password: 'password');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/update-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.update_name(name: '[NAME]');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.update_password(password: 'password');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/update-prefs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.update_prefs(prefs: {});

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/update-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.update_recovery(user_id: '[USER_ID]', secret: '[SECRET]', password: 'password', password_again: 'password');

puts response
15 changes: 15 additions & 0 deletions docs/examples/account/update-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'appwrite'

client = Appwrite::Client.new()

client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
;

account = Appwrite::Account.new(client);

response = account.update_verification(user_id: '[USER_ID]', secret: '[SECRET]');

puts response
2 changes: 1 addition & 1 deletion docs/examples/database/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ client

database = Appwrite::Database.new(client);

response = database.create_document(collection_id: '[COLLECTION_ID]', data: {}, read: [], write: []);
response = database.create_document(collection_id: '[COLLECTION_ID]', data: {});

puts response
2 changes: 1 addition & 1 deletion docs/examples/database/update-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ client

database = Appwrite::Database.new(client);

response = database.update_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]', read: [], write: []);
response = database.update_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]');

puts response
2 changes: 1 addition & 1 deletion docs/examples/database/update-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ client

database = Appwrite::Database.new(client);

response = database.update_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {}, read: [], write: []);
response = database.update_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {});

puts response
Loading

0 comments on commit 33273d3

Please sign in to comment.