mikemiles86/bazaarvoice-conversations-api

PHP Wrapper for the Bazaarvoice Conversations API

1.0.3 2017-07-11 12:06 UTC

This package is auto-updated.

Last update: 2024-11-05 00:31:08 UTC


README

Latest Version on Packagist Software License Total Downloads

PHP Wrapper for the Bazaarvoice Conversations API

Install

Via Composer

$ composer require mikemiles86/bazaarvoice-conversations-api

Usage

Creating a Conversations Object

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

Content Types

All conversation API content types are supported.

Depending on the specific content type, data can be retrieved and sent to Bazaarvoice.

Get wrapper for Reviews content type.

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');

Make a raw request

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$response = $conversations_wrapper->apiRequest('data/reviews');

Retrieve Content

Retrieve content for Content Type by Id.

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');

$review = $reviews_wrapper->getResultById('review_1234');

Retrieve content for Content Type by other parameters

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');

$configuration = [
  'arguments' => [
    'ProductId' => 'my_product',
  ],
];

$response = $reviews_wrapper->retrieveRequest($configuration);

$product_reviews = $response->getResponse('Results');

Submit Content

Get Submission Form

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');

$reviews_submit_form = $reviews_wrapper->getSubmissionForm();

Preview Submission

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');

$submission_data = [
  'Rating' => 5,
  'ReviewText' => 'This is my Review',
];

$reviews_wrapper->previewSubmission($submission_data);

Submit Submission

$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);

$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);

$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');

$submission_data = [
  'Rating' => 5,
  'ReviewText' => 'This is my Review',
];

$reviews_wrapper->submitSubmission($submission_data);

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see License File for more information.