WowPress-Tailwind/theme/wowpress/Api/WoWAudit.php

52 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2024-04-15 23:07:29 +02:00
<?php
namespace WoWPress\Api;
2024-04-23 00:44:42 +02:00
use WoWPress\Models\Character;
2024-05-02 23:31:44 +02:00
use WoWPress\Models\Log;
2024-04-23 00:44:42 +02:00
use WoWPress\Models\Raid;
2024-05-02 23:31:44 +02:00
use WoWPress\Models\User;
2024-04-23 00:44:42 +02:00
2024-04-15 23:07:29 +02:00
class WoWAudit extends Api{
protected $api_url = "https://www.wowaudit.com/v1/";
public function getRaids($include_past=false)
{
return $this->get('raids', ['include_past' => $include_past?"true":"false"],true,5);
}
2024-04-22 15:38:22 +02:00
public function getRaid($id,$force)
2024-04-15 23:07:29 +02:00
{
2024-04-22 15:38:22 +02:00
return $this->get("raids/$id", [], true, $force?-1:5);
2024-04-15 23:07:29 +02:00
}
public function getRoster(){
return $this->get("characters",[],true,5);
}
2024-04-23 00:44:42 +02:00
public function changeSignup($raid,$character,$status,$role,$comment="",$second_char=null){
if(empty($character->ID) || empty($raid->ID)) return false;
$body = [
'id' => $raid->id_wowaudit,
'signup_changes' => [
[
'character_id' => $character->id_wowaudit,
'status' => $status,
'role' => $role,
'class' => $second_char->ID?$second_char->class:$character->class,
'comment' => $comment,
]
],
];
$url = "raids/".$raid->id_wowaudit;
2024-05-02 23:31:44 +02:00
Log::write(json_encode(['char' => $character->name."-".$character->realm,'status' => $status,"role" => $role,'user' => User::find(get_current_user_id())->user_login]),Log::LOG_SIGNUP);
2024-04-23 00:44:42 +02:00
return $this->put($url,$body);
}
2024-04-15 23:07:29 +02:00
}