Skip to content

Commit

Permalink
Merge pull request #256 from jrdnrc/feature/partitions-set-operator
Browse files Browse the repository at this point in the history
[Product Partitions] Added a helper method to create SET operator.
  • Loading branch information
fiboknacky authored Mar 13, 2017
2 parents 33d97ef + d203904 commit 4af39d3
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/Google/AdsApi/AdWords/Shopping/v201702/ProductPartitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,7 @@ public static function asNegativeAdGroupCriterion($adGroupId,
* @return AdGroupCriterionOperation the ad group criterion operation
*/
public static function createAddOperation(AdGroupCriterion $criterion) {
$operation = new AdGroupCriterionOperation();
$operation->setOperand($criterion);
$operation->setOperator(Operator::ADD);

return $operation;
return self::createOperation($criterion, Operator::ADD);
}

/**
Expand All @@ -180,12 +176,35 @@ public static function createAddOperation(AdGroupCriterion $criterion) {
* @return AdGroupCriterionOperation the ad group criterion operation
*/
public static function createRemoveOperation(AdGroupCriterion $criterion) {
return self::createOperation($criterion, Operator::REMOVE);
}


/**
* Creates an ad group criterion operation for the given criterion.
*
* @param AdGroupCriterion $criterion the ad group criterion to create the
* SET operation
* @return AdGroupCriterionOperation the ad group criterion operation
*/
public static function createSetOperation(AdGroupCriterion $criterion) {
return self::createOperation($criterion, Operator::SET);
}

/**
* Creates an ad group criterion operation for the given criterion.
*
* @param AdGroupCriterion $criterion the ad group criterion
* @param string $operator the operator to use ADD|REMOVE|SET
* @return AdGroupCriterionOperation the ad group criterion operation
*/
protected static function createOperation(AdGroupCriterion $criterion, $operator) {
$operation = new AdGroupCriterionOperation();
$operation->setOperand($criterion);
$operation->setOperator(Operator::REMOVE);

$operation->setOperator($operator);
return $operation;
}

/**
* Returns the string representation of ad group criteria of the specified
* ad group ID by showing them hierarchically.
Expand Down

0 comments on commit 4af39d3

Please sign in to comment.