Sha256: 52f95435c8ff7b333e2f25328572e6b561e9320a9750e59a75d92d4963f26973

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

require 'ostruct'

module Credly
  class Api
    class Base
      extend Forwardable
      include Requierable

      attr_accessor :response

      def initialize(options = Hash.new)
        @client = options[:client]
      end

      def build_object
        return OpenStruct.new(MultiJson.load(@response))
      end

      def before_request(*args)
      end

      def get(*args)
        before_request(*args)
        @response = @client.get(*args)
        build_object
      end

      def post(*args)
        before_request(*args)
        @response = @client.post(*args)
        build_object
      end

      def put(*args)
        before_request(*args)
        @response = @client.put(*args)
        build_object
      end

      def delete(*args)
        before_request(*args)
        @response = @client.delet(*args)
        build_object
      end

      def patch(*args)
        before_request(*args)
        @response = @client.patch(*args)
        build_object
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
credly-0.0.1 lib/credly/api/base.rb