Push SDKs

This commit is contained in:
Jake Barnby
2024-03-08 10:58:46 +01:00
parent 19555651a5
commit 7d3f8a80ea
60 changed files with 441 additions and 53 deletions
+16 -16
View File
@@ -15,7 +15,7 @@ return [
[
'key' => 'web',
'name' => 'Web',
'version' => '14.0.0-rc.7',
'version' => '14.0.0',
'url' => 'https://github.com/appwrite/sdk-for-web',
'package' => 'https://www.npmjs.com/package/appwrite',
'enabled' => true,
@@ -63,7 +63,7 @@ return [
[
'key' => 'flutter',
'name' => 'Flutter',
'version' => '12.0.0-rc.6',
'version' => '12.0.0',
'url' => 'https://github.com/appwrite/sdk-for-flutter',
'package' => 'https://pub.dev/packages/appwrite',
'enabled' => true,
@@ -81,7 +81,7 @@ return [
[
'key' => 'apple',
'name' => 'Apple',
'version' => '5.0.0-rc.6',
'version' => '5.0.0',
'url' => 'https://github.com/appwrite/sdk-for-apple',
'package' => 'https://github.com/appwrite/sdk-for-apple',
'enabled' => true,
@@ -116,7 +116,7 @@ return [
[
'key' => 'android',
'name' => 'Android',
'version' => '5.0.0-rc.6',
'version' => '5.0.0',
'url' => 'https://github.com/appwrite/sdk-for-android',
'package' => 'https://search.maven.org/artifact/io.appwrite/sdk-for-android',
'enabled' => true,
@@ -203,7 +203,7 @@ return [
[
'key' => 'cli',
'name' => 'Command Line',
'version' => '4.2.0-rc.6',
'version' => '4.2.0',
'url' => 'https://github.com/appwrite/sdk-for-cli',
'package' => 'https://www.npmjs.com/package/appwrite-cli',
'enabled' => true,
@@ -231,7 +231,7 @@ return [
[
'key' => 'nodejs',
'name' => 'Node.js',
'version' => '12.0.0-rc.6',
'version' => '12.0.0',
'url' => 'https://github.com/appwrite/sdk-for-node',
'package' => 'https://www.npmjs.com/package/node-appwrite',
'enabled' => true,
@@ -249,7 +249,7 @@ return [
[
'key' => 'deno',
'name' => 'Deno',
'version' => '10.0.0-rc.6',
'version' => '10.0.0',
'url' => 'https://github.com/appwrite/sdk-for-deno',
'package' => 'https://deno.land/x/appwrite',
'enabled' => true,
@@ -267,7 +267,7 @@ return [
[
'key' => 'php',
'name' => 'PHP',
'version' => '11.0.0-rc.6',
'version' => '11.0.0',
'url' => 'https://github.com/appwrite/sdk-for-php',
'package' => 'https://packagist.org/packages/appwrite/appwrite',
'enabled' => true,
@@ -285,7 +285,7 @@ return [
[
'key' => 'python',
'name' => 'Python',
'version' => '5.0.0-rc.6',
'version' => '5.0.0',
'url' => 'https://github.com/appwrite/sdk-for-python',
'package' => 'https://pypi.org/project/appwrite/',
'enabled' => true,
@@ -303,7 +303,7 @@ return [
[
'key' => 'ruby',
'name' => 'Ruby',
'version' => '11.0.0-rc.6',
'version' => '11.0.0',
'url' => 'https://github.com/appwrite/sdk-for-ruby',
'package' => 'https://rubygems.org/gems/appwrite',
'enabled' => true,
@@ -321,7 +321,7 @@ return [
[
'key' => 'go',
'name' => 'Go',
'version' => '4.0.0-rc.6',
'version' => '4.0.0',
'url' => 'https://github.com/appwrite/sdk-for-go',
'package' => '',
'enabled' => false,
@@ -339,7 +339,7 @@ return [
[
'key' => 'java',
'name' => 'Java',
'version' => '4.0.0-rc.6',
'version' => '4.0.0',
'url' => 'https://github.com/appwrite/sdk-for-java',
'package' => '',
'enabled' => false,
@@ -357,7 +357,7 @@ return [
[
'key' => 'dotnet',
'name' => '.NET',
'version' => '0.8.0-rc.6',
'version' => '0.8.0',
'url' => 'https://github.com/appwrite/sdk-for-dotnet',
'package' => 'https://www.nuget.org/packages/Appwrite',
'enabled' => true,
@@ -375,7 +375,7 @@ return [
[
'key' => 'dart',
'name' => 'Dart',
'version' => '11.0.0-rc.6',
'version' => '11.0.0',
'url' => 'https://github.com/appwrite/sdk-for-dart',
'package' => 'https://pub.dev/packages/dart_appwrite',
'enabled' => true,
@@ -393,7 +393,7 @@ return [
[
'key' => 'kotlin',
'name' => 'Kotlin',
'version' => '5.0.0-rc.6',
'version' => '5.0.0',
'url' => 'https://github.com/appwrite/sdk-for-kotlin',
'package' => 'https://search.maven.org/artifact/io.appwrite/sdk-for-kotlin',
'enabled' => true,
@@ -415,7 +415,7 @@ return [
[
'key' => 'swift',
'name' => 'Swift',
'version' => '5.0.0-rc.6',
'version' => '5.0.0',
'url' => 'https://github.com/appwrite/sdk-for-swift',
'package' => 'https://github.com/appwrite/sdk-for-swift',
'enabled' => true,
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -3301,7 +3301,7 @@ App::patch('/v1/messaging/messages/email/:messageId')
: MessageStatus::SCHEDULED;
}
} else {
$status = null;
$status = $message->getAttribute('status');
}
if (
@@ -3472,7 +3472,7 @@ App::patch('/v1/messaging/messages/sms/:messageId')
: MessageStatus::SCHEDULED;
}
} else {
$status = null;
$status = $message->getAttribute('status');
}
if (
@@ -3636,7 +3636,7 @@ App::patch('/v1/messaging/messages/push/:messageId')
: MessageStatus::SCHEDULED;
}
} else {
$status = null;
$status = $message->getAttribute('status');
}
if (
+1 -1
View File
@@ -91,7 +91,7 @@
},
"config": {
"platform": {
"php": "8.2"
"php": "8.3"
}
}
}
Generated
+6 -6
View File
@@ -2731,16 +2731,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.37.0",
"version": "0.37.1",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "d93ce5def46917eaeb8b79f6a3daf6bc933ef56d"
"reference": "3e6a23febcd4392c83e9be772ce545ba42bfbb3a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d93ce5def46917eaeb8b79f6a3daf6bc933ef56d",
"reference": "d93ce5def46917eaeb8b79f6a3daf6bc933ef56d",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/3e6a23febcd4392c83e9be772ce545ba42bfbb3a",
"reference": "3e6a23febcd4392c83e9be772ce545ba42bfbb3a",
"shasum": ""
},
"require": {
@@ -2776,9 +2776,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.37.0"
"source": "https://github.com/appwrite/sdk-generator/tree/0.37.1"
},
"time": "2024-03-08T09:08:44+00:00"
"time": "2024-03-08T09:29:12+00:00"
},
{
"name": "doctrine/deprecations",
@@ -0,0 +1,2 @@
appwrite health getQueueUsage \
@@ -0,0 +1 @@
appwrite health getStorage
@@ -0,0 +1,3 @@
appwrite projects updateAPIStatusAll \
--projectId <PROJECT_ID> \
--status false
@@ -0,0 +1,4 @@
appwrite projects updateApiStatus \
--projectId <PROJECT_ID> \
--api rest \
--status false
@@ -0,0 +1,12 @@
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Health health = Health(client);
HealthQueue result = await health.getQueueUsage(
threshold: 0, // (optional)
);
@@ -0,0 +1,10 @@
import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
Health health = Health(client);
HealthStatus result = await health.getStorage();
@@ -0,0 +1,12 @@
import { Client, Health } from "https://deno.land/x/appwrite/mod.ts";
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
const health = new Health(client);
const response = await health.getQueueUsage(
null // threshold (optional)
);
@@ -0,0 +1,10 @@
import { Client, Health } from "https://deno.land/x/appwrite/mod.ts";
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
const health = new Health(client);
const response = await health.getStorage();
@@ -0,0 +1,14 @@
using Appwrite;
using Appwrite.Models;
using Appwrite.Services;
Client client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Health health = new Health(client);
HealthQueue result = await health.GetQueueUsage(
threshold: 0 // optional
);
@@ -0,0 +1,12 @@
using Appwrite;
using Appwrite.Models;
using Appwrite.Services;
Client client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Health health = new Health(client);
HealthStatus result = await health.GetStorage();
@@ -0,0 +1,7 @@
query {
healthGetQueueUsage(
threshold: 0
) {
size
}
}
@@ -0,0 +1,7 @@
query {
healthGetStorage {
name
ping
status
}
}
@@ -14,7 +14,7 @@ databases.createRelationshipAttribute(
"<DATABASE_ID>", // databaseId
"<COLLECTION_ID>", // collectionId
"<RELATED_COLLECTION_ID>", // relatedCollectionId
RelationshipType.ONE_TO_ONE, // type
RelationshipType.ONETOONE, // type
false, // twoWay (optional)
"", // key (optional)
"", // twoWayKey (optional)
@@ -13,7 +13,7 @@ Functions functions = new Functions(client);
functions.create(
"<FUNCTION_ID>", // functionId
"<NAME>", // name
.NODE145, // runtime
.NODE_14_5, // runtime
listOf("any"), // execute (optional)
listOf(), // events (optional)
"", // schedule (optional)
@@ -12,7 +12,7 @@ Functions functions = new Functions(client);
functions.update(
"<FUNCTION_ID>", // functionId
"<NAME>", // name
.NODE145, // runtime (optional)
.NODE_14_5, // runtime (optional)
listOf("any"), // execute (optional)
listOf(), // events (optional)
"", // schedule (optional)
@@ -11,7 +11,7 @@ Client client = new Client()
Health health = new Health(client);
health.getFailedJobs(
.V1DATABASE, // name
.V1_DATABASE, // name
0, // threshold (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
@@ -0,0 +1,23 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Health;
Client client = new Client()
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Health health = new Health(client);
health.getQueueUsage(
0, // threshold (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
System.out.println(result);
})
);
@@ -0,0 +1,19 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Health;
Client client = new Client()
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Health health = new Health(client);
health.getStorage(new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
System.out.println(result);
}));
@@ -14,7 +14,7 @@ val response = databases.createRelationshipAttribute(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
relatedCollectionId = "<RELATED_COLLECTION_ID>",
type = RelationshipType.ONE_TO_ONE,
type = RelationshipType.ONETOONE,
twoWay = false, // optional
key = "", // optional
twoWayKey = "", // optional
@@ -13,7 +13,7 @@ val functions = Functions(client)
val response = functions.create(
functionId = "<FUNCTION_ID>",
name = "<NAME>",
runtime = .NODE145,
runtime = .NODE_14_5,
execute = listOf("any"), // optional
events = listOf(), // optional
schedule = "", // optional
@@ -11,6 +11,6 @@ val client = Client()
val health = Health(client)
val response = health.getFailedJobs(
name = .V1DATABASE,
name = .V1_DATABASE,
threshold = 0 // optional
)
@@ -0,0 +1,14 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Health
val client = Client()
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val health = Health(client)
val response = health.getQueueUsage(
threshold = 0 // optional
)
@@ -0,0 +1,12 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Health
val client = Client()
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val health = Health(client)
val response = health.getStorage()
@@ -0,0 +1,12 @@
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
const health = new sdk.Health(client);
const result = await health.getQueueUsage(
null // threshold (optional)
);
@@ -0,0 +1,10 @@
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
const health = new sdk.Health(client);
const result = await health.getStorage();
@@ -12,7 +12,7 @@ $client = (new Client())
$avatars = new Avatars($client);
$result = $avatars->getBrowser(
code: Browser::AVANT_BROWSER(),
code: Browser::AVANTBROWSER(),
width: 0, // optional
height: 0, // optional
quality: 0 // optional
@@ -12,7 +12,7 @@ $client = (new Client())
$avatars = new Avatars($client);
$result = $avatars->getCreditCard(
code: CreditCard::AMERICAN_EXPRESS(),
code: CreditCard::AMERICANEXPRESS(),
width: 0, // optional
height: 0, // optional
quality: 0 // optional
@@ -15,7 +15,7 @@ $result = $databases->createRelationshipAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
relatedCollectionId: '<RELATED_COLLECTION_ID>',
type: RelationshipType::ONE_TO_ONE(),
type: RelationshipType::ONETOONE(),
twoWay: false, // optional
key: '', // optional
twoWayKey: '', // optional
@@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Health;
$client = (new Client())
->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
$health = new Health($client);
$result = $health->getQueueUsage(
threshold: null // optional
);
@@ -0,0 +1,13 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Health;
$client = (new Client())
->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key
$health = new Health($client);
$result = $health->getStorage();
@@ -12,7 +12,7 @@ result = databases.create_relationship_attribute(
database_id = '<DATABASE_ID>',
collection_id = '<COLLECTION_ID>',
related_collection_id = '<RELATED_COLLECTION_ID>',
type = RelationshipType.ONE_TO_ONE,
type = RelationshipType.ONETOONE,
two_way = False, # optional
key = '', # optional
two_way_key = '', # optional
@@ -11,7 +11,7 @@ functions = Functions(client)
result = functions.create(
function_id = '<FUNCTION_ID>',
name = '<NAME>',
runtime = .NODE-14.5,
runtime = .NODE_14_5,
execute = ["any"], # optional
events = [], # optional
schedule = '', # optional
@@ -10,7 +10,7 @@ functions = Functions(client)
result = functions.update(
function_id = '<FUNCTION_ID>',
name = '<NAME>',
runtime = .NODE-14.5, # optional
runtime = .NODE_14_5, # optional
execute = ["any"], # optional
events = [], # optional
schedule = '', # optional
@@ -9,6 +9,6 @@ client.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
health = Health(client)
result = health.get_failed_jobs(
name = .V1-DATABASE,
name = .V1_DATABASE,
threshold = None # optional
)
@@ -0,0 +1,12 @@
from appwrite.client import Client
client = Client()
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('5df5acd0d48c2') # Your project ID
client.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
health = Health(client)
result = health.get_queue_usage(
threshold = None # optional
)
@@ -0,0 +1,10 @@
from appwrite.client import Client
client = Client()
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('5df5acd0d48c2') # Your project ID
client.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
health = Health(client)
result = health.get_storage()
@@ -0,0 +1,7 @@
GET /v1/health/queue/usage-dump HTTP/1.1
Host: cloud.appwrite.io
Content-Type: application/json
X-Appwrite-Response-Format: 1.5.0
X-Appwrite-Project: 5df5acd0d48c2
X-Appwrite-Key: 919c2d18fb5d4...a2ae413da83346ad2
@@ -0,0 +1,7 @@
GET /v1/health/storage HTTP/1.1
Host: cloud.appwrite.io
Content-Type: application/json
X-Appwrite-Response-Format: 1.5.0
X-Appwrite-Project: 5df5acd0d48c2
X-Appwrite-Key: 919c2d18fb5d4...a2ae413da83346ad2
@@ -14,7 +14,7 @@ result = databases.create_relationship_attribute(
database_id: '<DATABASE_ID>',
collection_id: '<COLLECTION_ID>',
related_collection_id: '<RELATED_COLLECTION_ID>',
type: RelationshipType::ONE_TO_ONE,
type: RelationshipType::ONETOONE,
two_way: false, # optional
key: '', # optional
two_way_key: '', # optional
@@ -13,7 +13,7 @@ functions = Functions.new(client)
result = functions.create(
function_id: '<FUNCTION_ID>',
name: '<NAME>',
runtime: ::NODE-14.5,
runtime: ::NODE_14_5,
execute: ["any"], # optional
events: [], # optional
schedule: '', # optional
@@ -12,7 +12,7 @@ functions = Functions.new(client)
result = functions.update(
function_id: '<FUNCTION_ID>',
name: '<NAME>',
runtime: ::NODE-14.5, # optional
runtime: ::NODE_14_5, # optional
execute: ["any"], # optional
events: [], # optional
schedule: '', # optional
@@ -11,6 +11,6 @@ client = Client.new
health = Health.new(client)
result = health.get_failed_jobs(
name: ::V1-DATABASE,
name: ::V1_DATABASE,
threshold: null # optional
)
@@ -0,0 +1,14 @@
require 'appwrite'
include Appwrite
client = Client.new
.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
health = Health.new(client)
result = health.get_queue_usage(
threshold: null # optional
)
@@ -0,0 +1,12 @@
require 'appwrite'
include Appwrite
client = Client.new
.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
health = Health.new(client)
result = health.get_storage()
@@ -9,7 +9,7 @@ let client = Client()
let health = Health(client)
let healthQueue = try await health.getFailedJobs(
name: .v1database,
name: .v1Database,
threshold: 0 // optional
)
@@ -0,0 +1,13 @@
import Appwrite
let client = Client()
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let health = Health(client)
let healthQueue = try await health.getQueueUsage(
threshold: 0 // optional
)
@@ -0,0 +1,11 @@
import Appwrite
let client = Client()
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let health = Health(client)
let healthStatus = try await health.getStorage()
@@ -3,11 +3,13 @@
namespace Tests\E2E\Services\Messaging;
use Appwrite\Messaging\Status as MessageStatus;
use CURLFile;
use Tests\E2E\Client;
use Utopia\App;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;
use Utopia\DSN\DSN;
@@ -879,6 +881,94 @@ trait MessagingBase
return $message;
}
public function testCreateDraftPushWithImage()
{
// Create User 1
$response = $this->client->call(Client::METHOD_POST, '/users', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'userId' => ID::unique(),
'email' => uniqid() . "@example.com",
'password' => 'password',
'name' => 'Messaging User 1',
]);
$this->assertEquals(201, $response['headers']['status-code'], "Error creating user: " . var_export($response['body'], true));
$user1 = $response['body'];
$this->assertEquals(1, \count($user1['targets']));
$targetId1 = $user1['targets'][0]['$id'];
// Create bucket
$bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'fileSecurity' => true,
'maximumFileSize' => 2000000, // 2MB
'allowedFileExtensions' => ['jpg', 'png'],
'permissions' => [
Permission::read(Role::user('x')),
Permission::create(Role::user('x')),
Permission::update(Role::user('x')),
Permission::delete(Role::user('x')),
],
]);
$this->assertEquals(201, $response['headers']['status-code']);
$bucketId = $response['body']['$id'];
// Create file
$file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
]);
$fileId = $file['body']['$id'];
// Create Push
$response = $this->client->call(Client::METHOD_POST, '/messaging/messages/push', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'messageId' => ID::unique(),
'targets' => [$targetId1],
'title' => 'New blog post',
'body' => 'Check out the new blog post at http://localhost',
'image' => "{$bucketId}:{$fileId}",
'draft' => true
]);
$this->assertEquals(201, $response['headers']['status-code']);
$message = $response['body'];
$this->assertEquals(MessageStatus::DRAFT, $message['status']);
$imageUrl = $message['data']['image']['url'];
$image = $this->client->call(Client::METHOD_GET, $imageUrl);
$this->assertEquals(200, $image['headers']['status-code']);
return $message;
}
public function testScheduledMessage(): void
{
// Create user