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

getUserByKey default response is not working properly #66

Open
brunofno opened this issue Jan 18, 2017 · 3 comments
Open

getUserByKey default response is not working properly #66

brunofno opened this issue Jan 18, 2017 · 3 comments

Comments

@brunofno
Copy link

Hi,

In the following documentation: https://getstarted.sailthru.com/new-for-developers-overview/email-and-user-profiles/user/#User_Profile_Fields_Reference

We can read this in the documentation for the parameter "fields" : The default response consists of keys, vars, lists, engagement, and optout_email.

In the code, if the parameter "fields" is not set, its default value is an empty array.
public function getUserByKey($id, $key, array $fields = [ ])

The problem is, if you call that function using the default values, the payload will contain an empty fields array. The response is literally this:
[]

For the default response to work, the payload must not contain the fields parameters, but the way the function is done, it always include an empty fields array if it's not set. We can't access the default response because of that.

Unless that is wanted and the documentation is out of date. I'm not sure on that part, that's why I'm opening an issue so you can decide. :)

Thank you and have a nice day!

@silverman63
Copy link
Contributor

Hi @brunofno,

To clarify:

  • The default user API response when fields are not specified is all fields
  • The getUserByKey asks for you to specify which fields you want, but default behavior returns nothing.
  • You'd like getUserByKey to reflect the default Sailthru API behavior.

Is that correct? While we don't encourage pulling for more information than you need, the consistency makes sense, and I think updates the request to reflect this makes sense.

I can try to address this in the next update, or you can feel free to make a pull request.

@brunofno
Copy link
Author

brunofno commented Jan 19, 2017

Hi @silverman63

I'm not really used to github. I've tried to make a pull request, seems I have some authentification issues, not really sure. Anyway, the fix is easy, it looks like this:

public function getUserByKey($id, $key, array $fields = [ ]) {
        $data = [
            'id' => $id,
            'key' => $key
        ];
        if (!empty($fields)){
            $data['fields'] = $fields;
        }

        return $this->apiGet('user', $data);
}

This prevent returning the empty array response.

Thank you!

@silverman63
Copy link
Contributor

Hi @brunofno, I think that's a reasonable change. Will add this in the next release.

@silverman63 silverman63 mentioned this issue Aug 15, 2017
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