This repository has been archived by the owner on Jun 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tests.php
97 lines (80 loc) · 2.56 KB
/
Tests.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
<?php
namespace Tests;
/**
* Dependencies
*/
require_once __DIR__ . '/vendor/autoload.php'; // Composer
use nyco\EligibilityScreeningLibrary\AuthToken as AuthToken;
use nyco\EligibilityScreeningLibrary\EligibilityPrograms as EligibilityPrograms;
use nyco\EligibilityScreeningLibrary\BulkSubmission as BulkSubmission;
class Tests {
/**
* Sample Password Reset Request
*/
public static function resetPassword() {
$endpoint = new AuthToken;
$endpoint->debug = true;
var_dump($endpoint->resetPassword());
}
/**
* Sample Token Request
*/
public static function authToken() {
$endpoint = new AuthToken;
$endpoint->debug = true;
var_dump($endpoint->fetch());
var_dump(
'You now have a new Token that will expire at '
. date('g:ia', $endpoint->expires) . ' '
. date_default_timezone_get()
);
}
/**
* Sample Token Request
*/
public static function replaceConfig() {
$endpoint = new AuthToken;
$endpoint->debug = true;
var_dump($endpoint->fetch());
var_dump(
'You now have a new Token that will expire at '
. date('g:ia', $endpoint->expires) . ' '
. date_default_timezone_get()
);
}
/**
* Full Sample Request including authentication for Single Requests
*/
public static function eligibilityPrograms() {
// 1. Authentication
$auth = new AuthToken;
$auth->path = './';
$token = $auth->fetch()['token'];
// 2. Make request
$endpoint = new EligibilityPrograms;
$endpoint->data = $endpoint->data; // This isn't needed because it's setting itself but it is an example of how to set the client's data.
$endpoint->token = $auth->fresh($token); // To ensure a fresh token, use the AuthToken Fresh method.
$endpoint->debug = true;
var_dump($endpoint->fetch());
}
/**
* Full Sample Request including authentication for Bulk Submissions
*/
public static function bulkSubmission($file = false, $programs = []) {
// 1. Authentication
$auth = new AuthToken;
$auth->path = './';
$token = $auth->fetch()['token'];
// 2. Make request
$endpoint = new BulkSubmission;
$endpoint->data = $endpoint->data; // This isn't needed because it's setting itself but it is an example of how to set the client's data.
$endpoint->interestedPrograms = $programs;
$endpoint->token = $auth->fresh($token); // To ensure a fresh token, use the AuthToken Fresh method.
$endpoint->debug = true;
if ($file) {
var_dump($endpoint->fetch()->toFile());
} else {
var_dump($endpoint->fetch()->toArray());
}
}
}