| 1 |
<?php |
| 2 |
|
| 3 |
namespace Texty\Gateways; |
| 4 |
|
| 5 |
use WP_Error; |
| 6 |
|
| 7 |
/** |
| 8 |
* Twilio Class |
| 9 |
* |
| 10 |
* @see https://www.twilio.com/docs/sms/api/message |
| 11 |
*/ |
| 12 |
class Fake implements GatewayInterface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Get the display order. |
| 16 |
* |
| 17 |
* @return int |
| 18 |
*/ |
| 19 |
public function order() { |
| 20 |
return 99; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Get the name |
| 25 |
* |
| 26 |
* @return string |
| 27 |
*/ |
| 28 |
public function name() { |
| 29 |
return __( 'Fake Gateway', 'texty' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Get the name |
| 34 |
* |
| 35 |
* @return string |
| 36 |
*/ |
| 37 |
public function description() { |
| 38 |
return __( 'This is a fake gateway that logs the messages to <code>debug.log</code> file without sending the actual SMS.', 'texty' ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Get the logo |
| 43 |
* |
| 44 |
* @return string |
| 45 |
*/ |
| 46 |
public function logo() { |
| 47 |
return TEXTY_URL . '/assets/images/gateways/common-sms.png'; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Get the settings |
| 52 |
* |
| 53 |
* @return array |
| 54 |
*/ |
| 55 |
public function get_settings() { |
| 56 |
return []; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Send SMS |
| 61 |
* |
| 62 |
* @param string $to |
| 63 |
* @param string $message |
| 64 |
* |
| 65 |
* @return WP_Error|array |
| 66 |
*/ |
| 67 |
public function send( $to, $message ) { |
| 68 |
$message = sprintf( 'To: %s; Message: %s', $to, $message ); |
| 69 |
error_log( $message ); |
| 70 |
|
| 71 |
return [ |
| 72 |
'success' => true, |
| 73 |
'reference_id' => 'fake_' . time(), |
| 74 |
]; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Validate a REST API request |
| 79 |
* |
| 80 |
* @param WP_REST_Request $request |
| 81 |
* |
| 82 |
* @return WP_Error|true |
| 83 |
*/ |
| 84 |
public function validate( $request ) { |
| 85 |
return []; |
| 86 |
} |
| 87 |
} |
| 88 |
|