Completed
Push — master ( f77348...ad6f80 )
by Sergey
03:41
created

Conversations   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 6
Bugs 0 Features 1
Metric Value
wmc 2
c 6
b 0
f 1
lcom 1
cbo 4
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendMessage() 0 10 1
A last() 0 8 1
1
<?php
2
namespace seregazhuk\PinterestBot\Api\Providers;
3
4
use seregazhuk\PinterestBot\Api\Request;
5
use seregazhuk\PinterestBot\Helpers\UrlHelper;
6
7
class Conversations extends Provider
8
{
9
    protected $loginRequired = ['last', 'sendMessage'];
10
11
    /**
12
     * Send message to a user
13
     *
14
     * @param $userId
15
     * @param $text
16
     *
17
     * @return bool
18
     */
19
    public function sendMessage($userId, $text)
20
    {
21
        $requestOptions = array(
22
            "user_ids" => array($userId),
23
            "emails"   => array(),
24
            "text"     => $text,
25
        );
26
27
        return $this->callPostRequest($requestOptions, UrlHelper::RESOURCE_SEND_MESSAGE);
28
    }
29
30
    /**
31
     * Get last user conversations
32
     *
33
     * @return array|bool
34
     */
35
    public function last()
36
    {
37
        $response = $this->request->exec(
38
            UrlHelper::RESOURCE_GET_LAST_CONVERSATIONS.'?'.Request::createQuery()
39
        );
40
41
        return $this->response->getData($response);
42
    }
43
}
44