class CoachClient::Client

A client to communicate with the CyberCoach service.

Attributes

max_size[RW]

The maximum size of the requests

@return [Integer]

url[R]

The URL of the CyberCoach service.

@return [String]

Public Class Methods

new(host, path = '/', max_size = 1000) click to toggle source

Creates a new client with the CyberCoach informations.

@param [String] host the host address @param [String] path the path to the resources @param [Integer] max_size the maximum size of requests @return [CoachClient::Client]

# File lib/coach_client/client.rb, line 20
def initialize(host, path = '/', max_size = 1000)
  @url = host + path
  @max_size = max_size
end

Public Instance Methods

authenticated?(username, password) click to toggle source

Returns whether the given credentials are valid.

@param [String] username @param [String] password @return [Boolean]

# File lib/coach_client/client.rb, line 30
def authenticated?(username, password)
  begin
    CoachClient::Request.get("#{@url}authenticateduser/",
                             username: username, password: password)
    true
  rescue CoachClient::Unauthorized
    false
  end
end
get_partnership(user1, user2) click to toggle source

Returns the partnership from the CyberCoach service.

@param [CoachClient::User, String] user1 @param [CoachClient::User, String] user2 @return [CoachClient::Partnership]

# File lib/coach_client/client.rb, line 63
def get_partnership(user1, user2)
  partnership = CoachClient::Partnership.new(self, user1, user2)
  partnership.update
end
get_partnership_subscription(user1, user2, sport) click to toggle source

Returns the subscription of a partnership from the CyberCoach service.

@param [CoachClient::User, String] user1 @param [CoachClient::User, String] user2 @param [CoachClient::Sport, String, Symbol] sport @return [CoachClient::PartnershipSubscription]

# File lib/coach_client/client.rb, line 84
def get_partnership_subscription(user1, user2, sport)
  partnership = CoachClient::Partnership.new(self, user1, user2)
  subscription = CoachClient::PartnershipSubscription.new(self, partnership, sport)
  subscription.update
end
get_sport(sportname) click to toggle source

Returns the sport from the CyberCoach service.

@param [String, Symbol] sportname @return [CoachClient::Sport]

# File lib/coach_client/client.rb, line 44
def get_sport(sportname)
  sport = CoachClient::Sport.new(self, sportname)
  sport.update
end
get_user(username) click to toggle source

Returns the user from the CyberCoach service.

@param [String] username @return [CoachClient::User]

# File lib/coach_client/client.rb, line 53
def get_user(username)
  user = CoachClient::User.new(self, username)
  user.update
end
get_user_subscription(user, sport) click to toggle source

Returns the subscription of a user from the CyberCoach service.

@param [CoachClient::User, String] user @param [CoachClient::Sport, String, Symbol] sport @return [CoachClient::UserSubscription]

# File lib/coach_client/client.rb, line 73
def get_user_subscription(user, sport)
  subscription = CoachClient::UserSubscription.new(self, user, sport)
  subscription.update
end