Class: Foil::Server::OrganizationsResource

Inherits:
BaseResource show all
Defined in:
lib/foil/server/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ OrganizationsResource

Returns a new instance of OrganizationsResource.



282
283
284
285
# File 'lib/foil/server/client.rb', line 282

def initialize(client)
  super(client)
  @api_keys = ApiKeysResource.new(client)
end

Instance Attribute Details

#api_keysObject (readonly)

Returns the value of attribute api_keys.



280
281
282
# File 'lib/foil/server/client.rb', line 280

def api_keys
  @api_keys
end

Instance Method Details

#create(name:, slug:) ⇒ Object



287
288
289
# File 'lib/foil/server/client.rb', line 287

def create(name:, slug:)
  @client.request_json("POST", "/v1/organizations", body: { name: name, slug: slug })[:data]
end

#get(organization_id) ⇒ Object



291
292
293
# File 'lib/foil/server/client.rb', line 291

def get(organization_id)
  @client.request_json("GET", "/v1/organizations/#{CGI.escape(organization_id)}")[:data]
end

#update(organization_id, name: nil, status: nil) ⇒ Object



295
296
297
298
299
300
# File 'lib/foil/server/client.rb', line 295

def update(organization_id, name: nil, status: nil)
  @client.request_json("PATCH", "/v1/organizations/#{CGI.escape(organization_id)}", body: {
    name: name,
    status: status
  }.reject { |_key, value| value.nil? })[:data]
end