Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <dev@noladev.com>
8 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Shipping\Auth;
16
17/**
18 * Pop shipping auth client interface
19 *
20 * @category   Pop
21 * @package    Pop\Shipping
22 * @author     Nick Sagona, III <dev@noladev.com>
23 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
24 * @license    https://www.popphp.org/license     New BSD License
25 * @version    4.0.0
26 */
27interface AuthClientInterface
28{
29
30    /**
31     * Set auth API URL
32     *
33     * @param  string $authApiUrl
34     * @return AuthClientInterface
35     */
36    public function setAuthApiUrl(string $authApiUrl): AuthClientInterface;
37
38    /**
39     * Get auth API URL
40     *
41     * @return ?string
42     */
43    public function getAuthApiUrl(): ?string;
44
45    /**
46     * Has auth API URL
47     *
48     * @return bool
49     */
50    public function hasAuthApiUrl(): bool;
51
52    /**
53     * Set account number
54     *
55     * @param  string $accountNumber
56     * @return AuthClientInterface
57     */
58    public function setAccountNumber(string $accountNumber): AuthClientInterface;
59
60    /**
61     * Get account number
62     *
63     * @return ?string
64     */
65    public function getAccountNumber(): ?string;
66
67    /**
68     * Has account number
69     *
70     * @return bool
71     */
72    public function hasAccountNumber(): bool;
73
74    /**
75     * Get token data
76     *
77     * @param  ?string $key
78     * @return mixed
79     */
80    public function getTokenData(?string $key = null): mixed;
81
82    /**
83     * Has token data
84     *
85     * @return bool
86     */
87    public function hasTokenData(): bool;
88
89    /**
90     * Load token data
91     *
92     * @param  array $tokenData
93     * @return AuthClientInterface
94     */
95    public function loadTokenData(array $tokenData): AuthClientInterface;
96
97    /**
98     * Load token data from file
99     *
100     * @param  string $tokenFile
101     * @return AuthClientInterface
102     */
103    public function loadTokenDataFromFile(string $tokenFile): AuthClientInterface;
104
105    /**
106     * Save token data to file
107     *
108     * @param  string $tokenFile
109     * @param  ?array $tokenData
110     * @return AuthClientInterface
111     */
112    public function saveTokenDataToFile(string $tokenFile, ?array $tokenData = null): AuthClientInterface;
113
114    /**
115     * Has token data file
116     *
117     * @param  string $tokenFile
118     * @return bool
119     */
120    public function hasTokenDataFile(string $tokenFile): bool;
121
122    /**
123     * Has valid auth token
124     *
125     * @return bool
126     */
127    public function hasAuthToken(): bool;
128
129    /**
130     * Get auth token
131     *
132     * @return ?string
133     */
134    public function getAuthToken(): ?string;
135
136    /**
137     * Fetch auth token, either the current valid one, or get a new/refreshed auth token
138     *
139     * @param  ?string $tokenFile
140     * @param  int     $buffer     Buffer in seconds to check the expiration
141     * @return ?string
142     */
143    public function fetchAuthToken(?string $tokenFile = null, int $buffer = 10): ?string;
144
145    /**
146     * Has auth token type
147     *
148     * @return bool
149     */
150    public function hasTokenType(): bool;
151
152    /**
153     * Get auth token type
154     *
155     * @return ?string
156     */
157    public function getTokenType(): ?string;
158
159    /**
160     * Has auth token expiration
161     *
162     * @return bool
163     */
164    public function hasExpiration(): bool;
165
166    /**
167     * Get auth token expiration
168     *
169     * @return ?int
170     */
171    public function getExpiration(): ?int;
172
173    /**
174     * Determine if the auth token has expired
175     *
176     * @return bool
177     */
178    public function isExpired(): bool;
179
180    /**
181     * Determine when the token will expire in seconds
182     *
183     * @return int
184     */
185    public function willExpireIn(): int;
186
187    /**
188     * Authenticate and get auth token
189     *
190     * @param  ?string $tokenFile
191     * @return AuthClientInterface
192     */
193    public function authenticate(?string $tokenFile = null): AuthClientInterface;
194
195    /**
196     * Refresh auth token
197     *
198     * @param  ?string $tokenFile
199     * @return AuthClientInterface
200     */
201    public function refresh(?string $tokenFile = null): AuthClientInterface;
202
203}