|
| 1 | +<?php |
| 2 | + |
| 3 | +// The content of this file was automatically generated |
| 4 | + |
| 5 | +namespace ProcessOut; |
| 6 | + |
| 7 | +use ProcessOut\ProcessOut; |
| 8 | +use ProcessOut\Networking\Request; |
| 9 | + |
| 10 | +class ProjectSFTPSettingsPublic implements \JsonSerializable |
| 11 | +{ |
| 12 | + |
| 13 | + /** |
| 14 | + * ProcessOut's client |
| 15 | + * @var ProcessOut\ProcessOut |
| 16 | + */ |
| 17 | + protected $client; |
| 18 | + |
| 19 | + /** |
| 20 | + * Whether the SFTP settings are enabled |
| 21 | + * @var boolean |
| 22 | + */ |
| 23 | + protected $enabled; |
| 24 | + |
| 25 | + /** |
| 26 | + * SFTP server endpoint with port |
| 27 | + * @var string |
| 28 | + */ |
| 29 | + protected $endpoint; |
| 30 | + |
| 31 | + /** |
| 32 | + * SFTP server username |
| 33 | + * @var string |
| 34 | + */ |
| 35 | + protected $username; |
| 36 | + |
| 37 | + /** |
| 38 | + * ProjectSFTPSettingsPublic constructor |
| 39 | + * @param ProcessOut\ProcessOut $client |
| 40 | + * @param array|null $prefill |
| 41 | + */ |
| 42 | + public function __construct(ProcessOut $client, $prefill = array()) |
| 43 | + { |
| 44 | + $this->client = $client; |
| 45 | + |
| 46 | + $this->fillWithData($prefill); |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | + /** |
| 51 | + * Get Enabled |
| 52 | + * Whether the SFTP settings are enabled |
| 53 | + * @return bool |
| 54 | + */ |
| 55 | + public function getEnabled() |
| 56 | + { |
| 57 | + return $this->enabled; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Set Enabled |
| 62 | + * Whether the SFTP settings are enabled |
| 63 | + * @param bool $value |
| 64 | + * @return $this |
| 65 | + */ |
| 66 | + public function setEnabled($value) |
| 67 | + { |
| 68 | + $this->enabled = $value; |
| 69 | + return $this; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Get Endpoint |
| 74 | + * SFTP server endpoint with port |
| 75 | + * @return string |
| 76 | + */ |
| 77 | + public function getEndpoint() |
| 78 | + { |
| 79 | + return $this->endpoint; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Set Endpoint |
| 84 | + * SFTP server endpoint with port |
| 85 | + * @param string $value |
| 86 | + * @return $this |
| 87 | + */ |
| 88 | + public function setEndpoint($value) |
| 89 | + { |
| 90 | + $this->endpoint = $value; |
| 91 | + return $this; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Get Username |
| 96 | + * SFTP server username |
| 97 | + * @return string |
| 98 | + */ |
| 99 | + public function getUsername() |
| 100 | + { |
| 101 | + return $this->username; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Set Username |
| 106 | + * SFTP server username |
| 107 | + * @param string $value |
| 108 | + * @return $this |
| 109 | + */ |
| 110 | + public function setUsername($value) |
| 111 | + { |
| 112 | + $this->username = $value; |
| 113 | + return $this; |
| 114 | + } |
| 115 | + |
| 116 | + |
| 117 | + /** |
| 118 | + * Fills the current object with the new values pulled from the data |
| 119 | + * @param array $data |
| 120 | + * @return ProjectSFTPSettingsPublic |
| 121 | + */ |
| 122 | + public function fillWithData($data) |
| 123 | + { |
| 124 | + if(! empty($data['enabled'])) |
| 125 | + $this->setEnabled($data['enabled']); |
| 126 | + |
| 127 | + if(! empty($data['endpoint'])) |
| 128 | + $this->setEndpoint($data['endpoint']); |
| 129 | + |
| 130 | + if(! empty($data['username'])) |
| 131 | + $this->setUsername($data['username']); |
| 132 | + |
| 133 | + return $this; |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * Implements the JsonSerializable interface |
| 138 | + * @return object |
| 139 | + */ |
| 140 | + public function jsonSerialize() { |
| 141 | + return array( |
| 142 | + "enabled" => $this->getEnabled(), |
| 143 | + "endpoint" => $this->getEndpoint(), |
| 144 | + "username" => $this->getUsername(), |
| 145 | + ); |
| 146 | + } |
| 147 | + |
| 148 | + |
| 149 | + /** |
| 150 | + * Fetch the SFTP settings for the project. |
| 151 | + * @param string $id |
| 152 | + * @param array $options |
| 153 | + * @return $this |
| 154 | + */ |
| 155 | + public function fetchSftpSettings($id, $options = array()) |
| 156 | + { |
| 157 | + $this->fillWithData($options); |
| 158 | + |
| 159 | + $request = new Request($this->client); |
| 160 | + $path = "/projects/" . urlencode($id) . "/sftp-settings"; |
| 161 | + |
| 162 | + $data = array( |
| 163 | + |
| 164 | + ); |
| 165 | + |
| 166 | + $response = $request->get($path, $data, $options); |
| 167 | + $returnValues = array(); |
| 168 | + |
| 169 | + |
| 170 | + // Handling for field sftp_settings |
| 171 | + $body = $response->getBody(); |
| 172 | + $body = $body['sftp_settings']; |
| 173 | + $returnValues['fetchSftpSettings'] = $this->fillWithData($body); |
| 174 | + |
| 175 | + return array_values($returnValues)[0]; |
| 176 | + } |
| 177 | + |
| 178 | +} |
0 commit comments