Skip to content

Commit

Permalink
Merge pull request #42 from tarfin-labs/laravel-11-support
Browse files Browse the repository at this point in the history
Laravel 11 and PHP 8.3 support
  • Loading branch information
YunusEmreNalbant authored Apr 8, 2024
2 parents bc809bd + f86da41 commit 5b3d3ad
Show file tree
Hide file tree
Showing 26 changed files with 181 additions and 171 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4, '8.0', 8.1, 8.2]
laravel: [8, 9, 10]
php: [7.4, '8.0', 8.1, 8.2, 8.3]
laravel: [8, 9, 10, 11]
exclude:
- php: 7.4
laravel: 9
- php: 7.4
laravel: 10
- php: 7.4
laravel: 11
- php: '8.0'
laravel: 10
- php: '8.0'
laravel: 11
- php: 8.1
laravel: 11
- php: 8.2
laravel: 8

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `netgsm` will be documented in this file

## Unreleased

## [4.6.0] - 2024-04-08

- Laravel 11 and PHP 8.3 support added.

## [4.5.0] - 2023-05-11

- Php 8.2 support added.
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
}
],
"require": {
"php": "^7.4|^8.0|^8.1|^8.2",
"php": "^7.4|^8.0|^8.1|^8.2|^8.3",
"guzzlehttp/guzzle": "^7.1",
"illuminate/support": "^8.0|^9.0|^10.0",
"illuminate/notifications": "^8.0|^9.0|^10.0",
"illuminate/translation": "^8.0|^9.0|^10.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
"illuminate/notifications": "^8.0|^9.0|^10.0|^11.0",
"illuminate/translation": "^8.0|^9.0|^10.0|^11.0",
"nesbot/carbon": "^2.0",
"ext-simplexml": "*"
},
"require-dev": {
"fakerphp/faker": "^1.14",
"phpunit/phpunit": "^9.4",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^6.0|^7.0|^8.0"
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 7 additions & 7 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
return [
'credentials' => [
'user_code' => env('NETGSM_USERCODE'),
'secret' => env('NETGSM_SECRET'),
'brand_code'=> env('NETGSM_BRANDCODE'),
'secret' => env('NETGSM_SECRET'),
'brand_code' => env('NETGSM_BRANDCODE'),
],
'defaults' => [
'language' => env('NETGSM_LANGUAGE', 'tr'),
'header' => env('NETGSM_HEADER', null),
'defaults' => [
'language' => env('NETGSM_LANGUAGE', 'tr'),
'header' => env('NETGSM_HEADER', null),
'sms_sending_method' => env('NETGSM_SMS_SENDING_METHOD', 'get'),
'base_uri' => env('NETGSM_BASE_URI', 'https://api.netgsm.com.tr'),
'timeout' => env('NETGSM_TIMEOUT', 60),
'base_uri' => env('NETGSM_BASE_URI', 'https://api.netgsm.com.tr'),
'timeout' => env('NETGSM_TIMEOUT', 60),
],
];
26 changes: 13 additions & 13 deletions resources/lang/en/errors.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php

return [
'message_too_long' => 'Message length limit exceeded.',
'start_date_incorrect' => 'Invalid start date. Proceeded with system date.',
'end_date_incorrect' => 'Invalid end date. Proceeded with system date.',
'sender_incorrect' => 'Message title (sender name) is not defined in system',
'credentials_incorrect' => 'Invalid username and password or user does not have API access',
'parameters_incorrect' => 'invalid query. One of the parameters that you send is invalid or required parameters are missing.',
'receiver_incorrect' => 'Invalid recipient.',
'message_too_long' => 'Message length limit exceeded.',
'start_date_incorrect' => 'Invalid start date. Proceeded with system date.',
'end_date_incorrect' => 'Invalid end date. Proceeded with system date.',
'sender_incorrect' => 'Message title (sender name) is not defined in system',
'credentials_incorrect' => 'Invalid username and password or user does not have API access',
'parameters_incorrect' => 'invalid query. One of the parameters that you send is invalid or required parameters are missing.',
'receiver_incorrect' => 'Invalid recipient.',
'otp_account_not_defined' => 'There is no OTP SMS package in your account.',
'query_limit_exceed' => 'Query limit exceeded.',
'system_error' => 'system error.',
'netgsm_general_error' => 'Netgsm responded an error :',
'no_record' => 'No record',
'job_id_not_found' => 'Job id not found',
'query_limit_exceed' => 'Query limit exceeded.',
'system_error' => 'system error.',
'netgsm_general_error' => 'Netgsm responded an error :',
'no_record' => 'No record',
'job_id_not_found' => 'Job id not found',

'invalid_netgsm_message' => 'invalid netgsm message',
'method_not_allowed' => ':method method is not allowed',
'method_not_allowed' => ':method method is not allowed',
];
26 changes: 13 additions & 13 deletions resources/lang/tr/errors.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php

return [
'message_too_long' => 'Mesaj metnindeki bir problemden dolayı gönderilemedi veya standart maksimum mesaj karakter sayısını geçtiniz.',
'start_date_incorrect' => 'Mesaj gönderim baslangıç tarihinde hata var. Sistem tarihi ile değiştirilip işleme alındı.',
'end_date_incorrect' => 'Mesaj gönderim sonlandırılma tarihinde hata var. Sistem tarihi ile değiştirilip işleme alındı.Bitiş tarihi başlangıç tarihinden küçük girilmiş ise, sistem bitiş tarihine içinde bulunduğu tarihe 24 saat ekler.',
'sender_incorrect' => 'Mesaj başlığınız (gönderici adınızın) sistemde tanımlı değil.',
'credentials_incorrect' => 'Geçersiz kullanıcı adı, şifre veya kullanıcınızın API erişim izni yok.',
'parameters_incorrect' => 'Hatalı sorgulama. Gönderdiğiniz parametrelerden birisi hatalı veya zorunlu alanlardan biri eksik.',
'receiver_incorrect' => 'Gönderilen numara hatalı.',
'message_too_long' => 'Mesaj metnindeki bir problemden dolayı gönderilemedi veya standart maksimum mesaj karakter sayısını geçtiniz.',
'start_date_incorrect' => 'Mesaj gönderim baslangıç tarihinde hata var. Sistem tarihi ile değiştirilip işleme alındı.',
'end_date_incorrect' => 'Mesaj gönderim sonlandırılma tarihinde hata var. Sistem tarihi ile değiştirilip işleme alındı.Bitiş tarihi başlangıç tarihinden küçük girilmiş ise, sistem bitiş tarihine içinde bulunduğu tarihe 24 saat ekler.',
'sender_incorrect' => 'Mesaj başlığınız (gönderici adınızın) sistemde tanımlı değil.',
'credentials_incorrect' => 'Geçersiz kullanıcı adı, şifre veya kullanıcınızın API erişim izni yok.',
'parameters_incorrect' => 'Hatalı sorgulama. Gönderdiğiniz parametrelerden birisi hatalı veya zorunlu alanlardan biri eksik.',
'receiver_incorrect' => 'Gönderilen numara hatalı.',
'otp_account_not_defined' => 'Hesabınızda OTP SMS Paketi tanımlı değildir.',
'query_limit_exceed' => 'Hesabınızda OTP SMS Paketi tanımlı değildir.',
'system_error' => 'Sistem hatası.',
'netgsm_general_error' => 'Netgsm hatalı cevap döndü :',
'no_record' => 'Kayıt yok',
'job_id_not_found' => 'Job id bulunamadı',
'query_limit_exceed' => 'Hesabınızda OTP SMS Paketi tanımlı değildir.',
'system_error' => 'Sistem hatası.',
'netgsm_general_error' => 'Netgsm hatalı cevap döndü :',
'no_record' => 'Kayıt yok',
'job_id_not_found' => 'Job id bulunamadı',

'invalid_netgsm_message' => 'Geçerli bir Netgsm mesajı değil',
'method_not_allowed' => ':method metoduna izin verilmiyor',
'method_not_allowed' => ':method metoduna izin verilmiyor',
];
4 changes: 2 additions & 2 deletions src/Balance/NetgsmAvailableCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class NetgsmAvailableCredit extends NetgsmApiClient
* @var array
*/
protected $errorCodes = [
'30' => NetgsmErrors::CREDENTIALS_INCORRECT,
'40' => NetgsmErrors::NO_RECORD,
'30' => NetgsmErrors::CREDENTIALS_INCORRECT,
'40' => NetgsmErrors::NO_RECORD,
'100' => NetgsmErrors::SYSTEM_ERROR,
];

Expand Down
8 changes: 4 additions & 4 deletions src/Balance/NetgsmPackages.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class NetgsmPackages extends NetgsmApiClient
* @var array
*/
protected $errorCodes = [
'30' => NetgsmErrors::CREDENTIALS_INCORRECT,
'40' => NetgsmErrors::NO_RECORD,
'30' => NetgsmErrors::CREDENTIALS_INCORRECT,
'40' => NetgsmErrors::NO_RECORD,
'100' => NetgsmErrors::SYSTEM_ERROR,
];

Expand All @@ -49,8 +49,8 @@ public function parseResponse(): array
$columns = array_filter(explode('|', $row));
$columns = array_map('trim', $columns);
$availablePackages[] = [
'amount' => (int) $columns[0],
'amountType' => $columns[1] ?? null,
'amount' => (int) $columns[0],
'amountType' => $columns[1] ?? null,
'packageType' => $columns[2] ?? null,
];
}
Expand Down
14 changes: 7 additions & 7 deletions src/Iys/AbstractNetgsmIys.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ abstract class AbstractNetgsmIys extends NetgsmApiClient
public function send(): string
{
$response = $this->client->request($this->method, $this->url, [
'headers' => [
'Content-Type' => 'application/json',
'headers' => [
'Content-Type' => 'application/json',
],
'json' => [
'header' => [
'username' => $this->credentials['user_code'],
'password' => $this->credentials['secret'],
'header' => [
'username' => $this->credentials['user_code'],
'password' => $this->credentials['secret'],
'brandCode' => $this->credentials['brand_code'],
],
'body' => [
'data' => $this->body,
'body' => [
'data' => $this->body,
],
],
]);
Expand Down
18 changes: 9 additions & 9 deletions src/Iys/Requests/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ public function setDefaults(array $defaults): self
public function body(): array
{
return [
'refid' => $this->refId ?? null,
'type' => $this->type ?? null,
'source' => $this->source ?? null,
'recipient' => $this->recipient ?? null,
'status' => $this->status ?? null,
'consentDate' => $this->consentDate ?? null,
'recipientType' => $this->recipientType ?? null,
'retailerCode' => $this->retailerCode ?? null,
'retailerAccess' => $this->retailerAccess ?? null,
'refid' => $this->refId ?? null,
'type' => $this->type ?? null,
'source' => $this->source ?? null,
'recipient' => $this->recipient ?? null,
'status' => $this->status ?? null,
'consentDate' => $this->consentDate ?? null,
'recipientType' => $this->recipientType ?? null,
'retailerCode' => $this->retailerCode ?? null,
'retailerAccess' => $this->retailerAccess ?? null,
];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Iys/Requests/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public function setDefaults(array $defaults): self
public function body(): array
{
return [
'type' => $this->type ?? null,
'recipient' => $this->recipient ?? null,
'recipientType' => $this->recipientType ?? null,
'refid' => $this->refId ?? null,
'type' => $this->type ?? null,
'recipient' => $this->recipient ?? null,
'recipientType' => $this->recipientType ?? null,
'refid' => $this->refId ?? null,
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Netgsm.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function sendSms(AbstractNetgsmMessage $netgsmMessage)
* Get sms status report between given dates.
*
* @param AbstractNetgsmReport $report
* @param $startDate
* @param $endDate
* @param $startDate
* @param $endDate
* @param array $filters
* @return Collection
*
Expand Down
4 changes: 2 additions & 2 deletions src/NetgsmApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function setCredentials(array $credentials): self
/**
* Sends requests to netgsm api endpoints with specified credentials.
*
* @param $method
* @param $url
* @param $method
* @param $url
* @param null $params
* @param array $headers
* @return string
Expand Down
2 changes: 1 addition & 1 deletion src/NetgsmServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function register()

$client = new Client([
'base_uri' => $config['defaults']['base_uri'],
'timeout' => $config['defaults']['timeout'],
'timeout' => $config['defaults']['timeout'],
]);

return new Netgsm($client, $config['credentials'], $config['defaults']);
Expand Down
8 changes: 4 additions & 4 deletions src/Report/AbstractNetgsmReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public function setPage(int $page): self
/**
* formats the value by specified type.
*
* @param $value
* @param $format
* @param $value
* @param $format
* @return int|string
*/
protected function formatValue($value, $format)
Expand Down Expand Up @@ -160,7 +160,7 @@ protected function formatValue($value, $format)
public function getReports(): Collection
{
$data = [
'page' => 1,
'page' => 1,
];

$data = array_merge($data, $this->filters);
Expand Down Expand Up @@ -190,7 +190,7 @@ public function getReports(): Collection
/**
* validates the response returned from netgsm report api.
*
* @param $response
* @param $response
* @return bool
*
* @throws ReportException
Expand Down
20 changes: 10 additions & 10 deletions src/Report/NetgsmSmsDetailReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class NetgsmSmsDetailReport extends AbstractNetgsmReport
* @var array
*/
protected $filters = [
'type' => 1,
'type' => 1,
'version' => 1,
'view' => 2,
'view' => 2,
];

/**
Expand All @@ -65,26 +65,26 @@ public function setBulkId($bulkId): AbstractNetgsmReport
/**
* Processes and returns a report line.
*
* @param $line
* @param $line
* @return array
*/
public function processRow($line): array
{
return [
'jobId' => (int) $line->msginfo->jobID,
'message' => (string) $line->msginfo->msg,
'jobId' => (int) $line->msginfo->jobID,
'message' => (string) $line->msginfo->msg,
'startDate' => (string) $line->datetime->startdate,
'endDate' => (string) $line->datetime->stopdate,
'status' => (string) $line->msginfo->state,
'total' => (string) $line->msginfo->total,
'header' => (string) $line->msginfo->msgheader,
'endDate' => (string) $line->datetime->stopdate,
'status' => (string) $line->msginfo->state,
'total' => (string) $line->msginfo->total,
'header' => (string) $line->msginfo->msgheader,
];
}

/**
* Parses the XML response returned from the Netgsm API service.
*
* @param $response
* @param $response
* @return Collection
*
* @throws \TarfinLabs\Netgsm\Exceptions\ReportException
Expand Down
Loading

0 comments on commit 5b3d3ad

Please sign in to comment.