Class: Zaikio::Hub::CurrentOrganization

Inherits:
Base
  • Object
show all
Defined in:
lib/zaikio/hub/current_organization.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.findObject



8
9
10
# File 'lib/zaikio/hub/current_organization.rb', line 8

def self.find
  all.find_one
end

.find_with_fallback(fallback) ⇒ Object



12
13
14
# File 'lib/zaikio/hub/current_organization.rb', line 12

def self.find_with_fallback(fallback)
  all.with_fallback(fallback).find_one
end

Instance Method Details

#create_subscription(status: "active", plan_name: nil) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/zaikio/hub/current_organization.rb', line 54

def create_subscription(status: "active", plan_name: nil)
  return unless Zaikio::Hub.current_token_data.subject_type == "Organization"

  result = self.class.request(:post, "organization/subscription",
                              subscription: { status: status, plan_name: plan_name })
  Zaikio::Hub::Subscription.new(result.data)
end

#fetchObject



42
43
44
# File 'lib/zaikio/hub/current_organization.rb', line 42

def fetch
  self.attributes = get
end

#membersObject



50
51
52
# File 'lib/zaikio/hub/current_organization.rb', line 50

def members
  memberships.with_fallback.map(&:person)
end

#reloadObject



46
47
48
# File 'lib/zaikio/hub/current_organization.rb', line 46

def reload
  self.attributes = self.class.find.attributes
end