Class: CoachClient::PartnershipSubscription
- Inherits:
-
Subscription
- Object
- Resource
- Subscription
- CoachClient::PartnershipSubscription
- Defined in:
- lib/coach_client/partnership_subscription.rb
Overview
A partnership subscription resource of the CyberCoach service.
Instance Attribute Summary collapse
- #datesubscribed ⇒ Integer readonly
- #id ⇒ Integer readonly
- #partnership ⇒ CoachClient::Partnership
Attributes inherited from Subscription
#entries, #publicvisible, #sport
Attributes inherited from Resource
Class Method Summary collapse
-
.path ⇒ String
Returns the relative path to the partnership subscription resource.
Instance Method Summary collapse
-
#delete ⇒ true
Deletes the partnership subscription on the CyberCoach service.
-
#initialize(client, partnership, sport, publicvisible: nil) ⇒ CoachClient::PartnershipSubscription
constructor
Creates a new partnership subscription.
-
#save ⇒ CoachClient::PartnershipSubscription
Saves the partnership subscription to the CyberCoach service.
-
#to_s ⇒ String
Returns the string representation of the partnership subscription.
-
#update(size: 20, start: 0, all: false) ⇒ CoachClient::PartnershipSubscription
Updates the partnership subscription with the data from the CyberCoach service.
-
#url ⇒ String
Returns the URL of the partnership subscription.
Methods inherited from Resource
Constructor Details
#initialize(client, partnership, sport, publicvisible: nil) ⇒ CoachClient::PartnershipSubscription
Creates a new partnership subscription.
24 25 26 27 28 29 30 31 32 33 |
# 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 |
Instance Attribute Details
#datesubscribed ⇒ Integer (readonly)
5 6 7 |
# File 'lib/coach_client/partnership_subscription.rb', line 5 def datesubscribed @datesubscribed end |
#id ⇒ Integer (readonly)
5 6 7 |
# File 'lib/coach_client/partnership_subscription.rb', line 5 def id @id end |
#partnership ⇒ CoachClient::Partnership
8 9 10 |
# File 'lib/coach_client/partnership_subscription.rb', line 8 def partnership @partnership end |
Class Method Details
.path ⇒ String
Returns the relative path to the partnership subscription resource.
13 14 15 |
# File 'lib/coach_client/partnership_subscription.rb', line 13 def self.path 'partnerships/' end |
Instance Method Details
#delete ⇒ true
Deletes the partnership subscription on the CyberCoach service.
79 80 81 82 83 84 85 |
# File 'lib/coach_client/partnership_subscription.rb', line 79 def delete begin super(@partnership.user1) rescue CoachClient::Exception super(@partnership.user2) end end |
#save ⇒ CoachClient::PartnershipSubscription
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.
65 66 67 68 69 70 71 |
# File 'lib/coach_client/partnership_subscription.rb', line 65 def save begin super(@partnership.user1) rescue CoachClient::Exception super(@partnership.user2) end end |
#to_s ⇒ String
Returns the string representation of the partnership subscription.
97 98 99 |
# File 'lib/coach_client/partnership_subscription.rb', line 97 def to_s "#{@partnership}/#{@sport}" end |
#update(size: 20, start: 0, all: false) ⇒ CoachClient::PartnershipSubscription
Updates the partnership subscription with the data from the CyberCoach service.
45 46 47 48 49 50 51 |
# 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 |
#url ⇒ String
Returns the URL of the partnership subscription.
90 91 92 |
# File 'lib/coach_client/partnership_subscription.rb', line 90 def url "#{@partnership.url}/#{@sport}" end |