diff --git a/CHANGELOG.md b/CHANGELOG.md index a1ae209..e1091e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.21.0] - 2022-05-03 + +### Added + +- Adds optional `total_price` and `currency` field to `order` creation +- Adds optional `amount` and `unit` field to `order` creation +- Adds inventory to `project` responses +- Adds inventory to `order` responses + +### Changed + +- Deprecates `mass_g` and `total_price_cents_usd` fields for create `order` requests +- Deprecates `average_price_per_tonne_cents_usd` and `remaining_mass_g` from `project` responses +- Deprecates `price_cents_usd`, `patch_fee_cents_usd`, and `mass_g` from `order` responses + ## [1.20.0] - 2022-04-18 ### Added diff --git a/README.md b/README.md index 54a0370..241156f 100644 --- a/README.md +++ b/README.md @@ -65,22 +65,25 @@ import patch_api patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY')) # Create an order - you can create an order -# providing either mass_g or total_price_cents_usd, but not both +# providing either amount (and unit) or total_price (and currency), but not both -# Create order with mass -patch.orders.create_order(mass_g=1_000_000) # Pass in the mass in grams (i.e. 1 metric tonne) +# Create order with amount +amount = 1_000_000 # Pass in the amount in unit specified +unit = "g" +patch.orders.create_order(amount=amount, unit=unit) -# Create an order with maximum total price -total_price_cents_usd = 5_00 # Pass in the total price in cents (i.e. 5 dollars) -patch.orders.create_order(total_price_cents_usd=total_price_cents_usd) +# Create an order with total price +total_price = 5_00 # Pass in the total price in smallest currency unit (ie cents for USD). +currency = "USD" +patch.orders.create_order(total_price=total_price, currency=currency) ## You can also specify a project-id field (optional) to be used instead of the preferred one project_id = 'pro_test_1234' # Pass in the project's ID -patch.orders.create_order(project_id=project_id, mass_g=mass_g) +patch.orders.create_order(project_id=project_id, amount=amount, unit=unit) ## Orders also accept a metadata field (optional) metadata = {user: "john doe"} -patch.orders.create_order(metadata=metadata, mass_g=mass_g) +patch.orders.create_order(metadata=metadata, amount=amount, unit=unit) # Retrieve an order order_id = 'ord_test_1234' # Pass in the order's id diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 53c1ffd..2e3672d 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "1.20.0" +__version__ = "1.21.0" # import ApiClient from patch_api.api_client import ApiClient diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index 8a44b29..056dfa8 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -59,6 +59,10 @@ class EstimatesApi(object): "number_of_nights", "number_of_rooms", "vintage_year", + "total_price", + "currency", + "amount", + "unit", ] def __init__(self, api_client=None): @@ -158,6 +162,10 @@ def create_bitcoin_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -328,6 +336,10 @@ def create_ethereum_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -498,6 +510,10 @@ def create_flight_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -668,6 +684,10 @@ def create_hotel_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -838,6 +858,10 @@ def create_mass_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -1008,6 +1032,10 @@ def create_shipping_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -1178,6 +1206,10 @@ def create_vehicle_estimate_with_http_info( all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -1342,6 +1374,10 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -1496,6 +1532,10 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 65e3469..11de538 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -59,6 +59,10 @@ class OrdersApi(object): "number_of_nights", "number_of_rooms", "vintage_year", + "total_price", + "currency", + "amount", + "unit", ] def __init__(self, api_client=None): @@ -152,6 +156,10 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -308,6 +316,10 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -472,6 +484,10 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -626,6 +642,10 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -791,6 +811,10 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index bb94af3..8427e62 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -59,6 +59,10 @@ class ProjectsApi(object): "number_of_nights", "number_of_rooms", "vintage_year", + "total_price", + "currency", + "amount", + "unit", ] def __init__(self, api_client=None): @@ -152,6 +156,10 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -312,6 +320,10 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/technology_types_api.py b/patch_api/api/technology_types_api.py index 05b9d73..c5a6c78 100644 --- a/patch_api/api/technology_types_api.py +++ b/patch_api/api/technology_types_api.py @@ -59,6 +59,10 @@ class TechnologyTypesApi(object): "number_of_nights", "number_of_rooms", "vintage_year", + "total_price", + "currency", + "amount", + "unit", ] def __init__(self, api_client=None): @@ -150,6 +154,10 @@ def retrieve_technology_types_with_http_info(self, **kwargs): # noqa: E501 all_params.append("number_of_nights") all_params.append("number_of_rooms") all_params.append("vintage_year") + all_params.append("total_price") + all_params.append("currency") + all_params.append("amount") + all_params.append("unit") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 9ea2edf..652f783 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -91,7 +91,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "patch-python/1.20.0" + self.user_agent = "patch-python/1.21.0" def __del__(self): if self._pool: diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 3006d9a..9179e1f 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -341,7 +341,7 @@ def to_debug_report(self): "OS: {env}\n" "Python Version: {pyversion}\n" "Version of the API: v1\n" - "SDK Package Version: 1.20.0".format( + "SDK Package Version: 1.21.0".format( env=sys.platform, pyversion=sys.version ) ) diff --git a/patch_api/models/__init__.py b/patch_api/models/__init__.py index 4dd4178..f4b1c4f 100644 --- a/patch_api/models/__init__.py +++ b/patch_api/models/__init__.py @@ -38,8 +38,11 @@ from patch_api.models.estimate_list_response import EstimateListResponse from patch_api.models.estimate_response import EstimateResponse from patch_api.models.highlight import Highlight +from patch_api.models.inventory import Inventory from patch_api.models.meta_index_object import MetaIndexObject from patch_api.models.order import Order +from patch_api.models.order_inventory import OrderInventory +from patch_api.models.order_inventory_project import OrderInventoryProject from patch_api.models.order_list_response import OrderListResponse from patch_api.models.order_response import OrderResponse from patch_api.models.parent_technology_type import ParentTechnologyType diff --git a/patch_api/models/create_order_request.py b/patch_api/models/create_order_request.py index 841df43..86e68ff 100644 --- a/patch_api/models/create_order_request.py +++ b/patch_api/models/create_order_request.py @@ -40,6 +40,10 @@ class CreateOrderRequest(object): "metadata": "object", "state": "str", "vintage_year": "int", + "total_price": "int", + "currency": "str", + "amount": "int", + "unit": "str", } attribute_map = { @@ -49,6 +53,10 @@ class CreateOrderRequest(object): "metadata": "metadata", "state": "state", "vintage_year": "vintage_year", + "total_price": "total_price", + "currency": "currency", + "amount": "amount", + "unit": "unit", } def __init__( @@ -59,6 +67,10 @@ def __init__( metadata=None, state=None, vintage_year=None, + total_price=None, + currency=None, + amount=None, + unit=None, local_vars_configuration=None, ): # noqa: E501 """CreateOrderRequest - a model defined in OpenAPI""" # noqa: E501 @@ -72,6 +84,10 @@ def __init__( self._metadata = None self._state = None self._vintage_year = None + self._total_price = None + self._currency = None + self._amount = None + self._unit = None self.discriminator = None self.mass_g = mass_g @@ -80,6 +96,10 @@ def __init__( self.metadata = metadata self.state = state self.vintage_year = vintage_year + self.total_price = total_price + self.currency = currency + self.amount = amount + self.unit = unit @property def mass_g(self): @@ -257,6 +277,124 @@ def vintage_year(self, vintage_year): self._vintage_year = vintage_year + @property + def total_price(self): + """Gets the total_price of this CreateOrderRequest. # noqa: E501 + + + :return: The total_price of this CreateOrderRequest. # noqa: E501 + :rtype: int + """ + return self._total_price + + @total_price.setter + def total_price(self, total_price): + """Sets the total_price of this CreateOrderRequest. + + + :param total_price: The total_price of this CreateOrderRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and total_price is not None + and total_price < 1 + ): # noqa: E501 + raise ValueError( + "Invalid value for `total_price`, must be a value greater than or equal to `1`" + ) # noqa: E501 + + self._total_price = total_price + + @property + def currency(self): + """Gets the currency of this CreateOrderRequest. # noqa: E501 + + + :return: The currency of this CreateOrderRequest. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this CreateOrderRequest. + + + :param currency: The currency of this CreateOrderRequest. # noqa: E501 + :type: str + """ + + self._currency = currency + + @property + def amount(self): + """Gets the amount of this CreateOrderRequest. # noqa: E501 + + + :return: The amount of this CreateOrderRequest. # noqa: E501 + :rtype: int + """ + return self._amount + + @amount.setter + def amount(self, amount): + """Sets the amount of this CreateOrderRequest. + + + :param amount: The amount of this CreateOrderRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and amount is not None + and amount > 100000000000 + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount`, must be a value less than or equal to `100000000000`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and amount is not None + and amount < 0 + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount`, must be a value greater than or equal to `0`" + ) # noqa: E501 + + self._amount = amount + + @property + def unit(self): + """Gets the unit of this CreateOrderRequest. # noqa: E501 + + + :return: The unit of this CreateOrderRequest. # noqa: E501 + :rtype: str + """ + return self._unit + + @unit.setter + def unit(self, unit): + """Sets the unit of this CreateOrderRequest. + + + :param unit: The unit of this CreateOrderRequest. # noqa: E501 + :type: str + """ + allowed_values = [None, "g", "Wh"] # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and unit not in allowed_values + ): # noqa: E501 + raise ValueError( + "Invalid value for `unit` ({0}), must be one of {1}".format( # noqa: E501 + unit, allowed_values + ) + ) + + self._unit = unit + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/patch_api/models/inventory.py b/patch_api/models/inventory.py new file mode 100644 index 0000000..e8532fb --- /dev/null +++ b/patch_api/models/inventory.py @@ -0,0 +1,272 @@ +# coding: utf-8 + +""" + Patch API V1 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: v1 + Contact: engineering@usepatch.com + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from patch_api.configuration import Configuration + + +class Inventory(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "vintage_year": "int", + "amount_available": "int", + "price": "int", + "currency": "str", + "unit": "str", + } + + attribute_map = { + "vintage_year": "vintage_year", + "amount_available": "amount_available", + "price": "price", + "currency": "currency", + "unit": "unit", + } + + def __init__( + self, + vintage_year=None, + amount_available=None, + price=None, + currency=None, + unit=None, + local_vars_configuration=None, + ): # noqa: E501 + """Inventory - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._vintage_year = None + self._amount_available = None + self._price = None + self._currency = None + self._unit = None + self.discriminator = None + + self.vintage_year = vintage_year + self.amount_available = amount_available + self.price = price + self.currency = currency + self.unit = unit + + @property + def vintage_year(self): + """Gets the vintage_year of this Inventory. # noqa: E501 + + The year in which the climate impacts of the project occurred, or will occur. # noqa: E501 + + :return: The vintage_year of this Inventory. # noqa: E501 + :rtype: int + """ + return self._vintage_year + + @vintage_year.setter + def vintage_year(self, vintage_year): + """Sets the vintage_year of this Inventory. + + The year in which the climate impacts of the project occurred, or will occur. # noqa: E501 + + :param vintage_year: The vintage_year of this Inventory. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and vintage_year is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `vintage_year`, must not be `None`" + ) # noqa: E501 + + self._vintage_year = vintage_year + + @property + def amount_available(self): + """Gets the amount_available of this Inventory. # noqa: E501 + + The amount available for this vintage year. # noqa: E501 + + :return: The amount_available of this Inventory. # noqa: E501 + :rtype: int + """ + return self._amount_available + + @amount_available.setter + def amount_available(self, amount_available): + """Sets the amount_available of this Inventory. + + The amount available for this vintage year. # noqa: E501 + + :param amount_available: The amount_available of this Inventory. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and amount_available is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount_available`, must not be `None`" + ) # noqa: E501 + + self._amount_available = amount_available + + @property + def price(self): + """Gets the price of this Inventory. # noqa: E501 + + The price per tonne (1,000,000 g) or MWh (1,000,000 Wh) of inventory. Prices are always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :return: The price of this Inventory. # noqa: E501 + :rtype: int + """ + return self._price + + @price.setter + def price(self, price): + """Sets the price of this Inventory. + + The price per tonne (1,000,000 g) or MWh (1,000,000 Wh) of inventory. Prices are always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :param price: The price of this Inventory. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and price is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `price`, must not be `None`" + ) # noqa: E501 + + self._price = price + + @property + def currency(self): + """Gets the currency of this Inventory. # noqa: E501 + + The currency code for `price`. # noqa: E501 + + :return: The currency of this Inventory. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this Inventory. + + The currency code for `price`. # noqa: E501 + + :param currency: The currency of this Inventory. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and currency is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `currency`, must not be `None`" + ) # noqa: E501 + + self._currency = currency + + @property + def unit(self): + """Gets the unit of this Inventory. # noqa: E501 + + The unit of measurement (ie \"g\" or \"Wh\") for `amount_available`. # noqa: E501 + + :return: The unit of this Inventory. # noqa: E501 + :rtype: str + """ + return self._unit + + @unit.setter + def unit(self, unit): + """Sets the unit of this Inventory. + + The unit of measurement (ie \"g\" or \"Wh\") for `amount_available`. # noqa: E501 + + :param unit: The unit of this Inventory. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and unit is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `unit`, must not be `None`" + ) # noqa: E501 + + self._unit = unit + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, Inventory): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, Inventory): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/order.py b/patch_api/models/order.py index 5aa083b..6ed49ec 100644 --- a/patch_api/models/order.py +++ b/patch_api/models/order.py @@ -39,12 +39,18 @@ class Order(object): "mass_g": "int", "production": "bool", "state": "str", + "amount": "int", + "unit": "str", + "price": "int", + "patch_fee": "int", + "currency": "str", "allocation_state": "str", "price_cents_usd": "int", "patch_fee_cents_usd": "int", "allocations": "list[Allocation]", "registry_url": "str", "metadata": "object", + "inventory": "list[OrderInventory]", } attribute_map = { @@ -53,12 +59,18 @@ class Order(object): "mass_g": "mass_g", "production": "production", "state": "state", + "amount": "amount", + "unit": "unit", + "price": "price", + "patch_fee": "patch_fee", + "currency": "currency", "allocation_state": "allocation_state", "price_cents_usd": "price_cents_usd", "patch_fee_cents_usd": "patch_fee_cents_usd", "allocations": "allocations", "registry_url": "registry_url", "metadata": "metadata", + "inventory": "inventory", } def __init__( @@ -68,12 +80,18 @@ def __init__( mass_g=None, production=None, state=None, + amount=None, + unit=None, + price=None, + patch_fee=None, + currency=None, allocation_state=None, price_cents_usd=None, patch_fee_cents_usd=None, allocations=None, registry_url=None, metadata=None, + inventory=None, local_vars_configuration=None, ): # noqa: E501 """Order - a model defined in OpenAPI""" # noqa: E501 @@ -86,12 +104,18 @@ def __init__( self._mass_g = None self._production = None self._state = None + self._amount = None + self._unit = None + self._price = None + self._patch_fee = None + self._currency = None self._allocation_state = None self._price_cents_usd = None self._patch_fee_cents_usd = None self._allocations = None self._registry_url = None self._metadata = None + self._inventory = None self.discriminator = None self.id = id @@ -100,6 +124,11 @@ def __init__( self.mass_g = mass_g self.production = production self.state = state + self.amount = amount + self.unit = unit + self.price = price + self.patch_fee = patch_fee + self.currency = currency self.allocation_state = allocation_state self.price_cents_usd = price_cents_usd self.patch_fee_cents_usd = patch_fee_cents_usd @@ -108,6 +137,8 @@ def __init__( if registry_url is not None: self.registry_url = registry_url self.metadata = metadata + if inventory is not None: + self.inventory = inventory @property def id(self): @@ -163,7 +194,7 @@ def created_at(self, created_at): def mass_g(self): """Gets the mass_g of this Order. # noqa: E501 - The amount of carbon offsets in grams purchased through this order. # noqa: E501 + DEPRECATED, use `amount` and `unit` fields instead. The amount of carbon offsets in grams purchased through this order. # noqa: E501 :return: The mass_g of this Order. # noqa: E501 :rtype: int @@ -174,7 +205,7 @@ def mass_g(self): def mass_g(self, mass_g): """Sets the mass_g of this Order. - The amount of carbon offsets in grams purchased through this order. # noqa: E501 + DEPRECATED, use `amount` and `unit` fields instead. The amount of carbon offsets in grams purchased through this order. # noqa: E501 :param mass_g: The mass_g of this Order. # noqa: E501 :type: int @@ -278,6 +309,167 @@ def state(self, state): self._state = state + @property + def amount(self): + """Gets the amount of this Order. # noqa: E501 + + The amount in `unit`s purchased through this order. # noqa: E501 + + :return: The amount of this Order. # noqa: E501 + :rtype: int + """ + return self._amount + + @amount.setter + def amount(self, amount): + """Sets the amount of this Order. + + The amount in `unit`s purchased through this order. # noqa: E501 + + :param amount: The amount of this Order. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and amount is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount`, must not be `None`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and amount is not None + and amount > 100000000000 + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount`, must be a value less than or equal to `100000000000`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and amount is not None + and amount < 0 + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount`, must be a value greater than or equal to `0`" + ) # noqa: E501 + + self._amount = amount + + @property + def unit(self): + """Gets the unit of this Order. # noqa: E501 + + The unit of measurement (ie \"g\" or \"Wh\") for the `amount` ordered. # noqa: E501 + + :return: The unit of this Order. # noqa: E501 + :rtype: str + """ + return self._unit + + @unit.setter + def unit(self, unit): + """Sets the unit of this Order. + + The unit of measurement (ie \"g\" or \"Wh\") for the `amount` ordered. # noqa: E501 + + :param unit: The unit of this Order. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and unit is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `unit`, must not be `None`" + ) # noqa: E501 + + self._unit = unit + + @property + def price(self): + """Gets the price of this Order. # noqa: E501 + + The total price for the `amount` ordered. Prices are always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :return: The price of this Order. # noqa: E501 + :rtype: int + """ + return self._price + + @price.setter + def price(self, price): + """Sets the price of this Order. + + The total price for the `amount` ordered. Prices are always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :param price: The price of this Order. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and price is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `price`, must not be `None`" + ) # noqa: E501 + + self._price = price + + @property + def patch_fee(self): + """Gets the patch_fee of this Order. # noqa: E501 + + The Patch Fee for this order. Patch Fee is always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :return: The patch_fee of this Order. # noqa: E501 + :rtype: int + """ + return self._patch_fee + + @patch_fee.setter + def patch_fee(self, patch_fee): + """Sets the patch_fee of this Order. + + The Patch Fee for this order. Patch Fee is always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :param patch_fee: The patch_fee of this Order. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and patch_fee is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `patch_fee`, must not be `None`" + ) # noqa: E501 + + self._patch_fee = patch_fee + + @property + def currency(self): + """Gets the currency of this Order. # noqa: E501 + + The currency code for the `price` and `patch_fee`. # noqa: E501 + + :return: The currency of this Order. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this Order. + + The currency code for the `price` and `patch_fee`. # noqa: E501 + + :param currency: The currency of this Order. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and currency is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `currency`, must not be `None`" + ) # noqa: E501 + + self._currency = currency + @property def allocation_state(self): """Gets the allocation_state of this Order. # noqa: E501 @@ -322,7 +514,7 @@ def allocation_state(self, allocation_state): def price_cents_usd(self): """Gets the price_cents_usd of this Order. # noqa: E501 - The total price in cents USD of the carbon offsets purchased through this order. # noqa: E501 + DEPRECATED, use the `price` and `currency` fields instead. The total price in cents USD of the carbon offsets purchased through this order. # noqa: E501 :return: The price_cents_usd of this Order. # noqa: E501 :rtype: int @@ -333,7 +525,7 @@ def price_cents_usd(self): def price_cents_usd(self, price_cents_usd): """Sets the price_cents_usd of this Order. - The total price in cents USD of the carbon offsets purchased through this order. # noqa: E501 + DEPRECATED, use the `price` and `currency` fields instead. The total price in cents USD of the carbon offsets purchased through this order. # noqa: E501 :param price_cents_usd: The price_cents_usd of this Order. # noqa: E501 :type: int @@ -345,7 +537,7 @@ def price_cents_usd(self, price_cents_usd): def patch_fee_cents_usd(self): """Gets the patch_fee_cents_usd of this Order. # noqa: E501 - The Patch Fee in cents USD for this order. # noqa: E501 + DEPRECATED, use the `patch_fee` and `currency` fields instead. The Patch Fee in cents USD for this order. # noqa: E501 :return: The patch_fee_cents_usd of this Order. # noqa: E501 :rtype: int @@ -356,7 +548,7 @@ def patch_fee_cents_usd(self): def patch_fee_cents_usd(self, patch_fee_cents_usd): """Sets the patch_fee_cents_usd of this Order. - The Patch Fee in cents USD for this order. # noqa: E501 + DEPRECATED, use the `patch_fee` and `currency` fields instead. The Patch Fee in cents USD for this order. # noqa: E501 :param patch_fee_cents_usd: The patch_fee_cents_usd of this Order. # noqa: E501 :type: int @@ -439,6 +631,29 @@ def metadata(self, metadata): self._metadata = metadata + @property + def inventory(self): + """Gets the inventory of this Order. # noqa: E501 + + An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price. # noqa: E501 + + :return: The inventory of this Order. # noqa: E501 + :rtype: list[OrderInventory] + """ + return self._inventory + + @inventory.setter + def inventory(self, inventory): + """Sets the inventory of this Order. + + An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price. # noqa: E501 + + :param inventory: The inventory of this Order. # noqa: E501 + :type: list[OrderInventory] + """ + + self._inventory = inventory + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/patch_api/models/order_inventory.py b/patch_api/models/order_inventory.py new file mode 100644 index 0000000..98c793f --- /dev/null +++ b/patch_api/models/order_inventory.py @@ -0,0 +1,305 @@ +# coding: utf-8 + +""" + Patch API V1 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: v1 + Contact: engineering@usepatch.com + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from patch_api.configuration import Configuration + + +class OrderInventory(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + "project": "OrderInventoryProject", + "vintage_year": "int", + "amount": "int", + "unit": "str", + "price": "int", + "currency": "str", + } + + attribute_map = { + "project": "project", + "vintage_year": "vintage_year", + "amount": "amount", + "unit": "unit", + "price": "price", + "currency": "currency", + } + + def __init__( + self, + project=None, + vintage_year=None, + amount=None, + unit=None, + price=None, + currency=None, + local_vars_configuration=None, + ): # noqa: E501 + """OrderInventory - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._project = None + self._vintage_year = None + self._amount = None + self._unit = None + self._price = None + self._currency = None + self.discriminator = None + + self.project = project + self.vintage_year = vintage_year + self.amount = amount + self.unit = unit + self.price = price + self.currency = currency + + @property + def project(self): + """Gets the project of this OrderInventory. # noqa: E501 + + An object containing information about the project associated with the inventory allocated. # noqa: E501 + + :return: The project of this OrderInventory. # noqa: E501 + :rtype: OrderInventoryProject + """ + return self._project + + @project.setter + def project(self, project): + """Sets the project of this OrderInventory. + + An object containing information about the project associated with the inventory allocated. # noqa: E501 + + :param project: The project of this OrderInventory. # noqa: E501 + :type: OrderInventoryProject + """ + if ( + self.local_vars_configuration.client_side_validation and project is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `project`, must not be `None`" + ) # noqa: E501 + + self._project = project + + @property + def vintage_year(self): + """Gets the vintage_year of this OrderInventory. # noqa: E501 + + The year in which the climate impacts of the project occurred, or will occur. # noqa: E501 + + :return: The vintage_year of this OrderInventory. # noqa: E501 + :rtype: int + """ + return self._vintage_year + + @vintage_year.setter + def vintage_year(self, vintage_year): + """Sets the vintage_year of this OrderInventory. + + The year in which the climate impacts of the project occurred, or will occur. # noqa: E501 + + :param vintage_year: The vintage_year of this OrderInventory. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and vintage_year is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `vintage_year`, must not be `None`" + ) # noqa: E501 + + self._vintage_year = vintage_year + + @property + def amount(self): + """Gets the amount of this OrderInventory. # noqa: E501 + + The amount ordered for the given project and vintage year. # noqa: E501 + + :return: The amount of this OrderInventory. # noqa: E501 + :rtype: int + """ + return self._amount + + @amount.setter + def amount(self, amount): + """Sets the amount of this OrderInventory. + + The amount ordered for the given project and vintage year. # noqa: E501 + + :param amount: The amount of this OrderInventory. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and amount is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `amount`, must not be `None`" + ) # noqa: E501 + + self._amount = amount + + @property + def unit(self): + """Gets the unit of this OrderInventory. # noqa: E501 + + The unit of measurement (ie \"g\" or \"Wh\") for the `amount` ordered for the given project and vintage year. # noqa: E501 + + :return: The unit of this OrderInventory. # noqa: E501 + :rtype: str + """ + return self._unit + + @unit.setter + def unit(self, unit): + """Sets the unit of this OrderInventory. + + The unit of measurement (ie \"g\" or \"Wh\") for the `amount` ordered for the given project and vintage year. # noqa: E501 + + :param unit: The unit of this OrderInventory. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and unit is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `unit`, must not be `None`" + ) # noqa: E501 + + self._unit = unit + + @property + def price(self): + """Gets the price of this OrderInventory. # noqa: E501 + + The price for the given amount ordered for the given project and vintage year. Does not include any Patch fee. Prices are always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :return: The price of this OrderInventory. # noqa: E501 + :rtype: int + """ + return self._price + + @price.setter + def price(self, price): + """Sets the price of this OrderInventory. + + The price for the given amount ordered for the given project and vintage year. Does not include any Patch fee. Prices are always represented in the smallest currency unit (ie cents for USD). # noqa: E501 + + :param price: The price of this OrderInventory. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation and price is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `price`, must not be `None`" + ) # noqa: E501 + + self._price = price + + @property + def currency(self): + """Gets the currency of this OrderInventory. # noqa: E501 + + The currency code for the `price`. # noqa: E501 + + :return: The currency of this OrderInventory. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this OrderInventory. + + The currency code for the `price`. # noqa: E501 + + :param currency: The currency of this OrderInventory. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and currency is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `currency`, must not be `None`" + ) # noqa: E501 + + self._currency = currency + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, OrderInventory): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, OrderInventory): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/order_inventory_project.py b/patch_api/models/order_inventory_project.py new file mode 100644 index 0000000..634b9b8 --- /dev/null +++ b/patch_api/models/order_inventory_project.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + Patch API V1 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: v1 + Contact: engineering@usepatch.com + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from patch_api.configuration import Configuration + + +class OrderInventoryProject(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {"id": "str", "name": "str"} + + attribute_map = {"id": "id", "name": "name"} + + def __init__(self, id=None, name=None, local_vars_configuration=None): # noqa: E501 + """OrderInventoryProject - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._id = None + self._name = None + self.discriminator = None + + self.id = id + self.name = name + + @property + def id(self): + """Gets the id of this OrderInventoryProject. # noqa: E501 + + The unique uid for a project. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in. # noqa: E501 + + :return: The id of this OrderInventoryProject. # noqa: E501 + :rtype: str + """ + return self._id + + @id.setter + def id(self, id): + """Sets the id of this OrderInventoryProject. + + The unique uid for a project. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in. # noqa: E501 + + :param id: The id of this OrderInventoryProject. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 + raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 + + self._id = id + + @property + def name(self): + """Gets the name of this OrderInventoryProject. # noqa: E501 + + The name of the project. # noqa: E501 + + :return: The name of this OrderInventoryProject. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this OrderInventoryProject. + + The name of the project. # noqa: E501 + + :param name: The name of this OrderInventoryProject. # noqa: E501 + :type: str + """ + if ( + self.local_vars_configuration.client_side_validation and name is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `name`, must not be `None`" + ) # noqa: E501 + + self._name = name + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, OrderInventoryProject): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, OrderInventoryProject): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/project.py b/patch_api/models/project.py index 1014a8a..e772187 100644 --- a/patch_api/models/project.py +++ b/patch_api/models/project.py @@ -54,6 +54,7 @@ class Project(object): "tagline": "str", "technology_type": "TechnologyType", "highlights": "list[Highlight]", + "inventory": "list[Inventory]", } attribute_map = { @@ -77,6 +78,7 @@ class Project(object): "tagline": "tagline", "technology_type": "technology_type", "highlights": "highlights", + "inventory": "inventory", } def __init__( @@ -101,6 +103,7 @@ def __init__( tagline=None, technology_type=None, highlights=None, + inventory=None, local_vars_configuration=None, ): # noqa: E501 """Project - a model defined in OpenAPI""" # noqa: E501 @@ -128,6 +131,7 @@ def __init__( self._tagline = None self._technology_type = None self._highlights = None + self._inventory = None self.discriminator = None self.id = id @@ -154,6 +158,7 @@ def __init__( self.tagline = tagline self.technology_type = technology_type self.highlights = highlights + self.inventory = inventory @property def id(self): @@ -479,7 +484,7 @@ def photos(self, photos): def average_price_per_tonne_cents_usd(self): """Gets the average_price_per_tonne_cents_usd of this Project. # noqa: E501 - The average price per tonne in USD cents for carbon offsets supplied by this project. # noqa: E501 + DEPRECATED. The average price per tonne in USD cents for carbon offsets supplied by this project. # noqa: E501 :return: The average_price_per_tonne_cents_usd of this Project. # noqa: E501 :rtype: int @@ -490,7 +495,7 @@ def average_price_per_tonne_cents_usd(self): def average_price_per_tonne_cents_usd(self, average_price_per_tonne_cents_usd): """Sets the average_price_per_tonne_cents_usd of this Project. - The average price per tonne in USD cents for carbon offsets supplied by this project. # noqa: E501 + DEPRECATED. The average price per tonne in USD cents for carbon offsets supplied by this project. # noqa: E501 :param average_price_per_tonne_cents_usd: The average_price_per_tonne_cents_usd of this Project. # noqa: E501 :type: int @@ -509,7 +514,7 @@ def average_price_per_tonne_cents_usd(self, average_price_per_tonne_cents_usd): def remaining_mass_g(self): """Gets the remaining_mass_g of this Project. # noqa: E501 - The remaining mass in grams available for purchase for this project. # noqa: E501 + DEPRECATED. The remaining mass in grams available for purchase for this project. # noqa: E501 :return: The remaining_mass_g of this Project. # noqa: E501 :rtype: int @@ -520,7 +525,7 @@ def remaining_mass_g(self): def remaining_mass_g(self, remaining_mass_g): """Sets the remaining_mass_g of this Project. - The remaining mass in grams available for purchase for this project. # noqa: E501 + DEPRECATED. The remaining mass in grams available for purchase for this project. # noqa: E501 :param remaining_mass_g: The remaining_mass_g of this Project. # noqa: E501 :type: int @@ -659,7 +664,7 @@ def technology_type(self, technology_type): def highlights(self): """Gets the highlights of this Project. # noqa: E501 - An array of objects containing the highlight's slug, title, and a URL for the corresponding icon. A highlight's title is a short string that spotlights a characteristic about the project. # noqa: E501 + An array of objects containing the highlight's slug, title, and a URL for the corresponding icon. A highlight's title is a short string that spotlights a characteristic about the project. # noqa: E501 :return: The highlights of this Project. # noqa: E501 :rtype: list[Highlight] @@ -670,7 +675,7 @@ def highlights(self): def highlights(self, highlights): """Sets the highlights of this Project. - An array of objects containing the highlight's slug, title, and a URL for the corresponding icon. A highlight's title is a short string that spotlights a characteristic about the project. # noqa: E501 + An array of objects containing the highlight's slug, title, and a URL for the corresponding icon. A highlight's title is a short string that spotlights a characteristic about the project. # noqa: E501 :param highlights: The highlights of this Project. # noqa: E501 :type: list[Highlight] @@ -684,6 +689,35 @@ def highlights(self, highlights): self._highlights = highlights + @property + def inventory(self): + """Gets the inventory of this Project. # noqa: E501 + + An array of objects containing available inventory for a project. Available inventory is grouped by a project's vintage year and returns amount and pricing available for a given vintage year. # noqa: E501 + + :return: The inventory of this Project. # noqa: E501 + :rtype: list[Inventory] + """ + return self._inventory + + @inventory.setter + def inventory(self, inventory): + """Sets the inventory of this Project. + + An array of objects containing available inventory for a project. Available inventory is grouped by a project's vintage year and returns amount and pricing available for a given vintage year. # noqa: E501 + + :param inventory: The inventory of this Project. # noqa: E501 + :type: list[Inventory] + """ + if ( + self.local_vars_configuration.client_side_validation and inventory is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `inventory`, must not be `None`" + ) # noqa: E501 + + self._inventory = inventory + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/setup.py b/setup.py index 2749b67..cebcd9e 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "1.20.0" +VERSION = "1.21.0" # To install the library, run the following # # python setup.py install diff --git a/test/test_orders_api.py b/test/test_orders_api.py index 798d762..2e3ea7e 100644 --- a/test/test_orders_api.py +++ b/test/test_orders_api.py @@ -11,6 +11,7 @@ """ from __future__ import absolute_import +from locale import currency import unittest import os @@ -118,6 +119,23 @@ def test_create_order_with_vintage_year(self): self.assertTrue(order) + def test_create_order_with_amount_and_unit(self): + """Test case for amount and unit on create order""" + order = self.api.create_order(amount=100, unit="g") + + self.assertTrue(order) + self.assertEqual(order.data.amount, 100) + self.assertEqual(order.data.unit, "g") + self.assertEqual(order.data.inventory[0].unit, "g") + + def test_create_order_with_total_price_and_currency(self): + """Test case for total price and currency on create order""" + order = self.api.create_order(total_price=100, currency="EUR") + + self.assertTrue(order) + self.assertTrue(99 <= (order.data.price + order.data.patch_fee) <= 101) + self.assertEqual(order.data.currency, "EUR") + if __name__ == "__main__": unittest.main() diff --git a/test/test_projects_api.py b/test/test_projects_api.py index 1f3976e..e38f642 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -56,6 +56,14 @@ def test_retrieve_project(self): self.assertTrue(isinstance(parent_technology_type.name, str)) self.assertTrue(isinstance(parent_technology_type.slug, str)) + inventory = project.inventory + self.assertTrue(isinstance(inventory, list)) + self.assertTrue(isinstance(inventory[0].vintage_year, int)) + self.assertTrue(isinstance(inventory[0].amount_available, int)) + self.assertTrue(isinstance(inventory[0].price, int)) + self.assertTrue(isinstance(inventory[0].currency, str)) + self.assertTrue(isinstance(inventory[0].unit, str)) + def test_retrieve_projects(self): """Test case for retrieve_projects