Test Failed
Pull Request — master (#38)
by Patrick
16:04 queued 12:22
created

ProjektronClientFacade::writeActivities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\ProjektronClient;
13
14
use ForecastAutomation\Activity\Shared\Dto\ActivityDtoCollection;
15
use ForecastAutomation\Kernel\AbstractFacade;
16
use ForecastAutomation\ProjektronClient\Business\PayloadDTO;
17
18
/**
19
 * @method \ForecastAutomation\JiraClient\JiraClientFactory getFactory()
20
 */
21
class ProjektronClientFacade extends AbstractFacade
22
{
23
    private $url;
24
    private $headers;
25
    private $payloadDTO;
26
27
    public function send() {
28
        $this->url = 'https://projektron.valantic.com/bcs/taskdetail/effortrecording/edit?oid=1701894153411_JTask';
29
        $this->headers = [
30
            'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
31
            'Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7',
32
            'Cache-Control: no-cache',
33
            'Connection: keep-alive',
34
            'Content-Type: application/x-www-form-urlencoded',
35
            'Cookie: _gcl_au=1.1.1981414287.1723202755; __qca=P0-1366456151-1723202755461; OAuthCSRFState=9JN6PUckKBwKzJXLPJt-hxcI1mD5dO2LG2G7fSL1z4A; TABLET=false; COLOR_SCHEME=Light; JSESSIONID=F73E27B955FC0B5C37FFC09E3234C8FD; BROWSER_ENCRYPTION_KEY=vtzQfWGcFnlGthQeytSHMA4JK7KsRufo88WdH+Wq0WQ=; CSRF_Token=B54W-Zkk-aHq9JDFzCIUtOOBjbTYrKmDxRJrh1Ofpck',
36
            'Origin: null',
37
            'Pragma: no-cache',
38
            'Sec-Fetch-Dest: document',
39
            'Sec-Fetch-Mode: navigate',
40
            'Sec-Fetch-Site: same-origin',
41
            'Sec-Fetch-User: ?1',
42
            'Upgrade-Insecure-Requests: 1',
43
            'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
44
            'sec-ch-ua: "Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
45
            'sec-ch-ua-mobile: ?0',
46
            'sec-ch-ua-platform: "Linux"'
47
        ];
48
        $this->payloadDTO = new PayloadDTO();
49
50
        $ch = curl_init($this->url);
51
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
52
        curl_setopt($ch, CURLOPT_POST, true);
53
        curl_setopt($ch, CURLOPT_POSTFIELDS, $this->payloadDTO->getEncodedData());
54
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
55
56
        $response = curl_exec($ch);
57
        if (curl_errno($ch)) {
58
            throw new Exception(curl_error($ch));
0 ignored issues
show
Bug introduced by
The type ForecastAutomation\ProjektronClient\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
59
        }
60
        curl_close($ch);
61
62
        return $response;
63
    }
64
65
    public function writeActivities(ActivityDtoCollection $activityDtoCollection): int
66
    {
67
//        https://projektron.valantic.com/bcs/login
68
        $this->send();
69
        $test = $activityDtoCollection;
0 ignored issues
show
Unused Code introduced by
The assignment to $test is dead and can be removed.
Loading history...
70
        return 10;
71
    }
72
}
73