Unable to access the `get` method of a service
mevinbabuc opened this issue · 4 comments
I see a get method exposed on the service object, but I'm unable to access this.
In [10]: from appnexus import InsertionOrder
In [11]: InsertionOrder.get
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-11-8f1db379ca76> in <module>()
----> 1 InsertionOrder.get
AttributeError: type object 'InsertionOrder' has no attribute 'get'
Is this expected ?
Hi @mevinbabuc,
Yep, it's the AppNexusClient
class that owns that method, not models. You should not use that method directly; use InsertionOrder.find
instead. Or if you really want to, use client.get
. Is there a particular use-case that InsertionOrder.find
doesn't cover that you want to address?
Sorry, you're right, we do have a Service.get
method. It isn't a classmethod
, so it's normal that you can't use it the way you tried.
I'm not sure about why we have this, though. Let me investigate and report back.
@Shir0kamii any thought about this?
Hey I think it's useful, when all you want to do is pull some data from an endpoint, that needs to be authenticated. find
expects the response to be JSON and it converts it into a Cursor
object, which may not be the case everywhere.
For example, In reporting to download the reports, you simply have to make a get request to the download URL and it returns the data in CSV format.
Yeah, you're right, that's why we have it.
Although, this is meant to be used via the client
object, not via the Model
children. client.insertion_order.get()
is what you want to do.
We don't want that method in the Model
class because we couldn't generate a model instance if what we get is not JSON.
Does that make sense to you?
We really lack a proper documentation, sorry about this.