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

Conversations::last()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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