class Movescount::Member

Attributes

options[R]

debug_output $stderr

Public Class Methods

new(options={}) click to toggle source
# File lib/movescount/member.rb, line 11
def initialize(options={})
  raise ArgumentError, 'An email is required as an option' unless options[:email]
  raise ArgumentError, 'A userkey is required as an option' unless options[:userkey]
  self.class.base_uri Movescount.configuration.api_uri
  @options = {
    query: {
      appKey: Movescount.configuration.app_key,
      userKey: options.delete(:userkey),
      email: options.delete(:email)
    }
  }.merge options
end

Public Instance Methods

move_by_id(id) click to toggle source

Get a move by move_id

# File lib/movescount/member.rb, line 48
def move_by_id(id)
  Move.new self, self.class.get("/moves/#{id}", @options)
end
moves(options = {}, force = false) click to toggle source

Returns the user's moves Options include: startDate, endDate and maxcount Force argument forces reload of data from api

# File lib/movescount/member.rb, line 38
def moves(options = {}, force = false)
  # Return moves if present and not forcing reload
  return @moves if @moves && !force
  # Get moves from the api and create move objects
  @moves = get_moves(options).map do |move|
    Move.new self, move
  end
end
profile(force = false) click to toggle source

Returns the entire user profile Force argument forces reload of data from api

# File lib/movescount/member.rb, line 26
def profile(force = false)
  force ? @profile = get_profile : @profile ||= get_profile
end
username() click to toggle source

Returns the user's movescount username

# File lib/movescount/member.rb, line 31
def username
  profile['Username']
end

Private Instance Methods

combined_options(options) click to toggle source

Combine the instance variable options hash with arguments options

# File lib/movescount/member.rb, line 65
def combined_options(options)
  resp = @options
  resp[:query].merge! options
  resp
end
get_moves(options) click to toggle source

Get the moves from the api

# File lib/movescount/member.rb, line 55
def get_moves(options)
  self.class.get "/members/#{username}/moves", combined_options(options)
end
get_profile() click to toggle source

Get the profile page from the api

# File lib/movescount/member.rb, line 60
def get_profile
  self.class.get '/members/private', @options
end