Class: Clerk::Resources::Organizations

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/clerk/resources/organizations.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Organizations

Returns a new instance of Organizations.



9
10
11
12
# File 'lib/clerk/resources/organizations.rb', line 9

def initialize(client)
  @client = client
  @resource = PluralResource.new(client, "organizations")
end

Instance Method Details

#create_invitation(org_id, data) ⇒ Object



31
32
33
# File 'lib/clerk/resources/organizations.rb', line 31

def create_invitation(org_id, data)
  @client.request(:post, invitations_path(org_id), body: data)
end

#create_membership(org_id, data) ⇒ Object



46
47
48
# File 'lib/clerk/resources/organizations.rb', line 46

def create_membership(org_id, data)
  @client.request(:post, memberships_path(org_id), body: data)
end

#delete_membership(org_id, user_id) ⇒ Object



54
55
56
# File 'lib/clerk/resources/organizations.rb', line 54

def delete_membership(org_id, user_id)
  @client.request(:delete, memberships_path(org_id, user_id))
end

#memberships(org_id, query_params = {}) ⇒ Object

Memberships



42
43
44
# File 'lib/clerk/resources/organizations.rb', line 42

def memberships(org_id, query_params = {})
  @client.request(:get, memberships_path(org_id), query: query_params)
end

#pending_invitations(org_id, query_params = {}) ⇒ Object

Invitations



27
28
29
# File 'lib/clerk/resources/organizations.rb', line 27

def pending_invitations(org_id, query_params = {})
  @client.request(:get, "#{invitations_path(org_id)}/pending", query: query_params)
end

#revoke_invitation(org_id, invitation_id, data) ⇒ Object



35
36
37
# File 'lib/clerk/resources/organizations.rb', line 35

def revoke_invitation(org_id, invitation_id, data)
  @client.request(:post, "#{invitations_path(org_id, invitation_id)}/revoke", body: data)
end

#update_membership(org_id, user_id, data) ⇒ Object



50
51
52
# File 'lib/clerk/resources/organizations.rb', line 50

def update_membership(org_id, user_id, data)
  @client.request(:patch, memberships_path(org_id, user_id), body: data)
end

#update_metadata(org_id, private_metadata: {}, public_metadata: {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/clerk/resources/organizations.rb', line 16

def (org_id, private_metadata: {}, public_metadata: {})
  data = {}
  data["private_metadata"] = .to_json if !.empty?
  data["public_metadata"] = .to_json if !.empty?

  @client.request(:patch, "#{@resource.resource_path(org_id)}/metadata", body: data)
end