-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Ruby SDK update for version 25.1.0 #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ```ruby | ||
| require 'appwrite' | ||
|
|
||
| include Appwrite | ||
|
|
||
| client = Client.new | ||
| .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint | ||
| .set_project('<YOUR_PROJECT_ID>') # Your project ID | ||
| .set_key('<YOUR_API_KEY>') # Your secret API key | ||
|
|
||
| health = Health.new(client) | ||
|
|
||
| result = health.get_audits_db() | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ```ruby | ||
| require 'appwrite' | ||
|
|
||
| include Appwrite | ||
|
|
||
| client = Client.new | ||
| .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint | ||
| .set_project('<YOUR_PROJECT_ID>') # Your project ID | ||
| .set_key('<YOUR_API_KEY>') # Your secret API key | ||
|
|
||
| messaging = Messaging.new(client) | ||
|
|
||
| result = messaging.create_ses_provider( | ||
| provider_id: '<PROVIDER_ID>', | ||
| name: '<NAME>', | ||
| access_key: '<ACCESS_KEY>', # optional | ||
| secret_key: '<SECRET_KEY>', # optional | ||
| region: '<REGION>', # optional | ||
| from_name: '<FROM_NAME>', # optional | ||
| from_email: 'email@example.com', # optional | ||
| reply_to_name: '<REPLY_TO_NAME>', # optional | ||
| reply_to_email: 'email@example.com', # optional | ||
| enabled: false # optional | ||
| ) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ```ruby | ||
| require 'appwrite' | ||
|
|
||
| include Appwrite | ||
|
|
||
| client = Client.new | ||
| .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint | ||
| .set_project('<YOUR_PROJECT_ID>') # Your project ID | ||
| .set_key('<YOUR_API_KEY>') # Your secret API key | ||
|
|
||
| messaging = Messaging.new(client) | ||
|
|
||
| result = messaging.update_ses_provider( | ||
| provider_id: '<PROVIDER_ID>', | ||
| name: '<NAME>', # optional | ||
| enabled: false, # optional | ||
| access_key: '<ACCESS_KEY>', # optional | ||
| secret_key: '<SECRET_KEY>', # optional | ||
| region: '<REGION>', # optional | ||
| from_name: '<FROM_NAME>', # optional | ||
| from_email: 'email@example.com', # optional | ||
| reply_to_name: '<REPLY_TO_NAME>', # optional | ||
| reply_to_email: '<REPLY_TO_EMAIL>' # optional | ||
| ) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ```ruby | ||
| require 'appwrite' | ||
|
|
||
| include Appwrite | ||
|
|
||
| client = Client.new | ||
| .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint | ||
| .set_project('<YOUR_PROJECT_ID>') # Your project ID | ||
| .set_key('<YOUR_API_KEY>') # Your secret API key | ||
|
|
||
| project = Project.new(client) | ||
|
|
||
| result = project.update_o_auth2_server( | ||
| enabled: false, | ||
| authorization_url: 'https://example.com', | ||
| scopes: [], # optional | ||
| access_token_duration: 60, # optional | ||
| refresh_token_duration: 60, # optional | ||
| public_access_token_duration: 60, # optional | ||
| public_refresh_token_duration: 60, # optional | ||
| confidential_pkce: false # optional | ||
| ) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ```ruby | ||
| require 'appwrite' | ||
|
|
||
| include Appwrite | ||
|
|
||
| client = Client.new | ||
| .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint | ||
| .set_project('<YOUR_PROJECT_ID>') # Your project ID | ||
| .set_key('<YOUR_API_KEY>') # Your secret API key | ||
|
|
||
| project = Project.new(client) | ||
|
|
||
| result = project.update_password_strength_policy( | ||
| min: 8, # optional | ||
| uppercase: false, # optional | ||
| lowercase: false, # optional | ||
| number: false, # optional | ||
| symbols: false # optional | ||
| ) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,11 @@ def initialize | |
| 'x-sdk-name'=> 'Ruby', | ||
| 'x-sdk-platform'=> 'server', | ||
| 'x-sdk-language'=> 'ruby', | ||
| 'x-sdk-version'=> '25.0.0', | ||
| 'x-sdk-version'=> '25.1.0', | ||
| 'X-Appwrite-Response-Format' => '1.9.5' | ||
| } | ||
| @endpoint = 'https://cloud.appwrite.io/v1' | ||
| @config = {} | ||
| end | ||
|
|
||
| # Set Project | ||
|
|
@@ -29,7 +30,7 @@ def initialize | |
| # | ||
| # @return [self] | ||
| def set_project(value) | ||
| add_header('x-appwrite-project', value) | ||
| @config['project'] = value | ||
|
|
||
| self | ||
| end | ||
|
Comment on lines
32
to
36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Every other setter ( Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
@@ -43,6 +44,7 @@ def set_project(value) | |
| # @return [self] | ||
| def set_key(value) | ||
| add_header('x-appwrite-key', value) | ||
| @config['key'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -56,6 +58,7 @@ def set_key(value) | |
| # @return [self] | ||
| def set_jwt(value) | ||
| add_header('x-appwrite-jwt', value) | ||
| @config['jwt'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -67,6 +70,7 @@ def set_jwt(value) | |
| # @return [self] | ||
| def set_locale(value) | ||
| add_header('x-appwrite-locale', value) | ||
| @config['locale'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -80,6 +84,7 @@ def set_locale(value) | |
| # @return [self] | ||
| def set_session(value) | ||
| add_header('x-appwrite-session', value) | ||
| @config['session'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -93,6 +98,7 @@ def set_session(value) | |
| # @return [self] | ||
| def set_forwarded_user_agent(value) | ||
| add_header('x-forwarded-user-agent', value) | ||
| @config['forwardeduseragent'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -106,6 +112,7 @@ def set_forwarded_user_agent(value) | |
| # @return [self] | ||
| def set_dev_key(value) | ||
| add_header('x-appwrite-dev-key', value) | ||
| @config['devkey'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -119,6 +126,7 @@ def set_dev_key(value) | |
| # @return [self] | ||
| def set_cookie(value) | ||
| add_header('cookie', value) | ||
| @config['cookie'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -132,6 +140,7 @@ def set_cookie(value) | |
| # @return [self] | ||
| def set_impersonate_user_id(value) | ||
| add_header('x-appwrite-impersonate-user-id', value) | ||
| @config['impersonateuserid'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -145,6 +154,7 @@ def set_impersonate_user_id(value) | |
| # @return [self] | ||
| def set_impersonate_user_email(value) | ||
| add_header('x-appwrite-impersonate-user-email', value) | ||
| @config['impersonateuseremail'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
@@ -158,10 +168,15 @@ def set_impersonate_user_email(value) | |
| # @return [self] | ||
| def set_impersonate_user_phone(value) | ||
| add_header('x-appwrite-impersonate-user-phone', value) | ||
| @config['impersonateuserphone'] = value | ||
|
|
||
| self | ||
| end | ||
|
|
||
| def get_config(key) | ||
| @config[key] || '' | ||
| end | ||
|
|
||
| # Set endpoint. | ||
| # | ||
| # @param [String] endpoint The endpoint to set | ||
|
|
@@ -223,7 +238,8 @@ def call( | |
| params: {}, | ||
| response_type: nil | ||
| ) | ||
| uri = URI.parse(@endpoint + path + ((method == "GET" && params.length) ? '?' + encode(params) : '')) | ||
| separator = path.include?('?') ? '&' : '?' | ||
| uri = URI.parse(@endpoint + path + ((method == "GET" && params.length) ? separator + encode(params) : '')) | ||
|
|
||
| fetch(method, uri, headers, params, response_type) | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #frozen_string_literal: true | ||
|
|
||
| module Appwrite | ||
| module Models | ||
| class PolicyPasswordStrength | ||
| attr_reader :id | ||
| attr_reader :min | ||
| attr_reader :uppercase | ||
| attr_reader :lowercase | ||
| attr_reader :number | ||
| attr_reader :symbols | ||
|
|
||
| def initialize( | ||
| id:, | ||
| min:, | ||
| uppercase:, | ||
| lowercase:, | ||
| number:, | ||
| symbols: | ||
| ) | ||
| @id = id | ||
| @min = min | ||
| @uppercase = uppercase | ||
| @lowercase = lowercase | ||
| @number = number | ||
| @symbols = symbols | ||
| end | ||
|
|
||
| def self.from(map:) | ||
| PolicyPasswordStrength.new( | ||
| id: map["$id"], | ||
| min: map["min"], | ||
| uppercase: map["uppercase"], | ||
| lowercase: map["lowercase"], | ||
| number: map["number"], | ||
| symbols: map["symbols"] | ||
| ) | ||
| end | ||
|
|
||
| def to_map | ||
| { | ||
| "$id": @id, | ||
| "min": @min, | ||
| "uppercase": @uppercase, | ||
| "lowercase": @lowercase, | ||
| "number": @number, | ||
| "symbols": @symbols | ||
| } | ||
| end | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
policy_password_strengthrequire is inserted out of alphabetical order —personal_data(p) should precedestrength(s). While Ruby's require order doesn't affect correctness here, the existing file follows strict alphabetical ordering for requires and this breaks that convention.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!