Class: Coop::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/coop/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, password) ⇒ Session

Public: Creates a new API session

email - (String) the user’s email password - (String) the user’s password

Examples

Coop::Session.new("[email protected]", "password123")
# => #<Coop::Session @email="[email protected]">

Returns a Coop::Session instance



16
17
18
19
# File 'lib/coop/session.rb', line 16

def initialize(email, password)
  @email = email
  password = password
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/coop/session.rb', line 3

def email
  @email
end

Instance Method Details

#group(id) ⇒ Object

Public: Creates a Coop::Group object

id - (Fixnum) the group id (as found in the app URL: coopapp.com/groups/[group_id])

Examples

session.group(12345)
# => #<Coop::Group @id=12345>

Returns a Coop::Group instance



31
32
33
34
35
# File 'lib/coop/session.rb', line 31

def group(id)
  Coop::Group.new({
    id: id
  })
end

#groupsObject

Public: List of all the groups a user belongs to

Examples

session.groups
# => [#<Coop::APIObject>, #<Coop::APIObject>, ...]

Returns Array of APIObjects with group data



59
60
61
# File 'lib/coop/session.rb', line 59

def groups
  Coop.get_parsed("/groups")
end

#user(id) ⇒ Object

Public: Creates a Coop::Group object

id - (Fixnum) the group id (as found in the app URL: coopapp.com/groups/[group_id]/users/[user_id])

Examples

session.user(12345)
# => #<Coop::User @id=12345>

Returns a Coop::User instance



47
48
49
# File 'lib/coop/session.rb', line 47

def user(id)
  Coop::User.find(id)
end