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

Iterator interface would be nice for responses with arrays #67

Open
grimmdude opened this issue Mar 7, 2017 · 2 comments
Open

Iterator interface would be nice for responses with arrays #67

grimmdude opened this issue Mar 7, 2017 · 2 comments

Comments

@grimmdude
Copy link

grimmdude commented Mar 7, 2017

It would be helpful if the response object implemented an iterator interface when the data includes an array so that something like this would work as expected:

$lists = api("list/list", array("ids" => "all");
if ($lists->success) {
    foreach($lists as $list) {
        echo $list->id;
    }
}

Intuitively that would just iterate through the lists, but currently it includes all visible properties of the object so you can't really use it like that. I realize that iterating over $lists->{0} will work instead, but just thought I would suggest this improvement. Thanks!

-Garrett

@grimmdude
Copy link
Author

grimmdude commented Mar 7, 2017

Actually, even iterating over $lists->{0} doesn't seem to work as expected. If there is only one list this will be a flat object, not an array with a single object in it.

@grimmdude
Copy link
Author

Last message I promise.

Just realized $lists->{0} will always only return one item, but according to the API docs (http://www.activecampaign.com/api/example.php?call=list_list) property0 is an array. 😕

-Garrett

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

1 participant