This repository has been archived by the owner on Dec 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from seregazhuk/develop
Develop
- Loading branch information
Showing
9 changed files
with
268 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,12 @@ if you don't use such operations as creating pins, writing comments or sending m | |
- [Topics](#topics) | ||
- [Search](#search) | ||
- [Inbox](#inbox) | ||
- [News](#news) | ||
- [Notifications](#notifications) | ||
- [Conversations](#conversations) | ||
- [Write a message](#write-a-message) | ||
- [Send email](#send-email) | ||
- [Contact requests](#contact-requests) | ||
- [Keywords](#keywords) | ||
- [Errors handling](#errors-handling) | ||
- [Use proxy](#use-proxy) | ||
|
@@ -260,6 +266,11 @@ Get your current username: | |
$username = $bot->user->username(); | ||
``` | ||
|
||
Get your current user id: | ||
```php | ||
$userId = $bot->user->id(); | ||
``` | ||
|
||
Check if your account is banned: | ||
```php | ||
if ($bot->user->isBanned() { | ||
|
@@ -382,11 +393,44 @@ $bot->boards->sendWithEmail($boardId, 'Message', '[email protected]'); // One e | |
$bot->boards->sendWithEmail($boardId, 'Message', ['[email protected]', '[email protected]']); // many | ||
``` | ||
|
||
### Invites | ||
|
||
Get your boards invites: | ||
```php | ||
$invites = $bot->boards->invites(); | ||
``` | ||
|
||
Invite someone to your board: | ||
```php | ||
// to a user by email | ||
$bot->boards->sendInvite($boardId, '[email protected]'); | ||
|
||
// to a user by user id | ||
$bot->boards->sendInvite($boardId, $userId); | ||
|
||
// to users by email | ||
$bot->boards->sendInvite($boardId, ['[email protected]', '[email protected]']); | ||
// to users by user id | ||
$bot->boards->sendInvite($boardId, [$user1Id, $user2Id]); | ||
``` | ||
|
||
Accept an invite to a board: | ||
```php | ||
$bot->boards->acceptInvite($boardId); | ||
``` | ||
|
||
Ignore an invite to a board: | ||
```php | ||
$bot->boards->ignoreInvite($boardId); | ||
``` | ||
|
||
Delete invite. Removes from the board collaborators, requires an id of the user, you want to remove from the board: | ||
```php | ||
$bot->boards->deleteInvite($boardId, $userId); | ||
// also you can ban a user specifying third argument as true | ||
$bot->boards->deleteInvite($boardId, $userId, true); | ||
``` | ||
|
||
## Pins | ||
|
||
Notice! Try not to be very aggressive when pinning or commenting pins, or Pinterest will gonna ban you. | ||
|
@@ -877,6 +921,27 @@ Attach pin to email: | |
$bot->inbox->sendEmail('[email protected]', 'message text', $pindId); | ||
``` | ||
|
||
### Contact requests | ||
When someone at first sends you an invitation to a board, you receive a contact request. | ||
Get a list of contact requests: | ||
|
||
```php | ||
$requests = $bot->inbox->contactRequests(); | ||
``` | ||
|
||
To accept or to ignore a request you need to specify a request ID. This ID can be received from the array | ||
returned in `$bot->inbox->contactRequests()` method. | ||
|
||
Accept a request: | ||
```php | ||
$bot->inbox->acceptContactRequest($requestId); | ||
``` | ||
|
||
Ignore a request: | ||
```php | ||
$bot->inbox->ignoreContactRequest($requestId); | ||
``` | ||
|
||
## Keywords | ||
Get recommended keywords for the query: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
namespace seregazhuk\PinterestBot\Api\Traits; | ||
|
||
use seregazhuk\PinterestBot\Helpers\UrlBuilder; | ||
|
||
trait BoardsInvites | ||
{ | ||
use HandlesRequest; | ||
|
||
/** | ||
* Get boards invites | ||
* @return array | ||
*/ | ||
public function invites() | ||
{ | ||
$data = [ | ||
'current_user' => true, | ||
'field_set_key' => 'news', | ||
]; | ||
|
||
$invites = $this->get($data, UrlBuilder::RESOURCE_BOARDS_INVITES); | ||
|
||
return !$invites ? [] : $invites; | ||
} | ||
|
||
/** | ||
* @param string $boardId | ||
* @param string|array $emails | ||
* @return bool | ||
*/ | ||
public function sendInviteByEmail($boardId, $emails) | ||
{ | ||
$emails = is_array($emails) ? $emails : [$emails]; | ||
$data = [ | ||
"board_id" => $boardId, | ||
"emails" => $emails, | ||
]; | ||
|
||
return $this->post($data, UrlBuilder::RESOURCE_CREATE_EMAIL_INVITE); | ||
} | ||
|
||
/** | ||
* @param string $boardId | ||
* @param string|array $users | ||
* @return bool | ||
*/ | ||
public function sendInvite($boardId, $users) | ||
{ | ||
$users = is_array($users) ? $users : [$users]; | ||
|
||
$isEmail = filter_var($users[0], FILTER_VALIDATE_EMAIL); | ||
|
||
return $isEmail ? | ||
$this->sendInviteByEmail($boardId, $users) : | ||
$this->sendInviteByUserId($boardId, $users); | ||
} | ||
|
||
/** | ||
* @param string $boardId | ||
* @param string|array $userIds | ||
* @return bool | ||
*/ | ||
public function sendInviteByUserId($boardId, $userIds) | ||
{ | ||
$userIds = is_array($userIds) ? $userIds : [$userIds]; | ||
$data = [ | ||
"board_id" => $boardId, | ||
"invited_user_ids" => $userIds, | ||
]; | ||
|
||
return $this->post($data, UrlBuilder::RESOURCE_CREATE_USER_ID_INVITE); | ||
} | ||
|
||
/** | ||
* @param string $boardId | ||
* @param string $userId | ||
* @param bool $ban | ||
* @return bool | ||
*/ | ||
public function deleteInvite($boardId, $userId, $ban = false) | ||
{ | ||
$data = [ | ||
'ban' => $ban, | ||
'board_id' => $boardId, | ||
'field_set_key' => 'boardEdit', | ||
'invited_user_id' => $userId, | ||
]; | ||
|
||
return $this->post($data, UrlBuilder::RESOURCE_DELETE_INVITE); | ||
} | ||
|
||
/** | ||
* @param string $boardId | ||
* @return bool | ||
*/ | ||
public function ignoreInvite($boardId) | ||
{ | ||
$data = [ | ||
'board_id' => $boardId, | ||
'invited_user_id' => $this->container->user->id(), | ||
]; | ||
|
||
return $this->post($data, UrlBuilder::RESOURCE_DELETE_INVITE); | ||
} | ||
|
||
/** | ||
* @param string $boardId | ||
* @return bool | ||
*/ | ||
public function acceptInvite($boardId) | ||
{ | ||
$data = [ | ||
'board_id' => $boardId, | ||
'invited_user_id' => $this->container->user->id(), | ||
]; | ||
|
||
return $this->post($data, UrlBuilder::RESOURCE_ACCEPT_INVITE); | ||
} | ||
} |
Oops, something went wrong.