class CoachClient::PartnershipSubscription
A partnership subscription resource of the CyberCoach service.
Attributes
@return [Integer]
@return [Integer]
@return [CoachClient::Partnership]
Public Class Methods
Creates a new partnership subscription.
@param [CoachClient::Client] client @param [String, CoachClient::Partnership] partnership @param [String, Symbol, CoachClient::Sport] sport @param [Integer] publicvisible @return [CoachClient::PartnershipSubscription]
CoachClient::Subscription::new
# File lib/coach_client/partnership_subscription.rb, line 24 def initialize(client, partnership, sport, publicvisible: nil) super(client, sport, publicvisible: publicvisible) @partnership = if partnership.is_a?(CoachClient::Partnership) partnership else uri = "partnerships/#{partnership}/" users = CoachClient::Partnership.extract_users_from_uri(uri) CoachClient::Partnership.new(client, *users) end end
Returns the relative path to the partnership subscription resource.
@return [String] the relative path
# File lib/coach_client/partnership_subscription.rb, line 13 def self.path 'partnerships/' end
Public Instance Methods
Deletes the partnership subscription on the CyberCoach service.
@raise [CoachClient::NotFound] if the partnership subscription does not
exist
@raise [CoachClient::Unauthorized] if not authorized @return [true]
CoachClient::Subscription#delete
# File lib/coach_client/partnership_subscription.rb, line 79 def delete begin super(@partnership.user1) rescue CoachClient::Exception super(@partnership.user2) end end
Saves the partnership subscription to the CyberCoach service.
The partnership 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 partnership subscription could not
be saved
@return [CoachClient::PartnershipSubscription] the saved partnership
subscription
CoachClient::Subscription#save
# File lib/coach_client/partnership_subscription.rb, line 65 def save begin super(@partnership.user1) rescue CoachClient::Exception super(@partnership.user2) end end
Returns the string representation of the partnership subscription.
@return [String]
# File lib/coach_client/partnership_subscription.rb, line 97 def to_s "#{@partnership}/#{@sport}" end
Updates the partnership 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 partnership subscription does not
exist
@return [CoachClient::PartnershipSubscription] the updated partnership
subscription
CoachClient::Subscription#update
# File lib/coach_client/partnership_subscription.rb, line 45 def update(size: 20, start: 0, all: false) begin super(@partnership.user1, size: size, start: start, all: all) rescue CoachClient::Exception super(@partnership.user2, size: size, start: start, all: all) end end
Returns the URL of the partnership subscription.
@return [String] the url of the partnership subscription
# File lib/coach_client/partnership_subscription.rb, line 90 def url "#{@partnership.url}/#{@sport}" end