Class: Ey::Core::Client::Membership

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/membership.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Method Details

#accept!Object



21
22
23
24
25
26
27
28
29
# File 'lib/ey-core/models/membership.rb', line 21

def accept!
  params = {
    "membership" => {
      "accepted" => true
    }
  }
  params["id"] = self.id
  merge_attributes(self.connection.update_membership(params).body["membership"])
end

#save!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ey-core/models/membership.rb', line 31

def save!
  if new_record?
    params = {
      "membership" => {
        "account"      => self.,
        "user"         => self.user_id,
        "role"         => self.role,
        "email"        => self.email,
        "redirect_url" => self.redirect_url,
      }
    }

    merge_attributes(self.connection.create_membership(params).body["membership"])
  else
    raise "Updating memberships is not yet supported"
  end
end