Sha256: 00224b447f7677933e8c131fa1117758114f92e51aadd1f386d4a7a341dca131

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

require 'httparty'
require 'thron/entity/base'
require 'thron/routable'

module Thron
  module Gateway
    Package = Struct::new(:name, :domain, :service) do
      def to_s
        "#{name}/#{domain}/#{service}"
      end
    end

    class NoActiveSessionError < StandardError; end

    class Base
      include Routable

      base_uri "#{Config::thron::protocol}://#{Config::thron.client_id}-view.4me.it/api"

      NO_ACTIVE_SESSION = "Please provide a valid token ID"

      def self.service_name
        self.name.split('::').last.downcase
      end

      def self.client_id
        @client_id ||= Config.thron.client_id
      end

      attr_accessor :token_id

      def client_id
        self.class.client_id
      end

      def check_session
        fail NoActiveSessionError, NO_ACTIVE_SESSION unless token_id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thron-0.7.0 lib/thron/gateway/base.rb