This repository has been archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.php
121 lines (105 loc) · 2.76 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/vendor/autoload.php';
load_env(__DIR__);
use NNV\OneSignal\OneSignal;
use NNV\OneSignal\API\App;
use NNV\OneSignal\API\Player;
use NNV\OneSignal\Utils\Validation;
use NNV\OneSignal\API\Notification;
$demoAppID = env('APP_ID');
$demoAppRestKey = env('APP_REST_KEY');
$oneSignal = new OneSignal(env('USER_AUTH_KEY'), $demoAppID, $demoAppRestKey);
$app = new App($oneSignal);
$player = new Player($oneSignal);
$notification = new Notification($oneSignal);
$otherOneSignal = $oneSignal->copy(null, 'Other AppID', 'Other RESTful API key', [
'timeout' => 20,
]);
# Find app by appId
// dump($app->get('APP_ID'));
# Get all apps
// $apps = $app->all();
// dump($apps);
# Create app
// $appData = [
// 'name' => 'Test from API',
// 'apns_env' => 'sanbox',
// ];
// dump($app->create($appData));
# Update app
// $appData = [
// 'name' => 'Test from API updated',
// ];
// dump($app->update('APP_ID', $appData));
$rules = [
'required' => [
'name',
'email'
],
'defined' => [
'name' => 'string',
'email' => [
'allowedTypes' => 'string',
],
'gender' => [
'allowedTypes' => 'string',
'allowedValues' => ['Male', 'Female', 'Unknow'],
]
]
];
$data = [
'email' => 'namnv609',
'name' => '123456',
'gender' => 'ABC'
];
$notificationData = [
'included_segments' => ['All', 'Free User'],
'contents' => [
'en' => 'Welcome',
'vi' => 'Chao mung',
],
'headings' => [
'en' => 'Hello',
'vi' => 'Xin chao'
],
'buttons' => [
[
'id' => 'id1',
'text' => 'Button 1',
'icon' => 'icon_1'
],
[
'id' => 'id2',
'text' => 'Button 2',
'icon' => 'icon_2'
]
],
// 'filters' => [
// [
// 'field' => 'tag',
// 'key' => 'level',
// 'relation' => '>',
// 'value' => '10'
// ],
// [
// 'field' => 'amount_spent',
// 'relation' => '>',
// 'value' => '0'
// ]
// ],
'send_after' => 'Sep 24 2017 14:00:00 GMT-0700',
'delivery_time_of_day' => '09:00AM',
// 'include_player_ids' => ['2445818a-8e72-4477-a014-de8667d860a2'],
// 'isAndroid' => true,
];
$validation = new Validation();
$validation->setMultiRequired($rules['required'])
->setMultiDefined($rules['defined'])
->setAllowedValues('email', function($emailAddr) {
return filter_var($emailAddr, FILTER_VALIDATE_EMAIL);
});
// $validation->validate($data);
\Psy\Shell::debug(get_defined_vars());