diff --git a/composer.json b/composer.json index d5c5ef79..2d0b021b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "seregazhuk/pinterest-bot", + "name": "maparole/pinterest-bot", "description": "PHP library for Pintrest", "keywords": [ "php", diff --git a/src/Api/Providers/BoardSections.php b/src/Api/Providers/BoardSections.php index 39e05d0e..3596cbdb 100644 --- a/src/Api/Providers/BoardSections.php +++ b/src/Api/Providers/BoardSections.php @@ -50,7 +50,7 @@ public function update($sectionId, $title) { $requestOptions = [ 'section_id' => $sectionId, - 'name' => $title, + 'title' => $title, ]; return $this->post(UrlBuilder::RESOURCE_EDIT_BOARD_SECTION, $requestOptions); diff --git a/src/Api/Providers/Boards.php b/src/Api/Providers/Boards.php index f66fb308..375ea088 100644 --- a/src/Api/Providers/Boards.php +++ b/src/Api/Providers/Boards.php @@ -106,8 +106,8 @@ public function info($username, $board) */ protected function formatBoardName($board) { - $nameWithRemovedSpaces = str_replace(' ', '-', $board); - return function_exists('mb_strtolower') ? mb_strtolower($nameWithRemovedSpaces) : strtolower($nameWithRemovedSpaces); + $nameWithRemovedSpacesAndSingleQuotes = str_replace([' ', "'"], ['-', ''], $board); + return function_exists('mb_strtolower') ? mb_strtolower($nameWithRemovedSpacesAndSingleQuotes) : strtolower($nameWithRemovedSpacesAndSingleQuotes); } /** @@ -138,10 +138,6 @@ public function pins($boardId, $limit = Pagination::DEFAULT_LIMIT) */ public function update($boardId, $attributes) { - if (isset($attributes['name'])) { - $attributes['name'] = $this->formatBoardName($attributes['name']); - } - $requestOptions = array_merge( [ 'board_id' => $boardId, diff --git a/tests/Bot/Providers/BoardsTest.php b/tests/Bot/Providers/BoardsTest.php index 1e2ff249..de8c628a 100644 --- a/tests/Bot/Providers/BoardsTest.php +++ b/tests/Bot/Providers/BoardsTest.php @@ -75,6 +75,21 @@ public function it_formats_a_board_name_with_spaces_when_fetching_its_info() $this->assertWasGetRequest(UrlBuilder::RESOURCE_GET_BOARD, $request); } + /** @test */ + public function it_formats_a_board_name_with_single_quotes_when_fetching_its_info() + { + $provider = $this->getProvider(); + + $provider->info('johnDoe', "'my board's name'"); + + $request = [ + 'slug' => 'my-boards-name', + 'username' => 'johnDoe', + 'field_set_key' => 'detailed', + ]; + $this->assertWasGetRequest(UrlBuilder::RESOURCE_GET_BOARD, $request); + } + /** @test */ public function it_creates_a_public_board() {