Code Duplication    Length = 47-48 lines in 2 locations

src/Api/Customer.php 1 location

@@ 8-54 (lines=47) @@
5
use Groove\Api;
6
use Groove\Models\Customer as Model;
7
8
class Customer extends Api
9
{
10
    /**
11
     * List customers.
12
     *
13
     * @param  array $params
14
     * @return \Illuminate\Support\Collection
15
     */
16
    public function list($params = [])
17
    {
18
        $response = $this->client->get('customers', $params);
19
20
        return collect($response->customers)->transform(function ($customer) {
21
            return new Model($customer, $this->client);
22
        });
23
    }
24
25
    /**
26
     * Find a customer.
27
     *
28
     * @param  string $email
29
     * @return Model
30
     */
31
    public function find($email)
32
    {
33
        $response = $this->client->get("customers/$email");
34
35
        return new Model($response->customer, $this->client);
36
    }
37
38
    /**
39
     * Update a customer.
40
     *
41
     * @param  string $existingEmail
42
     * @param  string $updatedEmail
43
     * @param  array $params
44
     * @return Model
45
     */
46
    public function update($existingEmail, $updatedEmail, $params = [])
47
    {
48
        $params = array_merge(['email' => $updatedEmail], $params);
49
50
        $response = $this->client->put("customers/$existingEmail", $params);
51
52
        return new Model($response->customer, $this->client);
53
    }
54
}
55

src/Api/Message.php 1 location

@@ 8-55 (lines=48) @@
5
use Groove\Api;
6
use Groove\Models\Message as Model;
7
8
class Message extends Api
9
{
10
    /**
11
     * List messages for a ticket.
12
     *
13
     * @param  int $ticketNumber
14
     * @param  array $params
15
     * @return \Illuminate\Support\Collection
16
     */
17
    public function list($ticketNumber, $params = [])
18
    {
19
        $response = $this->client->get("tickets/$ticketNumber/messages", $params);
20
21
        return collect($response->messages)->transform(function ($ticket) {
22
            return new Model($ticket, $this->client);
23
        });
24
    }
25
26
    /**
27
     * Find a message.
28
     *
29
     * @param  int|string $messageID
30
     * @return Model
31
     */
32
    public function find($messageID)
33
    {
34
        $response = $this->client->get("messages/$messageID");
35
36
        return new Model($response->message, $this->client);
37
    }
38
39
    /**
40
     * Create a message for a ticket.
41
     *
42
     * @param  int $ticketNumber
43
     * @param  string $body
44
     * @param  array $params
45
     * @return Model
46
     */
47
    public function create($ticketNumber, $body, $params = [])
48
    {
49
        $params = array_merge(['body' => $body], $params);
50
51
        $response = $this->client->post("tickets/$ticketNumber/messages", $params);
52
53
        return new Model($response->message, $this->client);
54
    }
55
}
56