Пример #1
0
 /**
  * @param array $conversionData
  * @return CMService_AdWords_Conversion
  */
 public static function fromArray(array $conversionData)
 {
     $conversion = new CMService_AdWords_Conversion();
     $conversion->setId(isset($conversionData['google_conversion_id']) ? $conversionData['google_conversion_id'] : null);
     $conversion->setLanguage(isset($conversionData['google_conversion_language']) ? $conversionData['google_conversion_language'] : null);
     $conversion->setFormat(isset($conversionData['google_conversion_format']) ? $conversionData['google_conversion_format'] : null);
     $conversion->setColor(isset($conversionData['google_conversion_color']) ? $conversionData['google_conversion_color'] : null);
     $conversion->setLabel(isset($conversionData['google_conversion_label']) ? $conversionData['google_conversion_label'] : null);
     $conversion->setRemarketingOnly(isset($conversionData['google_remarketing_only']) ? $conversionData['google_remarketing_only'] : null);
     $conversion->setConversionValue(isset($conversionData['google_conversion_value']) ? $conversionData['google_conversion_value'] : null);
     $conversion->setConversionCurrency(isset($conversionData['google_conversion_currency']) ? $conversionData['google_conversion_currency'] : null);
     $conversion->setCustomParameterList(isset($conversionData['google_custom_params']) ? $conversionData['google_custom_params'] : null);
     return $conversion;
 }
Пример #2
0
    public function testToJson()
    {
        $conversion = new CMService_AdWords_Conversion();
        $this->assertSame('{}', $conversion->toJson());
        $conversion->setColor('666666');
        $conversion->setConversionCurrency('USD');
        $conversion->setConversionValue(123);
        $conversion->setCustomParameterList(['a' => 1, 'b' => 2]);
        $conversion->setFormat('1');
        $conversion->setId(123456);
        $conversion->setLabel('label');
        $conversion->setLanguage('en');
        $conversion->setRemarketingOnly(true);
        $this->assertSame(<<<EOD
{"google_conversion_id":123456,"google_conversion_language":"en","google_conversion_format":"1","google_conversion_color":"666666","google_conversion_label":"label","google_remarketing_only":true,"google_conversion_value":123,"google_conversion_currency":"USD","google_custom_params":{"a":1,"b":2}}
EOD
, $conversion->toJson());
    }