Skip to content

Commit

Permalink
Ads SDK v2.10 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Chen committed Jul 18, 2017
1 parent d7fefc0 commit bfea2cc
Show file tree
Hide file tree
Showing 71 changed files with 853 additions and 106 deletions.
35 changes: 35 additions & 0 deletions src/FacebookAds/AnonymousSession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
* form for use in connection with the web services and APIs provided by
* Facebook.
*
* As with any software that integrates with the Facebook platform, your use
* of this software is subject to the Facebook Developer Principles and
* Policies [http://developers.facebook.com/policy/]. This copyright notice
* shall be included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

namespace FacebookAds;

class AnonymousSession implements SessionInterface {

/**
* @return array
*/
public function getRequestParameters() {
return array();
}
}
23 changes: 17 additions & 6 deletions src/FacebookAds/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Api {
protected static $instance;

/**
* @var Session
* @var SessionInterface
*/
private $session;

Expand All @@ -64,11 +64,11 @@ class Api {

/**
* @param Client $http_client
* @param Session $session A Facebook API session
* @param SessionInterface $session A Facebook API session
*/
public function __construct(
Client $http_client,
Session $session) {
SessionInterface $session) {
$this->httpClient = $http_client;
$this->session = $session;
}
Expand Down Expand Up @@ -101,6 +101,17 @@ public static function setInstance(Api $instance) {
static::$instance = $instance;
}

/**
* @param SessionInterface $session
* @return Api
*/
public function getCopyWithSession(SessionInterface $session) {
$api = new self($this->getHttpClient(), $session);
$api->setDefaultGraphVersion($this->getDefaultGraphVersion());
$api->setLogger($this->getLogger());
return $api;
}

/**
* @param string $string
* @return string
Expand Down Expand Up @@ -136,8 +147,8 @@ public function prepareRequest(
if (!empty($params)) {
$params_ref->enhance($params);
}
$params_ref['access_token'] = $this->getSession()->getAccessToken();
$params_ref['appsecret_proof'] = $this->getSession()->getAppSecretProof();

$params_ref->enhance($this->getSession()->getRequestParameters());

return $request;
}
Expand Down Expand Up @@ -194,7 +205,7 @@ public function call(
}

/**
* @return Session
* @return SessionInterface
*/
public function getSession() {
return $this->session;
Expand Down
4 changes: 2 additions & 2 deletions src/FacebookAds/ApiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
namespace FacebookAds;
class ApiConfig {
const APIVersion = '2.9';
const SDKVersion = '2.9.2';
const APIVersion = '2.10';
const SDKVersion = '2.10.1';
const TYPE_CHECKER_STRICT_MODE = false;
}
12 changes: 8 additions & 4 deletions src/FacebookAds/Http/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RequestException extends Exception {
*/
public function __construct(ResponseInterface $response) {
$this->response = $response;
$error_data = static::getErrorData($response->getContent());
$error_data = static::getErrorData($response);

parent::__construct($error_data['message'], $error_data['code']);

Expand Down Expand Up @@ -104,10 +104,14 @@ protected static function idx(array $array, $key, $default = null) {
}

/**
* @param array $response_data
* @param ResponseInterface $response
* @return array
*/
protected static function getErrorData(array $response_data) {
protected static function getErrorData(ResponseInterface $response) {
$response_data = $response->getContent();
if (is_null($response_data)) {
$response_data = array();
}
$error_data = static::idx($response_data, 'error', array());

return array(
Expand All @@ -131,7 +135,7 @@ protected static function getErrorData(array $response_data) {
* @return RequestException
*/
public static function create(ResponseInterface $response) {
$error_data = static::getErrorData($response->getContent());
$error_data = static::getErrorData($response);
if (in_array(
$error_data['error_subcode'], array(458, 459, 460, 463, 464, 467))
|| in_array($error_data['code'], array(100, 102, 190))
Expand Down
2 changes: 1 addition & 1 deletion src/FacebookAds/Http/ResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getBody();
public function setBody($body);

/**
* @return array
* @return array|null
*/
public function getContent();
}
2 changes: 2 additions & 0 deletions src/FacebookAds/Object/Ad.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public function getInsights(array $fields = array(), array $params = array(), $p
'time_increment' => 'string',
'time_range' => 'Object',
'time_ranges' => 'list<Object>',
'use_account_attribution_setting' => 'bool',
);
$enums = array(
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(),
Expand Down Expand Up @@ -237,6 +238,7 @@ public function getInsightsAsync(array $fields = array(), array $params = array(
'time_increment' => 'string',
'time_range' => 'Object',
'time_ranges' => 'list<Object>',
'use_account_attribution_setting' => 'bool',
);
$enums = array(
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(),
Expand Down
47 changes: 12 additions & 35 deletions src/FacebookAds/Object/AdAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use FacebookAds\TypeChecker;
use FacebookAds\Object\Fields\AdAccountFields;
use FacebookAds\Object\Values\AdAccountAccessTypeValues;
use FacebookAds\Object\Values\AdAccountDeliveryEstimateOptimizationGoalValues;
use FacebookAds\Object\Values\AdAccountPermittedRolesValues;
use FacebookAds\Object\Values\AdAccountRoasFieldsValues;
use FacebookAds\Object\Values\AdAccountTargetingUnifiedLimitTypeValues;
Expand Down Expand Up @@ -349,9 +350,9 @@ public function createAdImage(array $fields = array(), array $params = array(),
$this->assureId();

$param_types = array(
'bytes' => 'string',
'bytes' => 'Object',
'copy_from' => 'Object',
'zipbytes' => 'string',
'zipbytes' => 'Object',
);
$enums = array(
);
Expand Down Expand Up @@ -617,7 +618,6 @@ public function createAdSet(array $fields = array(), array $params = array(), $p
'promoted_object' => 'Object',
'redownload' => 'bool',
'rf_prediction_id' => 'string',
'rtb_flag' => 'bool',
'start_time' => 'datetime',
'status' => 'status_enum',
'targeting' => 'Targeting',
Expand Down Expand Up @@ -783,6 +783,7 @@ public function createAdVideo(array $fields = array(), array $params = array(),
'og_object_id' => 'string',
'og_phrase' => 'string',
'og_suggestion_mechanism' => 'string',
'original_fov' => 'unsigned int',
'original_projection_type' => 'original_projection_type_enum',
'referenced_sticker_id' => 'string',
'slideshow_spec' => 'map',
Expand Down Expand Up @@ -962,7 +963,6 @@ public function getCampaigns(array $fields = array(), array $params = array(), $
$this->assureId();

$param_types = array(
'ad_draft_id' => 'string',
'date_preset' => 'date_preset_enum',
'effective_status' => 'list<effective_status_enum>',
'is_completed' => 'bool',
Expand Down Expand Up @@ -1148,13 +1148,11 @@ public function createCustomConversion(array $fields = array(), array $params =
$this->assureId();

$param_types = array(
'aggregation_rule' => 'string',
'custom_event_type' => 'custom_event_type_enum',
'default_conversion_value' => 'float',
'description' => 'string',
'event_source_id' => 'string',
'name' => 'string',
'retention_days' => 'int',
'rule' => 'string',
);
$enums = array(
Expand All @@ -1180,21 +1178,22 @@ public function getDeliveryEstimate(array $fields = array(), array $params = arr
$this->assureId();

$param_types = array(
'optimization_goal' => 'adaccountdelivery_estimate_optimization_goal_enum_param',
'optimization_goal' => 'optimization_goal_enum',
'promoted_object' => 'Object',
'targeting_spec' => 'Targeting',
);
$enums = array(
'optimization_goal_enum' => AdAccountDeliveryEstimateOptimizationGoalValues::getInstance()->getValues(),
);

$request = new ApiRequest(
$this->api,
$this->data['id'],
RequestInterface::METHOD_GET,
'/delivery_estimate',
new DeliveryEstimate(),
new AdAccountDeliveryEstimate(),
'EDGE',
DeliveryEstimate::getFieldsEnum()->getValues(),
AdAccountDeliveryEstimate::getFieldsEnum()->getValues(),
new TypeChecker($param_types, $enums)
);
$request->addParams($params);
Expand Down Expand Up @@ -1259,6 +1258,7 @@ public function getInsights(array $fields = array(), array $params = array(), $p
'time_increment' => 'string',
'time_range' => 'Object',
'time_ranges' => 'list<Object>',
'use_account_attribution_setting' => 'bool',
);
$enums = array(
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(),
Expand Down Expand Up @@ -1309,6 +1309,7 @@ public function getInsightsAsync(array $fields = array(), array $params = array(
'time_increment' => 'string',
'time_range' => 'Object',
'time_ranges' => 'list<Object>',
'use_account_attribution_setting' => 'bool',
);
$enums = array(
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(),
Expand Down Expand Up @@ -1430,32 +1431,6 @@ public function getOfflineConversionDataSets(array $fields = array(), array $par
return $pending ? $request : $request->execute();
}

public function createOfflineConversion(array $fields = array(), array $params = array(), $pending = false) {
$this->assureId();

$param_types = array(
'event' => 'string',
'payload' => 'list<Object>',
'pixel_id' => 'string',
);
$enums = array(
);

$request = new ApiRequest(
$this->api,
$this->data['id'],
RequestInterface::METHOD_POST,
'/offlineconversions',
new AbstractCrudObject(),
'EDGE',
array(),
new TypeChecker($param_types, $enums)
);
$request->addParams($params);
$request->addFields($fields);
return $pending ? $request : $request->execute();
}

public function getOffsitePixels(array $fields = array(), array $params = array(), $pending = false) {
$this->assureId();

Expand Down Expand Up @@ -1586,6 +1561,7 @@ public function createProductAudience(array $fields = array(), array $params = a
'DATA_SET',
'BAG_OF_ACCOUNTS',
'STUDY_RULE_AUDIENCE',
'FOX',
),
);

Expand Down Expand Up @@ -2048,6 +2024,7 @@ public function updateSelf(array $fields = array(), array $params = array(), $pe

$param_types = array(
'agency_client_declaration' => 'map',
'attribution_spec' => 'list<Object>',
'business_info' => 'map',
'end_advertiser' => 'string',
'is_notifications_enabled' => 'bool',
Expand Down
59 changes: 59 additions & 0 deletions src/FacebookAds/Object/AdAccountDeliveryEstimate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
* form for use in connection with the web services and APIs provided by
* Facebook.
*
* As with any software that integrates with the Facebook platform, your use
* of this software is subject to the Facebook Developer Principles and
* Policies [http://developers.facebook.com/policy/]. This copyright notice
* shall be included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

namespace FacebookAds\Object;

use FacebookAds\ApiRequest;
use FacebookAds\Cursor;
use FacebookAds\Http\RequestInterface;
use FacebookAds\TypeChecker;
use FacebookAds\Object\Fields\AdAccountDeliveryEstimateFields;
use FacebookAds\Object\Values\AdAccountDeliveryEstimateOptimizationGoalValues;

/**
* This class is auto-genereated.
*
* For any issues or feature requests related to this class, please let us know
* on github and we'll fix in our codegen framework. We'll not be able to accept
* pull request for this class.
*
*/

class AdAccountDeliveryEstimate extends AbstractObject {

/**
* @return AdAccountDeliveryEstimateFields
*/
public static function getFieldsEnum() {
return AdAccountDeliveryEstimateFields::getInstance();
}

protected static function getReferencedEnums() {
$ref_enums = array();
$ref_enums['OptimizationGoal'] = AdAccountDeliveryEstimateOptimizationGoalValues::getInstance()->getValues();
return $ref_enums;
}


}
Loading

0 comments on commit bfea2cc

Please sign in to comment.