Skip to content

Commit

Permalink
Merge pull request #395 from Pixelao/main
Browse files Browse the repository at this point in the history
Refactor: Updated naming from resources to endpoints
  • Loading branch information
ksvirkou-hubspot authored Aug 13, 2022
2 parents 32742d3 + abca283 commit d6b3328
Show file tree
Hide file tree
Showing 45 changed files with 371 additions and 371 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $hubspot = new SevenShores\Hubspot\Factory([
]);

// Then you can call a resource
// When referencing resources, use camelCase
// When referencing endpoints, use camelCase

$hubspot->contactlists
```
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class Endpoint
protected $client;

/**
* Makin' a good old resource.
* Makin' a good old endpoint.
*
* @param \SevenShores\Hubspot\Http\Client $client
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Utils
{
public function __call(string $name, $arguments = null)
{
$resource = 'SevenShores\\Hubspot\\Utils\\'.ucfirst($name);
$endpoint = 'SevenShores\\Hubspot\\Utils\\'.ucfirst($name);

return new $resource();
return new $endpoint();
}

public static function getFactory()
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Abstraction/BlogPostTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function setUp(): void
parent::setUp();
}

protected function createPost(BlogPosts $resource)
protected function createPost(BlogPosts $endpoint)
{
$date = new DateTime();

return $resource->create([
return $endpoint->create([
'name' => 'My Super Awesome Post '.uniqid(),
'content_group_id' => $this->blogId,
'publish_date' => $date->getTimestamp(),
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Abstraction/ContactListsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ abstract class ContactListsTestCase extends EntityTestCase
/**
* @var ContactLists
*/
protected $resource;
protected $endpoint;

/**
* @var ContactLists::class
*/
protected $resourceClass = ContactLists::class;
protected $endpointClass = ContactLists::class;

/**
* @var bool
Expand All @@ -33,7 +33,7 @@ public function setUp(): void

protected function createEntity()
{
return $this->resource->create(
return $this->endpoint->create(
[
'name' => 'Test '.uniqid(),
'dynamic' => $this->dynamic,
Expand All @@ -54,6 +54,6 @@ protected function createEntity()

protected function deleteEntity()
{
return $this->resource->delete($this->entity->listId);
return $this->endpoint->delete($this->entity->listId);
}
}
18 changes: 9 additions & 9 deletions tests/Integration/Abstraction/CrmPipelinesTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class CrmPipelinesTestCase extends EntityTestCase
/**
* @var SevenShores\Hubspot\Endpoints\CrmPipelines
*/
protected $resource;
protected $endpoint;

/**
* @var SevenShores\Hubspot\Endpoints\CrmPipelines::class
*/
protected $resourceClass = CrmPipelines::class;
protected $endpointClass = CrmPipelines::class;

public function setUp(): void
{
if (empty($this->resource)) {
$this->resource = new $this->resourceClass($this->getClient(), $this->type);
if (empty($this->endpoint)) {
$this->endpoint = new $this->endpointClass($this->getClient(), $this->type);
}
sleep(1);

Expand All @@ -38,15 +38,15 @@ public function setUp(): void
/** @test */
public function getAllPipelinesTest()
{
$response = $this->resource->all();
$response = $this->endpoint->all();

$this->assertEquals(200, $response->getStatusCode());
}

/** @test */
public function getAllPipelinesIncludingDeleted()
{
$response = $this->resource->all(['includeInactive' => 'INCLUDE_DELETED']);
$response = $this->endpoint->all(['includeInactive' => 'INCLUDE_DELETED']);

$this->assertEquals(200, $response->getStatusCode());
}
Expand All @@ -60,7 +60,7 @@ public function createPipeline()
/** @test */
public function updatePipeline()
{
$response = $this->resource->update(
$response = $this->endpoint->update(
$this->entity->pipelineId,
$this->getData('Updated '.$this->type.' Pipeline')
);
Expand All @@ -80,12 +80,12 @@ public function deletePipeline()

protected function createEntity()
{
return $this->resource->create($this->getData());
return $this->endpoint->create($this->getData());
}

protected function deleteEntity()
{
return $this->resource->delete($this->entity->pipelineId);
return $this->endpoint->delete($this->entity->pipelineId);
}

protected function getData(string $label = null)
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Abstraction/DefaultTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class DefaultTestCase extends TestCase
/**
* @var null|SevenShores\Hubspot\Endpoints\Endpoint
*/
protected $resource;
protected $endpoint;

/**
* @var null|SevenShores\Hubspot\Endpoints\Endpoint::class
*/
protected $resourceClass;
protected $endpointClass;

/**
* @var string
Expand All @@ -30,8 +30,8 @@ public function setUp(): void
{
parent::setUp();

if (empty($this->resource)) {
$this->resource = new $this->resourceClass($this->getClient());
if (empty($this->endpoint)) {
$this->endpoint = new $this->endpointClass($this->getClient());
}
sleep(1);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Abstraction/HubDBRowTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ abstract class HubDBRowTestCase extends EntityTestCase
/**
* @var null|Timeline
*/
protected $resource;
protected $endpoint;

/**
* @var null|Timeline::class
*/
protected $resourceClass = HubDB::class;
protected $endpointClass = HubDB::class;

/**
* @var string
Expand All @@ -34,7 +34,7 @@ public function setUp(): void

protected function createEntity()
{
return $this->resource->createTable('Test Table'.uniqid(), [
return $this->endpoint->createTable('Test Table'.uniqid(), [
[
'name' => 'Name',
'type' => 'TEXT',
Expand All @@ -48,6 +48,6 @@ protected function createEntity()

protected function deleteEntity()
{
return $this->resource->deleteTable($this->entity->id);
return $this->endpoint->deleteTable($this->entity->id);
}
}
10 changes: 5 additions & 5 deletions tests/Integration/Abstraction/PropertiesTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class PropertiesTestCase extends EntityTestCase
/** @test */
public function all()
{
$response = $this->resource->all();
$response = $this->endpoint->all();

$this->assertEquals(200, $response->getStatusCode());
$this->assertGreaterThanOrEqual(1, count($response->getData()));
Expand All @@ -21,7 +21,7 @@ public function all()
/** @test */
public function get()
{
$response = $this->resource->get($this->entity->name);
$response = $this->endpoint->get($this->entity->name);

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals($this->entity->label, $response->label);
Expand All @@ -39,7 +39,7 @@ public function update()
{
$property = $this->getDataForUpdate();

$response = $this->resource->update($this->entity->name, $property);
$response = $this->endpoint->update($this->entity->name, $property);

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals($property['label'], $response->label);
Expand All @@ -62,7 +62,7 @@ public function delete()
*/
protected function createEntity()
{
return $this->resource->create($this->getData());
return $this->endpoint->create($this->getData());
}

/**
Expand All @@ -72,7 +72,7 @@ protected function createEntity()
*/
protected function deleteEntity()
{
return $this->resource->delete($this->entity->name);
return $this->endpoint->delete($this->entity->name);
}

protected function getData()
Expand Down
14 changes: 7 additions & 7 deletions tests/Integration/Abstraction/PropertyGroupsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class PropertyGroupsTestCase extends EntityTestCase
/** @test */
public function all()
{
$response = $this->resource->getAllGroups();
$response = $this->endpoint->getAllGroups();

$this->assertEquals(200, $response->getStatusCode());
$this->assertGreaterThanOrEqual(1, count($response->getData()));
Expand All @@ -22,7 +22,7 @@ public function all()
/** @test */
public function allWithProperties()
{
$response = $this->resource->getAllGroups(true);
$response = $this->endpoint->getAllGroups(true);

$this->assertEquals(200, $response->getStatusCode());
$this->assertGreaterThanOrEqual(1, count($response->getData()));
Expand All @@ -35,7 +35,7 @@ public function getGroup()
if (!$this->getGroup) {
return true;
}
$response = $this->resource->getGroup($this->entity->name);
$response = $this->endpoint->getGroup($this->entity->name);

$this->assertEquals(200, $response->getStatusCode());
}
Expand All @@ -55,7 +55,7 @@ public function update()
'displayOrder' => 7,
];

$response = $this->resource->updateGroup($this->entity->name, $group);
$response = $this->endpoint->updateGroup($this->entity->name, $group);

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('An Updated Property Group', $response->displayName);
Expand All @@ -64,7 +64,7 @@ public function update()
/** @test */
public function delete()
{
$response = $this->resource->deleteGroup($this->entity->name);
$response = $this->endpoint->deleteGroup($this->entity->name);

$this->assertEquals(204, $response->getStatusCode());

Expand All @@ -78,7 +78,7 @@ public function delete()
*/
protected function deleteEntity()
{
return $this->resource->deleteGroup($this->entity->name);
return $this->endpoint->deleteGroup($this->entity->name);
}

/**
Expand All @@ -94,6 +94,6 @@ protected function createEntity()
'displayOrder' => 7,
];

return $this->resource->createGroup($data);
return $this->endpoint->createGroup($data);
}
}
8 changes: 4 additions & 4 deletions tests/Integration/Abstraction/TimelineTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ abstract class TimelineTestCase extends EntityTestCase
/**
* @var null|Timeline
*/
protected $resource;
protected $endpoint;

/**
* @var null|Timeline::class
*/
protected $resourceClass = Timeline::class;
protected $endpointClass = Timeline::class;

/**
* @var string
Expand All @@ -40,15 +40,15 @@ public function setUp(): void

public function deleteEntity()
{
return $this->resource->deleteEventType(
return $this->endpoint->deleteEventType(
$this->appId,
$this->entity->id
);
}

protected function createEntity()
{
return $this->resource->createEventType(
return $this->endpoint->createEventType(
$this->appId,
'Test Event Name',
'Test Event header template',
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Abstraction/TimelineWithProprtyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function tearDown(): void

public function deleteProperty()
{
return $this->resource->deleteEventTypeProperty(
return $this->endpoint->deleteEventTypeProperty(
$this->appId,
$this->entity->id,
$this->property->id
Expand All @@ -35,7 +35,7 @@ public function deleteProperty()

protected function createProperty()
{
return $this->resource->createEventTypeProperty(
return $this->endpoint->createEventTypeProperty(
$this->appId,
$this->entity->id,
'test_property',
Expand Down
Loading

0 comments on commit d6b3328

Please sign in to comment.