class CoachClient::UserSubscription
A user subscription resource of the CyberCoach service.
Attributes
@return [Integer]
@return [Integer]
@return [CoachClient::User]
Public Class Methods
Creates a new user subscription.
@param [CoachClient::Client] client @param [String, CoachClient::User] user @param [String, Symbol, CoachClient::Sport] sport @param [Integer] publicvisible @return [CoachClient::UserSubscription]
CoachClient::Subscription::new
# File lib/coach_client/user_subscription.rb, line 24 def initialize(client, user, sport, publicvisible: nil) super(client, sport, publicvisible: publicvisible) @user = if user.is_a?(CoachClient::User) user else CoachClient::User.new(client, user) end end
Returns the relative path to the user subscription resource.
@return [String] the relative path
# File lib/coach_client/user_subscription.rb, line 13 def self.path 'users/' end
Public Instance Methods
Deletes the user subscription on the CyberCoach service.
@raise [CoachClient::NotFound] if the user subscription does not exist @raise [CoachClient::Unauthorized] if not authorized @return [true]
CoachClient::Subscription#delete
# File lib/coach_client/user_subscription.rb, line 63 def delete super(@user) end
Saves the user subscription to the CyberCoach service.
The user subscription is created if it does not exist on the CyberCoach service, otherwise it tries to overwrite it.
@raise [CoachClient::Unauthorized] if not authorized @raise [CoachClient::IncompleteInformation] if not all needed information
is given
@raise [CoachClient::NotSaved] if the user subscription could not be saved @return [CoachClient::UserSubscription] the saved user subscription
CoachClient::Subscription#save
# File lib/coach_client/user_subscription.rb, line 54 def save super(@user) end
Returns the string representation of the user subscription.
@return [String]
# File lib/coach_client/user_subscription.rb, line 77 def to_s "#{@user.username}/#{@sport}" end
Updates the user subscription with the data from the CyberCoach service.
@param [Integer] size the number of entries @param [Integer] start the start of entries list @param [Boolean] all whether all entries are retrieved @raise [CoachClient::NotFound] if the user subscription does not exist @return [CoachClient::UserSubscription] the updated user subscription
CoachClient::Subscription#update
# File lib/coach_client/user_subscription.rb, line 40 def update(size: 20, start: 0, all: false) super(@user, size: size, start: start, all: all) end
Returns the URL of the user subscription.
@return [String] the url of the user subscription
# File lib/coach_client/user_subscription.rb, line 70 def url "#{@user.url}/#{@sport}" end