brandon14/ebay-sdk-php

View on GitHub
src/Buy/Order/V2/Model/ShippingOption.php

Summary

Maintainability
F
1 wk
Test Coverage
<?php

/**
 * This file is part of the trollandtoad/ebay-sdk-php package.
 *
 * MIT License
 *
 * Copyright (c) 2022 Brandon Clothier
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission 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.
 *
 */

declare(strict_types=1);

/**
 * ShippingOption.
 *
 * PHP version ^7.2 || ^8.0
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Order API.
 *
 * <span class=\"tablenote\"><b>Note:</b> The Order API (v2) currently only supports the guest payment/checkout flow. If you need to support member payment/checkout flow, use the <a href=\"/api-docs/buy/order_v1/resources/methods\">v1_beta version</a> of the Order API.</span><br /><br /><span class=\"tablenote\"><b>Note:</b> This is a <a href=\"https://developer.ebay.com/api-docs/static/versioning.html#limited\" target=\"_blank\"><img src=\"/cms/img/docs/partners-api.svg\" class=\"legend-icon partners-icon\"  alt=\"Limited Release\" title=\"Limited Release\" />(Limited Release)</a> API available only to select developers approved by business units.</span><br /><br />The Order API provides interfaces that let shoppers pay for items. It also returns payment and shipping status of the order.
 *
 * The version of the OpenAPI document: v2.1.0
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 5.4.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace TNT\Ebay\Buy\Order\V2\Model;

use TNT\Ebay\Buy\Order\V2\ObjectSerializer;

/**
 * ShippingOption Class Doc Comment.
 *
 * @category Class
 *
 * @description A type that defines the fields for the shipping options.
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @implements \ArrayAccess<TKey, TValue>
 *
 * @template TKey int|null
 * @template TValue mixed|null
 */
class ShippingOption implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
     * The original name of the model.
     *
     * @var string
     */
    protected static $openAPIModelName = 'ShippingOption';

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'base_delivery_cost' => '\TNT\Ebay\Buy\Order\V2\Model\Amount',
        'delivery_discount' => '\TNT\Ebay\Buy\Order\V2\Model\Amount',
        'import_charges' => '\TNT\Ebay\Buy\Order\V2\Model\Amount',
        'max_estimated_delivery_date' => 'string',
        'min_estimated_delivery_date' => 'string',
        'selected' => 'bool',
        'shipping_carrier_code' => 'string',
        'shipping_option_id' => 'string',
        'shipping_service_code' => 'string',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     *
     * @phpstan-var array<string, string|null>
     *
     * @psalm-var array<string, string|null>
     */
    protected static $openAPIFormats = [
        'base_delivery_cost' => null,
        'delivery_discount' => null,
        'import_charges' => null,
        'max_estimated_delivery_date' => null,
        'min_estimated_delivery_date' => null,
        'selected' => null,
        'shipping_carrier_code' => null,
        'shipping_option_id' => null,
        'shipping_service_code' => null,
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'base_delivery_cost' => 'baseDeliveryCost',
        'delivery_discount' => 'deliveryDiscount',
        'import_charges' => 'importCharges',
        'max_estimated_delivery_date' => 'maxEstimatedDeliveryDate',
        'min_estimated_delivery_date' => 'minEstimatedDeliveryDate',
        'selected' => 'selected',
        'shipping_carrier_code' => 'shippingCarrierCode',
        'shipping_option_id' => 'shippingOptionId',
        'shipping_service_code' => 'shippingServiceCode',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'base_delivery_cost' => 'setBaseDeliveryCost',
        'delivery_discount' => 'setDeliveryDiscount',
        'import_charges' => 'setImportCharges',
        'max_estimated_delivery_date' => 'setMaxEstimatedDeliveryDate',
        'min_estimated_delivery_date' => 'setMinEstimatedDeliveryDate',
        'selected' => 'setSelected',
        'shipping_carrier_code' => 'setShippingCarrierCode',
        'shipping_option_id' => 'setShippingOptionId',
        'shipping_service_code' => 'setShippingServiceCode',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'base_delivery_cost' => 'getBaseDeliveryCost',
        'delivery_discount' => 'getDeliveryDiscount',
        'import_charges' => 'getImportCharges',
        'max_estimated_delivery_date' => 'getMaxEstimatedDeliveryDate',
        'min_estimated_delivery_date' => 'getMinEstimatedDeliveryDate',
        'selected' => 'getSelected',
        'shipping_carrier_code' => 'getShippingCarrierCode',
        'shipping_option_id' => 'getShippingOptionId',
        'shipping_service_code' => 'getShippingServiceCode',
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    /**
     * Associative array for storing property values.
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor.
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['base_delivery_cost'] = $data['base_delivery_cost'] ?? null;
        $this->container['delivery_discount'] = $data['delivery_discount'] ?? null;
        $this->container['import_charges'] = $data['import_charges'] ?? null;
        $this->container['max_estimated_delivery_date'] = $data['max_estimated_delivery_date'] ?? null;
        $this->container['min_estimated_delivery_date'] = $data['min_estimated_delivery_date'] ?? null;
        $this->container['selected'] = $data['selected'] ?? null;
        $this->container['shipping_carrier_code'] = $data['shipping_carrier_code'] ?? null;
        $this->container['shipping_option_id'] = $data['shipping_option_id'] ?? null;
        $this->container['shipping_service_code'] = $data['shipping_service_code'] ?? null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed.
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }

    /**
     * Gets base_delivery_cost.
     *
     * @return \TNT\Ebay\Buy\Order\V2\Model\Amount|null
     */
    public function getBaseDeliveryCost()
    {
        return $this->container['base_delivery_cost'];
    }

    /**
     * Sets base_delivery_cost.
     *
     * @param \TNT\Ebay\Buy\Order\V2\Model\Amount|null $base_delivery_cost base_delivery_cost
     *
     * @return self
     */
    public function setBaseDeliveryCost($base_delivery_cost)
    {
        $this->container['base_delivery_cost'] = $base_delivery_cost;

        return $this;
    }

    /**
     * Gets delivery_discount.
     *
     * @return \TNT\Ebay\Buy\Order\V2\Model\Amount|null
     */
    public function getDeliveryDiscount()
    {
        return $this->container['delivery_discount'];
    }

    /**
     * Sets delivery_discount.
     *
     * @param \TNT\Ebay\Buy\Order\V2\Model\Amount|null $delivery_discount delivery_discount
     *
     * @return self
     */
    public function setDeliveryDiscount($delivery_discount)
    {
        $this->container['delivery_discount'] = $delivery_discount;

        return $this;
    }

    /**
     * Gets import_charges.
     *
     * @return \TNT\Ebay\Buy\Order\V2\Model\Amount|null
     */
    public function getImportCharges()
    {
        return $this->container['import_charges'];
    }

    /**
     * Sets import_charges.
     *
     * @param \TNT\Ebay\Buy\Order\V2\Model\Amount|null $import_charges import_charges
     *
     * @return self
     */
    public function setImportCharges($import_charges)
    {
        $this->container['import_charges'] = $import_charges;

        return $this;
    }

    /**
     * Gets max_estimated_delivery_date.
     *
     * @return string|null
     */
    public function getMaxEstimatedDeliveryDate()
    {
        return $this->container['max_estimated_delivery_date'];
    }

    /**
     * Sets max_estimated_delivery_date.
     *
     * @param string|null $max_estimated_delivery_date the end of the date range in which the purchase order is expected to be delivered to the shipping address
     *
     * @return self
     */
    public function setMaxEstimatedDeliveryDate($max_estimated_delivery_date)
    {
        $this->container['max_estimated_delivery_date'] = $max_estimated_delivery_date;

        return $this;
    }

    /**
     * Gets min_estimated_delivery_date.
     *
     * @return string|null
     */
    public function getMinEstimatedDeliveryDate()
    {
        return $this->container['min_estimated_delivery_date'];
    }

    /**
     * Sets min_estimated_delivery_date.
     *
     * @param string|null $min_estimated_delivery_date the beginning of the date range in which the purchase order is expected to be delivered to the shipping address
     *
     * @return self
     */
    public function setMinEstimatedDeliveryDate($min_estimated_delivery_date)
    {
        $this->container['min_estimated_delivery_date'] = $min_estimated_delivery_date;

        return $this;
    }

    /**
     * Gets selected.
     *
     * @return bool|null
     */
    public function getSelected()
    {
        return $this->container['selected'];
    }

    /**
     * Sets selected.
     *
     * @param bool|null $selected a field that indicates whether the shipping method is selected
     *
     * @return self
     */
    public function setSelected($selected)
    {
        $this->container['selected'] = $selected;

        return $this;
    }

    /**
     * Gets shipping_carrier_code.
     *
     * @return string|null
     */
    public function getShippingCarrierCode()
    {
        return $this->container['shipping_carrier_code'];
    }

    /**
     * Sets shipping_carrier_code.
     *
     * @param string|null $shipping_carrier_code the shipping provider for the line item, such as FedEx or USPS
     *
     * @return self
     */
    public function setShippingCarrierCode($shipping_carrier_code)
    {
        $this->container['shipping_carrier_code'] = $shipping_carrier_code;

        return $this;
    }

    /**
     * Gets shipping_option_id.
     *
     * @return string|null
     */
    public function getShippingOptionId()
    {
        return $this->container['shipping_option_id'];
    }

    /**
     * Sets shipping_option_id.
     *
     * @param string|null $shipping_option_id a unique ID for the selected shipping option/method
     *
     * @return self
     */
    public function setShippingOptionId($shipping_option_id)
    {
        $this->container['shipping_option_id'] = $shipping_option_id;

        return $this;
    }

    /**
     * Gets shipping_service_code.
     *
     * @return string|null
     */
    public function getShippingServiceCode()
    {
        return $this->container['shipping_service_code'];
    }

    /**
     * Sets shipping_service_code.
     *
     * @param string|null $shipping_service_code The name of the shipping service code. For example, Priority Mail Express (provided by USPS) or FedEx International Priority (Provided by FedEx).
     *
     * @return self
     */
    public function setShippingServiceCode($shipping_service_code)
    {
        $this->container['shipping_service_code'] = $shipping_service_code;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, $value): void
    {
        if (null === $offset) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     *
     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed returns data which can be serialized by json_encode(), which is a value
     *               of any type other than a resource
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object.
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object.
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}