0 ) {
$convert_status['status'] = 'converted';
}
} catch ( Exception $e ) {
// Error when retrieving campaigns, do not handle conversion.
$convert_status['status'] = 'unknown';
}
$convert_status['updated'] = time();
$this->options->update( OptionsInterface::CAMPAIGN_CONVERT_STATUS, $convert_status );
}
return $convert_status['status'];
}
/**
* Return a temporary resource name for the campaign.
*
* @return string
*/
protected function temporary_resource_name() {
return ResourceNames::forCampaign( $this->options->get_ads_id(), self::TEMPORARY_ID );
}
/**
* Returns a campaign create operation.
*
* @param string $campaign_name
* @param string $country
*
* @return MutateOperation
*/
protected function create_operation( string $campaign_name, string $country ): MutateOperation {
$campaign = new Campaign(
[
'resource_name' => $this->temporary_resource_name(),
'name' => $campaign_name,
'advertising_channel_type' => AdvertisingChannelType::PERFORMANCE_MAX,
'status' => CampaignStatus::number( 'enabled' ),
'campaign_budget' => $this->budget->temporary_resource_name(),
'maximize_conversion_value' => new MaximizeConversionValue(),
'url_expansion_opt_out' => true,
'shopping_setting' => new ShoppingSetting(
[
'merchant_id' => $this->options->get_merchant_id(),
'sales_country' => $country,
]
),
]
);
$operation = ( new CampaignOperation() )->setCreate( $campaign );
return ( new MutateOperation() )->setCampaignOperation( $operation );
}
/**
* Returns a campaign edit operation.
*
* @param integer $campaign_id
* @param array $fields
*
* @return MutateOperation
*/
protected function edit_operation( int $campaign_id, array $fields ): MutateOperation {
$fields['resource_name'] = ResourceNames::forCampaign( $this->options->get_ads_id(), $campaign_id );
$campaign = new Campaign( $fields );
$operation = new CampaignOperation();
$operation->setUpdate( $campaign );
$operation->setUpdateMask( FieldMasks::allSetFieldsOf( $campaign ) );
return ( new MutateOperation() )->setCampaignOperation( $operation );
}
/**
* Returns a campaign delete operation.
*
* @param string $campaign_resource_name
*
* @return MutateOperation
*/
protected function delete_operation( string $campaign_resource_name ): MutateOperation {
$operation = ( new CampaignOperation() )->setRemove( $campaign_resource_name );
return ( new MutateOperation() )->setCampaignOperation( $operation );
}
/**
* Convert campaign data to an array.
*
* @param GoogleAdsRow $row Data row returned from a query request.
*
* @return array
*/
protected function convert_campaign( GoogleAdsRow $row ): array {
$campaign = $row->getCampaign();
$data = [
'id' => $campaign->getId(),
'name' => $campaign->getName(),
'status' => CampaignStatus::label( $campaign->getStatus() ),
'type' => CampaignType::label( $campaign->getAdvertisingChannelType() ),
'targeted_locations' => [],
];
$budget = $row->getCampaignBudget();
if ( $budget ) {
$data += [
'amount' => $this->from_micro( $budget->getAmountMicros() ),
];
}
$shopping = $campaign->getShoppingSetting();
if ( $shopping ) {
$data += [
'country' => $shopping->getSalesCountry(),
];
}
return $data;
}
/**
* Combine converted campaigns data with campaign criterion results data
*
* @param array $campaigns Campaigns data returned from a query request and converted by convert_campaign function.
*
* @return array
*/
protected function combine_campaigns_and_campaign_criterion_results( array $campaigns ): array {
if ( empty( $campaigns ) ) {
return [];
}
$campaign_criterion_results = ( new AdsCampaignCriterionQuery() )->set_client( $this->client, $this->options->get_ads_id() )
->where( 'campaign.id', array_keys( $campaigns ), 'IN' )
// negative: Whether to target (false) or exclude (true) the criterion.
->where( 'campaign_criterion.negative', 'false', '=' )
->where( 'campaign_criterion.status', 'REMOVED', '!=' )
->where( 'campaign_criterion.location.geo_target_constant', '', 'IS NOT NULL' )
->get_results();
/** @var GoogleAdsRow $row */
foreach ( $campaign_criterion_results->iterateAllElements() as $row ) {
$campaign = $row->getCampaign();
$campaign_id = $campaign->getId();
if ( ! isset( $campaigns[ $campaign_id ] ) ) {
continue;
}
$campaign_criterion = $row->getCampaignCriterion();
$location = $campaign_criterion->getLocation();
$geo_target_constant = $location->getGeoTargetConstant();
$location_id = $this->parse_geo_target_location_id( $geo_target_constant );
$country_code = $this->google_helper->find_country_code_by_id( $location_id );
if ( $country_code ) {
$campaigns[ $campaign_id ]['targeted_locations'][] = $country_code;
}
}
return $campaigns;
}
/**
* Send a batch of operations to mutate a campaign.
*
* @param MutateOperation[] $operations
*
* @return int Campaign ID from the MutateOperationResponse.
* @throws ApiException If any of the operations fail.
*/
protected function mutate( array $operations ): int {
$responses = $this->client->getGoogleAdsServiceClient()->mutate(
$this->options->get_ads_id(),
$operations
);
foreach ( $responses->getMutateOperationResponses() as $response ) {
if ( 'campaign_result' === $response->getResponse() ) {
$campaign_result = $response->getCampaignResult();
return $this->parse_campaign_id( $campaign_result->getResourceName() );
}
}
// When editing only the budget there is no campaign mutate result.
return 0;
}
/**
* Convert ID from a resource name to an int.
*
* @param string $name Resource name containing ID number.
*
* @return int
* @throws Exception When unable to parse resource ID.
*/
protected function parse_campaign_id( string $name ): int {
try {
$parts = CampaignServiceClient::parseName( $name );
return absint( $parts['campaign_id'] );
} catch ( ValidationException $e ) {
throw new Exception( __( 'Invalid campaign ID', 'google-listings-and-ads' ) );
}
}
/**
* Convert location ID from a geo target constant resource name to an int.
*
* @param string $geo_target_constant Resource name containing ID number.
*
* @return int
* @throws Exception When unable to parse resource ID.
*/
protected function parse_geo_target_location_id( string $geo_target_constant ): int {
if ( 1 === preg_match( '#geoTargetConstants/(?\d+)#', $geo_target_constant, $parts ) ) {
return absint( $parts['id'] );
} else {
throw new Exception( __( 'Invalid geo target location ID', 'google-listings-and-ads' ) );
}
}
}
wireless speaker MG met FM radio-ZWART M61G – SuperKeus
Skip to navigation
Skip to content
Snelle klantenservice
Gratis verzending voor bestellingen over 24,99
Voor 16:00 besteld morgen in huis
wireless speaker MG met FM radio-ZWART M61G
wireless speaker MG met FM radio-ZWART M61G € 39,99 incl. BTW
1 op voorraad
momenteel kunnen we je niet terug bellen
Met de MG Speaker M61G draag je een tas vol muziek mee. Draag deze flinke Bluetooth Speaker en geniet van een krachtig 2.1 Stereogeluid. De Speaker maakt een verbinding Met je mobiele apparaat via Bluetooth, maar heeft ook ingangen Voor een usb stick en een SD kaart. Als je geen opgeslagen muziek bij je hebt, luister je naar de radio via de ingebouwde FM tuner. Met de knoppen aan de zijkant wissel je snel tussen de verschillende afspeelmogelijkheden, kies je een nummer en pas je het volume aan.
AUX kabel
MG Speaker M61G
Gratis verzending voor bestellingen over 24,99
Directe communicatie via whatsapp
Whatsapp nummer: 06-2000720
100% veilig afrekenen
Met onze speciale integratie kan je gerust afrekenen
© SuperKeus V.O.F 2020-2023
Beoordelingen
Er zijn nog geen beoordelingen.