Last active
June 21, 2016 21:30
-
-
Save peterkappus/9c0a318aec642d01c8c435b721a876bb to your computer and use it in GitHub Desktop.
A draft ruby wrapper for the WeekDone REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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