Skip to content
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

How to properly extract data from GET /orders API response? #282

Open
shaifulborhan opened this issue May 25, 2021 · 1 comment
Open

How to properly extract data from GET /orders API response? #282

shaifulborhan opened this issue May 25, 2021 · 1 comment

Comments

@shaifulborhan
Copy link
Contributor

shaifulborhan commented May 25, 2021

Hi,

I made the following API call to the get a user latest order.

$orders = $infusionsoft->orders()->where([
            'contactId' => 123
])->first();

echo '<pre>'; print_r($orders); echo '</pre>';

However the response came back like this.

Screenshot 2021-05-26 at 1 05 29 AM

To get the clean data I have to do $orders->attributesToArray(). Do I have to do this whenever I am using where()? What is the correct way to extract the orders array out of this response data?

Reason I am asking is because I am familiar with Laravel's Eloquent methods like first() and get() and they just work straightaway without any extra methods to unwrap the results. Since the method naming convention is pretty similar in the PHP-SDK I was expecting it to work similarly.

Thanks.

@skeemer
Copy link
Contributor

skeemer commented May 25, 2021

Laravel actually works the same, you get an Eloquent model/collection back from first()/get() then have to use ->toArray() to get "clean" data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants