class Twenty3AndMe::Client
Constants
- VERSION
Attributes
refresh_token[RW]
token[RW]
Public Instance Methods
ancestry(threshold)
click to toggle source
# File lib/twenty3andme/client.rb, line 56 def ancestry(threshold) get("/ancestry/?threshold=#{threshold.to_f}") end
genomes(profile_id)
click to toggle source
# File lib/twenty3andme/client.rb, line 64 def genomes(profile_id) get("/genomes/#{profile_id}") end
genotypes(locations)
click to toggle source
# File lib/twenty3andme/client.rb, line 51 def genotypes(locations) locations_uri = Array(locations).join(" ") get("/genotypes/?locations=#{locations_uri}") end
get(path)
click to toggle source
# File lib/twenty3andme/client.rb, line 13 def get(path) options = { :headers => {"Authorization" => "Bearer #{@token}"} } fullpath = URI.escape(VERSION + path) resp = self.class.get(fullpath, options).parsed_response if resp.class == Hash raise APIRequestError, resp['error_description'] if resp['error'] end resp end
haplogroups()
click to toggle source
# File lib/twenty3andme/client.rb, line 47 def haplogroups get('/haplogroups') end
names()
click to toggle source
# File lib/twenty3andme/client.rb, line 43 def names get('/names') end
relatives()
click to toggle source
# File lib/twenty3andme/client.rb, line 60 def relatives get("/relatives") end
request_refresh_token()
click to toggle source
TODO
# File lib/twenty3andme/client.rb, line 34 def request_refresh_token() end
request_token(client_id, client_secret, code, redirect_uri, scope)
click to toggle source
# File lib/twenty3andme/client.rb, line 23 def request_token(client_id, client_secret, code, redirect_uri, scope) scope_uri = Array(scope).join(" ") req_body = {:client_id => client_id, :client_secret => client_secret, :grant_type => 'authorization_code', :code => code, :redirect_uri => redirect_uri, :scope => scope_uri} resp = self.class.post("https://api.23andme.com:443/token", :body => req_body) raise TokenRequestError, resp['error_description'] if resp['error'] @token = resp['access_token'] @refresh_token = resp['refresh_token'] end
user()
click to toggle source
Requests
# File lib/twenty3andme/client.rb, line 39 def user get('/user') end