MediaMath / t1-python

Python SDK for MediaMath Platform APIs
https://developer.mediamath.com/
Apache License 2.0
18 stars 30 forks source link

Limit #149

Closed FodT closed 7 years ago

FodT commented 7 years ago

Remove client-side enforcement of the page_limit parameter - The service can and does enforce this. Allows for a variable number of entities to be requested from each service.

FodT commented 7 years ago

I'm a little confused, the get_all function will use the page_limit param passed in to handle the pagination:

for page_offset in six.moves.range(0, num_recs, num_to_fetch):

in the function, page_limit will default to 100:

num_to_fetch = kwargs.get('page_limit', 100)
FodT commented 7 years ago

Ah do you mean if the service just blindly returns 100 entities? As it stands, all services (afaik) will 400 if the user requests >$max_allowed entities.

pswaminathan commented 7 years ago

Ah yes I do mean if the service just blindly returns 100 entities. I remember you mentioning that it will 400 if you request >max allowed (in fact, I remember that being justification for removing the client-side check), but let's confirm. If it 400s then this looks good to me.

FodT commented 7 years ago

https://api.mediamath.com/api/v2.0/strategies?page_limit=101:

{
  "errors": [
    {
      "type": "field-error",
      "message": "query parameter 'page_limit' may not exceed 100",
      "field": "page_limit"
    }
  ],
  "meta": {
    "called_on": "2017-04-24T16:56:26+0000",
    "status": "invalid"
  }
}

https://api.mediamath.com/media/v1.0/deals?page_limit=60000:

{
  "meta": {
    "status": "error"
  },
  "errors": [
    {
      "code": "Input payload validation failed",
      "message": "'page_limit' parameter cannot be greater than 5000",
      "field": "page_limit"
    }
  ]
}