| Total Complexity | 4 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 7 | class Document extends AbstractResource |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Document constructor. |
||
| 11 | * |
||
| 12 | * @param null|string|array $values |
||
| 13 | * @param null|Client $client |
||
| 14 | */ |
||
| 15 | public function __construct($values = null, Client $client = null) |
||
| 23 | } |
||
| 24 | |||
| 25 | |||
| 26 | /** |
||
| 27 | * Upload a document using a multipart form. |
||
| 28 | * |
||
| 29 | * @param string $type |
||
| 30 | * @param string $file |
||
| 31 | * @param string|null $candidateId |
||
| 32 | * |
||
| 33 | * @return $this |
||
| 34 | */ |
||
| 35 | public function upload($type, $file, $candidateId = null) |
||
| 36 | { |
||
| 37 | if ($candidateId !== null) { |
||
| 38 | $this->setAttribute('candidate_id', $candidateId); |
||
| 39 | } |
||
| 40 | |||
| 41 | $response = $this->uploadRequest($this->processPath('candidates/:candidate_id/documents', |
||
| 42 | ['candidate_id' => $this->getAttribute('candidate_id')]), |
||
| 43 | ['multipart' => [ |
||
| 44 | ['name' => 'type', 'contents' => $type], |
||
| 45 | ['name' => 'file', 'contents' => fopen($file, 'rb')], |
||
| 46 | ], |
||
| 47 | ]); |
||
| 48 | $this->setAttributes([]); |
||
| 49 | $this->setValues($response); |
||
| 50 | |||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | protected function uploadRequest($path, $options) |
||
| 57 | } |
||
| 58 | } |
||
| 59 |