You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.4 KiB

4 years ago
  1. <?php
  2. /*
  3. * Connection.php
  4. * Copyright (c) 2021 james@firefly-iii.org
  5. *
  6. * This file is part of the Firefly III Data Importer
  7. * (https://github.com/firefly-iii/data-importer).
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. declare(strict_types=1);
  23. namespace App\Services\Spectre\Model;
  24. use Carbon\Carbon;
  25. /**
  26. * Class Connection
  27. */
  28. class Connection
  29. {
  30. public string $categorization;
  31. public string $countryCode;
  32. public string $customerId;
  33. public string $id;
  34. public Carbon $lastSuccess;
  35. public ?string $nextPossibleRefreshAt;
  36. public string $providerCode;
  37. public string $providerId;
  38. public string $providerName;
  39. public string $secret;
  40. public string $status;
  41. public Carbon $updatedAt;
  42. /**
  43. * Customer constructor.
  44. */
  45. private function __construct()
  46. {
  47. }
  48. /**
  49. * @param array $data
  50. *
  51. * @return static
  52. */
  53. public static function fromArray(array $data): self
  54. {
  55. $model = new self();
  56. $model->id = (string)$data['id'];
  57. $model->categorization = $data['categorization'];
  58. $model->countryCode = $data['country_code'];
  59. $model->customerId = $data['customer_id'];
  60. $model->nextPossibleRefreshAt = $data['next_refresh_possible_at'];
  61. $model->providerCode = $data['provider_code'];
  62. $model->providerId = $data['provider_id'];
  63. $model->providerName = $data['provider_name'];
  64. $model->status = $data['status'];
  65. $model->lastSuccess = new Carbon($data['last_success_at']);
  66. $model->updatedAt = new Carbon($data['updated_at']);
  67. return $model;
  68. }
  69. }