Skip to content

Commit 62b2fbe

Browse files
holtbppcothenet
andauthored
Remove /estimates/ecommerce endpoint calls (#79)
* Remove /estimates/ecommerce endpoint calls * Pin the version of black being used * Latest ubuntu? * Bump test version * Do we even need to set up Python? * Clean up .DS_Store --------- Co-authored-by: Paul Cothenet <pcothenet@gmail.com>
1 parent 4df2d30 commit 62b2fbe

File tree

11 files changed

+25
-259
lines changed

11 files changed

+25
-259
lines changed

.DS_Store

8 KB
Binary file not shown.

.github/workflows/test.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,16 @@ jobs:
1212
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
1313
- uses: actions/setup-python@e9aba2c848f5ebd159c070c61ea2c4e2b122355e # v2.3.4
1414
- uses: psf/black@stable
15-
15+
with:
16+
version: "24.10.0"
17+
1618
build-and-test:
17-
# 03/27/23: it looks like there are issues with the tarballs for all python 3.6 versions
18-
# that are on ubuntu-22.04 (ubuntu-latest at the time). To maintain python compatibility
19-
# we're pinning ubuntu-20.04 so that we can properly run install python 3.6.
20-
#
21-
# As soon as this issue is addressed, we should put the image back to ubuntu-latest:
22-
# https://github.com/actions/setup-python/issues/544
23-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-latest
2420
name: Python Library tests
2521
steps:
2622
- name: Check out code
2723
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
2824

29-
- name: Setup Python
30-
uses: actions/setup-python@e9aba2c848f5ebd159c070c61ea2c4e2b122355e # v2.3.4
31-
with:
32-
python-version: '3.6'
33-
3425
- name: Run tests
3526
env:
3627
SANDBOX_API_KEY: ${{ secrets.SANDBOX_API_KEY }}

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ repos:
1212
- id: flake8
1313
args: ["--config=.flake8"]
1414
- repo: https://github.com/psf/black
15-
rev: 24.10.0
15+
rev: 24.4.2
1616
hooks:
1717
- id: black

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM python:3.8.6 AS base
33

44
FROM base AS lint
55

6-
RUN pip install black
6+
RUN pip install black==24.4.2
77

88
WORKDIR /data
99
ENTRYPOINT ["black"]
@@ -24,9 +24,9 @@ ENTRYPOINT [ "python", "setup.py", "install" ]
2424

2525
FROM dependencies as test
2626

27-
COPY test-requirements.txt .
27+
COPY test-requirements.txt .
2828
RUN pip install -r test-requirements.txt
2929

3030
COPY . .
3131

32-
ENTRYPOINT ["python", "-m", "unittest", "discover", "test/"]
32+
ENTRYPOINT ["python", "-m", "unittest", "discover", "test/"]

patch_api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from __future__ import absolute_import
1717

18-
__version__ = "2.3.0"
18+
__version__ = "2.3.1"
1919

2020
# import ApiClient
2121
from patch_api.api_client import ApiClient

patch_api/api/estimates_api.py

-201
Original file line numberDiff line numberDiff line change
@@ -485,207 +485,6 @@ def create_bitcoin_estimate_with_http_info(
485485
collection_formats=collection_formats,
486486
)
487487

488-
def create_ecommerce_estimate(
489-
self, create_ecommerce_estimate_request={}, **kwargs
490-
): # noqa: E501
491-
"""Create an e-commerce estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501
492-
493-
Creates a e-commerce estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # noqa: E501
494-
This method makes a synchronous HTTP request by default. To make an
495-
asynchronous HTTP request, please pass async_req=True
496-
>>> thread = api.create_ecommerce_estimate(create_ecommerce_estimate_request, async_req=True)
497-
>>> result = thread.get()
498-
499-
:param async_req bool: execute request asynchronously
500-
:param CreateEcommerceEstimateRequest create_ecommerce_estimate_request: (required)
501-
:param int patch_version:
502-
:param _preload_content: if False, the urllib3.HTTPResponse object will
503-
be returned without reading/decoding response
504-
data. Default is True.
505-
:param _request_timeout: timeout setting for this request. If one
506-
number provided, it will be total request
507-
timeout. It can also be a pair (tuple) of
508-
(connection, read) timeouts.
509-
:return: EstimateResponse
510-
If the method is called asynchronously,
511-
returns the request thread.
512-
"""
513-
kwargs["_return_http_data_only"] = True
514-
return self.create_ecommerce_estimate_with_http_info(
515-
create_ecommerce_estimate_request, **kwargs
516-
) # noqa: E501
517-
518-
def create_ecommerce_estimate_with_http_info(
519-
self, create_ecommerce_estimate_request, **kwargs
520-
): # noqa: E501
521-
"""Create an e-commerce estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501
522-
523-
Creates a e-commerce estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # noqa: E501
524-
This method makes a synchronous HTTP request by default. To make an
525-
asynchronous HTTP request, please pass async_req=True
526-
>>> thread = api.create_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, async_req=True)
527-
>>> result = thread.get()
528-
529-
:param async_req bool: execute request asynchronously
530-
:param CreateEcommerceEstimateRequest create_ecommerce_estimate_request: (required)
531-
:param int patch_version:
532-
:param _return_http_data_only: response data without head status code
533-
and headers
534-
:param _preload_content: if False, the urllib3.HTTPResponse object will
535-
be returned without reading/decoding response
536-
data. Default is True.
537-
:param _request_timeout: timeout setting for this request. If one
538-
number provided, it will be total request
539-
timeout. It can also be a pair (tuple) of
540-
(connection, read) timeouts.
541-
:return: tuple(EstimateResponse, status_code(int), headers(HTTPHeaderDict))
542-
If the method is called asynchronously,
543-
returns the request thread.
544-
"""
545-
546-
local_var_params = locals()
547-
548-
all_params = [
549-
"create_ecommerce_estimate_request",
550-
"patch_version",
551-
] # noqa: E501
552-
all_params.append("async_req")
553-
all_params.append("_return_http_data_only")
554-
all_params.append("_preload_content")
555-
all_params.append("_request_timeout")
556-
all_params.append("mass_g")
557-
all_params.append("total_price_cents_usd")
558-
all_params.append("project_id")
559-
all_params.append("metadata")
560-
all_params.append("distance_m")
561-
all_params.append("transportation_method")
562-
all_params.append("package_mass_g")
563-
all_params.append("create_order")
564-
all_params.append("make")
565-
all_params.append("model")
566-
all_params.append("year")
567-
all_params.append("transaction_value_btc_sats")
568-
all_params.append("transaction_value_eth_gwei")
569-
all_params.append("gas_used")
570-
all_params.append("transaction_value_btc_sats")
571-
all_params.append("average_daily_balance_btc_sats")
572-
all_params.append("average_daily_balance_eth_gwei")
573-
all_params.append("timestamp")
574-
all_params.append("origin_airport")
575-
all_params.append("destination_airport")
576-
all_params.append("aircraft_code")
577-
all_params.append("cabin_class")
578-
all_params.append("passenger_count")
579-
all_params.append("state")
580-
all_params.append("country_code")
581-
all_params.append("city")
582-
all_params.append("region")
583-
all_params.append("star_rating")
584-
all_params.append("number_of_nights")
585-
all_params.append("number_of_rooms")
586-
all_params.append("vintage_year")
587-
all_params.append("total_price")
588-
all_params.append("currency")
589-
all_params.append("amount")
590-
all_params.append("unit")
591-
all_params.append("issued_to")
592-
all_params.append("cargo_type")
593-
all_params.append("container_size_code")
594-
all_params.append("destination_country_code")
595-
all_params.append("destination_locode")
596-
all_params.append("destination_postal_code")
597-
all_params.append("emissions_scope")
598-
all_params.append("freight_mass_g")
599-
all_params.append("freight_volume_cubic_m")
600-
all_params.append("fuel_type")
601-
all_params.append("number_of_containers")
602-
all_params.append("origin_country_code")
603-
all_params.append("origin_locode")
604-
all_params.append("origin_postal_code")
605-
all_params.append("truck_weight_t")
606-
all_params.append("vessel_imo")
607-
all_params.append("vintage_start_year")
608-
all_params.append("vintage_end_year")
609-
610-
for key, val in six.iteritems(local_var_params["kwargs"]):
611-
if key not in all_params:
612-
raise ApiTypeError(
613-
"Got an unexpected keyword argument '%s'"
614-
" to method create_ecommerce_estimate" % key
615-
)
616-
local_var_params[key] = val
617-
del local_var_params["kwargs"]
618-
# verify the required parameter 'create_ecommerce_estimate_request' is set
619-
if (
620-
"create_ecommerce_estimate_request" not in local_var_params
621-
or local_var_params["create_ecommerce_estimate_request"] is None
622-
):
623-
raise ApiValueError(
624-
"Missing the required parameter `create_ecommerce_estimate_request` when calling `create_ecommerce_estimate`"
625-
) # noqa: E501
626-
627-
collection_formats = {}
628-
629-
path_params = {}
630-
631-
query_params = []
632-
633-
# do not add duplicate keys to query_params list
634-
existing_keys = []
635-
for param in query_params:
636-
existing_keys.append(param[0])
637-
638-
for key in kwargs:
639-
if key not in existing_keys:
640-
query_params.append([key, kwargs.get(key)])
641-
642-
header_params = {}
643-
if "patch_version" in local_var_params:
644-
header_params["Patch-Version"] = local_var_params[
645-
"patch_version"
646-
] # noqa: E501
647-
648-
form_params = []
649-
local_var_files = {}
650-
651-
body_params = None
652-
if "create_ecommerce_estimate_request" in local_var_params:
653-
body_params = local_var_params["create_ecommerce_estimate_request"]
654-
# HTTP header `Accept`
655-
header_params["Accept"] = self.api_client.select_header_accept(
656-
["application/json"]
657-
) # noqa: E501
658-
659-
# HTTP header `Content-Type`
660-
header_params["Content-Type"] = (
661-
self.api_client.select_header_content_type( # noqa: E501
662-
["application/json"]
663-
)
664-
) # noqa: E501
665-
666-
# Authentication setting
667-
auth_settings = ["bearer_auth"] # noqa: E501
668-
669-
return self.api_client.call_api(
670-
"/v1/estimates/ecommerce",
671-
"POST",
672-
path_params,
673-
query_params,
674-
header_params,
675-
body=body_params,
676-
post_params=form_params,
677-
files=local_var_files,
678-
response_type="EstimateResponse", # noqa: E501
679-
auth_settings=auth_settings,
680-
async_req=local_var_params.get("async_req"),
681-
_return_http_data_only=local_var_params.get(
682-
"_return_http_data_only"
683-
), # noqa: E501
684-
_preload_content=local_var_params.get("_preload_content", True),
685-
_request_timeout=local_var_params.get("_request_timeout"),
686-
collection_formats=collection_formats,
687-
)
688-
689488
def create_flight_estimate(
690489
self, create_flight_estimate_request={}, **kwargs
691490
): # noqa: E501

patch_api/api_client.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# coding: utf-8
22
"""
3-
Patch API V2
3+
Patch API V2
44
5-
The core API used to integrate with Patch's service # noqa: E501
5+
The core API used to integrate with Patch's service # noqa: E501
66
7-
The version of the OpenAPI document: 2
8-
Contact: engineering@usepatch.com
9-
Generated by: https://openapi-generator.tech
7+
The version of the OpenAPI document: 2
8+
Contact: engineering@usepatch.com
9+
Generated by: https://openapi-generator.tech
1010
"""
1111

1212
from __future__ import absolute_import
@@ -92,7 +92,7 @@ def __init__(
9292
self.default_headers[header_name] = header_value
9393
self.cookie = cookie
9494
# Set default User-Agent.
95-
self.user_agent = "patch-python/2.3.0"
95+
self.user_agent = "patch-python/2.3.1"
9696
# Set default Patch-Version
9797
self.patch_version = 2
9898

@@ -130,9 +130,6 @@ def user_agent(self):
130130
def user_agent(self, value):
131131
self.default_headers["User-Agent"] = value
132132

133-
def set_default_header(self, header_name, header_value):
134-
self.default_headers[header_name] = header_value
135-
136133
@property
137134
def patch_version(self):
138135
"""API version for this API client"""
@@ -142,6 +139,9 @@ def patch_version(self):
142139
def patch_version(self, value):
143140
self.default_headers["Patch-Version"] = value
144141

142+
def set_default_header(self, header_name, header_value):
143+
self.default_headers[header_name] = header_value
144+
145145
def __call_api(
146146
self,
147147
resource_path,

patch_api/configuration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def to_debug_report(self):
341341
"OS: {env}\n"
342342
"Python Version: {pyversion}\n"
343343
"Version of the API: 2\n"
344-
"SDK Package Version: 2.3.0".format(env=sys.platform, pyversion=sys.version)
344+
"SDK Package Version: 2.3.1".format(env=sys.platform, pyversion=sys.version)
345345
)
346346

347347
def get_host_settings(self):

patch_api/models/__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
from patch_api.models.create_bitcoin_estimate_request import (
2222
CreateBitcoinEstimateRequest,
2323
)
24-
from patch_api.models.create_ecommerce_estimate_request import (
25-
CreateEcommerceEstimateRequest,
26-
)
2724
from patch_api.models.create_flight_estimate_request import CreateFlightEstimateRequest
2825
from patch_api.models.create_hotel_estimate_request import CreateHotelEstimateRequest
2926
from patch_api.models.create_mass_estimate_request import CreateMassEstimateRequest

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from setuptools import setup, find_packages # noqa: H301
1212

1313
NAME = "patch-api"
14-
VERSION = "2.3.0"
14+
VERSION = "2.3.1"
1515
# To install the library, run the following
1616
#
1717
# python setup.py install

test/test_estimates_api.py

+5-26
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# coding: utf-8
22

33
"""
4-
Patch API V1
4+
Patch API V1
55
6-
The core API used to integrate with Patch's service # noqa: E501
6+
The core API used to integrate with Patch's service # noqa: E501
77
8-
The version of the OpenAPI document: v1
9-
Contact: developers@usepatch.com
10-
Generated by: https://openapi-generator.tech
8+
The version of the OpenAPI document: v1
9+
Contact: developers@usepatch.com
10+
Generated by: https://openapi-generator.tech
1111
"""
1212

1313

@@ -113,27 +113,6 @@ def test_create_hotel_estimate(self):
113113
estimate.data.mass_g, 15_000
114114
) # not setting an exact value since this is changing daily
115115

116-
def test_create_and_retrieve_ecommerce_estimate(self):
117-
"""Test case for create_ecommerce_estimate
118-
119-
Create an estimate based on the shipping distance, transportation method, and package mass # noqa: E501
120-
"""
121-
distance_m = 10000000
122-
package_mass_g = 1000
123-
transportation_method = "sea"
124-
estimate = self.api.create_ecommerce_estimate(
125-
distance_m=distance_m,
126-
package_mass_g=package_mass_g,
127-
transportation_method=transportation_method,
128-
create_order=False,
129-
)
130-
self.assertEqual(estimate.data.order, None)
131-
self.assertEqual(estimate.data.type, "ecommerce")
132-
self.assertGreater(estimate.data.mass_g, 200)
133-
134-
retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id)
135-
self.assertTrue(retrieved_estimate)
136-
137116
def test_create_air_shipping_estimate_airport_iatas(self):
138117
"""Test case for create_air_shipping_estimate
139118

0 commit comments

Comments
 (0)