1 | <?php |
||
10 | class CreateSMSHandler implements HandlerInterface |
||
11 | { |
||
12 | /** @var SMSRepository */ |
||
13 | protected $smss; |
||
14 | |||
15 | /** |
||
16 | * CreateSMSHandler constructor. |
||
17 | * @param SMSRepository $smss |
||
18 | */ |
||
19 | public function __construct(SMSRepository $smss) |
||
23 | |||
24 | /** |
||
25 | * Persist the missive in the database using |
||
26 | * the repository create method and command attributes. |
||
27 | * |
||
28 | * @param CommandInterface $command |
||
29 | */ |
||
30 | public function handle(CommandInterface $command) |
||
34 | |||
35 | /** |
||
36 | * Arrange the attributes for creating the model. |
||
37 | * |
||
38 | * If the relay provider is telerivet: |
||
39 | * |
||
40 | * from |
||
41 | * |
||
42 | * [ |
||
43 | * 'secret' => 'ABC12344567890', //miscellaneous field |
||
44 | * 'from_number' => '+639171234567', |
||
45 | * 'to_number' => '+639187654321', |
||
46 | * 'content' => 'The quick brown fox...', |
||
47 | * ] |
||
48 | * |
||
49 | * to |
||
50 | * |
||
51 | * [ |
||
52 | * 'from' => '+639171234567', |
||
53 | * 'to' => '+639187654321', |
||
54 | * 'message' => 'The quick brown fox...', |
||
55 | * ] |
||
56 | * |
||
57 | * @param CommandInterface $command |
||
58 | * @return array |
||
59 | */ |
||
60 | protected function getCommandAttributes(CommandInterface $command): array |
||
73 | |||
74 | /** |
||
75 | * Extract the fields of the SMS model e.g. |
||
76 | * |
||
77 | * [ |
||
78 | * 'from', |
||
79 | * 'to', |
||
80 | * 'message', |
||
81 | * ] |
||
82 | * |
||
83 | * @return mixed |
||
84 | */ |
||
85 | protected function getSMSFields() |
||
89 | } |
||
90 |