• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

amalfra / supportbee / 22672668775

04 Mar 2026 02:00PM UTC coverage: 30.822% (+4.5%) from 26.282%
22672668775

push

github

amalfra
make php 8.4 as min required version

45 of 146 relevant lines covered (30.82%)

0.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.89
/src/Client.php
1
<?php
2

3
namespace Amalfra\SupportBee;
4

5
use Amalfra\SupportBee\Exceptions\ConfigException;
6
use Amalfra\SupportBee\API\Tickets;
7
use Amalfra\SupportBee\API\Replies;
8
use Amalfra\SupportBee\API\Comments;
9
use Amalfra\SupportBee\API\Agents;
10
use Amalfra\SupportBee\API\Labels;
11
use Amalfra\SupportBee\API\Snippets;
12
use Amalfra\SupportBee\API\WebHooks;
13
use Amalfra\SupportBee\API\Reports;
14
use Amalfra\SupportBee\API\Emails;
15

16
/**
17
 * Class Client
18
 *
19
 * @package Amalfra\SupportBee
20
 */
21
class Client {
22
  const BASE = 'https://COMPANY.supportbee.com/';
23

24
  public static $base_url   = null;
25
  public static $auth_token = null;
26
  public static $headers    = array();
27

28
  public function __construct($config = array()) {
29
    $this->validate($config);
4✔
30

31
    self::$base_url = str_replace('COMPANY', $config['company'], self::BASE);
1✔
32
    self::$auth_token = $config['token'];
1✔
33

34
    self::$headers = array(
1✔
35
      'Content-Type' => 'application/json',
1✔
36
      'Accept'       => 'application/json'
1✔
37
    );
1✔
38
  }
39

40
  /**
41
   * Validates the SupportBee configuration options
42
   *
43
   * @params  array       $config
44
   *
45
   * @throws  SupportBee\Exceptions\ConfigException    When a config value does not meet its validation criteria
46
   */
47
  private function validate($config) {
48
    if (count($config) == 0) {
4✔
49
      throw new ConfigException('Auth token and company need to be set.');
1✔
50
    }
51

52
    if (!isset($config['token'])) {
3✔
53
      throw new ConfigException('Token is required.');
1✔
54
    }
55

56
    if (!isset($config['company'])) {
2✔
57
      throw new ConfigException('Company name is required.');
1✔
58
    }
59
  }
60

61
  public function tickets($options = array()) {
62
    return new Tickets()->tickets($options);
×
63
  }
64

65
  public function ticket($id = 0) {
66
    return new Tickets()->get_ticket($id);
×
67
  }
68

69
  public function createTicket($options = array()) {
70
    return new Tickets()->create_ticket($options);
×
71
  }
72

73
  public function deleteTicket($id = 0) {
74
    return new Tickets()->delete_ticket($id);
×
75
  }
76

77
  public function archiveTicket($id = 0) {
78
    return new Tickets()->archive_ticket($id);
×
79
  }
80

81
  public function unarchiveTicket($id = 0) {
82
    return new Tickets()->unarchive_ticket($id);
×
83
  }
84

85
  public function assignTicketToUser($id = 0, $options = array()) {
86
    return new Tickets()->assign_ticket_to_user($id, $options);
×
87
  }
88

89
  public function spamTicket($id = 0) {
90
    return new Tickets()->spam_ticket($id);
×
91
  }
92

93
  public function unspamTicket($id = 0) {
94
    return new Tickets()->unspam_ticket($id);
×
95
  }
96

97
  public function trashTicket($id = 0) {
98
    return new Tickets()->trash_ticket($id);
×
99
  }
100

101
  public function untrashTicket($id = 0) {
102
    return new Tickets()->untrash_ticket($id);
×
103
  }
104
  
105
  public function addLabelToTicket($id = 0, $label = '') {
106
    return new Tickets()->add_label($id, $label);
×
107
  }
108
  
109
  public function removeLabelFromTicket($id = 0, $label = '') {
110
    return new Tickets()->remove_label($id, $label);
×
111
  }
112

113
  public function searchTickets($options = array()) {
114
    if (!is_array($options)) {
×
115
      $options = array('query' => $options);
×
116
    }
117

118
    return new Tickets()->search($options);
×
119
  }
120

121
  public function replies($id = 0) {
122
    return new Replies()->replies($id);
×
123
  }
124

125
  public function reply($ticket_id = 0, $reply_id = 0) {
126
    return new Replies()->get_reply($ticket_id, $reply_id);
×
127
  }
128

129
  public function comments($id = 0) {
130
    return new Comments()->comments($id);
×
131
  }
132

133
  public function createComment($ticket_id = 0, $options = array()) {
134
    return new Comments()->create_comment($ticket_id, $options);
×
135
  }
136

137
  public function agents($options = array()) {
138
    if (!is_array($options)) {
×
139
      $options = array('with_invited' => $options);
×
140
    }
141

142
    return new Agents()->agents($options);
×
143
  }
144

145
  public function agent($id = 0) {
146
    return new Agents()->get_agent($id);
×
147
  }
148

149
  public function labels() {
150
    return new Labels()->labels();
×
151
  }
152

153
  public function snippets() {
154
    return new Snippets()->snippets();
×
155
  }
156

157
  public function webhooks() {
158
    return new WebHooks()->webhooks();
×
159
  }
160

161
  public function avgFirstResponseTimeReport($options = array()) {
162
    return new Reports()->avg_first_response_time_report($options);
×
163
  }
164

165
  public function ticketsCountReport($options = array()) {
166
    return new Reports()->tickets_count_report($options);
×
167
  }
168

169
  public function repliesCountReport($options = array()) {
170
    return new Reports()->replies_count_report($options);
×
171
  }
172

173
  public function emails() {
174
    return new Emails()->emails();
×
175
  }
176

177
  public function createEmail($options = array()) {
178
    return new Emails()->create_email($options);
×
179
  }
180
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc