@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | class Site |
| 10 | 10 | { |
| 11 | 11 | public function __construct() { |
| 12 | - $this->key = '?api_key='.config('laravel-solaredge-api.key'); |
|
| 12 | + $this->key = '?api_key=' . config('laravel-solaredge-api.key'); |
|
| 13 | 13 | $this->id = config('laravel-solaredge-api.installation_id'); |
| 14 | 14 | $this->endpoint = 'https://monitoringapi.solaredge.com/'; |
| 15 | 15 | } |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | * @param $siteProperty |
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | - function getFromSite($siteProperty){ |
|
| 25 | + function getFromSite($siteProperty) { |
|
| 26 | 26 | $request = Curl::to($this->endpoint . 'site/' . $this->id . '/' . $siteProperty . $this->key)->asJson()->get(); |
| 27 | 27 | return $request; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - function getFromSiteWithStartAndEnd($siteProperty,$timeUnit,$startDate,$endDate,$withTime = false){ |
|
| 31 | - if(!$withTime) { |
|
| 30 | + function getFromSiteWithStartAndEnd($siteProperty, $timeUnit, $startDate, $endDate, $withTime = false) { |
|
| 31 | + if (!$withTime) { |
|
| 32 | 32 | $request = |
| 33 | 33 | Curl::to($this->endpoint . 'site/' . $this->id . '/' . $siteProperty . |
| 34 | 34 | $this->key . |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Get Site details |
| 54 | 54 | * @return mixed |
| 55 | 55 | */ |
| 56 | - function details(){ |
|
| 56 | + function details() { |
|
| 57 | 57 | $request = self::getFromSite('details')->{'details'}; |
| 58 | 58 | |
| 59 | 59 | $details = collect(); |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | * Get Site energy |
| 81 | 81 | * @return mixed |
| 82 | 82 | */ |
| 83 | - function energy($subtractDays, $asc = true){ |
|
| 83 | + function energy($subtractDays, $asc = true) { |
|
| 84 | 84 | $start = Carbon::now()->subDays($subtractDays-1)->format('Y-m-d'); |
| 85 | 85 | $end = Carbon::now()->format('Y-m-d'); |
| 86 | - $request = self::getFromSiteWithStartAndEnd('energy','QUARTER_OF_AN_HOUR', $start, $end)->{'energy'}; |
|
| 86 | + $request = self::getFromSiteWithStartAndEnd('energy', 'QUARTER_OF_AN_HOUR', $start, $end)->{'energy'}; |
|
| 87 | 87 | |
| 88 | 88 | $energy = collect(); |
| 89 | 89 | |
| 90 | 90 | $energy->measured_by = $request->measuredBy; |
| 91 | 91 | $energy->unit = $request->unit; |
| 92 | - if($asc == true){ |
|
| 92 | + if ($asc == true) { |
|
| 93 | 93 | $energy->days = collect($request->values)->sortBy('date')->reverse(); |
| 94 | 94 | } |
| 95 | - elseif($asc == false) { |
|
| 95 | + elseif ($asc == false) { |
|
| 96 | 96 | $energy->days = collect($request->values)->sortBy('date'); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -103,19 +103,19 @@ discard block |
||
| 103 | 103 | * Get Site power |
| 104 | 104 | * @return mixed |
| 105 | 105 | */ |
| 106 | - function power($subtractDays, $asc = true){ |
|
| 106 | + function power($subtractDays, $asc = true) { |
|
| 107 | 107 | $start = Carbon::now()->subDays($subtractDays-1)->format('Y-m-d%20H:i:s'); |
| 108 | 108 | $end = Carbon::now()->format('Y-m-d%20H:i:s'); |
| 109 | - $request = self::getFromSiteWithStartAndEnd('power','DAY', $start, $end,true)->{'power'}; |
|
| 109 | + $request = self::getFromSiteWithStartAndEnd('power', 'DAY', $start, $end, true)->{'power'}; |
|
| 110 | 110 | |
| 111 | 111 | $power = collect(); |
| 112 | 112 | |
| 113 | 113 | $power->interval = $request->timeUnit; |
| 114 | 114 | $power->unit = $request->unit; |
| 115 | - if($asc == true){ |
|
| 115 | + if ($asc == true) { |
|
| 116 | 116 | $power->days = collect($request->values)->sortBy('date')->reverse(); |
| 117 | 117 | } |
| 118 | - elseif($asc == false) { |
|
| 118 | + elseif ($asc == false) { |
|
| 119 | 119 | $power->days = collect($request->values)->sortBy('date'); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * Get Site overview |
| 127 | 127 | * @return mixed |
| 128 | 128 | */ |
| 129 | - function overview(){ |
|
| 129 | + function overview() { |
|
| 130 | 130 | $request = self::getFromSite('overview')->{'overview'}; |
| 131 | 131 | |
| 132 | 132 | $overview = collect(); |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | '&endDate=' . $endDate . |
| 37 | 37 | '&timeUnit=' . $timeUnit |
| 38 | 38 | )->asJson()->get(); |
| 39 | - } |
|
| 40 | - else { |
|
| 39 | + } else { |
|
| 41 | 40 | $request = |
| 42 | 41 | Curl::to($this->endpoint . 'site/' . $this->id . '/' . $siteProperty . |
| 43 | 42 | $this->key . |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | $energy->unit = $request->unit; |
| 92 | 91 | if($asc == true){ |
| 93 | 92 | $energy->days = collect($request->values)->sortBy('date')->reverse(); |
| 94 | - } |
|
| 95 | - elseif($asc == false) { |
|
| 93 | + } elseif($asc == false) { |
|
| 96 | 94 | $energy->days = collect($request->values)->sortBy('date'); |
| 97 | 95 | } |
| 98 | 96 | |
@@ -114,8 +112,7 @@ discard block |
||
| 114 | 112 | $power->unit = $request->unit; |
| 115 | 113 | if($asc == true){ |
| 116 | 114 | $power->days = collect($request->values)->sortBy('date')->reverse(); |
| 117 | - } |
|
| 118 | - elseif($asc == false) { |
|
| 115 | + } elseif($asc == false) { |
|
| 119 | 116 | $power->days = collect($request->values)->sortBy('date'); |
| 120 | 117 | } |
| 121 | 118 | |
@@ -13,19 +13,19 @@ |
||
| 13 | 13 | $this->site = $site; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public function details(){ |
|
| 16 | + public function details() { |
|
| 17 | 17 | return $this->site->details(); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function power(){ |
|
| 21 | - return $this->site->power(7,true); |
|
| 20 | + public function power() { |
|
| 21 | + return $this->site->power(7, true); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function energy(){ |
|
| 25 | - return $this->site->energy(7,true); |
|
| 24 | + public function energy() { |
|
| 25 | + return $this->site->energy(7, true); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function overview(){ |
|
| 28 | + public function overview() { |
|
| 29 | 29 | return $this->site->overview(); |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |