Sha256: 9fdd6531a05207c2977000d09959a87184056bddda3506fcedea29e019abfa30

Contents?: true

Size: 1.04 KB

Versions: 38

Compression:

Stored size: 1.04 KB

Contents

class Ey::Core::Client::Membership < Ey::Core::Model
  extend Ey::Core::Associations

  identity :id

  attribute :role
  attribute :email
  attribute :redirect_url

  attribute :accepted_at
  attribute :rejected_at

  attribute :created_at
  attribute :deleted_at
  attribute :updated_at

  has_one :account
  has_one :user
  has_one :requester, collection: :users, resource: :user

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

  def save!
    if new_record?
      params = {
        "membership" => {
          "account"      => self.account_id,
          "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

end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
ey-core-3.6.4 lib/ey-core/models/membership.rb
ey-core-3.6.3 lib/ey-core/models/membership.rb
ey-core-3.6.1 lib/ey-core/models/membership.rb
groove-ey-core-3.6.3 lib/ey-core/models/membership.rb
groove-ey-core-3.6.2 lib/ey-core/models/membership.rb
groove-ey-core-3.6.1 lib/ey-core/models/membership.rb
ey-core-3.5.0 lib/ey-core/models/membership.rb
ey-core-3.4.4 lib/ey-core/models/membership.rb
ey-core-3.4.2 lib/ey-core/models/membership.rb
ey-core-3.4.1 lib/ey-core/models/membership.rb
ey-core-3.4.0 lib/ey-core/models/membership.rb
ey-core-3.3.1 lib/ey-core/models/membership.rb
ey-core-3.3.0 lib/ey-core/models/membership.rb
ey-core-3.2.6 lib/ey-core/models/membership.rb
ey-core-3.2.5 lib/ey-core/models/membership.rb
ey-core-3.2.4 lib/ey-core/models/membership.rb
ey-core-3.2.3 lib/ey-core/models/membership.rb
ey-core-3.2.2 lib/ey-core/models/membership.rb
ey-core-3.2.1 lib/ey-core/models/membership.rb
ey-core-3.2.0 lib/ey-core/models/membership.rb