Skip to content

Commit 0bd5e4a

Browse files
ciunguleteactions-user
authored andcommitted
Fix styling
1 parent e011996 commit 0bd5e4a

File tree

3 files changed

+64
-49
lines changed

3 files changed

+64
-49
lines changed

src/Smartbill.php

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,44 @@
44

55
class Smartbill
66
{
7-
8-
const INVOICE_URL = 'https://ws.smartbill.ro:8183/SBORO/api/invoice';
9-
const STATUS_INVOICE_URL = 'https://ws.smartbill.ro:8183/SBORO/api/invoice/paymentstatus';
10-
const PROFORMA_URL = 'https://ws.smartbill.ro:8183/SBORO/api/estimate';
11-
const STATUS_PROFORMA_URL = 'https://ws.smartbill.ro:8183/SBORO/api/estimate/invoices';
12-
const PAYMENT_URL = 'https://ws.smartbill.ro:8183/SBORO/api/payment';
13-
const EMAIL_URL = 'https://ws.smartbill.ro:8183/SBORO/api/document/send';
14-
const TAXES_URL = 'https://ws.smartbill.ro:8183/SBORO/api/tax?cif=%s';
15-
const SERIES_URL = 'https://ws.smartbill.ro:8183/SBORO/api/series?cif=%s&type=%s';
16-
const PRODUCTS_STOCK_URL = 'https://ws.smartbill.ro:8183/SBORO/api/stocks?cif=%s&date=%s&warehouseName=%s&productName=%s&productCode=%s';
17-
const PARAMS_PDF = '/pdf?cif=%s&seriesname=%s&number=%s';
18-
const PARAMS_DELETE = '?cif=%s&seriesname=%s&number=%s';
19-
const PARAMS_DELETE_RECEIPT = '/chitanta?cif=%s&seriesname=%s&number=%s';
20-
const PARAMS_CANCEL = '/cancel?cif=%s&seriesname=%s&number=%s';
21-
const PARAMS_RESTORE = '/restore?cif=%s&seriesname=%s&number=%s';
22-
const PARAMS_STATUS = '?cif=%s&seriesname=%s&number=%s';
23-
const PARAMS_FISCAL_RECEIPT = '/text?cif=%s&id=%s';
24-
25-
const PaymentType_OrdinPlata = 'Ordin plata';
26-
const PaymentType_Chitanta = 'Chitanta';
27-
const PaymentType_Card = 'Card';
28-
const PaymentType_CEC = 'CEC';
29-
const PaymentType_BiletOrdin = 'Bilet ordin';
30-
const PaymentType_MandatPostal = 'Mandat postal';
31-
const PaymentType_Other = 'Alta incasare';
32-
const PaymentType_BonFiscal = 'Bon';
33-
34-
const DiscountType_Valoric = 1;
35-
const DiscountType_Value = 1; // en
36-
const DiscountType_Procentual = 2;
37-
const DiscountType_Percent = 2; // en
38-
39-
const DocumentType_Invoice = 'factura'; // en
40-
const DocumentType_Factura = 'factura';
41-
const DocumentType_Proforma = 'proforma';
42-
const DocumentType_Receipt = 'chitanta'; // en
43-
const DocumentType_Chitanta = 'chitanta';
44-
45-
const DEBUG_ON_ERROR = false; // use this only in development phase; DON'T USE IN PRODUCTION !!!
7+
public const INVOICE_URL = 'https://ws.smartbill.ro:8183/SBORO/api/invoice';
8+
public const STATUS_INVOICE_URL = 'https://ws.smartbill.ro:8183/SBORO/api/invoice/paymentstatus';
9+
public const PROFORMA_URL = 'https://ws.smartbill.ro:8183/SBORO/api/estimate';
10+
public const STATUS_PROFORMA_URL = 'https://ws.smartbill.ro:8183/SBORO/api/estimate/invoices';
11+
public const PAYMENT_URL = 'https://ws.smartbill.ro:8183/SBORO/api/payment';
12+
public const EMAIL_URL = 'https://ws.smartbill.ro:8183/SBORO/api/document/send';
13+
public const TAXES_URL = 'https://ws.smartbill.ro:8183/SBORO/api/tax?cif=%s';
14+
public const SERIES_URL = 'https://ws.smartbill.ro:8183/SBORO/api/series?cif=%s&type=%s';
15+
public const PRODUCTS_STOCK_URL = 'https://ws.smartbill.ro:8183/SBORO/api/stocks?cif=%s&date=%s&warehouseName=%s&productName=%s&productCode=%s';
16+
public const PARAMS_PDF = '/pdf?cif=%s&seriesname=%s&number=%s';
17+
public const PARAMS_DELETE = '?cif=%s&seriesname=%s&number=%s';
18+
public const PARAMS_DELETE_RECEIPT = '/chitanta?cif=%s&seriesname=%s&number=%s';
19+
public const PARAMS_CANCEL = '/cancel?cif=%s&seriesname=%s&number=%s';
20+
public const PARAMS_RESTORE = '/restore?cif=%s&seriesname=%s&number=%s';
21+
public const PARAMS_STATUS = '?cif=%s&seriesname=%s&number=%s';
22+
public const PARAMS_FISCAL_RECEIPT = '/text?cif=%s&id=%s';
23+
24+
public const PaymentType_OrdinPlata = 'Ordin plata';
25+
public const PaymentType_Chitanta = 'Chitanta';
26+
public const PaymentType_Card = 'Card';
27+
public const PaymentType_CEC = 'CEC';
28+
public const PaymentType_BiletOrdin = 'Bilet ordin';
29+
public const PaymentType_MandatPostal = 'Mandat postal';
30+
public const PaymentType_Other = 'Alta incasare';
31+
public const PaymentType_BonFiscal = 'Bon';
32+
33+
public const DiscountType_Valoric = 1;
34+
public const DiscountType_Value = 1; // en
35+
public const DiscountType_Procentual = 2;
36+
public const DiscountType_Percent = 2; // en
37+
38+
public const DocumentType_Invoice = 'factura'; // en
39+
public const DocumentType_Factura = 'factura';
40+
public const DocumentType_Proforma = 'proforma';
41+
public const DocumentType_Receipt = 'chitanta'; // en
42+
public const DocumentType_Chitanta = 'chitanta';
43+
44+
public const DEBUG_ON_ERROR = false; // use this only in development phase; DON'T USE IN PRODUCTION !!!
4645
private $hash = '';
4746

4847
public function __construct($user, $token)
@@ -63,19 +62,19 @@ private function _cURL($url, $data, $request, $headAccept)
6362
curl_setopt($ch, CURLOPT_HEADER, 0);
6463
curl_setopt($ch, CURLOPT_VERBOSE, 0);
6564
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
66-
if (!empty($data)) {
65+
if (! empty($data)) {
6766
$headers[] = "Content-Type: application/json; charset=utf-8";
6867
curl_setopt($ch, CURLOPT_POST, 1);
6968
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
7069
}
71-
if (!empty($request)) {
70+
if (! empty($request)) {
7271
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request);
7372
}
7473
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
7574

7675
// debugging
7776
$isDebug = self::DEBUG_ON_ERROR;
78-
if (!empty($isDebug)) {
77+
if (! empty($isDebug)) {
7978
$debug = [
8079
'URL: ' => $url,
8180
'data: ' => $data,
@@ -102,9 +101,9 @@ private function _callServer($url, $data = '', $request = '', $headAccept = "Acc
102101
$errorMessage = json_decode($return, true);
103102

104103
if (false !== strpos($url, self::EMAIL_URL)) {
105-
$errorMessage = !empty($errorMessage['status']['code']) ? $errorMessage['status']['message'] : $return;
104+
$errorMessage = ! empty($errorMessage['status']['code']) ? $errorMessage['status']['message'] : $return;
106105
} else {
107-
$errorMessage = !empty($errorMessage['errorText']) ? $errorMessage['errorText'] : $return;
106+
$errorMessage = ! empty($errorMessage['errorText']) ? $errorMessage['errorText'] : $return;
108107
}
109108

110109
throw new \Exception($errorMessage);
@@ -119,10 +118,10 @@ private function _callServer($url, $data = '', $request = '', $headAccept = "Acc
119118

120119
private function _prepareDocumentData(&$data)
121120
{
122-
if (!empty($data['subject'])) {
121+
if (! empty($data['subject'])) {
123122
$data['subject'] = base64_encode($data['subject']);
124123
}
125-
if (!empty($data['bodyText'])) {
124+
if (! empty($data['bodyText'])) {
126125
$data['bodyText'] = base64_encode($data['bodyText']);
127126
}
128127
}
@@ -146,34 +145,39 @@ public function PDFInvoice($companyVatCode, $seriesName, $number)
146145
{
147146
$seriesName = urlencode($seriesName);
148147
$url = sprintf(self::INVOICE_URL . self::PARAMS_PDF, $companyVatCode, $seriesName, $number);
148+
149149
return $this->_callServer($url, '', '', "Accept: application/octet-stream");
150150
}
151151

152152
public function PDFProforma($companyVatCode, $seriesName, $number)
153153
{
154154
$seriesName = urlencode($seriesName);
155155
$url = sprintf(self::PROFORMA_URL . self::PARAMS_PDF, $companyVatCode, $seriesName, $number);
156+
156157
return $this->_callServer($url, '', '', "Accept: application/octet-stream");
157158
}
158159

159160
public function deleteInvoice($companyVatCode, $seriesName, $number)
160161
{
161162
$seriesName = urlencode($seriesName);
162163
$url = sprintf(self::INVOICE_URL . self::PARAMS_DELETE, $companyVatCode, $seriesName, $number);
164+
163165
return $this->_callServer($url, '', 'DELETE');
164166
}
165167

166168
public function deleteProforma($companyVatCode, $seriesName, $number)
167169
{
168170
$seriesName = urlencode($seriesName);
169171
$url = sprintf(self::PROFORMA_URL . self::PARAMS_DELETE, $companyVatCode, $seriesName, $number);
172+
170173
return $this->_callServer($url, '', 'DELETE');
171174
}
172175

173176
public function deleteReceipt($companyVatCode, $seriesName, $number)
174177
{
175178
$seriesName = urlencode($seriesName);
176179
$url = sprintf(self::PAYMENT_URL . self::PARAMS_DELETE_RECEIPT, $companyVatCode, $seriesName, $number);
180+
177181
return $this->_callServer($url, '', 'DELETE');
178182
}
179183

@@ -186,74 +190,85 @@ public function cancelInvoice($companyVatCode, $seriesName, $number)
186190
{
187191
$seriesName = urlencode($seriesName);
188192
$url = sprintf(self::INVOICE_URL . self::PARAMS_CANCEL, $companyVatCode, $seriesName, $number);
193+
189194
return $this->_callServer($url, '', 'PUT');
190195
}
191196

192197
public function cancelProforma($companyVatCode, $seriesName, $number)
193198
{
194199
$seriesName = urlencode($seriesName);
195200
$url = sprintf(self::PROFORMA_URL . self::PARAMS_CANCEL, $companyVatCode, $seriesName, $number);
201+
196202
return $this->_callServer($url, '', 'PUT');
197203
}
198204

199205
public function cancelPayment($companyVatCode, $seriesName, $number)
200206
{
201207
$seriesName = urlencode($seriesName);
202208
$url = sprintf(self::PAYMENT_URL . self::PARAMS_CANCEL, $companyVatCode, $seriesName, $number);
209+
203210
return $this->_callServer($url, '', 'PUT');
204211
}
205212

206213
public function restoreInvoice($companyVatCode, $seriesName, $number)
207214
{
208215
$seriesName = urlencode($seriesName);
209216
$url = sprintf(self::INVOICE_URL . self::PARAMS_RESTORE, $companyVatCode, $seriesName, $number);
217+
210218
return $this->_callServer($url, '', 'PUT');
211219
}
212220

213221
public function restoreProforma($companyVatCode, $seriesName, $number)
214222
{
215223
$seriesName = urlencode($seriesName);
216224
$url = sprintf(self::PROFORMA_URL . self::PARAMS_RESTORE, $companyVatCode, $seriesName, $number);
225+
217226
return $this->_callServer($url, '', 'PUT');
218227
}
219228

220229
public function sendDocument($data)
221230
{
222231
$this->_prepareDocumentData($data);
232+
223233
return $this->_callServer(self::EMAIL_URL, $data);
224234
}
225235

226236
public function getTaxes($companyVatCode)
227237
{
228238
$url = sprintf(self::TAXES_URL, $companyVatCode);
239+
229240
return $this->_callServer($url);
230241
}
231242

232243
public function getDocumentSeries($companyVatCode, $documentType = '')
233244
{
234-
$documentType = !empty($documentType) ? substr($documentType, 0, 1) : $documentType; // take the 1st character
245+
$documentType = ! empty($documentType) ? substr($documentType, 0, 1) : $documentType; // take the 1st character
235246
$url = sprintf(self::SERIES_URL, $companyVatCode, $documentType);
247+
236248
return $this->_callServer($url);
237249
}
238250

239251
public function statusInvoicePayments($companyVatCode, $seriesName, $number)
240252
{
241253
$seriesName = urlencode($seriesName);
242254
$url = sprintf(self::STATUS_INVOICE_URL . self::PARAMS_STATUS, $companyVatCode, $seriesName, $number);
255+
243256
return $this->_callServer($url);
244257
}
245258

246259
public function statusProforma($companyVatCode, $seriesName, $number)
247260
{
248261
$seriesName = urlencode($seriesName);
249262
$url = sprintf(self::STATUS_PROFORMA_URL . self::PARAMS_STATUS, $companyVatCode, $seriesName, $number);
263+
250264
return $this->_callServer($url);
251265
}
252266

253267
public function detailsFiscalReceipt($companyVatCode, $id)
254268
{
255269
$url = sprintf(self::PAYMENT_URL . self::PARAMS_FISCAL_RECEIPT, $companyVatCode, $id);
256270
$text = $this->_callServer($url);
271+
257272
try {
258273
$text = base64_decode($text['message']);
259274
} catch (\Exception $ex) {
@@ -268,6 +283,7 @@ public function productsStock($data)
268283
self::_validateProductsStock($data);
269284
$url = self::_urlProductsStock($data);
270285
$list = $this->_callServer($url);
286+
271287
try {
272288
$list = $list['list'];
273289
} catch (\Exception $ex) {

src/SmartbillServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Spatie\LaravelPackageTools\Package;
66
use Spatie\LaravelPackageTools\PackageServiceProvider;
7-
use Andali\Smartbill\Commands\SmartbillCommand;
87

98
class SmartbillServiceProvider extends PackageServiceProvider
109
{

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Andali\Smartbill\Tests;
44

5+
use Andali\Smartbill\SmartbillServiceProvider;
56
use Illuminate\Database\Eloquent\Factories\Factory;
67
use Orchestra\Testbench\TestCase as Orchestra;
7-
use Andali\Smartbill\SmartbillServiceProvider;
88

99
class TestCase extends Orchestra
1010
{

0 commit comments

Comments
 (0)