Sha256: c05b1d033ff7740dda34cea3781ec06fbed3e0b41087925a800a3e430354d9f5

Contents?: true

Size: 868 Bytes

Versions: 15

Compression:

Stored size: 868 Bytes

Contents

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

  identity :id

  attribute :role
  attribute :email

  attribute :created_at
  attribute :deleted_at
  attribute :updated_at

  has_one :account
  has_one :user
  has_one :requester

  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,
        }
      }
      merge_attributes(self.connection.create_membership(params).body["membership"])
    else
      raise "Updating memberships is not yet supported"
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ey-pro-cli-0.0.17 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.16 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.15 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.14 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.13 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.12 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.11 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.10 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.9 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.8 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.7 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.6 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.5 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.4 lib/vendor/core/ey-core/models/membership.rb
ey-pro-cli-0.0.3 lib/vendor/core/ey-core/models/membership.rb