Sha256: c3854c5914e4445d183e4890fa3154c01099e60adc82cc508b114c27cfad392c

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

module Roqua
  module CoreApi
    module Sessions
      class OrganizationSession < AppSession
        attr_reader :organization

        def initialize(organization, key, server = ENV["CORE_URL"])
          @organization = organization
          super(key, server)
        end

        def create_dossier(attributes)
          response = post "/dossiers", dossier: attributes
          fail response.inspect unless response.code == 201
          Models::Dossier.new(response)
        end

        def dossier_session(attributes)
          if attributes.is_a? Models::Dossier
            dossier = attributes
          else
            dossier = create_dossier(attributes)
          end
          DossierSession.new dossier, organization, key, server
        end

        private

        def base_url
          super + "/organizations/#{organization.key}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roqua-core-api-0.0.2 lib/roqua/core_api/sessions/organization_session.rb