Skip to content

Commit

Permalink
initial package
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamadmrt committed Jul 21, 2024
0 parents commit 36a1863
Show file tree
Hide file tree
Showing 30 changed files with 1,511 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Composer dependency directory
/vendor/

# Composer package file
composer.lock

# PHPStorm project files
.idea/

# NetBeans project files
nbproject/
nbproject/private/

# Symfony directories
/app/cache/
/app/logs/
/var/cache/
/var/logs/
/var/sessions/

# Laravel directories
/node_modules/
/public/storage
/public/hot
/storage/*.key
.env

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & 6 specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
Homestead.yaml
Homestead.json
.vagrant/

# PHPUnit
.phpunit.result.cache

# Directories for local environments
/.vagrant/
/homestead/

# Log files
*.log

# Backup files
*.bak

# Other development environment files
.env.local
.env.*.local
.php-version
/.env.local.php

# IDE files
/.phpstorm.meta.php
/.idea/
*.iml
*.iws
*.ipr
/.vscode/
_ide_helper.php
_ide_helper_models.php
.phpstorm.meta.php
/.phpunit.result.cache

# eZ Platform
/var/cache
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "ghasedaksms/php",
"type": "library",
"description": "a package for use ghasedaksms api services in php programming",
"keywords": ["ghasedak","ghasedaksms", "sms", "sms-api", "sms-gateway", "notification"],
"license": "MIT",
"autoload": {
"psr-4": {
"Ghasedak\\": "src/"
}
},
"authors": [
{
"name": "mrt",
"email": "mortezaei76@gmail.com"
}
],
"require": {
"php": ">=8.2",
"ext-curl": "*",
"ext-json": "*"
},
"minimum-stability" : "stable",
"prefer-stable" : true
}
28 changes: 28 additions & 0 deletions src/Constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Ghasedak;

final readonly class Constants
{
const URL = 'https://gw.ghasedak.me/Rest/api/v1/WebService';

const SEND_SINGLE = '/SendSingleSMS';

const SEND_BULK = '/SendBulkSMS';

const SEND_PAIR_TO_PAIR = '/SendPairToPairSMS';

const SEND_OTP = '/SendOtpSMS';

const SEND_OTP_WITH_PARAMS = '/SendOtpWithParams';

const CHECK_SMS_STATUS = '/CheckSmsStatus';

const GET_ACCOUNT_INFORMATION = '/GetAccountInformation';

const GET_RECEIVED_SMSES = '/GetReceivedSmses';

const GET_RECEIVED_SMSES_PAGING = '/GetReceivedSmsesPaging';

const GET_OTP_TEMPLATE_PARAMETERS = '/GetOtpTemplateParameters';
}
72 changes: 72 additions & 0 deletions src/DataTransferObjects/Request/BulkMessageDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Ghasedak\DataTransferObjects\Request;

use DateTimeInterface;

readonly class BulkMessageDTO
{

/**
* @param array<string> $receptors
*/
public function __construct(
private DateTimeInterface $sendDate,
private string $lineNumber,
private array $receptors,
private string $message,
private ?bool $isVoice = false,
private ?bool $udh = false,
private ?string $clientReferenceId = null,
)
{
}

public function getSendDate(): DateTimeInterface
{
return $this->sendDate;
}

public function getLineNumber(): string
{
return $this->lineNumber;
}

public function getReceptors(): array
{
return $this->receptors;
}

public function getMessage(): string
{
return $this->message;
}

public function getClientReferenceId(): string
{
return $this->clientReferenceId;
}

public function isVoice(): bool
{
return $this->isVoice;
}

public function isUdh(): bool
{
return $this->udh;
}

public function toArray(): array
{
return [
'sendDate' => $this->sendDate->format('c'),
'lineNumber' => $this->lineNumber,
'receptors' => $this->receptors,
'message' => $this->message,
'clientReferenceId' => $this->clientReferenceId,
'isVoice' => $this->isVoice,
'udh' => $this->udh
];
}
}
31 changes: 31 additions & 0 deletions src/DataTransferObjects/Request/CheckSmsStatusDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Ghasedak\DataTransferObjects\Request;

readonly class CheckSmsStatusDTO
{
public function __construct(
private array $ids,
private int $type
)
{
}

public function getIds(): array
{
return $this->ids;
}

public function getType(): int
{
return $this->type;
}

public function toArray(): array
{
return [
'Ids' => implode(',', $this->ids),
'type' => $this->type
];
}
}
24 changes: 24 additions & 0 deletions src/DataTransferObjects/Request/GetOtpTemplateParametersDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Ghasedak\DataTransferObjects\Request;

readonly class GetOtpTemplateParametersDTO
{
public function __construct(
private string $templateName
)
{
}

public function getTemplateName(): string
{
return $this->templateName;
}

public function toArray(): array
{
return [
'TemplateName' => $this->templateName
];
}
}
33 changes: 33 additions & 0 deletions src/DataTransferObjects/Request/GetReceivedSMSesDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Ghasedak\DataTransferObjects\Request;

readonly class GetReceivedSMSesDTO
{
public function __construct(
private string $lineNumber,
private ?bool $isRead = null
)
{
}

public function getLineNumber(): string
{
return $this->lineNumber;
}

public function isRead(): bool
{
return $this->isRead;
}

public function toArray(): array
{
return [
'LineNumber' => $this->lineNumber,
'IsRead' => $this->isRead
];
}


}
61 changes: 61 additions & 0 deletions src/DataTransferObjects/Request/GetReceivedSMSesPagingDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Ghasedak\DataTransferObjects\Request;

use DateTimeInterface;

readonly class GetReceivedSMSesPagingDTO
{
public function __construct(
private string $lineNumber,
private ?DateTimeInterface $startDate = null,
private ?DateTimeInterface $endDate = null,
private ?int $pageIndex = null,
private ?int $pageSize = null,
private ?bool $isRead = null
)
{
}

public function getLineNumber(): string
{
return $this->lineNumber;
}

public function isRead(): bool
{
return $this->isRead;
}

public function getStartDate(): DateTimeInterface
{
return $this->startDate;
}

public function getEndDate(): DateTimeInterface
{
return $this->endDate;
}

public function getPageIndex(): int
{
return $this->pageIndex;
}

public function getPageSize(): int
{
return $this->pageSize;
}

public function toArray(): array
{
return [
'LineNumber' => $this->lineNumber,
'IsRead' => $this->isRead,
'StartDate' => $this->startDate?->format('c'),
'EndDate' => $this->endDate?->format('c'),
'PageIndex' => $this->pageIndex,
'pageSize' => $this->pageSize
];
}
}
31 changes: 31 additions & 0 deletions src/DataTransferObjects/Request/InputDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Ghasedak\DataTransferObjects\Request;

readonly class InputDTO
{
public function __construct(
private string $param,
private string $value,
)
{
}

public function getParam(): string
{
return $this->param;
}

public function getValue(): string
{
return $this->value;
}

public function toArray(): array
{
return [
'param' => $this->param,
'value' => $this->value
];
}
}
Loading

0 comments on commit 36a1863

Please sign in to comment.