-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add ninja van carrier integration #596
base: main
Are you sure you want to change the base?
Feat/add ninja van carrier integration #596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general idea is that while the bootstrap command creates the plugin file structure.
You need to navigate through the files to setup the data and implementation specific to the NinjaVan API operations and logic
quicktype --src="${SCHEMAS}/error_response.json" --out="${LIB_MODULES}/error_response.py" | ||
quicktype --src="${SCHEMAS}/paperless_request.json" --out="${LIB_MODULES}/paperless_request.py" | ||
quicktype --src="${SCHEMAS}/paperless_response.json" --out="${LIB_MODULES}/paperless_response.py" | ||
quicktype --src="${SCHEMAS}/rating_request.json" --out="${LIB_MODULES}/rating_request.py" | ||
quicktype --src="${SCHEMAS}/rating_response.json" --out="${LIB_MODULES}/rating_response.py" | ||
quicktype --src="${SCHEMAS}/shipping_request.json" --out="${LIB_MODULES}/shipping_request.py" | ||
quicktype --src="${SCHEMAS}/shipping_response.json" --out="${LIB_MODULES}/shipping_response.py" | ||
quicktype --src="${SCHEMAS}/tracking_request.json" --out="${LIB_MODULES}/tracking_request.py" | ||
quicktype --src="${SCHEMAS}/tracking_response.json" --out="${LIB_MODULES}/tracking_response.py" | ||
quicktype --src="${SCHEMAS}/cancel_request.json" --out="${LIB_MODULES}/cancel_request.py" | ||
quicktype --src="${SCHEMAS}/cancel_response.json" --out="${LIB_MODULES}/cancel_response.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON files referenced here need to be from the NinjaVan API.
https://api-docs.ninjavan.co/en
|
||
def get_rates(self, request: lib.Serializable) -> lib.Deserializable[str]: | ||
response = lib.request( | ||
url=f"{self.settings.server_url}/service", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url=f"{self.settings.server_url}/service", | |
url=f"{self.settings.server_url}/1.0/public/price", |
This and all the subsequent API requests needs to be based on the corresponding operation from the NinjaVan API.
By example, this one is the Tariff API
|
||
def create_shipment(self, request: lib.Serializable) -> lib.Deserializable[str]: | ||
response = lib.request( | ||
url=f"{self.settings.server_url}/service", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this one needs to be updated to reflect the Order API
url=f"{self.settings.server_url}/service", | |
url=f"{self.settings.server_url}/4.2/orders", |
|
||
def cancel_shipment(self, request: lib.Serializable) -> lib.Deserializable[str]: | ||
response = lib.request( | ||
url=f"{self.settings.server_url}/service", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
|
||
def get_tracking(self, request: lib.Serializable) -> lib.Deserializable[str]: | ||
response = lib.request( | ||
url=f"{self.settings.server_url}/service", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one for tracking
gateway = karrio.gateway["ninja_van"].create( | ||
dict( | ||
# add required carrier API setting key/value here | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gateway = karrio.gateway["ninja_van"].create( | |
dict( | |
# add required carrier API setting key/value here | |
) | |
) | |
gateway = karrio.gateway["ninja_van"].create( | |
dict( | |
client_id="client_id", | |
client_secret="client_secret", | |
) | |
) |
ParsedRateResponse = [] | ||
|
||
|
||
RateRequest = {} | ||
|
||
RateResponse = """{} | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the tests, you want to run them and ensure that essentially when a request is created, you get the right output data that needs to be sent to NinjaVan
Sendle is a good example here https://github.com/karrioapi/karrio/blob/main/modules/connectors/sendle/tests/sendle/test_rate.py
ShipmentCancelPayload = { | ||
"shipment_identifier": "794947717776", | ||
} | ||
|
||
ParsedShipmentResponse = [] | ||
|
||
ParsedCancelShipmentResponse = [] | ||
|
||
|
||
ShipmentRequest = {} | ||
|
||
ShipmentCancelRequest = {} | ||
|
||
ShipmentResponse = """{} | ||
""" | ||
|
||
ShipmentCancelResponse = """{} | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the tests above
ParsedTrackingResponse = [] | ||
|
||
ParsedErrorResponse = [] | ||
|
||
|
||
TrackingRequest = {} | ||
|
||
TrackingResponse = """{} | ||
""" | ||
|
||
ErrorResponse = """{} | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
api_key = models.CharField(max_length=100, blank=True, null=True) | ||
secret_key = models.CharField(max_length=100, blank=True, null=True) | ||
track_api_key = models.CharField(max_length=100, blank=True, null=True) | ||
track_secret_key = models.CharField(max_length=100, blank=True, null=True) | ||
account_number = models.CharField(max_length=50, blank=True, null=True) | ||
account_country_code = models.CharField( | ||
max_length=3, blank=True, null=True, choices=providers.COUNTRIES | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to replace these the the client_id and client_secret that NinjaVan support
ThankYou so much @danh91 for detailed review and guide |
Hello @danh91
I wrote mannual migration |
Can you share more details? |
Changes
Feat: