Skip to content

Commit

Permalink
fix: update Data SDK err management (#6)
Browse files Browse the repository at this point in the history
* fix: add req obj validation in GetBidsDelivered method

Signed-off-by: Luca Georges Francois <[email protected]>

* fix: use req obj validation in GetBidsDelivered method

Signed-off-by: Luca Georges Francois <[email protected]>

---------

Signed-off-by: Luca Georges Francois <[email protected]>
  • Loading branch information
0xpanoramix committed Dec 3, 2023
1 parent 494d982 commit 0a48ae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions sdk/data/v1/data_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func (dataV1 *SDK) GetBidsDelivered(ctx context.Context, params *GetBidsDelivere
params = new(GetBidsDeliveredRequest)
}

if err := params.validate(); err != nil {
return nil, NewDataSDKError("GetBidsDelivered", err)
}

//nolint:exhaustruct
relayReq := &relay.Request{
Method: "GET",
Expand Down
12 changes: 8 additions & 4 deletions sdk/data/v1/req_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ func (r *GetBidsDeliveredRequest) WithOrder(order ResultsOrder) *GetBidsDelivere
return r
}

func (r *GetBidsDeliveredRequest) validate() error {
if r.queryParams.Has("slot") && r.queryParams.Has("cursor") {
return ErrConflictingParams
}

return nil
}

type GetBidsReceivedRequest struct {
queryParams url.Values
}
Expand Down Expand Up @@ -134,9 +142,5 @@ func (r *GetBidsReceivedRequest) validate() error {
return ErrMissingMandatoryParam
}

if r.queryParams.Has("slot") && r.queryParams.Has("cursor") {
return ErrConflictingParams
}

return nil
}

0 comments on commit 0a48ae9

Please sign in to comment.