summaryrefslogtreecommitdiffstats
path: root/lib/resources/api_keys.php
blob: d72c175082e85fba9f1dbda619b5676b71896d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

class APIKeys
{
  protected
    $name,
    $base_endpoint,
    $endpoint,
    $client;
  
  public function __construct($client, $options=NULL)
  {
    $this->name = NULL;
    $this->base_endpoint = "/v3/api_keys";
    $this->endpoint = "/v3/api_keys";
    $this->client = $client;
  }
  
  public function getBaseEndpoint(){
    return $this->base_endpoint;
  }
  
  public function getEndpoint(){
    return $this->endpoint;
  }
  
  public function getName(){
    return $this->name;
  }
  
  public function setEndpoint($endpoint){
    $this->endpoint = $endpoint;
  }
  
  public function get(){
    return $this->client->getRequest($this);
  }
  
  public function post($name){
    $data = array(
      'name' => $name,
    );
    return $this->client->postRequest($this, $data);
  }
  
  public function patch($api_key_id, $name){
    $data = array(
      'name' => $name,
    );
    $this->endpoint = $this->base_endpoint . "/" . $api_key_id; 
    return $this->client->patchRequest($this, $data);
  }  
  
  public function delete($api_key_id){
    $this->endpoint = $this->base_endpoint . "/" . $api_key_id;
    return $this->client->deleteRequest($this);
  }
}