Repository navigation
[domain] outgoing MMS support #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <?php | ||
|
|
||
| namespace AndroidSmsGateway\Domain; | ||
|
|
||
| /** | ||
| * A single attachment of an MMS message. | ||
| */ | ||
| final class MmsAttachment { | ||
| /** | ||
| * MIME type of the attachment (e.g. image/png) | ||
| * @var string | ||
| */ | ||
| private string $contentType; | ||
|
|
||
| /** | ||
| * Base64-encoded attachment content | ||
| * @var string | ||
| */ | ||
| private string $data; | ||
|
|
||
| /** | ||
| * Optional file name of the attachment | ||
| * @var string|null | ||
| */ | ||
| private ?string $name; | ||
|
|
||
| /** | ||
| * @param string $contentType MIME type of the attachment (e.g. image/png) | ||
| * @param string $data Base64-encoded attachment content | ||
| * @param string|null $name Optional file name of the attachment | ||
| */ | ||
| public function __construct(string $contentType, string $data, ?string $name = null) { | ||
| $this->contentType = $contentType; | ||
| $this->data = $data; | ||
| $this->name = $name; | ||
| } | ||
|
|
||
| public function ContentType(): string { | ||
| return $this->contentType; | ||
| } | ||
|
|
||
| public function Data(): string { | ||
| return $this->data; | ||
| } | ||
|
|
||
| public function Name(): ?string { | ||
| return $this->name; | ||
| } | ||
|
|
||
| public function ToObject(): \stdClass { | ||
| $obj = (object) [ | ||
| 'contentType' => $this->contentType, | ||
| 'name' => $this->name, | ||
| 'data' => $this->data, | ||
| ]; | ||
|
|
||
| if ($this->name === null) { | ||
| unset($obj->name); | ||
| } | ||
|
|
||
| return $obj; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
|
|
||
| namespace AndroidSmsGateway\Domain; | ||
|
|
||
| /** | ||
| * An MMS message with optional subject, text and attachments. | ||
| */ | ||
| final class MmsMessage { | ||
| /** | ||
| * Optional subject of the MMS | ||
| * @var string|null | ||
| */ | ||
| private ?string $subject; | ||
|
|
||
| /** | ||
| * Optional text body of the MMS | ||
| * @var string|null | ||
| */ | ||
| private ?string $text; | ||
|
|
||
| /** | ||
| * List of attachments. Omitted entirely from the wire when empty. | ||
| * @var array<MmsAttachment> | ||
| */ | ||
| private array $attachments; | ||
|
|
||
| /** | ||
| * @param string|null $subject Optional subject of the MMS | ||
| * @param string|null $text Optional text body of the MMS | ||
| * @param array<MmsAttachment> $attachments List of attachments | ||
| */ | ||
| public function __construct(?string $subject = null, ?string $text = null, array $attachments = []) { | ||
| $this->subject = $subject; | ||
| $this->text = $text; | ||
| $this->attachments = array_values($attachments); | ||
| } | ||
|
|
||
| public function Subject(): ?string { | ||
| return $this->subject; | ||
| } | ||
|
|
||
| public function Text(): ?string { | ||
| return $this->text; | ||
| } | ||
|
|
||
| /** | ||
| * @return array<MmsAttachment> | ||
| */ | ||
| public function Attachments(): array { | ||
| return $this->attachments; | ||
| } | ||
|
|
||
| public function ToObject(): \stdClass { | ||
| $obj = (object) [ | ||
| 'subject' => $this->subject, | ||
| 'text' => $this->text, | ||
| 'attachments' => array_map( | ||
| static fn(MmsAttachment $attachment) => $attachment->ToObject(), | ||
| $this->attachments | ||
| ), | ||
| ]; | ||
|
|
||
| if ($this->subject === null) { | ||
| unset($obj->subject); | ||
| } | ||
|
|
||
| if ($this->text === null) { | ||
| unset($obj->text); | ||
| } | ||
|
|
||
| if (count($this->attachments) === 0) { | ||
| unset($obj->attachments); | ||
| } | ||
|
|
||
| return $obj; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.