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

Add method to get ratings #2

Merged
merged 3 commits into from
Dec 16, 2016
Merged

Add method to get ratings #2

merged 3 commits into from
Dec 16, 2016

Conversation

rikmatena
Copy link
Contributor

@rikmatena rikmatena commented Dec 16, 2016

Pretty self-explanatory. Was using this in scoutest, now extracting out into the gem.

Small note: using start_date and end_date as variables, not start and end as they've defined them at Helpscout, because those make things break :D

rating = 0
query = {mailboxes: mailbox_id, user: user_id, start: start_date, end: end_date, rating: rating}

get("reports/user/ratings", page, modified_since, query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still your old Scoutest syntax, you need to move them to an options hash.

I'd write the whole method like this.

Thoughts: name it like the end point, has all the required parameters as parameters in the method. Might want to cast the dates to the right format (ISO 8601, in UTC) if you want.

def reports_user_ratings(user_id, rating, start_date, end_date, options)
  options = {
    user: user_id,
    rating: rating,
    start: start_date,
    end: end_date,
  }
  
  get("reports/user/ratings", options)

You can use all the extra parameters (modified_since, user_id, etc) via the options Hash in Scoutest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts: name it like the end point

Hhm, that's not currently the case for every method FYI. But I'll do that.

[... the code ...]

Perfect, thanks. I'll just commit this, fine for me.

@bittersweet bittersweet merged commit f8196c4 into master Dec 16, 2016
@bittersweet bittersweet deleted the add_get_ratings branch December 16, 2016 15:48
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

Successfully merging this pull request may close these issues.

3 participants