Skip to content

Commit

Permalink
[UPD] Release 1.4.1 (#45)
Browse files Browse the repository at this point in the history
* Introducing new param for the Api Class's request method
`override_group` which allows you to override the default group
for a particular method within a group.

This is useful for certain cases when a particular api is moved to a new
group but for backwards compatibility, you want to support old methods
as well.

For example, see ship_order_item method changes and new shipment create
owing to the new change: https://api.bol.com/retailer/public/Retailer-API/v10/releasenotes.html#_new_features_and_improvements_4

* Shipments group's list endpoint needs `order-id` instead of `order_id`
  • Loading branch information
karan-dreambits authored Feb 28, 2025
1 parent 0402730 commit 8138ac1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions bol/retailer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ def __init__(self, api, group, base_type="retailer"):
self.group = group
self.base_type = base_type

def request(self, method, path="", params={}, **kwargs):
def request(self, method, override_group=None, path="", params={}, **kwargs):
uri = path
base = self.base_type+"-demo" if self.api.demo else self.base_type

uri = "/{base}/{group}{path}".format(
base=base,
group=self.group,
group=override_group if override_group else self.group,
path=("/{}".format(path) if path else ""),
)
return self.api.request(method, uri, params=params, **kwargs)
Expand Down Expand Up @@ -101,7 +100,7 @@ def ship_order_item(
"trackAndTrace"
] = track_and_trace
resp = self.request(
"PUT", path="shipment", json=payload
"POST", override_group="shipments", json=payload
)
return ProcessStatus.parse(self.api, resp.text)

Expand Down Expand Up @@ -131,15 +130,14 @@ def list(self, fulfilment_method=None, page=None, order_id=None):
if page is not None:
params["page"] = page
if order_id:
params["order_id"] = order_id
params["order-id"] = order_id
resp = self.request("GET", params=params)
return Shipments.parse(self.api, resp.text)

def get(self, shipment_id):
resp = self.request("GET", path=str(shipment_id))
return Shipment.parse(self.api, resp.text)


class ProcessStatusMethods(MethodGroup):
def __init__(self, api):
super(ProcessStatusMethods, self).__init__(api, "process-status", "shared")
Expand Down

0 comments on commit 8138ac1

Please sign in to comment.