Class: Coach4rb::Resource::Partnership

Inherits:
Entity
  • Object
show all
Defined in:
lib/coach4rb/resource/partnership.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Entity

#[], #each

Methods included from Mixin::AsHash

included

Methods included from Mixin::Iterable

included

Methods included from Mixin::AutoConstructor

included

Instance Attribute Details

- (Object) datecreated Also known as: created

Returns the value of attribute datecreated



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def datecreated
  @datecreated
end

- (Object) id

Returns the value of attribute id



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def id
  @id
end

Returns the value of attribute links



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def links
  @links
end

- (Object) publicvisible Also known as: visible

Returns the value of attribute publicvisible



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def publicvisible
  @publicvisible
end

- (Object) subscriptions

Returns the value of attribute subscriptions



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def subscriptions
  @subscriptions
end

- (Object) uri

Returns the value of attribute uri



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def uri
  @uri
end

- (Object) user1 Also known as: first_user

Returns the value of attribute user1



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def user1
  @user1
end

- (Object) user2 Also known as: second_user

Returns the value of attribute user2



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def user2
  @user2
end

- (Object) userconfirmed1 Also known as: first_user_confirmed

Returns the value of attribute userconfirmed1



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def userconfirmed1
  @userconfirmed1
end

- (Object) userconfirmed2 Also known as: second_user_confirmed

Returns the value of attribute userconfirmed2



7
8
9
# File 'lib/coach4rb/resource/partnership.rb', line 7

def userconfirmed2
  @userconfirmed2
end

Class Method Details

+ (Object) from_coach(a_hash)



18
19
20
21
22
23
24
25
26
# File 'lib/coach4rb/resource/partnership.rb', line 18

def self.from_coach(a_hash)
  new_hash = a_hash.dup
  new_hash[:datecreated] = Time.at(new_hash[:datecreated]/1000).to_datetime rescue nil
  new_hash[:subscriptions] ||= []
  new_hash[:subscriptions] = new_hash[:subscriptions].map {|a_hash| Resource::Subscription.from_coach a_hash }
  new_hash[:user1] = Resource::User.from_coach(new_hash[:user1]) rescue nil
  new_hash[:user2] = Resource::User.from_coach(new_hash[:user2]) rescue nil
  super new_hash
end

Instance Method Details

- (Object) entity_path



29
30
31
# File 'lib/coach4rb/resource/partnership.rb', line 29

def entity_path
  "/partnerships/#{first_user.username};#{second_user.username}"
end