Skip to content

Commit

Permalink
Merge pull request #550 from karrioapi/fedex-rate-customs-clearance
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 authored Mar 30, 2024
2 parents 95a8800 + 53b54f8 commit ce61656
Show file tree
Hide file tree
Showing 13 changed files with 3,068 additions and 2,548 deletions.
2 changes: 1 addition & 1 deletion apps/api/karrio/server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.2.9
2024.2.10
5,492 changes: 2,962 additions & 2,530 deletions apps/api/karrio/server/static/karrio/js/karrio.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/api/karrio/server/static/karrio/js/karrio.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bin/deploy-hobby
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

export KARRIO_TAG="${KARRIO_TAG:-2024.2.9}"
export KARRIO_TAG="${KARRIO_TAG:-2024.2.10}"
export SENTRY_DSN="${SENTRY_DSN:-'https://[email protected]/1'}"

SECRET_KEY=$(head -c 28 /dev/urandom | sha224sum -b | head -c 56)
Expand All @@ -23,7 +23,7 @@ if ! [ -z "$1" ]
then
export KARRIO_TAG=$1
else
echo "What version of Karrio would you like to install? (We default to '2024.2.9')"
echo "What version of Karrio would you like to install? (We default to '2024.2.10')"
echo "You can check out available versions here: https://hub.docker.com/r/karrio/server/tags"
read -r KARRIO_TAG_READ
if [ -z "$KARRIO_TAG_READ" ]
Expand Down
2 changes: 1 addition & 1 deletion bin/upgrade-hobby
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ else
fi

[[ -f ".env" ]] && export $(cat .env | xargs) || ( echo "No .env file found. Please create it with SECRET_KEY and DOMAIN set." && exit 1)
export KARRIO_TAG="${KARRIO_TAG:-2024.2.9}"
export KARRIO_TAG="${KARRIO_TAG:-2024.2.10}"

# get karrio scripts
mkdir -p ./karrio
Expand Down
6 changes: 3 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
api:
container_name: karrio.api
image: karrio.docker.scarf.sh/karrio/server:2024.2.9
image: karrio.docker.scarf.sh/karrio/server:2024.2.10
restart: unless-stopped
ports:
- ${KARRIO_HTTP_PORT}:${KARRIO_HTTP_PORT}
Expand All @@ -25,7 +25,7 @@ services:

worker:
container_name: karrio.worker
image: karrio.docker.scarf.sh/karrio/server:2024.2.9
image: karrio.docker.scarf.sh/karrio/server:2024.2.10
restart: unless-stopped
depends_on:
- db
Expand All @@ -46,7 +46,7 @@ services:

dashboard:
container_name: karrio.dashboard
image: karrio.docker.scarf.sh/karrio/dashboard:2024.2.9
image: karrio.docker.scarf.sh/karrio/dashboard:2024.2.10
restart: unless-stopped
ports:
- ${DASHBOARD_PORT}:3000/tcp
Expand Down
71 changes: 70 additions & 1 deletion modules/connectors/fedex/karrio/providers/fedex/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def rate_request(
initializer=provider_units.shipping_options_initializer,
)

is_intl = shipper.country_code != recipient.country_code
request_types = lib.identity(
settings.connection_config.rate_request_types.state
if any(settings.connection_config.rate_request_types.state or [])
Expand All @@ -124,6 +125,22 @@ def rate_request(
if _options.state is not False
and option.code in provider_units.SHIPMENT_OPTIONS
]
customs = models.Customs(
commodities=(
packages.items
if any(packages.items)
else [
models.Commodity(
sku="0000",
quantity=1,
weight=packages.weight.value,
weight_unit=packages.weight_unit,
value_amount=options.declared_value.state or 1.0,
value_currency=options.currency.state or "USD",
)
]
)
)

request = fedex.RatingRequestType(
accountNumber=fedex.RatingRequestAccountNumberType(
Expand Down Expand Up @@ -233,7 +250,59 @@ def rate_request(
if any(shipment_options(packages.options))
else None
),
customsClearanceDetail=None,
customsClearanceDetail=lib.identity(
fedex.CustomsClearanceDetailType(
brokers=[],
commercialInvoice=None,
freightOnValue=None,
dutiesPayment=fedex.DutiesPaymentType(
payor=fedex.PayorType(
responsibleParty=fedex.ResponsiblePartyType(
address=None,
contact=None,
accountNumber=fedex.RatingRequestAccountNumberType(
value=settings.account_number,
),
),
),
paymentType=provider_units.PaymentType.map(
getattr(customs.duty, "paid_by", None) or "sender"
).value,
),
commodities=[
fedex.CommodityType(
description=lib.text(
item.title or item.description or "N/A", max=35
),
weight=fedex.WeightType(
units=packages.weight_unit,
value=item.weight,
),
unitPrice=(
fedex.FixedValueType(
amount=lib.to_money(item.value_amount),
currency=(
item.value_currency
or packages.options.currency.state
or customs.duty.currency
),
)
if item.value_amount
else None
),
quantity=item.quantity,
numberOfPieces=item.quantity,
quantityUnits="PCS",
harmonizedCode=item.hs_code,
name=None,
partNumber=item.sku,
)
for item in customs.commodities
],
)
if is_intl
else None
),
groupShipment=None,
serviceTypeDetail=None,
smartPostInfoDetail=lib.identity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def shipment_request(
additionalMeasures=[],
numberOfPieces=item.quantity,
quantity=item.quantity,
quantityUnits="EA",
quantityUnits="PCS",
customsValue=None,
countryOfManufacture=(
item.origin_country or shipper.country_code
Expand Down
2 changes: 1 addition & 1 deletion modules/connectors/fedex/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="karrio.fedex",
version="2024.2.7",
version="2024.2.10",
description="Karrio - FedEx Shipping Extension",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
19 changes: 19 additions & 0 deletions modules/connectors/fedex/tests/fedex/test_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ def test_parse_rate_response(self):
"residential": False,
}
},
"customsClearanceDetail": {
"dutiesPayment": {
"paymentType": "SENDER",
"payor": {
"responsibleParty": {"accountNumber": {"value": "2349857"}},
},
},
"commodities": [
{
"description": "N/A",
"numberOfPieces": 1,
"partNumber": "0000",
"quantity": 1,
"quantityUnits": "PCS",
"unitPrice": {"amount": 1.0, "currency": "USD"},
"weight": {"units": "LB", "value": 4.0},
}
],
},
"requestedPackageLineItems": [
{
"dimensions": {
Expand Down
6 changes: 3 additions & 3 deletions modules/connectors/fedex/tests/fedex/test_shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_parse_cancel_shipment_response(self):
"harmonizedCode": "00339BB",
"numberOfPieces": 1,
"quantity": 1,
"quantityUnits": "EA",
"quantityUnits": "PCS",
"weight": {"units": "LB", "value": 10.0},
}
],
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_parse_cancel_shipment_response(self):
"harmonizedCode": "00339BB",
"numberOfPieces": 1,
"quantity": 1,
"quantityUnits": "EA",
"quantityUnits": "PCS",
"weight": {"units": "LB", "value": 10.0},
}
],
Expand Down Expand Up @@ -500,7 +500,7 @@ def test_parse_cancel_shipment_response(self):
"harmonizedCode": "00339BB",
"numberOfPieces": 1,
"quantity": 1,
"quantityUnits": "EA",
"quantityUnits": "PCS",
"weight": {"units": "LB", "value": 10.0},
}
],
Expand Down
4 changes: 2 additions & 2 deletions packages/types/rest/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable */
/**
* Karrio API
* ## API Reference Karrio is an open source multi-carrier shipping API that simplifies the integration of logistics carrier services. The Karrio API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The Karrio API differs for every account as we release new versions. These docs are customized to your version of the API. ## Versioning When backwards-incompatible changes are made to the API, a new, dated version is released. The current version is `2024.2.9`. Read our API changelog to learn more about backwards compatibility. As a precaution, use API versioning to check a new API version before committing to an upgrade. ## Environments The Karrio API offer the possibility to create and retrieve certain objects in `test_mode`. In development, it is therefore possible to add carrier connections, get live rates, buy labels, create trackers and schedule pickups in `test_mode`. ## Pagination All top-level API resources have support for bulk fetches via \"list\" API methods. For instance, you can list addresses, list shipments, and list trackers. These list API methods share a common structure, taking at least these two parameters: limit, and offset. Karrio utilizes offset-based pagination via the offset and limit parameters. Both parameters take a number as value (see below) and return objects in reverse chronological order. The offset parameter returns objects listed after an index. The limit parameter take a limit on the number of objects to be returned from 1 to 100. ```json { \"count\": 100, \"next\": \"/v1/shipments?limit=25&offset=50\", \"previous\": \"/v1/shipments?limit=25&offset=25\", \"results\": [ { ... }, ] } ``` ## Metadata Updateable Karrio objects—including Shipment and Order have a metadata parameter. You can use this parameter to attach key-value data to these Karrio objects. Metadata is useful for storing additional, structured information on an object. As an example, you could store your user\'s full name and corresponding unique identifier from your system on a Karrio Order object. Do not store any sensitive information as metadata. ## Authentication API keys are used to authenticate requests. You can view and manage your API keys in the Dashboard. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. Authentication to the API is performed via HTTP Basic Auth. Provide your API token as the basic auth username value. You do not need to provide a password. ```shell $ curl https://instance.api.com/v1/shipments \\ -u key_xxxxxx: # The colon prevents curl from asking for a password. ``` If you need to authenticate via bearer auth (e.g., for a cross-origin request), use `-H \"Authorization: Token key_xxxxxx\"` instead of `-u key_xxxxxx`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). API requests without authentication will also fail.
* ## API Reference Karrio is an open source multi-carrier shipping API that simplifies the integration of logistics carrier services. The Karrio API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The Karrio API differs for every account as we release new versions. These docs are customized to your version of the API. ## Versioning When backwards-incompatible changes are made to the API, a new, dated version is released. The current version is `2024.2.10`. Read our API changelog to learn more about backwards compatibility. As a precaution, use API versioning to check a new API version before committing to an upgrade. ## Environments The Karrio API offer the possibility to create and retrieve certain objects in `test_mode`. In development, it is therefore possible to add carrier connections, get live rates, buy labels, create trackers and schedule pickups in `test_mode`. ## Pagination All top-level API resources have support for bulk fetches via \"list\" API methods. For instance, you can list addresses, list shipments, and list trackers. These list API methods share a common structure, taking at least these two parameters: limit, and offset. Karrio utilizes offset-based pagination via the offset and limit parameters. Both parameters take a number as value (see below) and return objects in reverse chronological order. The offset parameter returns objects listed after an index. The limit parameter take a limit on the number of objects to be returned from 1 to 100. ```json { \"count\": 100, \"next\": \"/v1/shipments?limit=25&offset=50\", \"previous\": \"/v1/shipments?limit=25&offset=25\", \"results\": [ { ... }, ] } ``` ## Metadata Updateable Karrio objects—including Shipment and Order have a metadata parameter. You can use this parameter to attach key-value data to these Karrio objects. Metadata is useful for storing additional, structured information on an object. As an example, you could store your user\'s full name and corresponding unique identifier from your system on a Karrio Order object. Do not store any sensitive information as metadata. ## Authentication API keys are used to authenticate requests. You can view and manage your API keys in the Dashboard. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. Authentication to the API is performed via HTTP Basic Auth. Provide your API token as the basic auth username value. You do not need to provide a password. ```shell $ curl https://instance.api.com/v1/shipments \\ -u key_xxxxxx: # The colon prevents curl from asking for a password. ``` If you need to authenticate via bearer auth (e.g., for a cross-origin request), use `-H \"Authorization: Token key_xxxxxx\"` instead of `-u key_xxxxxx`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). API requests without authentication will also fail.
*
* The version of the OpenAPI document: 2024.2.9
* The version of the OpenAPI document: 2024.2.10
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
4 changes: 2 additions & 2 deletions schemas/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ info:
## Versioning
When backwards-incompatible changes are made to the API, a new, dated version is released.
The current version is `2024.2.9`.
The current version is `2024.2.10`.
Read our API changelog to learn more about backwards compatibility.
Expand Down Expand Up @@ -86,7 +86,7 @@ info:
All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure).
API requests without authentication will also fail.
title: Karrio API
version: 2024.2.9
version: 2024.2.10
paths:
/:
get:
Expand Down

0 comments on commit ce61656

Please sign in to comment.