You are here

public function HttpServiceApiWrapperPosts::createPost in HTTP Client Manager 8.2

Create Post.

Parameters

string $title: The Post title.

mixed $body: The Post body.

Return value

array The service response array.

File

modules/http_client_manager_example/src/Plugin/HttpServiceApiWrapper/HttpServiceApiWrapperPosts.php, line 33

Class

HttpServiceApiWrapperPosts
Class HttpServiceApiWrapperPosts.

Namespace

Drupal\http_client_manager_example\Plugin\HttpServiceApiWrapper

Code

public function createPost($title, $body) {
  $args = [
    'userId' => $this->currentUser
      ->id(),
    'title' => $title,
    'body' => $body,
  ];
  return $this
    ->call(Posts::CREATE_POST, $args)
    ->toArray();
}