Skip to content

Instantly share code, notes, and snippets.

@peterkappus
Last active June 21, 2016 21:30
Show Gist options
  • Save peterkappus/9c0a318aec642d01c8c435b721a876bb to your computer and use it in GitHub Desktop.
Save peterkappus/9c0a318aec642d01c8c435b721a876bb to your computer and use it in GitHub Desktop.
A draft ruby wrapper for the WeekDone REST API
class WeekDoneClient
require 'rest-client'
# Initializes a new client object
#
# @param token [String] The auth token
# @return WeekDoneClient
def initialize(token)
@token = token
end
# Get all tags
#
# @return [Hash] Tag names mapped to IDs (for easy scanning)
def tags
tag_hash = {}
JSON.parse(RestClient.get "https://api.weekdone.com/1/tag", {:params => {:token=>@token}})['tags'].map{|tag| tag_hash[tag['tag']] = tag['id']}
tag_hash
end
# Get all users
#
# @return [Array]
def users
JSON.parse(RestClient.get "https://api.weekdone.com/1/users", {:params => {:token=>@token}})['users']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment