diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 7564077..b089014 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -3,11 +3,11 @@ # flake8: noqa """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "1.24.2" +__version__ = "2.0.0" # import ApiClient from patch_api.api_client import ApiClient diff --git a/patch_api/api/__init__.py b/patch_api/api/__init__.py index 0ceceec..3505903 100644 --- a/patch_api/api/__init__.py +++ b/patch_api/api/__init__.py @@ -4,6 +4,7 @@ # import apis into api package from patch_api.api.estimates_api import EstimatesApi +from patch_api.api.order_line_items_api import OrderLineItemsApi from patch_api.api.orders_api import OrdersApi from patch_api.api.projects_api import ProjectsApi from patch_api.api.technology_types_api import TechnologyTypesApi diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index c72d325..5960204 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -97,6 +97,7 @@ def create_air_shipping_estimate( :param async_req bool: execute request asynchronously :param CreateAirShippingEstimateRequest create_air_shipping_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -126,6 +127,7 @@ def create_air_shipping_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateAirShippingEstimateRequest create_air_shipping_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -142,7 +144,10 @@ def create_air_shipping_estimate_with_http_info( local_var_params = locals() - all_params = ["create_air_shipping_estimate_request"] # noqa: E501 + all_params = [ + "create_air_shipping_estimate_request", + "patch_version", + ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -232,6 +237,10 @@ def create_air_shipping_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -287,6 +296,7 @@ def create_bitcoin_estimate( :param async_req bool: execute request asynchronously :param CreateBitcoinEstimateRequest create_bitcoin_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -316,6 +326,7 @@ def create_bitcoin_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateBitcoinEstimateRequest create_bitcoin_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -332,7 +343,7 @@ def create_bitcoin_estimate_with_http_info( local_var_params = locals() - all_params = ["create_bitcoin_estimate_request"] # noqa: E501 + all_params = ["create_bitcoin_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -422,6 +433,10 @@ def create_bitcoin_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -477,6 +492,7 @@ def create_ecommerce_estimate( :param async_req bool: execute request asynchronously :param CreateEcommerceEstimateRequest create_ecommerce_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -506,6 +522,7 @@ def create_ecommerce_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateEcommerceEstimateRequest create_ecommerce_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -522,7 +539,10 @@ def create_ecommerce_estimate_with_http_info( local_var_params = locals() - all_params = ["create_ecommerce_estimate_request"] # noqa: E501 + all_params = [ + "create_ecommerce_estimate_request", + "patch_version", + ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -612,6 +632,10 @@ def create_ecommerce_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -667,6 +691,7 @@ def create_ethereum_estimate( :param async_req bool: execute request asynchronously :param CreateEthereumEstimateRequest create_ethereum_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -696,6 +721,7 @@ def create_ethereum_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateEthereumEstimateRequest create_ethereum_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -712,7 +738,7 @@ def create_ethereum_estimate_with_http_info( local_var_params = locals() - all_params = ["create_ethereum_estimate_request"] # noqa: E501 + all_params = ["create_ethereum_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -802,6 +828,10 @@ def create_ethereum_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -857,6 +887,7 @@ def create_flight_estimate( :param async_req bool: execute request asynchronously :param CreateFlightEstimateRequest create_flight_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -886,6 +917,7 @@ def create_flight_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateFlightEstimateRequest create_flight_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -902,7 +934,7 @@ def create_flight_estimate_with_http_info( local_var_params = locals() - all_params = ["create_flight_estimate_request"] # noqa: E501 + all_params = ["create_flight_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -992,6 +1024,10 @@ def create_flight_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -1047,6 +1083,7 @@ def create_hotel_estimate( :param async_req bool: execute request asynchronously :param CreateHotelEstimateRequest create_hotel_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -1076,6 +1113,7 @@ def create_hotel_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateHotelEstimateRequest create_hotel_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -1092,7 +1130,7 @@ def create_hotel_estimate_with_http_info( local_var_params = locals() - all_params = ["create_hotel_estimate_request"] # noqa: E501 + all_params = ["create_hotel_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -1182,6 +1220,10 @@ def create_hotel_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -1237,6 +1279,7 @@ def create_mass_estimate( :param async_req bool: execute request asynchronously :param CreateMassEstimateRequest create_mass_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -1266,6 +1309,7 @@ def create_mass_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateMassEstimateRequest create_mass_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -1282,7 +1326,7 @@ def create_mass_estimate_with_http_info( local_var_params = locals() - all_params = ["create_mass_estimate_request"] # noqa: E501 + all_params = ["create_mass_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -1372,6 +1416,10 @@ def create_mass_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -1427,6 +1475,7 @@ def create_rail_shipping_estimate( :param async_req bool: execute request asynchronously :param CreateRailShippingEstimateRequest create_rail_shipping_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -1456,6 +1505,7 @@ def create_rail_shipping_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateRailShippingEstimateRequest create_rail_shipping_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -1472,7 +1522,10 @@ def create_rail_shipping_estimate_with_http_info( local_var_params = locals() - all_params = ["create_rail_shipping_estimate_request"] # noqa: E501 + all_params = [ + "create_rail_shipping_estimate_request", + "patch_version", + ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -1562,6 +1615,10 @@ def create_rail_shipping_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -1617,6 +1674,7 @@ def create_road_shipping_estimate( :param async_req bool: execute request asynchronously :param CreateRoadShippingEstimateRequest create_road_shipping_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -1646,6 +1704,7 @@ def create_road_shipping_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateRoadShippingEstimateRequest create_road_shipping_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -1662,7 +1721,10 @@ def create_road_shipping_estimate_with_http_info( local_var_params = locals() - all_params = ["create_road_shipping_estimate_request"] # noqa: E501 + all_params = [ + "create_road_shipping_estimate_request", + "patch_version", + ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -1752,6 +1814,10 @@ def create_road_shipping_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -1807,6 +1873,7 @@ def create_sea_shipping_estimate( :param async_req bool: execute request asynchronously :param CreateSeaShippingEstimateRequest create_sea_shipping_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -1836,6 +1903,7 @@ def create_sea_shipping_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateSeaShippingEstimateRequest create_sea_shipping_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -1852,7 +1920,10 @@ def create_sea_shipping_estimate_with_http_info( local_var_params = locals() - all_params = ["create_sea_shipping_estimate_request"] # noqa: E501 + all_params = [ + "create_sea_shipping_estimate_request", + "patch_version", + ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -1942,6 +2013,10 @@ def create_sea_shipping_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -1997,6 +2072,7 @@ def create_shipping_estimate( :param async_req bool: execute request asynchronously :param CreateShippingEstimateRequest create_shipping_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -2026,6 +2102,7 @@ def create_shipping_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateShippingEstimateRequest create_shipping_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -2042,7 +2119,7 @@ def create_shipping_estimate_with_http_info( local_var_params = locals() - all_params = ["create_shipping_estimate_request"] # noqa: E501 + all_params = ["create_shipping_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -2132,6 +2209,10 @@ def create_shipping_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -2187,6 +2268,7 @@ def create_vehicle_estimate( :param async_req bool: execute request asynchronously :param CreateVehicleEstimateRequest create_vehicle_estimate_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -2216,6 +2298,7 @@ def create_vehicle_estimate_with_http_info( :param async_req bool: execute request asynchronously :param CreateVehicleEstimateRequest create_vehicle_estimate_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -2232,7 +2315,7 @@ def create_vehicle_estimate_with_http_info( local_var_params = locals() - all_params = ["create_vehicle_estimate_request"] # noqa: E501 + all_params = ["create_vehicle_estimate_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -2322,6 +2405,10 @@ def create_vehicle_estimate_with_http_info( query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -2375,6 +2462,7 @@ def retrieve_estimate(self, id={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -2400,6 +2488,7 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -2416,7 +2505,7 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 + all_params = ["id", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -2505,6 +2594,10 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -2549,6 +2642,7 @@ def retrieve_estimates(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -2574,6 +2668,7 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -2590,7 +2685,7 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["page"] # noqa: E501 + all_params = ["page", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -2674,6 +2769,10 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} diff --git a/patch_api/api/order_line_items_api.py b/patch_api/api/order_line_items_api.py new file mode 100644 index 0000000..158fe51 --- /dev/null +++ b/patch_api/api/order_line_items_api.py @@ -0,0 +1,718 @@ +# coding: utf-8 + +""" + Patch API V2 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: engineering@usepatch.com + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from patch_api.exceptions import ApiTypeError, ApiValueError + + +class OrderLineItemsApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + ALLOWED_QUERY_PARAMS = [ + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "transaction_value_eth_gwei", + "gas_used", + "average_daily_balance_btc_sats", + "average_daily_balance_eth_gwei", + "timestamp", + "origin_airport", + "destination_airport", + "aircraft_code", + "cabin_class", + "passenger_count", + "state", + "country_code", + "city", + "region", + "star_rating", + "number_of_nights", + "number_of_rooms", + "vintage_year", + "total_price", + "currency", + "amount", + "unit", + "issued_to", + "cargo_type", + "container_size_code", + "destination_country_code", + "destination_locode", + "destination_postal_code", + "emissions_scope", + "freight_mass_g", + "freight_volume_cubic_m", + "fuel_type", + "number_of_containers", + "origin_country_code", + "origin_locode", + "origin_postal_code", + "truck_weight_t", + "vessel_imo", + ] + + def __init__(self, api_client=None): + self.api_client = api_client + + def create_order_line_item( + self, order_id={}, create_order_line_item_request={}, **kwargs + ): # noqa: E501 + """Creates an order line item # noqa: E501 + + Creates a line item on an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_order_line_item(order_id, create_order_line_item_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: (required) + :param CreateOrderLineItemRequest create_order_line_item_request: (required) + :param int patch_version: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: OrderLineItemResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.create_order_line_item_with_http_info( + order_id, create_order_line_item_request, **kwargs + ) # noqa: E501 + + def create_order_line_item_with_http_info( + self, order_id, create_order_line_item_request, **kwargs + ): # noqa: E501 + """Creates an order line item # noqa: E501 + + Creates a line item on an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_order_line_item_with_http_info(order_id, create_order_line_item_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: (required) + :param CreateOrderLineItemRequest create_order_line_item_request: (required) + :param int patch_version: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(OrderLineItemResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = [ + "order_id", + "create_order_line_item_request", + "patch_version", + ] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("transaction_value_eth_gwei") + all_params.append("gas_used") + all_params.append("transaction_value_btc_sats") + all_params.append("average_daily_balance_btc_sats") + all_params.append("average_daily_balance_eth_gwei") + all_params.append("timestamp") + all_params.append("origin_airport") + all_params.append("destination_airport") + all_params.append("aircraft_code") + all_params.append("cabin_class") + all_params.append("passenger_count") + all_params.append("state") + all_params.append("country_code") + all_params.append("city") + all_params.append("region") + all_params.append("star_rating") + 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") + all_params.append("issued_to") + all_params.append("cargo_type") + all_params.append("container_size_code") + all_params.append("destination_country_code") + all_params.append("destination_locode") + all_params.append("destination_postal_code") + all_params.append("emissions_scope") + all_params.append("freight_mass_g") + all_params.append("freight_volume_cubic_m") + all_params.append("fuel_type") + all_params.append("number_of_containers") + all_params.append("origin_country_code") + all_params.append("origin_locode") + all_params.append("origin_postal_code") + all_params.append("truck_weight_t") + all_params.append("vessel_imo") + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_order_line_item" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + # verify the required parameter 'order_id' is set + if "order_id" not in local_var_params or local_var_params["order_id"] is None: + raise ApiValueError( + "Missing the required parameter `order_id` when calling `create_order_line_item`" + ) # noqa: E501 + # verify the required parameter 'create_order_line_item_request' is set + if ( + "create_order_line_item_request" not in local_var_params + or local_var_params["create_order_line_item_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_order_line_item_request` when calling `create_order_line_item`" + ) # noqa: E501 + + collection_formats = {} + + path_params = {} + if "order_id" in local_var_params: + path_params["order_id"] = local_var_params["order_id"] # noqa: E501 + + query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + + for key in kwargs: + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) + + header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 + + form_params = [] + local_var_files = {} + + body_params = None + if "create_order_line_item_request" in local_var_params: + body_params = local_var_params["create_order_line_item_request"] + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # HTTP header `Content-Type` + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = ["bearer_auth"] # noqa: E501 + + return self.api_client.call_api( + "/v1/orders/{order_id}/line_items", + "POST", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="OrderLineItemResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def delete_order_line_item( + self, order_id={}, serial_number={}, **kwargs + ): # noqa: E501 + """Deletes an order line item # noqa: E501 + + Deletes a line item on an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_order_line_item(order_id, serial_number, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: (required) + :param str serial_number: (required) + :param int patch_version: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: DeleteOrderResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.delete_order_line_item_with_http_info( + order_id, serial_number, **kwargs + ) # noqa: E501 + + def delete_order_line_item_with_http_info( + self, order_id, serial_number, **kwargs + ): # noqa: E501 + """Deletes an order line item # noqa: E501 + + Deletes a line item on an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_order_line_item_with_http_info(order_id, serial_number, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: (required) + :param str serial_number: (required) + :param int patch_version: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(DeleteOrderResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ["order_id", "serial_number", "patch_version"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("transaction_value_eth_gwei") + all_params.append("gas_used") + all_params.append("transaction_value_btc_sats") + all_params.append("average_daily_balance_btc_sats") + all_params.append("average_daily_balance_eth_gwei") + all_params.append("timestamp") + all_params.append("origin_airport") + all_params.append("destination_airport") + all_params.append("aircraft_code") + all_params.append("cabin_class") + all_params.append("passenger_count") + all_params.append("state") + all_params.append("country_code") + all_params.append("city") + all_params.append("region") + all_params.append("star_rating") + 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") + all_params.append("issued_to") + all_params.append("cargo_type") + all_params.append("container_size_code") + all_params.append("destination_country_code") + all_params.append("destination_locode") + all_params.append("destination_postal_code") + all_params.append("emissions_scope") + all_params.append("freight_mass_g") + all_params.append("freight_volume_cubic_m") + all_params.append("fuel_type") + all_params.append("number_of_containers") + all_params.append("origin_country_code") + all_params.append("origin_locode") + all_params.append("origin_postal_code") + all_params.append("truck_weight_t") + all_params.append("vessel_imo") + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_order_line_item" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + # verify the required parameter 'order_id' is set + if "order_id" not in local_var_params or local_var_params["order_id"] is None: + raise ApiValueError( + "Missing the required parameter `order_id` when calling `delete_order_line_item`" + ) # noqa: E501 + # verify the required parameter 'serial_number' is set + if ( + "serial_number" not in local_var_params + or local_var_params["serial_number"] is None + ): + raise ApiValueError( + "Missing the required parameter `serial_number` when calling `delete_order_line_item`" + ) # noqa: E501 + + collection_formats = {} + + path_params = {} + if "order_id" in local_var_params: + path_params["order_id"] = local_var_params["order_id"] # noqa: E501 + if "serial_number" in local_var_params: + path_params["serial_number"] = local_var_params[ + "serial_number" + ] # noqa: E501 + + query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + + for key in kwargs: + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) + + header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = ["bearer_auth"] # noqa: E501 + + return self.api_client.call_api( + "/v1/orders/{order_id}/line_items/{serial_number}", + "DELETE", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="DeleteOrderResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def update_order_line_item( + self, order_id={}, serial_number={}, update_order_line_item_request={}, **kwargs + ): # noqa: E501 + """Updates an order line item # noqa: E501 + + Updates a line item on an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_order_line_item(order_id, serial_number, update_order_line_item_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: (required) + :param str serial_number: (required) + :param UpdateOrderLineItemRequest update_order_line_item_request: (required) + :param int patch_version: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: OrderLineItemResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.update_order_line_item_with_http_info( + order_id, serial_number, update_order_line_item_request, **kwargs + ) # noqa: E501 + + def update_order_line_item_with_http_info( + self, order_id, serial_number, update_order_line_item_request, **kwargs + ): # noqa: E501 + """Updates an order line item # noqa: E501 + + Updates a line item on an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_order_line_item_with_http_info(order_id, serial_number, update_order_line_item_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: (required) + :param str serial_number: (required) + :param UpdateOrderLineItemRequest update_order_line_item_request: (required) + :param int patch_version: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(OrderLineItemResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = [ + "order_id", + "serial_number", + "update_order_line_item_request", + "patch_version", + ] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("transaction_value_eth_gwei") + all_params.append("gas_used") + all_params.append("transaction_value_btc_sats") + all_params.append("average_daily_balance_btc_sats") + all_params.append("average_daily_balance_eth_gwei") + all_params.append("timestamp") + all_params.append("origin_airport") + all_params.append("destination_airport") + all_params.append("aircraft_code") + all_params.append("cabin_class") + all_params.append("passenger_count") + all_params.append("state") + all_params.append("country_code") + all_params.append("city") + all_params.append("region") + all_params.append("star_rating") + 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") + all_params.append("issued_to") + all_params.append("cargo_type") + all_params.append("container_size_code") + all_params.append("destination_country_code") + all_params.append("destination_locode") + all_params.append("destination_postal_code") + all_params.append("emissions_scope") + all_params.append("freight_mass_g") + all_params.append("freight_volume_cubic_m") + all_params.append("fuel_type") + all_params.append("number_of_containers") + all_params.append("origin_country_code") + all_params.append("origin_locode") + all_params.append("origin_postal_code") + all_params.append("truck_weight_t") + all_params.append("vessel_imo") + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method update_order_line_item" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + # verify the required parameter 'order_id' is set + if "order_id" not in local_var_params or local_var_params["order_id"] is None: + raise ApiValueError( + "Missing the required parameter `order_id` when calling `update_order_line_item`" + ) # noqa: E501 + # verify the required parameter 'serial_number' is set + if ( + "serial_number" not in local_var_params + or local_var_params["serial_number"] is None + ): + raise ApiValueError( + "Missing the required parameter `serial_number` when calling `update_order_line_item`" + ) # noqa: E501 + # verify the required parameter 'update_order_line_item_request' is set + if ( + "update_order_line_item_request" not in local_var_params + or local_var_params["update_order_line_item_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `update_order_line_item_request` when calling `update_order_line_item`" + ) # noqa: E501 + + collection_formats = {} + + path_params = {} + if "order_id" in local_var_params: + path_params["order_id"] = local_var_params["order_id"] # noqa: E501 + if "serial_number" in local_var_params: + path_params["serial_number"] = local_var_params[ + "serial_number" + ] # noqa: E501 + + query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + + for key in kwargs: + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) + + header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 + + form_params = [] + local_var_files = {} + + body_params = None + if "update_order_line_item_request" in local_var_params: + body_params = local_var_params["update_order_line_item_request"] + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # HTTP header `Content-Type` + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = ["bearer_auth"] # noqa: E501 + + return self.api_client.call_api( + "/v1/orders/{order_id}/line_items/{serial_number}", + "PATCH", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="OrderLineItemResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index a4b80d6..77e3242 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -95,6 +95,7 @@ def cancel_order(self, id={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -120,6 +121,7 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -136,7 +138,7 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 + all_params = ["id", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -225,6 +227,10 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -261,7 +267,7 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 def create_order(self, create_order_request={}, **kwargs): # noqa: E501 """Creates an order # noqa: E501 - Creates an order in the `placed` or `draft` state. # noqa: E501 + Creates an order in the `placed` or `draft`, or `reserved` state. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_order(create_order_request, async_req=True) @@ -269,6 +275,7 @@ def create_order(self, create_order_request={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param CreateOrderRequest create_order_request: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -288,7 +295,7 @@ def create_order(self, create_order_request={}, **kwargs): # noqa: E501 def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: E501 """Creates an order # noqa: E501 - Creates an order in the `placed` or `draft` state. # noqa: E501 + Creates an order in the `placed` or `draft`, or `reserved` state. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_order_with_http_info(create_order_request, async_req=True) @@ -296,6 +303,7 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: :param async_req bool: execute request asynchronously :param CreateOrderRequest create_order_request: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -312,7 +320,7 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: local_var_params = locals() - all_params = ["create_order_request"] # noqa: E501 + all_params = ["create_order_request", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -402,6 +410,10 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -444,6 +456,186 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: collection_formats=collection_formats, ) + def delete_order(self, uid={}, **kwargs): # noqa: E501 + """Deletes a draft order # noqa: E501 + + Deletes an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_order(uid, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str uid: (required) + :param int patch_version: + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: DeleteOrderResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.delete_order_with_http_info(uid, **kwargs) # noqa: E501 + + def delete_order_with_http_info(self, uid, **kwargs): # noqa: E501 + """Deletes a draft order # noqa: E501 + + Deletes an order that is in the `draft` state. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_order_with_http_info(uid, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str uid: (required) + :param int patch_version: + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(DeleteOrderResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ["uid", "patch_version"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("transaction_value_eth_gwei") + all_params.append("gas_used") + all_params.append("transaction_value_btc_sats") + all_params.append("average_daily_balance_btc_sats") + all_params.append("average_daily_balance_eth_gwei") + all_params.append("timestamp") + all_params.append("origin_airport") + all_params.append("destination_airport") + all_params.append("aircraft_code") + all_params.append("cabin_class") + all_params.append("passenger_count") + all_params.append("state") + all_params.append("country_code") + all_params.append("city") + all_params.append("region") + all_params.append("star_rating") + 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") + all_params.append("issued_to") + all_params.append("cargo_type") + all_params.append("container_size_code") + all_params.append("destination_country_code") + all_params.append("destination_locode") + all_params.append("destination_postal_code") + all_params.append("emissions_scope") + all_params.append("freight_mass_g") + all_params.append("freight_volume_cubic_m") + all_params.append("fuel_type") + all_params.append("number_of_containers") + all_params.append("origin_country_code") + all_params.append("origin_locode") + all_params.append("origin_postal_code") + all_params.append("truck_weight_t") + all_params.append("vessel_imo") + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_order" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + # verify the required parameter 'uid' is set + if "uid" not in local_var_params or local_var_params["uid"] is None: + raise ApiValueError( + "Missing the required parameter `uid` when calling `delete_order`" + ) # noqa: E501 + + collection_formats = {} + + path_params = {} + if "uid" in local_var_params: + path_params["uid"] = local_var_params["uid"] # noqa: E501 + + query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + + for key in kwargs: + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) + + header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # Authentication setting + auth_settings = ["bearer_auth"] # noqa: E501 + + return self.api_client.call_api( + "/v1/orders/{uid}", + "DELETE", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="DeleteOrderResponse", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + def place_order(self, id={}, **kwargs): # noqa: E501 """Place an order # noqa: E501 @@ -455,6 +647,7 @@ def place_order(self, id={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param PlaceOrderRequest place_order_request: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response @@ -481,6 +674,7 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param PlaceOrderRequest place_order_request: :param _return_http_data_only: response data without head status code and headers @@ -498,7 +692,7 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id", "place_order_request"] # noqa: E501 + all_params = ["id", "patch_version", "place_order_request"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -587,6 +781,10 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -640,6 +838,7 @@ def retrieve_order(self, id={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -665,6 +864,7 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -681,7 +881,7 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 + all_params = ["id", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -770,6 +970,10 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -817,6 +1021,7 @@ def retrieve_orders(self, **kwargs): # noqa: E501 :param str metadata: :param str metadata_example1: :param str metadata_example2: + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -845,6 +1050,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 :param str metadata: :param str metadata_example1: :param str metadata_example2: + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -866,6 +1072,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 "metadata", "metadata_example1", "metadata_example2", + "patch_version", ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") @@ -962,6 +1169,10 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index f5186f5..402e412 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -96,6 +96,7 @@ def retrieve_project(self, id={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) :param str accept_language: + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -122,6 +123,7 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param str id: (required) :param str accept_language: + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -138,7 +140,7 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id", "accept_language"] # noqa: E501 + all_params = ["id", "accept_language", "patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -231,6 +233,10 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 header_params["Accept-Language"] = local_var_params[ "accept_language" ] # noqa: E501 + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} @@ -279,6 +285,7 @@ def retrieve_projects(self, **kwargs): # noqa: E501 :param str type: :param int minimum_available_mass: :param str accept_language: + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -308,6 +315,7 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 :param str type: :param int minimum_available_mass: :param str accept_language: + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -330,6 +338,7 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 "type", "minimum_available_mass", "accept_language", + "patch_version", ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") @@ -426,6 +435,10 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 header_params["Accept-Language"] = local_var_params[ "accept_language" ] # noqa: E501 + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} diff --git a/patch_api/api/technology_types_api.py b/patch_api/api/technology_types_api.py index 5778bb1..4e32b6a 100644 --- a/patch_api/api/technology_types_api.py +++ b/patch_api/api/technology_types_api.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -94,6 +94,7 @@ def retrieve_technology_types(self, **kwargs): # noqa: E501 >>> result = thread.get() :param async_req bool: execute request asynchronously + :param int patch_version: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -118,6 +119,7 @@ def retrieve_technology_types_with_http_info(self, **kwargs): # noqa: E501 >>> result = thread.get() :param async_req bool: execute request asynchronously + :param int patch_version: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -134,7 +136,7 @@ def retrieve_technology_types_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = [] # noqa: E501 + all_params = ["patch_version"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") @@ -216,6 +218,10 @@ def retrieve_technology_types_with_http_info(self, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) header_params = {} + if "patch_version" in local_var_params: + header_params["Patch-Version"] = local_var_params[ + "patch_version" + ] # noqa: E501 form_params = [] local_var_files = {} diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 9f192ab..b308160 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -1,10 +1,10 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -26,6 +26,7 @@ from patch_api.configuration import Configuration import patch_api.models from patch_api.api.estimates_api import EstimatesApi +from patch_api.api.order_line_items_api import OrderLineItemsApi from patch_api.api.orders_api import OrdersApi from patch_api.api.projects_api import ProjectsApi from patch_api.api.technology_types_api import TechnologyTypesApi @@ -91,7 +92,9 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "patch-python/1.24.2" + self.user_agent = "patch-python/2.0.0" + # Set default Patch-Version + self.patch_version = 2 def __del__(self): if self._pool: @@ -103,6 +106,7 @@ def __getattr__(self, method): resource = { "projects": ProjectsApi, "orders": OrdersApi, + "order_line_items": OrderLineItemsApi, "estimates": EstimatesApi, "technology_types": TechnologyTypesApi, }[method] @@ -129,6 +133,18 @@ def user_agent(self, value): def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value + @property + def patch_version(self): + """API version for this API client""" + return self.default_headers["Patch-Version"] + + @patch_version.setter + def patch_version(self, value): + self.default_headers["Patch-Version"] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + def __call_api( self, resource_path, diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 1d8f234..9d4f034 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -340,10 +340,8 @@ def to_debug_report(self): "Python SDK Debug Report:\n" "OS: {env}\n" "Python Version: {pyversion}\n" - "Version of the API: v1\n" - "SDK Package Version: 1.24.2".format( - env=sys.platform, pyversion=sys.version - ) + "Version of the API: 2\n" + "SDK Package Version: 2.0.0".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/patch_api/exceptions.py b/patch_api/exceptions.py index 160fdd9..b744b51 100644 --- a/patch_api/exceptions.py +++ b/patch_api/exceptions.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/__init__.py b/patch_api/models/__init__.py index 5d9c584..24eb011 100644 --- a/patch_api/models/__init__.py +++ b/patch_api/models/__init__.py @@ -2,11 +2,11 @@ # flake8: noqa """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -15,7 +15,6 @@ from __future__ import absolute_import # import models into model package -from patch_api.models.allocation import Allocation from patch_api.models.create_air_shipping_estimate_request import ( CreateAirShippingEstimateRequest, ) @@ -31,6 +30,7 @@ from patch_api.models.create_flight_estimate_request import CreateFlightEstimateRequest from patch_api.models.create_hotel_estimate_request import CreateHotelEstimateRequest from patch_api.models.create_mass_estimate_request import CreateMassEstimateRequest +from patch_api.models.create_order_line_item_request import CreateOrderLineItemRequest from patch_api.models.create_order_request import CreateOrderRequest from patch_api.models.create_rail_shipping_estimate_request import ( CreateRailShippingEstimateRequest, @@ -48,6 +48,7 @@ from patch_api.models.create_vehicle_estimate_request import ( CreateVehicleEstimateRequest, ) +from patch_api.models.delete_order_response import DeleteOrderResponse from patch_api.models.error_response import ErrorResponse from patch_api.models.estimate import Estimate from patch_api.models.estimate_list_response import EstimateListResponse @@ -56,9 +57,10 @@ 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_issued_to import OrderIssuedTo +from patch_api.models.order_line_item import OrderLineItem +from patch_api.models.order_line_item_project import OrderLineItemProject +from patch_api.models.order_line_item_response import OrderLineItemResponse 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 @@ -71,3 +73,4 @@ from patch_api.models.standard import Standard from patch_api.models.technology_type import TechnologyType from patch_api.models.technology_type_list_response import TechnologyTypeListResponse +from patch_api.models.update_order_line_item_request import UpdateOrderLineItemRequest diff --git a/patch_api/models/create_air_shipping_estimate_request.py b/patch_api/models/create_air_shipping_estimate_request.py index 5f410fe..c132bb6 100644 --- a/patch_api/models/create_air_shipping_estimate_request.py +++ b/patch_api/models/create_air_shipping_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_bitcoin_estimate_request.py b/patch_api/models/create_bitcoin_estimate_request.py index 1ce3ce1..2a3be88 100644 --- a/patch_api/models/create_bitcoin_estimate_request.py +++ b/patch_api/models/create_bitcoin_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_ecommerce_estimate_request.py b/patch_api/models/create_ecommerce_estimate_request.py index c38ae7c..8235fa6 100644 --- a/patch_api/models/create_ecommerce_estimate_request.py +++ b/patch_api/models/create_ecommerce_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_ethereum_estimate_request.py b/patch_api/models/create_ethereum_estimate_request.py index 1743a91..53e9228 100644 --- a/patch_api/models/create_ethereum_estimate_request.py +++ b/patch_api/models/create_ethereum_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_flight_estimate_request.py b/patch_api/models/create_flight_estimate_request.py index 577b885..9e6c2bd 100644 --- a/patch_api/models/create_flight_estimate_request.py +++ b/patch_api/models/create_flight_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_hotel_estimate_request.py b/patch_api/models/create_hotel_estimate_request.py index 08d2a80..db88463 100644 --- a/patch_api/models/create_hotel_estimate_request.py +++ b/patch_api/models/create_hotel_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_mass_estimate_request.py b/patch_api/models/create_mass_estimate_request.py index dbc02f4..33267bd 100644 --- a/patch_api/models/create_mass_estimate_request.py +++ b/patch_api/models/create_mass_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_order_line_item_request.py b/patch_api/models/create_order_line_item_request.py new file mode 100644 index 0000000..a80e799 --- /dev/null +++ b/patch_api/models/create_order_line_item_request.py @@ -0,0 +1,307 @@ +# coding: utf-8 + +""" + Patch API V2 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: 2 + 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 CreateOrderLineItemRequest(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_id": "str", + "vintage_year": "int", + "price": "int", + "currency": "str", + "amount": "int", + "unit": "str", + } + + attribute_map = { + "project_id": "project_id", + "vintage_year": "vintage_year", + "price": "price", + "currency": "currency", + "amount": "amount", + "unit": "unit", + } + + def __init__( + self, + project_id=None, + vintage_year=None, + price=None, + currency=None, + amount=None, + unit=None, + local_vars_configuration=None, + ): # noqa: E501 + """CreateOrderLineItemRequest - 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_id = None + self._vintage_year = None + self._price = None + self._currency = None + self._amount = None + self._unit = None + self.discriminator = None + + if project_id is not None: + self.project_id = project_id + self.vintage_year = vintage_year + self.price = price + self.currency = currency + self.amount = amount + self.unit = unit + + @property + def project_id(self): + """Gets the project_id of this CreateOrderLineItemRequest. # noqa: E501 + + + :return: The project_id of this CreateOrderLineItemRequest. # noqa: E501 + :rtype: str + """ + return self._project_id + + @project_id.setter + def project_id(self, project_id): + """Sets the project_id of this CreateOrderLineItemRequest. + + + :param project_id: The project_id of this CreateOrderLineItemRequest. # noqa: E501 + :type: str + """ + + self._project_id = project_id + + @property + def vintage_year(self): + """Gets the vintage_year of this CreateOrderLineItemRequest. # noqa: E501 + + + :return: The vintage_year of this CreateOrderLineItemRequest. # noqa: E501 + :rtype: int + """ + return self._vintage_year + + @vintage_year.setter + def vintage_year(self, vintage_year): + """Sets the vintage_year of this CreateOrderLineItemRequest. + + + :param vintage_year: The vintage_year of this CreateOrderLineItemRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and vintage_year is not None + and vintage_year > 2100 + ): # noqa: E501 + raise ValueError( + "Invalid value for `vintage_year`, must be a value less than or equal to `2100`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and vintage_year is not None + and vintage_year < 1900 + ): # noqa: E501 + raise ValueError( + "Invalid value for `vintage_year`, must be a value greater than or equal to `1900`" + ) # noqa: E501 + + self._vintage_year = vintage_year + + @property + def price(self): + """Gets the price of this CreateOrderLineItemRequest. # noqa: E501 + + + :return: The price of this CreateOrderLineItemRequest. # noqa: E501 + :rtype: int + """ + return self._price + + @price.setter + def price(self, price): + """Sets the price of this CreateOrderLineItemRequest. + + + :param price: The price of this CreateOrderLineItemRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and price is not None + and price < 2 + ): # noqa: E501 + raise ValueError( + "Invalid value for `price`, must be a value greater than or equal to `2`" + ) # noqa: E501 + + self._price = price + + @property + def currency(self): + """Gets the currency of this CreateOrderLineItemRequest. # noqa: E501 + + + :return: The currency of this CreateOrderLineItemRequest. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this CreateOrderLineItemRequest. + + + :param currency: The currency of this CreateOrderLineItemRequest. # noqa: E501 + :type: str + """ + + self._currency = currency + + @property + def amount(self): + """Gets the amount of this CreateOrderLineItemRequest. # noqa: E501 + + + :return: The amount of this CreateOrderLineItemRequest. # noqa: E501 + :rtype: int + """ + return self._amount + + @amount.setter + def amount(self, amount): + """Sets the amount of this CreateOrderLineItemRequest. + + + :param amount: The amount of this CreateOrderLineItemRequest. # 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 CreateOrderLineItemRequest. # noqa: E501 + + + :return: The unit of this CreateOrderLineItemRequest. # noqa: E501 + :rtype: str + """ + return self._unit + + @unit.setter + def unit(self, unit): + """Sets the unit of this CreateOrderLineItemRequest. + + + :param unit: The unit of this CreateOrderLineItemRequest. # 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 = {} + + 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, CreateOrderLineItemRequest): + 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, CreateOrderLineItemRequest): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/create_order_request.py b/patch_api/models/create_order_request.py index 9203653..1b385ee 100644 --- a/patch_api/models/create_order_request.py +++ b/patch_api/models/create_order_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -34,8 +34,6 @@ class CreateOrderRequest(object): and the value is json key in definition. """ openapi_types = { - "mass_g": "int", - "total_price_cents_usd": "int", "project_id": "str", "metadata": "object", "state": "str", @@ -48,8 +46,6 @@ class CreateOrderRequest(object): } attribute_map = { - "mass_g": "mass_g", - "total_price_cents_usd": "total_price_cents_usd", "project_id": "project_id", "metadata": "metadata", "state": "state", @@ -63,8 +59,6 @@ class CreateOrderRequest(object): def __init__( self, - mass_g=None, - total_price_cents_usd=None, project_id=None, metadata=None, state=None, @@ -81,8 +75,6 @@ def __init__( local_vars_configuration = Configuration() self.local_vars_configuration = local_vars_configuration - self._mass_g = None - self._total_price_cents_usd = None self._project_id = None self._metadata = None self._state = None @@ -94,8 +86,6 @@ def __init__( self._issued_to = None self.discriminator = None - self.mass_g = mass_g - self.total_price_cents_usd = total_price_cents_usd self.project_id = project_id self.metadata = metadata self.state = state @@ -107,72 +97,6 @@ def __init__( if issued_to is not None: self.issued_to = issued_to - @property - def mass_g(self): - """Gets the mass_g of this CreateOrderRequest. # noqa: E501 - - - :return: The mass_g of this CreateOrderRequest. # noqa: E501 - :rtype: int - """ - return self._mass_g - - @mass_g.setter - def mass_g(self, mass_g): - """Sets the mass_g of this CreateOrderRequest. - - - :param mass_g: The mass_g of this CreateOrderRequest. # noqa: E501 - :type: int - """ - if ( - self.local_vars_configuration.client_side_validation - and mass_g is not None - and mass_g > 100000000000 - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must be a value less than or equal to `100000000000`" - ) # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and mass_g is not None - and mass_g < 0 - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must be a value greater than or equal to `0`" - ) # noqa: E501 - - self._mass_g = mass_g - - @property - def total_price_cents_usd(self): - """Gets the total_price_cents_usd of this CreateOrderRequest. # noqa: E501 - - - :return: The total_price_cents_usd of this CreateOrderRequest. # noqa: E501 - :rtype: int - """ - return self._total_price_cents_usd - - @total_price_cents_usd.setter - def total_price_cents_usd(self, total_price_cents_usd): - """Sets the total_price_cents_usd of this CreateOrderRequest. - - - :param total_price_cents_usd: The total_price_cents_usd of this CreateOrderRequest. # noqa: E501 - :type: int - """ - if ( - self.local_vars_configuration.client_side_validation - and total_price_cents_usd is not None - and total_price_cents_usd < 1 - ): # noqa: E501 - raise ValueError( - "Invalid value for `total_price_cents_usd`, must be a value greater than or equal to `1`" - ) # noqa: E501 - - self._total_price_cents_usd = total_price_cents_usd - @property def project_id(self): """Gets the project_id of this CreateOrderRequest. # noqa: E501 @@ -304,10 +228,10 @@ def total_price(self, total_price): if ( self.local_vars_configuration.client_side_validation and total_price is not None - and total_price < 1 + and total_price < 2 ): # noqa: E501 raise ValueError( - "Invalid value for `total_price`, must be a value greater than or equal to `1`" + "Invalid value for `total_price`, must be a value greater than or equal to `2`" ) # noqa: E501 self._total_price = total_price diff --git a/patch_api/models/create_rail_shipping_estimate_request.py b/patch_api/models/create_rail_shipping_estimate_request.py index be84474..62d6e19 100644 --- a/patch_api/models/create_rail_shipping_estimate_request.py +++ b/patch_api/models/create_rail_shipping_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_road_shipping_estimate_request.py b/patch_api/models/create_road_shipping_estimate_request.py index 6163dfa..ed08036 100644 --- a/patch_api/models/create_road_shipping_estimate_request.py +++ b/patch_api/models/create_road_shipping_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_sea_shipping_estimate_request.py b/patch_api/models/create_sea_shipping_estimate_request.py index 1ea0c6a..1f6af0c 100644 --- a/patch_api/models/create_sea_shipping_estimate_request.py +++ b/patch_api/models/create_sea_shipping_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_shipping_estimate_request.py b/patch_api/models/create_shipping_estimate_request.py index 3aa586e..63bacbb 100644 --- a/patch_api/models/create_shipping_estimate_request.py +++ b/patch_api/models/create_shipping_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_success_response.py b/patch_api/models/create_success_response.py index 088b73e..c53d450 100644 --- a/patch_api/models/create_success_response.py +++ b/patch_api/models/create_success_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/create_vehicle_estimate_request.py b/patch_api/models/create_vehicle_estimate_request.py index a2cae0e..2cf4e75 100644 --- a/patch_api/models/create_vehicle_estimate_request.py +++ b/patch_api/models/create_vehicle_estimate_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/allocation.py b/patch_api/models/delete_order_response.py similarity index 51% rename from patch_api/models/allocation.py rename to patch_api/models/delete_order_response.py index e4916bb..0ce1547 100644 --- a/patch_api/models/allocation.py +++ b/patch_api/models/delete_order_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -19,7 +19,7 @@ from patch_api.configuration import Configuration -class Allocation(object): +class DeleteOrderResponse(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -33,111 +33,101 @@ class Allocation(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"id": "str", "production": "bool", "mass_g": "int"} + openapi_types = {"success": "bool", "error": "object", "data": "str"} - attribute_map = {"id": "id", "production": "production", "mass_g": "mass_g"} + attribute_map = {"success": "success", "error": "error", "data": "data"} def __init__( - self, id=None, production=None, mass_g=None, local_vars_configuration=None + self, success=None, error=None, data=None, local_vars_configuration=None ): # noqa: E501 - """Allocation - a model defined in OpenAPI""" # noqa: E501 + """DeleteOrderResponse - 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._production = None - self._mass_g = None + self._success = None + self._error = None + self._data = None self.discriminator = None - self.id = id - self.production = production - self.mass_g = mass_g + self.success = success + self.error = error + self.data = data @property - def id(self): - """Gets the id of this Allocation. # noqa: E501 + def success(self): + """Gets the success of this DeleteOrderResponse. # noqa: E501 - A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in. # noqa: E501 - :return: The id of this Allocation. # noqa: E501 - :rtype: str + :return: The success of this DeleteOrderResponse. # noqa: E501 + :rtype: bool """ - return self._id + return self._success - @id.setter - def id(self, id): - """Sets the id of this Allocation. + @success.setter + def success(self, success): + """Sets the success of this DeleteOrderResponse. - A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in. # noqa: E501 - :param id: The id of this Allocation. # noqa: E501 - :type: str + :param success: The success of this DeleteOrderResponse. # noqa: E501 + :type: bool """ if ( - self.local_vars_configuration.client_side_validation and id is None + self.local_vars_configuration.client_side_validation and success is None ): # noqa: E501 - raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 - self._id = id + self._success = success @property - def production(self): - """Gets the production of this Allocation. # noqa: E501 + def error(self): + """Gets the error of this DeleteOrderResponse. # noqa: E501 - A boolean indicating if this project is a production or demo mode project. # noqa: E501 - :return: The production of this Allocation. # noqa: E501 - :rtype: bool + :return: The error of this DeleteOrderResponse. # noqa: E501 + :rtype: object """ - return self._production + return self._error - @production.setter - def production(self, production): - """Sets the production of this Allocation. + @error.setter + def error(self, error): + """Sets the error of this DeleteOrderResponse. - A boolean indicating if this project is a production or demo mode project. # noqa: E501 - :param production: The production of this Allocation. # noqa: E501 - :type: bool + :param error: The error of this DeleteOrderResponse. # noqa: E501 + :type: object """ - if ( - self.local_vars_configuration.client_side_validation and production is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `production`, must not be `None`" - ) # noqa: E501 - self._production = production + self._error = error @property - def mass_g(self): - """Gets the mass_g of this Allocation. # noqa: E501 + def data(self): + """Gets the data of this DeleteOrderResponse. # noqa: E501 - The amount (in grams) of allocated carbon offsets. # noqa: E501 - :return: The mass_g of this Allocation. # noqa: E501 - :rtype: int + :return: The data of this DeleteOrderResponse. # noqa: E501 + :rtype: str """ - return self._mass_g + return self._data - @mass_g.setter - def mass_g(self, mass_g): - """Sets the mass_g of this Allocation. + @data.setter + def data(self, data): + """Sets the data of this DeleteOrderResponse. - The amount (in grams) of allocated carbon offsets. # noqa: E501 - :param mass_g: The mass_g of this Allocation. # noqa: E501 - :type: int + :param data: The data of this DeleteOrderResponse. # noqa: E501 + :type: str """ if ( - self.local_vars_configuration.client_side_validation and mass_g is None + self.local_vars_configuration.client_side_validation and data is None ): # noqa: E501 raise ValueError( - "Invalid value for `mass_g`, must not be `None`" + "Invalid value for `data`, must not be `None`" ) # noqa: E501 - self._mass_g = mass_g + self._data = data def to_dict(self): """Returns the model properties as a dict""" @@ -175,14 +165,14 @@ def __repr__(self): def __eq__(self, other): """Returns true if both objects are equal""" - if not isinstance(other, Allocation): + if not isinstance(other, DeleteOrderResponse): 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, Allocation): + if not isinstance(other, DeleteOrderResponse): return True return self.to_dict() != other.to_dict() diff --git a/patch_api/models/error_response.py b/patch_api/models/error_response.py index 15bccfc..3bdbd5f 100644 --- a/patch_api/models/error_response.py +++ b/patch_api/models/error_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/estimate.py b/patch_api/models/estimate.py index 4414091..7897623 100644 --- a/patch_api/models/estimate.py +++ b/patch_api/models/estimate.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/estimate_list_response.py b/patch_api/models/estimate_list_response.py index 8817c3e..b1abad0 100644 --- a/patch_api/models/estimate_list_response.py +++ b/patch_api/models/estimate_list_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/estimate_response.py b/patch_api/models/estimate_response.py index a7ec676..931a064 100644 --- a/patch_api/models/estimate_response.py +++ b/patch_api/models/estimate_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/highlight.py b/patch_api/models/highlight.py index 3d71fcf..2f1bdac 100644 --- a/patch_api/models/highlight.py +++ b/patch_api/models/highlight.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/inventory.py b/patch_api/models/inventory.py index e8532fb..1674cca 100644 --- a/patch_api/models/inventory.py +++ b/patch_api/models/inventory.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/meta_index_object.py b/patch_api/models/meta_index_object.py index 91dde6d..2512bf3 100644 --- a/patch_api/models/meta_index_object.py +++ b/patch_api/models/meta_index_object.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/order.py b/patch_api/models/order.py index 5bdad96..24a88e4 100644 --- a/patch_api/models/order.py +++ b/patch_api/models/order.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -36,7 +36,6 @@ class Order(object): openapi_types = { "id": "str", "created_at": "datetime", - "mass_g": "int", "production": "bool", "state": "str", "amount": "int", @@ -44,20 +43,15 @@ class Order(object): "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]", + "line_items": "list[OrderLineItem]", "issued_to": "OrderIssuedTo", } attribute_map = { "id": "id", "created_at": "created_at", - "mass_g": "mass_g", "production": "production", "state": "state", "amount": "amount", @@ -65,13 +59,9 @@ class Order(object): "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", + "line_items": "line_items", "issued_to": "issued_to", } @@ -79,7 +69,6 @@ def __init__( self, id=None, created_at=None, - mass_g=None, production=None, state=None, amount=None, @@ -87,13 +76,9 @@ def __init__( 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, + line_items=None, issued_to=None, local_vars_configuration=None, ): # noqa: E501 @@ -104,7 +89,6 @@ def __init__( self._id = None self._created_at = None - self._mass_g = None self._production = None self._state = None self._amount = None @@ -112,20 +96,15 @@ def __init__( 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._line_items = None self._issued_to = None self.discriminator = None self.id = id if created_at is not None: self.created_at = created_at - self.mass_g = mass_g self.production = production self.state = state self.amount = amount @@ -133,16 +112,11 @@ def __init__( 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 - if allocations is not None: - self.allocations = allocations if registry_url is not None: self.registry_url = registry_url self.metadata = metadata - if inventory is not None: - self.inventory = inventory + if line_items is not None: + self.line_items = line_items if issued_to is not None: self.issued_to = issued_to @@ -196,51 +170,6 @@ def created_at(self, created_at): self._created_at = created_at - @property - def mass_g(self): - """Gets the mass_g of 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 - """ - return self._mass_g - - @mass_g.setter - def mass_g(self, mass_g): - """Sets the mass_g of this Order. - - 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 - """ - if ( - self.local_vars_configuration.client_side_validation and mass_g is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must not be `None`" - ) # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and mass_g is not None - and mass_g > 100000000000 - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must be a value less than or equal to `100000000000`" - ) # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and mass_g is not None - and mass_g < 0 - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must be a value greater than or equal to `0`" - ) # noqa: E501 - - self._mass_g = mass_g - @property def production(self): """Gets the production of this Order. # noqa: E501 @@ -477,115 +406,6 @@ def currency(self, currency): self._currency = currency - @property - def allocation_state(self): - """Gets the allocation_state of this Order. # noqa: E501 - - DEPRECATED. Indicates if the order has been fully allocated to projects. # noqa: E501 - - :return: The allocation_state of this Order. # noqa: E501 - :rtype: str - """ - return self._allocation_state - - @allocation_state.setter - def allocation_state(self, allocation_state): - """Sets the allocation_state of this Order. - - DEPRECATED. Indicates if the order has been fully allocated to projects. # noqa: E501 - - :param allocation_state: The allocation_state of this Order. # noqa: E501 - :type: str - """ - if ( - self.local_vars_configuration.client_side_validation - and allocation_state is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `allocation_state`, must not be `None`" - ) # noqa: E501 - allowed_values = ["pending", "allocated"] # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and allocation_state not in allowed_values - ): # noqa: E501 - raise ValueError( - "Invalid value for `allocation_state` ({0}), must be one of {1}".format( # noqa: E501 - allocation_state, allowed_values - ) - ) - - self._allocation_state = allocation_state - - @property - def price_cents_usd(self): - """Gets the price_cents_usd of 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 - """ - return self._price_cents_usd - - @price_cents_usd.setter - def price_cents_usd(self, price_cents_usd): - """Sets the price_cents_usd of this Order. - - 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 - """ - - self._price_cents_usd = price_cents_usd - - @property - def patch_fee_cents_usd(self): - """Gets the patch_fee_cents_usd of 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 - """ - return self._patch_fee_cents_usd - - @patch_fee_cents_usd.setter - def patch_fee_cents_usd(self, patch_fee_cents_usd): - """Sets the patch_fee_cents_usd of this Order. - - 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 - """ - - self._patch_fee_cents_usd = patch_fee_cents_usd - - @property - def allocations(self): - """Gets the allocations of this Order. # noqa: E501 - - DEPRECATED. An array containing the inventory allocations for this order. # noqa: E501 - - :return: The allocations of this Order. # noqa: E501 - :rtype: list[Allocation] - """ - return self._allocations - - @allocations.setter - def allocations(self, allocations): - """Sets the allocations of this Order. - - DEPRECATED. An array containing the inventory allocations for this order. # noqa: E501 - - :param allocations: The allocations of this Order. # noqa: E501 - :type: list[Allocation] - """ - - self._allocations = allocations - @property def registry_url(self): """Gets the registry_url of this Order. # noqa: E501 @@ -639,27 +459,27 @@ def metadata(self, metadata): self._metadata = metadata @property - def inventory(self): - """Gets the inventory of this Order. # noqa: E501 + def line_items(self): + """Gets the line_items 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 + An array containing the line items allocated for this order. Line items are grouped by project, vintage year, and price. # noqa: E501 - :return: The inventory of this Order. # noqa: E501 - :rtype: list[OrderInventory] + :return: The line_items of this Order. # noqa: E501 + :rtype: list[OrderLineItem] """ - return self._inventory + return self._line_items - @inventory.setter - def inventory(self, inventory): - """Sets the inventory of this Order. + @line_items.setter + def line_items(self, line_items): + """Sets the line_items of this Order. - An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price. # noqa: E501 + An array containing the line items allocated for this order. Line items are grouped by project, vintage year, and price. # noqa: E501 - :param inventory: The inventory of this Order. # noqa: E501 - :type: list[OrderInventory] + :param line_items: The line_items of this Order. # noqa: E501 + :type: list[OrderLineItem] """ - self._inventory = inventory + self._line_items = line_items @property def issued_to(self): diff --git a/patch_api/models/order_issued_to.py b/patch_api/models/order_issued_to.py index 5683044..32074a8 100644 --- a/patch_api/models/order_issued_to.py +++ b/patch_api/models/order_issued_to.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/order_inventory.py b/patch_api/models/order_line_item.py similarity index 74% rename from patch_api/models/order_inventory.py rename to patch_api/models/order_line_item.py index 98c793f..583830b 100644 --- a/patch_api/models/order_inventory.py +++ b/patch_api/models/order_line_item.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -19,7 +19,7 @@ from patch_api.configuration import Configuration -class OrderInventory(object): +class OrderLineItem(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -34,7 +34,8 @@ class OrderInventory(object): and the value is json key in definition. """ openapi_types = { - "project": "OrderInventoryProject", + "id": "str", + "project": "OrderLineItemProject", "vintage_year": "int", "amount": "int", "unit": "str", @@ -43,6 +44,7 @@ class OrderInventory(object): } attribute_map = { + "id": "id", "project": "project", "vintage_year": "vintage_year", "amount": "amount", @@ -53,6 +55,7 @@ class OrderInventory(object): def __init__( self, + id=None, project=None, vintage_year=None, amount=None, @@ -61,11 +64,12 @@ def __init__( currency=None, local_vars_configuration=None, ): # noqa: E501 - """OrderInventory - a model defined in OpenAPI""" # noqa: E501 + """OrderLineItem - 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._project = None self._vintage_year = None self._amount = None @@ -74,6 +78,8 @@ def __init__( self._currency = None self.discriminator = None + if id is not None: + self.id = id self.project = project self.vintage_year = vintage_year self.amount = amount @@ -81,25 +87,48 @@ def __init__( self.price = price self.currency = currency + @property + def id(self): + """Gets the id of this OrderLineItem. # noqa: E501 + + The identifier for this order line item # noqa: E501 + + :return: The id of this OrderLineItem. # noqa: E501 + :rtype: str + """ + return self._id + + @id.setter + def id(self, id): + """Sets the id of this OrderLineItem. + + The identifier for this order line item # noqa: E501 + + :param id: The id of this OrderLineItem. # noqa: E501 + :type: str + """ + + self._id = id + @property def project(self): - """Gets the project of this OrderInventory. # noqa: E501 + """Gets the project of this OrderLineItem. # 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: The project of this OrderLineItem. # noqa: E501 + :rtype: OrderLineItemProject """ return self._project @project.setter def project(self, project): - """Sets the project of this OrderInventory. + """Sets the project of this OrderLineItem. 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 + :param project: The project of this OrderLineItem. # noqa: E501 + :type: OrderLineItemProject """ if ( self.local_vars_configuration.client_side_validation and project is None @@ -112,22 +141,22 @@ def project(self, project): @property def vintage_year(self): - """Gets the vintage_year of this OrderInventory. # noqa: E501 + """Gets the vintage_year of this OrderLineItem. # 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 + :return: The vintage_year of this OrderLineItem. # noqa: E501 :rtype: int """ return self._vintage_year @vintage_year.setter def vintage_year(self, vintage_year): - """Sets the vintage_year of this OrderInventory. + """Sets the vintage_year of this OrderLineItem. 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 + :param vintage_year: The vintage_year of this OrderLineItem. # noqa: E501 :type: int """ if ( @@ -142,22 +171,22 @@ def vintage_year(self, vintage_year): @property def amount(self): - """Gets the amount of this OrderInventory. # noqa: E501 + """Gets the amount of this OrderLineItem. # noqa: E501 The amount ordered for the given project and vintage year. # noqa: E501 - :return: The amount of this OrderInventory. # noqa: E501 + :return: The amount of this OrderLineItem. # noqa: E501 :rtype: int """ return self._amount @amount.setter def amount(self, amount): - """Sets the amount of this OrderInventory. + """Sets the amount of this OrderLineItem. The amount ordered for the given project and vintage year. # noqa: E501 - :param amount: The amount of this OrderInventory. # noqa: E501 + :param amount: The amount of this OrderLineItem. # noqa: E501 :type: int """ if ( @@ -171,22 +200,22 @@ def amount(self, amount): @property def unit(self): - """Gets the unit of this OrderInventory. # noqa: E501 + """Gets the unit of this OrderLineItem. # 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 + :return: The unit of this OrderLineItem. # noqa: E501 :rtype: str """ return self._unit @unit.setter def unit(self, unit): - """Sets the unit of this OrderInventory. + """Sets the unit of this OrderLineItem. 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 + :param unit: The unit of this OrderLineItem. # noqa: E501 :type: str """ if ( @@ -200,22 +229,22 @@ def unit(self, unit): @property def price(self): - """Gets the price of this OrderInventory. # noqa: E501 + """Gets the price of this OrderLineItem. # 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 + :return: The price of this OrderLineItem. # noqa: E501 :rtype: int """ return self._price @price.setter def price(self, price): - """Sets the price of this OrderInventory. + """Sets the price of this OrderLineItem. 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 + :param price: The price of this OrderLineItem. # noqa: E501 :type: int """ if ( @@ -229,22 +258,22 @@ def price(self, price): @property def currency(self): - """Gets the currency of this OrderInventory. # noqa: E501 + """Gets the currency of this OrderLineItem. # noqa: E501 The currency code for the `price`. # noqa: E501 - :return: The currency of this OrderInventory. # noqa: E501 + :return: The currency of this OrderLineItem. # noqa: E501 :rtype: str """ return self._currency @currency.setter def currency(self, currency): - """Sets the currency of this OrderInventory. + """Sets the currency of this OrderLineItem. The currency code for the `price`. # noqa: E501 - :param currency: The currency of this OrderInventory. # noqa: E501 + :param currency: The currency of this OrderLineItem. # noqa: E501 :type: str """ if ( @@ -292,14 +321,14 @@ def __repr__(self): def __eq__(self, other): """Returns true if both objects are equal""" - if not isinstance(other, OrderInventory): + if not isinstance(other, OrderLineItem): 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): + if not isinstance(other, OrderLineItem): return True return self.to_dict() != other.to_dict() diff --git a/patch_api/models/order_inventory_project.py b/patch_api/models/order_line_item_project.py similarity index 82% rename from patch_api/models/order_inventory_project.py rename to patch_api/models/order_line_item_project.py index 634b9b8..e46cdcb 100644 --- a/patch_api/models/order_inventory_project.py +++ b/patch_api/models/order_line_item_project.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -19,7 +19,7 @@ from patch_api.configuration import Configuration -class OrderInventoryProject(object): +class OrderLineItemProject(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -38,7 +38,7 @@ class OrderInventoryProject(object): 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 + """OrderLineItemProject - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() self.local_vars_configuration = local_vars_configuration @@ -52,22 +52,22 @@ def __init__(self, id=None, name=None, local_vars_configuration=None): # noqa: @property def id(self): - """Gets the id of this OrderInventoryProject. # noqa: E501 + """Gets the id of this OrderLineItemProject. # 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 + :return: The id of this OrderLineItemProject. # noqa: E501 :rtype: str """ return self._id @id.setter def id(self, id): - """Sets the id of this OrderInventoryProject. + """Sets the id of this OrderLineItemProject. 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 + :param id: The id of this OrderLineItemProject. # noqa: E501 :type: str """ if ( @@ -79,22 +79,22 @@ def id(self, id): @property def name(self): - """Gets the name of this OrderInventoryProject. # noqa: E501 + """Gets the name of this OrderLineItemProject. # noqa: E501 The name of the project. # noqa: E501 - :return: The name of this OrderInventoryProject. # noqa: E501 + :return: The name of this OrderLineItemProject. # noqa: E501 :rtype: str """ return self._name @name.setter def name(self, name): - """Sets the name of this OrderInventoryProject. + """Sets the name of this OrderLineItemProject. The name of the project. # noqa: E501 - :param name: The name of this OrderInventoryProject. # noqa: E501 + :param name: The name of this OrderLineItemProject. # noqa: E501 :type: str """ if ( @@ -142,14 +142,14 @@ def __repr__(self): def __eq__(self, other): """Returns true if both objects are equal""" - if not isinstance(other, OrderInventoryProject): + if not isinstance(other, OrderLineItemProject): 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): + if not isinstance(other, OrderLineItemProject): return True return self.to_dict() != other.to_dict() diff --git a/patch_api/models/order_line_item_response.py b/patch_api/models/order_line_item_response.py new file mode 100644 index 0000000..41c5c35 --- /dev/null +++ b/patch_api/models/order_line_item_response.py @@ -0,0 +1,178 @@ +# coding: utf-8 + +""" + Patch API V2 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: 2 + 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 OrderLineItemResponse(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 = {"success": "bool", "error": "object", "data": "OrderLineItem"} + + attribute_map = {"success": "success", "error": "error", "data": "data"} + + def __init__( + self, success=None, error=None, data=None, local_vars_configuration=None + ): # noqa: E501 + """OrderLineItemResponse - 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._success = None + self._error = None + self._data = None + self.discriminator = None + + self.success = success + self.error = error + self.data = data + + @property + def success(self): + """Gets the success of this OrderLineItemResponse. # noqa: E501 + + + :return: The success of this OrderLineItemResponse. # noqa: E501 + :rtype: bool + """ + return self._success + + @success.setter + def success(self, success): + """Sets the success of this OrderLineItemResponse. + + + :param success: The success of this OrderLineItemResponse. # noqa: E501 + :type: bool + """ + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 + + self._success = success + + @property + def error(self): + """Gets the error of this OrderLineItemResponse. # noqa: E501 + + + :return: The error of this OrderLineItemResponse. # noqa: E501 + :rtype: object + """ + return self._error + + @error.setter + def error(self, error): + """Sets the error of this OrderLineItemResponse. + + + :param error: The error of this OrderLineItemResponse. # noqa: E501 + :type: object + """ + + self._error = error + + @property + def data(self): + """Gets the data of this OrderLineItemResponse. # noqa: E501 + + + :return: The data of this OrderLineItemResponse. # noqa: E501 + :rtype: OrderLineItem + """ + return self._data + + @data.setter + def data(self, data): + """Sets the data of this OrderLineItemResponse. + + + :param data: The data of this OrderLineItemResponse. # noqa: E501 + :type: OrderLineItem + """ + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 + + self._data = data + + 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, OrderLineItemResponse): + 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, OrderLineItemResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/order_list_response.py b/patch_api/models/order_list_response.py index 6830ac3..9b3975b 100644 --- a/patch_api/models/order_list_response.py +++ b/patch_api/models/order_list_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/order_response.py b/patch_api/models/order_response.py index c2478a1..a387f38 100644 --- a/patch_api/models/order_response.py +++ b/patch_api/models/order_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/parent_technology_type.py b/patch_api/models/parent_technology_type.py index 7f049a7..06a01c7 100644 --- a/patch_api/models/parent_technology_type.py +++ b/patch_api/models/parent_technology_type.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/photo.py b/patch_api/models/photo.py index f8e684c..24260cb 100644 --- a/patch_api/models/photo.py +++ b/patch_api/models/photo.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/place_order_request.py b/patch_api/models/place_order_request.py index d6ab9f2..00df9f4 100644 --- a/patch_api/models/place_order_request.py +++ b/patch_api/models/place_order_request.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/project.py b/patch_api/models/project.py index 1096b06..236c38f 100644 --- a/patch_api/models/project.py +++ b/patch_api/models/project.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -38,16 +38,13 @@ class Project(object): "production": "bool", "name": "str", "description": "str", - "type": "str", "mechanism": "str", "country": "str", "state": "str", "latitude": "float", "longitude": "float", - "developer": "str", + "project_partner": "str", "photos": "list[Photo]", - "average_price_per_tonne_cents_usd": "int", - "remaining_mass_g": "int", "verifier": "str", "standard": "Standard", "sdgs": "list[Sdg]", @@ -62,16 +59,13 @@ class Project(object): "production": "production", "name": "name", "description": "description", - "type": "type", "mechanism": "mechanism", "country": "country", "state": "state", "latitude": "latitude", "longitude": "longitude", - "developer": "developer", + "project_partner": "project_partner", "photos": "photos", - "average_price_per_tonne_cents_usd": "average_price_per_tonne_cents_usd", - "remaining_mass_g": "remaining_mass_g", "verifier": "verifier", "standard": "standard", "sdgs": "sdgs", @@ -87,16 +81,13 @@ def __init__( production=None, name=None, description=None, - type=None, mechanism=None, country=None, state=None, latitude=None, longitude=None, - developer=None, + project_partner=None, photos=None, - average_price_per_tonne_cents_usd=None, - remaining_mass_g=None, verifier=None, standard=None, sdgs=None, @@ -115,16 +106,13 @@ def __init__( self._production = None self._name = None self._description = None - self._type = None self._mechanism = None self._country = None self._state = None self._latitude = None self._longitude = None - self._developer = None + self._project_partner = None self._photos = None - self._average_price_per_tonne_cents_usd = None - self._remaining_mass_g = None self._verifier = None self._standard = None self._sdgs = None @@ -138,18 +126,14 @@ def __init__( self.production = production self.name = name self.description = description - if type is not None: - self.type = type if mechanism is not None: self.mechanism = mechanism self.country = country self.state = state self.latitude = latitude self.longitude = longitude - self.developer = developer + self.project_partner = project_partner self.photos = photos - self.average_price_per_tonne_cents_usd = average_price_per_tonne_cents_usd - self.remaining_mass_g = remaining_mass_g if verifier is not None: self.verifier = verifier self.standard = standard @@ -274,29 +258,6 @@ def description(self, description): self._description = description - @property - def type(self): - """Gets the type of this Project. # noqa: E501 - - DEPRECATED. Favor the technology_type field instead. # noqa: E501 - - :return: The type of this Project. # noqa: E501 - :rtype: str - """ - return self._type - - @type.setter - def type(self, type): - """Sets the type of this Project. - - DEPRECATED. Favor the technology_type field instead. # noqa: E501 - - :param type: The type of this Project. # noqa: E501 - :type: str - """ - - self._type = type - @property def mechanism(self): """Gets the mechanism of this Project. # noqa: E501 @@ -419,33 +380,34 @@ def longitude(self, longitude): self._longitude = longitude @property - def developer(self): - """Gets the developer of this Project. # noqa: E501 + def project_partner(self): + """Gets the project_partner of this Project. # noqa: E501 - The name of the project developer. # noqa: E501 + The name of the project project partner. # noqa: E501 - :return: The developer of this Project. # noqa: E501 + :return: The project_partner of this Project. # noqa: E501 :rtype: str """ - return self._developer + return self._project_partner - @developer.setter - def developer(self, developer): - """Sets the developer of this Project. + @project_partner.setter + def project_partner(self, project_partner): + """Sets the project_partner of this Project. - The name of the project developer. # noqa: E501 + The name of the project project partner. # noqa: E501 - :param developer: The developer of this Project. # noqa: E501 + :param project_partner: The project_partner of this Project. # noqa: E501 :type: str """ if ( - self.local_vars_configuration.client_side_validation and developer is None + self.local_vars_configuration.client_side_validation + and project_partner is None ): # noqa: E501 raise ValueError( - "Invalid value for `developer`, must not be `None`" + "Invalid value for `project_partner`, must not be `None`" ) # noqa: E501 - self._developer = developer + self._project_partner = project_partner @property def photos(self): @@ -470,66 +432,6 @@ def photos(self, photos): self._photos = photos - @property - def average_price_per_tonne_cents_usd(self): - """Gets the average_price_per_tonne_cents_usd of 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 - """ - return self._average_price_per_tonne_cents_usd - - @average_price_per_tonne_cents_usd.setter - 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. - - 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 - """ - if ( - self.local_vars_configuration.client_side_validation - and average_price_per_tonne_cents_usd is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `average_price_per_tonne_cents_usd`, must not be `None`" - ) # noqa: E501 - - self._average_price_per_tonne_cents_usd = average_price_per_tonne_cents_usd - - @property - def remaining_mass_g(self): - """Gets the remaining_mass_g of 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 - """ - return self._remaining_mass_g - - @remaining_mass_g.setter - def remaining_mass_g(self, remaining_mass_g): - """Sets the remaining_mass_g of this Project. - - 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 - """ - if ( - self.local_vars_configuration.client_side_validation - and remaining_mass_g is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `remaining_mass_g`, must not be `None`" - ) # noqa: E501 - - self._remaining_mass_g = remaining_mass_g - @property def verifier(self): """Gets the verifier of this Project. # noqa: E501 diff --git a/patch_api/models/project_list_response.py b/patch_api/models/project_list_response.py index 56f4f76..9d0ab31 100644 --- a/patch_api/models/project_list_response.py +++ b/patch_api/models/project_list_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/project_response.py b/patch_api/models/project_response.py index f9a620b..73d7971 100644 --- a/patch_api/models/project_response.py +++ b/patch_api/models/project_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/sdg.py b/patch_api/models/sdg.py index 8731197..6a11432 100644 --- a/patch_api/models/sdg.py +++ b/patch_api/models/sdg.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/standard.py b/patch_api/models/standard.py index 33c1501..093f65b 100644 --- a/patch_api/models/standard.py +++ b/patch_api/models/standard.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/technology_type.py b/patch_api/models/technology_type.py index 171a8a5..53f1069 100644 --- a/patch_api/models/technology_type.py +++ b/patch_api/models/technology_type.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/technology_type_list_response.py b/patch_api/models/technology_type_list_response.py index bc69867..80fb997 100644 --- a/patch_api/models/technology_type_list_response.py +++ b/patch_api/models/technology_type_list_response.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/patch_api/models/update_order_line_item_request.py b/patch_api/models/update_order_line_item_request.py new file mode 100644 index 0000000..e0974c6 --- /dev/null +++ b/patch_api/models/update_order_line_item_request.py @@ -0,0 +1,280 @@ +# coding: utf-8 + +""" + Patch API V2 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: 2 + 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 UpdateOrderLineItemRequest(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", + "price": "int", + "currency": "str", + "amount": "int", + "unit": "str", + } + + attribute_map = { + "vintage_year": "vintage_year", + "price": "price", + "currency": "currency", + "amount": "amount", + "unit": "unit", + } + + def __init__( + self, + vintage_year=None, + price=None, + currency=None, + amount=None, + unit=None, + local_vars_configuration=None, + ): # noqa: E501 + """UpdateOrderLineItemRequest - 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._price = None + self._currency = None + self._amount = None + self._unit = None + self.discriminator = None + + self.vintage_year = vintage_year + self.price = price + self.currency = currency + self.amount = amount + self.unit = unit + + @property + def vintage_year(self): + """Gets the vintage_year of this UpdateOrderLineItemRequest. # noqa: E501 + + + :return: The vintage_year of this UpdateOrderLineItemRequest. # noqa: E501 + :rtype: int + """ + return self._vintage_year + + @vintage_year.setter + def vintage_year(self, vintage_year): + """Sets the vintage_year of this UpdateOrderLineItemRequest. + + + :param vintage_year: The vintage_year of this UpdateOrderLineItemRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and vintage_year is not None + and vintage_year > 2100 + ): # noqa: E501 + raise ValueError( + "Invalid value for `vintage_year`, must be a value less than or equal to `2100`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and vintage_year is not None + and vintage_year < 1900 + ): # noqa: E501 + raise ValueError( + "Invalid value for `vintage_year`, must be a value greater than or equal to `1900`" + ) # noqa: E501 + + self._vintage_year = vintage_year + + @property + def price(self): + """Gets the price of this UpdateOrderLineItemRequest. # noqa: E501 + + + :return: The price of this UpdateOrderLineItemRequest. # noqa: E501 + :rtype: int + """ + return self._price + + @price.setter + def price(self, price): + """Sets the price of this UpdateOrderLineItemRequest. + + + :param price: The price of this UpdateOrderLineItemRequest. # noqa: E501 + :type: int + """ + if ( + self.local_vars_configuration.client_side_validation + and price is not None + and price < 2 + ): # noqa: E501 + raise ValueError( + "Invalid value for `price`, must be a value greater than or equal to `2`" + ) # noqa: E501 + + self._price = price + + @property + def currency(self): + """Gets the currency of this UpdateOrderLineItemRequest. # noqa: E501 + + + :return: The currency of this UpdateOrderLineItemRequest. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this UpdateOrderLineItemRequest. + + + :param currency: The currency of this UpdateOrderLineItemRequest. # noqa: E501 + :type: str + """ + + self._currency = currency + + @property + def amount(self): + """Gets the amount of this UpdateOrderLineItemRequest. # noqa: E501 + + + :return: The amount of this UpdateOrderLineItemRequest. # noqa: E501 + :rtype: int + """ + return self._amount + + @amount.setter + def amount(self, amount): + """Sets the amount of this UpdateOrderLineItemRequest. + + + :param amount: The amount of this UpdateOrderLineItemRequest. # 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 UpdateOrderLineItemRequest. # noqa: E501 + + + :return: The unit of this UpdateOrderLineItemRequest. # noqa: E501 + :rtype: str + """ + return self._unit + + @unit.setter + def unit(self, unit): + """Sets the unit of this UpdateOrderLineItemRequest. + + + :param unit: The unit of this UpdateOrderLineItemRequest. # 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 = {} + + 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, UpdateOrderLineItemRequest): + 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, UpdateOrderLineItemRequest): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/rest.py b/patch_api/rest.py index a01a155..de2f357 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -1,11 +1,11 @@ # coding: utf-8 """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ diff --git a/setup.py b/setup.py index 572d46f..5327caa 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ """ - Patch API V1 + Patch API V2 The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech """ @@ -12,7 +12,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "1.24.2" +VERSION = "2.0.0" # To install the library, run the following # # python setup.py install @@ -29,11 +29,11 @@ setup( name=NAME, version=VERSION, - description="Patch API V1", + description="Patch API V2", author="Developer Support", author_email="engineering@usepatch.com", url="", - keywords=["OpenAPI", "OpenAPI-Generator", "Patch API V1"], + keywords=["OpenAPI", "OpenAPI-Generator", "Patch API V2"], python_requires=">=3.6", install_requires=REQUIRES, packages=find_packages(exclude=["test", "tests"]), diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index 81c44b3..8c16d4d 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -40,7 +40,7 @@ def test_create_and_retrieve_mass_estimate(self): mass_g=mass_g, project_id=project_id, create_order=True ) self.assertTrue(estimate) - self.assertEqual(estimate.data.order.mass_g, mass_g) + self.assertEqual(estimate.data.order.amount, mass_g) retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) self.assertTrue(retrieved_estimate) @@ -55,7 +55,7 @@ def test_create_and_retrieve_flight_estimate(self): distance_m=distance_m, create_order=True ) self.assertEqual(estimate.data.type, "flight") - self.assertGreater(estimate.data.order.mass_g, 50000) + self.assertGreater(estimate.data.order.amount, 50000) self.assertGreater(estimate.data.mass_g, 50000) retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) diff --git a/test/test_orders_api.py b/test/test_orders_api.py index 716aaf2..4886449 100644 --- a/test/test_orders_api.py +++ b/test/test_orders_api.py @@ -26,6 +26,7 @@ class TestOrdersApi(unittest.TestCase): def setUp(self): api_client = ApiClient(api_key=os.environ.get("SANDBOX_API_KEY")) self.api = api_client.orders # noqa: E501 + self.line_items_api = api_client.order_line_items # noqa: E501 def tearDown(self): self.api = None @@ -35,29 +36,29 @@ def test_interactions_with_an_order(self): """Create an order """ - order = self.api.create_order(mass_g=100) + order = self.api.create_order(amount=100, unit="g") self.assertTrue(order) self.assertIsInstance(order.data.created_at, datetime.datetime) - self.assertEqual(order.data.mass_g, 100) + self.assertEqual(order.data.amount, 100) + self.assertEqual(order.data.unit, "g") """Create an order on price """ - order = self.api.create_order(total_price_cents_usd=100) + order = self.api.create_order(total_price=100, currency="USD") self.assertTrue(order) - self.assertEqual( - order.data.price_cents_usd + order.data.patch_fee_cents_usd, 100 - ) + self.assertEqual(order.data.price + order.data.patch_fee, 100) """Create an order in draft state """ - order = self.api.create_order(mass_g=100, state="draft") + order = self.api.create_order(amount=100, unit="g", state="draft") self.assertTrue(order) - self.assertEqual(order.data.mass_g, 100) + self.assertEqual(order.data.amount, 100) + self.assertEqual(order.data.unit, "g") self.assertEqual(order.data.state, "draft") def test_retrieve_order(self): @@ -65,11 +66,11 @@ def test_retrieve_order(self): """Retrieve an order """ - order = self.api.create_order(mass_g=100) + order = self.api.create_order(amount=100, unit="g") retrieved_order = self.api.retrieve_order(id=order.data.id) self.assertTrue(retrieved_order) - self.assertEqual(retrieved_order.data.mass_g, 100) + self.assertEqual(retrieved_order.data.amount, 100) def test_retrieve_orders(self): """Test case for retrieve_orders @@ -86,16 +87,15 @@ def test_retrieve_orders(self): self.assertEqual(retrieved_order.production, False) self.assertEqual(retrieved_order.state, "placed") self.assertEqual(retrieved_order.metadata, {}) - self.assertTrue(isinstance(retrieved_order.allocations, list)) def test_create_and_retrieve_order_via_metadata(self): """Test case for create_order and retrieve_orders with metadata""" - mass_g = 100 + amount = 100 metadata = {"external_id": "abc-123"} - order = self.api.create_order(mass_g=mass_g, metadata=metadata) + order = self.api.create_order(amount=amount, unit="g", metadata=metadata) self.assertTrue(order) - self.assertEqual(order.data.mass_g, 100) + self.assertEqual(order.data.amount, 100) self.assertEqual(order.data.metadata, {"external_id": "abc-123"}) retrieved_orders = self.api.retrieve_orders( @@ -107,7 +107,7 @@ def test_create_and_retrieve_order_via_metadata(self): def test_cancel_order_in_draft_state(self): """Test case for cancel_order on draft orders""" - order = self.api.create_order(mass_g=100, state="draft") + order = self.api.create_order(amount=100, unit="g", state="draft") self.assertEqual(order.data.state, "draft") cancelled_order = self.api.cancel_order(id=order.data.id) @@ -115,7 +115,7 @@ def test_cancel_order_in_draft_state(self): def test_create_order_with_vintage_year(self): """Test case for vintage_year on create order""" - order = self.api.create_order(mass_g=100, vintage_year=2022) + order = self.api.create_order(amount=100, unit="g", vintage_year=2022) self.assertTrue(order) @@ -126,7 +126,8 @@ def test_create_order_with_amount_and_unit(self): self.assertTrue(order) self.assertEqual(order.data.amount, 100) self.assertEqual(order.data.unit, "g") - self.assertEqual(order.data.inventory[0].unit, "g") + self.assertEqual(order.data.line_items[0].amount, 100) + self.assertEqual(order.data.line_items[0].unit, "g") def test_create_order_with_total_price_and_currency(self): """Test case for total price and currency on create order""" @@ -138,12 +139,12 @@ def test_create_order_with_total_price_and_currency(self): def test_create_order_with_issued_to(self): """Test case for issued_to on create order""" - mass_g = 100 + amount = 100 issued_to = {"email": "sustainability@companyb.com", "name": "Company B"} - order = self.api.create_order(mass_g=mass_g, issued_to=issued_to) + order = self.api.create_order(amount=amount, unit="g", issued_to=issued_to) self.assertTrue(order) - self.assertEqual(order.data.mass_g, 100) + self.assertEqual(order.data.amount, 100) self.assertEqual(order.data.issued_to.email, "sustainability@companyb.com") self.assertEqual(order.data.issued_to.name, "Company B") @@ -155,6 +156,64 @@ def test_create_order_with_issued_to(self): ) self.assertEqual(retrieved_order.data.issued_to.name, "Company B") + def test_create_empty_order_add_line_items(self): + """Test case for creating an empty draft order and adding/editing line items""" + # Create empty order + create_order_response = self.api.create_order(state="draft") + + self.assertTrue(create_order_response.success) + self.assertEqual(create_order_response.data.price, 0) + self.assertEqual(create_order_response.data.amount, 0) + self.assertEqual(len(create_order_response.data.line_items), 0) + + # Add project to order + order_id = create_order_response.data.id + project_id = "pro_test_2b67b11a030b66e0a6dd61a56b49079a" + + create_line_item_response = self.line_items_api.create_order_line_item( + order_id=order_id, create_order_line_item_request={"project_id": project_id} + ) + + self.assertTrue(create_line_item_response.success) + self.assertEqual(create_line_item_response.data.amount, 0) + + # Update amount on line item + line_item_id = create_line_item_response.data.id + update_order_line_item_response = self.line_items_api.update_order_line_item( + order_id=order_id, + serial_number=line_item_id, + update_order_line_item_request={"amount": 1000, "unit": "g"}, + ) + + self.assertTrue(update_order_line_item_response.success) + self.assertEqual(update_order_line_item_response.data.id, line_item_id) + self.assertEqual(update_order_line_item_response.data.amount, 1000) + self.assertGreater(update_order_line_item_response.data.price, 0) + + # Fetch order and check line item matches + retrieve_order_response = self.api.retrieve_order(id=order_id) + self.assertEqual(retrieve_order_response.data.id, order_id) + self.assertEqual(len(retrieve_order_response.data.line_items), 1) + self.assertEqual(retrieve_order_response.data.line_items[0].id, line_item_id) + self.assertEqual(retrieve_order_response.data.line_items[0].amount, 1000) + + # Delete line item + delete_line_item_response = self.line_items_api.delete_order_line_item( + order_id=order_id, serial_number=line_item_id + ) + self.assertTrue(delete_line_item_response.success) + self.assertEqual(delete_line_item_response.data, line_item_id) + + # Fetch order and see it has no line items + retrieve_order_response = self.api.retrieve_order(id=order_id) + self.assertEqual(retrieve_order_response.data.id, order_id) + self.assertEqual(len(retrieve_order_response.data.line_items), 0) + + # Delete order + delete_order_response = self.api.delete_order(uid=order_id) + self.assertTrue(delete_order_response.success) + self.assertEqual(delete_order_response.data, order_id) + if __name__ == "__main__": unittest.main() diff --git a/test/test_projects_api.py b/test/test_projects_api.py index 3ef825e..46a102b 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -85,14 +85,11 @@ def test_retrieve_projects(self): project = projects[0] self.assertEqual(project.production, False) - self.assertGreater(project.average_price_per_tonne_cents_usd, 0) - self.assertGreater(project.remaining_mass_g, 0) self.assertIsInstance(project.standard, object) self.assertIsInstance(project.name, str) self.assertTrue(project.description) self.assertIsInstance(project.country, str) - self.assertIsInstance(project.type, str) - self.assertIsInstance(project.developer, str) + self.assertIsInstance(project.project_partner, str) self.assertIsInstance(project.photos, list) def test_retrieve_biomass_projects(self): @@ -105,7 +102,7 @@ def test_retrieve_biomass_projects(self): self.assertTrue(isinstance(projects, list)) for project in projects: - self.assertEqual(project.type, project_type) + self.assertEqual(project.technology_type.slug, project_type) def test_retrieve_american_projects(self): """Test case for retrieve_projects with a country filter @@ -131,7 +128,8 @@ def test_retrieve_projects_with_more_than_100_grams_of_inventory(self): self.assertTrue(isinstance(projects, list)) for project in projects: - self.assertTrue(project.remaining_mass_g >= minimum_available_mass) + remaining_amount = sum(inv.amount_available for inv in project.inventory) + self.assertTrue(remaining_amount >= minimum_available_mass) def test_retrieve_projects_language(self): """Test case for retrieve_projects with a type filter