Skip to content

Commit 11aed32

Browse files
committed
Update SDK for Appwrite 0.5.0
1 parent 4ad591c commit 11aed32

File tree

11 files changed

+55
-730
lines changed

11 files changed

+55
-730
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Appwrite SDK for Ruby
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1)
4-
![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1)
4+
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
55

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).**
6+
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
77

88
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)
99

lib/appwrite.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
require 'json'
44
require_relative 'appwrite/client'
55
require_relative 'appwrite/service'
6-
require_relative 'appwrite/services/account'
7-
require_relative 'appwrite/services/auth'
86
require_relative 'appwrite/services/avatars'
97
require_relative 'appwrite/services/database'
108
require_relative 'appwrite/services/locale'
11-
require_relative 'appwrite/services/projects'
129
require_relative 'appwrite/services/storage'
1310
require_relative 'appwrite/services/teams'
1411
require_relative 'appwrite/services/users'

lib/appwrite/client.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ def add_header(key, value)
6262
end
6363

6464
def call(method, path = '', headers = {}, params = {})
65-
uri = URI.parse(@endpoint + path + ((method == METHOD_GET) ? '?' + encode(params) : ''))
65+
uri = URI.parse(@endpoint + path + ((method == METHOD_GET && params.length) ? '?' + encode(params) : ''))
66+
return fetch(method, uri, headers, params)
67+
end
68+
69+
protected
70+
71+
private
72+
73+
def fetch(method, uri, headers, params, limit = 5)
74+
raise ArgumentError, 'Too Many HTTP Redirects' if limit == 0
75+
6676
http = Net::HTTP.new(uri.host, uri.port)
6777
http.use_ssl = (uri.scheme == 'https')
6878
payload = ''
@@ -83,14 +93,18 @@ def call(method, path = '', headers = {}, params = {})
8393
rescue => error
8494
raise 'Request Failed: ' + error.message
8595
end
96+
97+
# Handle Redirects
98+
if (response.class == Net::HTTPRedirection || response.class == Net::HTTPMovedPermanently)
99+
location = response['location']
100+
uri = URI.parse(uri.scheme + "://" + uri.host + "" + location)
101+
102+
return fetch(method, uri, headers, {}, limit - 1)
103+
end
86104

87105
return JSON.parse(response.body);
88106
end
89107

90-
protected
91-
92-
private
93-
94108
def encode(value, key = nil)
95109
case value
96110
when Hash then value.map { |k,v| encode(v, append_key(key,k)) }.join('&')

lib/appwrite/services/account.rb

Lines changed: 0 additions & 114 deletions
This file was deleted.

lib/appwrite/services/auth.rb

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)