<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/shopping/merchant/products/v1beta/products_common.proto

namespace Google\Shopping\Merchant\Products\V1beta;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\GPBUtil;
use Google\Protobuf\RepeatedField;

/**
 * Information regarding sustainability-related incentive programs such as
 * rebates or tax relief.
 *
 * Generated from protobuf message <code>google.shopping.merchant.products.v1beta.ProductSustainabilityIncentive</code>
 */
class ProductSustainabilityIncentive extends \Google\Protobuf\Internal\Message
{
    /**
     * Sustainability incentive program.
     *
     * Generated from protobuf field <code>optional .google.shopping.merchant.products.v1beta.ProductSustainabilityIncentive.Type type = 1;</code>
     */
    protected $type = null;
    protected $value;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Shopping\Type\Price $amount
     *           The fixed amount of the incentive.
     *     @type float $percentage
     *           The percentage of the sale price that the incentive is applied to.
     *     @type int $type
     *           Sustainability incentive program.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Shopping\Merchant\Products\V1Beta\ProductsCommon::initOnce();
        parent::__construct($data);
    }

    /**
     * The fixed amount of the incentive.
     *
     * Generated from protobuf field <code>.google.shopping.type.Price amount = 2;</code>
     * @return \Google\Shopping\Type\Price|null
     */
    public function getAmount()
    {
        return $this->readOneof(2);
    }

    public function hasAmount()
    {
        return $this->hasOneof(2);
    }

    /**
     * The fixed amount of the incentive.
     *
     * Generated from protobuf field <code>.google.shopping.type.Price amount = 2;</code>
     * @param \Google\Shopping\Type\Price $var
     * @return $this
     */
    public function setAmount($var)
    {
        GPBUtil::checkMessage($var, \Google\Shopping\Type\Price::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * The percentage of the sale price that the incentive is applied to.
     *
     * Generated from protobuf field <code>double percentage = 3;</code>
     * @return float
     */
    public function getPercentage()
    {
        return $this->readOneof(3);
    }

    public function hasPercentage()
    {
        return $this->hasOneof(3);
    }

    /**
     * The percentage of the sale price that the incentive is applied to.
     *
     * Generated from protobuf field <code>double percentage = 3;</code>
     * @param float $var
     * @return $this
     */
    public function setPercentage($var)
    {
        GPBUtil::checkDouble($var);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * Sustainability incentive program.
     *
     * Generated from protobuf field <code>optional .google.shopping.merchant.products.v1beta.ProductSustainabilityIncentive.Type type = 1;</code>
     * @return int
     */
    public function getType()
    {
        return isset($this->type) ? $this->type : 0;
    }

    public function hasType()
    {
        return isset($this->type);
    }

    public function clearType()
    {
        unset($this->type);
    }

    /**
     * Sustainability incentive program.
     *
     * Generated from protobuf field <code>optional .google.shopping.merchant.products.v1beta.ProductSustainabilityIncentive.Type type = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setType($var)
    {
        GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Products\V1beta\ProductSustainabilityIncentive\Type::class);
        $this->type = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getValue()
    {
        return $this->whichOneof("value");
    }

}

