Skip to content

Commit

Permalink
InstagramAds
Browse files Browse the repository at this point in the history
  • Loading branch information
edbizarro committed Apr 25, 2019
1 parent 4cb17a2 commit 63f6cbb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 20 deletions.
7 changes: 2 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
>
verbose="true">
<testsuites>
<testsuite name="Laravel Facebok Ads Test Suite">
<directory suffix=".php">./tests</directory>
Expand All @@ -22,8 +20,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
8 changes: 4 additions & 4 deletions src/AbstractFacebookAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

use FacebookAds\Api;
use Edbizarro\LaravelFacebookAds\Contracts\LaravelFacebookAdsContract;
use Illuminate\Support\Traits\Macroable;

/**
* Class AbstractFacebookAds.
*/
abstract class AbstractFacebookAds implements LaravelFacebookAdsContract
{
use Macroable;

/**
* @var Api
*/
protected $adsApiInstance;

/**
* {@inheritdoc}
*/
public function init($accessToken)
public function init($accessToken): FacebookAds
{
Api::init(
config('facebook-ads.app_id'),
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/LaravelFacebookAdsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ interface LaravelFacebookAdsContract
*
* @return FacebookAds
*/
public function init($accessToken);
public function init($accessToken): FacebookAds;
}
6 changes: 5 additions & 1 deletion src/Entities/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

namespace Edbizarro\LaravelFacebookAds\Entities;

use FacebookAds\Object\AbstractObject;
use Illuminate\Contracts\Support\Arrayable;

/**
* Class Entity.
*/
abstract class AbstractEntity implements Arrayable
{
protected $response = [];
/**
* @var AbstractObject|array
*/
protected $response;

public function __construct($class = [])
{
Expand Down
5 changes: 3 additions & 2 deletions src/Entities/AdAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class AdAccount extends AbstractEntity
*/
public function ads(array $fields = []): Collection
{
$ads = $this->response->getAds($fields);
return $this->format($ads);
return $this->format(
$this->response->getAds($fields)
);
}
}
8 changes: 4 additions & 4 deletions src/Entities/Insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class Insights
* List all campaigns.
*
* @param array $fields
* @param string $accountId
* @param string $accountId *
*
* @return Collection
* @return \FacebookAds\Object\AbstractObject|Collection
*
* @see https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns
* @throws \Edbizarro\LaravelFacebookAds\Exceptions\MissingEntityFormatter
* @see https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns
*/
public function all(array $fields, string $accountId): Collection
public function all(array $fields, string $accountId)
{
return $this->format(
(new AdAccount)->setId($accountId)->getCampaigns($fields)
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/InstagramAccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InstagramAccounts
* @throws \Edbizarro\LaravelFacebookAds\Exceptions\MissingEntityFormatter
* @see https://developers.facebook.com/docs/marketing-api/guides/instagramads
*/
public function all(array $fields = [], $accountId = 'me'): Collection
public function all(array $fields, $accountId): Collection
{
return $this->format(
(new FbAdAccount($accountId))->getInstagramAccounts($fields)
Expand Down
10 changes: 8 additions & 2 deletions tests/LaravelFacebookAds/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LaravelFacebookAds\Tests;

use Edbizarro\LaravelFacebookAds\Providers\LaravelFacebookServiceProvider;
use Mockery as m;
use Orchestra\Testbench\TestCase;

Expand All @@ -10,14 +11,19 @@
*/
class BaseTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
parent::tearDown();
m::close();
}

public function setUp()
public function setUp(): void
{
parent::setUp();
}

protected function getPackageProviders($app)
{
return [LaravelFacebookServiceProvider::class];
}
}

0 comments on commit 63f6cbb

Please sign in to comment.