Skip to content

Add method to get ratings - #2

Merged
bittersweet merged 3 commits into
masterfrom
add_get_ratings
Dec 16, 2016
Merged

bittersweet merged 3 commits into
masterfrom
add_get_ratings

Conversation

@rikmatena

@rikmatena rikmatena commented Dec 16, 2016 •

Copy link
Copy Markdown
Contributor

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

Comment thread lib/help_scout.rb Outdated
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
Copy Markdown
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
Copy Markdown
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