1
0
mirror of synced 2024-11-25 06:46:07 +03:00

marketplace api method (#31)

* marketplace integration
* update tests
This commit is contained in:
Alex Lushpai 2016-11-28 14:38:03 +03:00 committed by GitHub
parent 0fad2158be
commit 8c583de05b
7 changed files with 77 additions and 9 deletions

View File

@ -5,7 +5,6 @@ cache:
- $HOME/.composer/cache - $HOME/.composer/cache
php: php:
- '5.3'
- '5.4' - '5.4'
- '5.5' - '5.5'
- '5.6' - '5.6'

View File

@ -13,7 +13,8 @@
], ],
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.3.0",
"ext-curl": "*" "ext-curl": "*",
"phpunit/phpunit": "4.8.29"
}, },
"support": { "support": {
"email": "support@retailcrm.pro" "email": "support@retailcrm.pro"

View File

@ -1754,6 +1754,32 @@ class ApiClient
); );
} }
/**
* Edit marketplace configuration
*
* @param array $configuration
*
* @throws \RetailCrm\Exception\InvalidJsonException
* @throws \RetailCrm\Exception\CurlException
* @throws \InvalidArgumentException
*
* @return ApiResponse
*/
public function marketplaceSettingsEdit(array $configuration)
{
if (!count($configuration) || empty($configuration['code'])) {
throw new \InvalidArgumentException(
'Parameter `configuration` must contains a data & configuration `code` must be set'
);
}
return $this->client->makeRequest(
sprintf('/marketplace/external/setting/%s/edit', $configuration['code']),
Client::METHOD_POST,
array('configuration' => json_encode($configuration))
);
}
/** /**
* Update CRM basic statistic * Update CRM basic statistic
* *

View File

@ -0,0 +1,44 @@
<?php
/**
* PHP version 5.3
*
* API client marketplace test class
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
namespace RetailCrm\Tests;
use RetailCrm\Test\TestCase;
class ApiClientMarketplaceTest extends TestCase
{
const SNAME = 'Marketplace integration';
const SCODE = 'integration';
/**
* @group marketplace
*/
public function testConfigurationEdit()
{
$client = static::getApiClient();
$response = $client->marketplaceSettingsEdit(
array(
'name' => self::SNAME,
'code' => self::SCODE,
'logo' => 'http://download.retailcrm.pro/logos/setup.svg',
'active' => 'true'
)
);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
$this->assertTrue($response->isSuccessful());
}
}

View File

@ -77,16 +77,14 @@ class ApiClientReferenceTest extends TestCase
} }
$response = $client->$method($params); $response = $client->$method($params);
$this->assertEquals(201, $response->getStatusCode()); $this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
$response = $client->$method(array( $response = $client->$method(array(
'code' => $code, 'code' => $code,
'name' => 'Bbb', 'name' => 'Bbb',
)); ));
if ($response->getStatusCode() > 201) {
print_r($response); $this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
}
$this->assertEquals(200, $response->getStatusCode());
} }
/** /**

View File

@ -104,7 +104,7 @@ class ApiClientStoreTest extends TestCase
)); ));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isSuccessful());
} }
/** /**