Sha256: 790fd43b899a2028101d4c134c654a1daf18e7d2a9058a9c14e31e1d0b270a5f
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
module Roqua module CoreApi module Sessions # AppSession represents a session which is scoped to a specific app # in the Core database. It deals with managing organizations and dossiers, # but only on a anonymous base. It is not allowed to know who these dossiers # represent. class AppSession attr_reader :server attr_reader :key def initialize(key, server = ENV["CORE_URL"]) @server = server @key = key end def create_organization(attributes) response = post "/organizations", organization: attributes fail response.inspect unless response.code == 201 Models::Organization.new(response) end def organization_session(attributes) if attributes.is_a? Models::Organization organization = attributes else organization = create_organization(attributes) end OrganizationSession.new organization, key, server end private def post(url, params = {}) # TODO: Handle authentication here HTTParty.post(server + base_url + url + ".json", body: params) end def put(url, params = {}) # TODO: Handle authentication here HTTParty.put(server + base_url + url + ".json", body: params) end def base_url "/apps/#{key}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roqua-core-api-0.0.3 | lib/roqua/core_api/sessions/app_session.rb |
roqua-core-api-0.0.2 | lib/roqua/core_api/sessions/app_session.rb |