Sha256: 3b153a0533e77b5d963b79d13a0e172aa8d4965b75b05cf8d1b4f4ca07a77507

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

require 'forwardable'

module Credly
  class Api
    extend Forwardable

    attr_accessor :client

    def_delegators :@client, :get, :post, :request, :put, :delete, :patch

    def initialize(client)
      @client = client
    end

    private

    def self.endpoint(name)
      define_method name do
        $endpoint_resource = name.to_s if ENV['testing']
        Api::const_get(name.to_s.camelize).new(:client => @client)
      end
    end

    def self.endpoints(*names)
      names.each { |name| endpoint(name) }
    end

    public

    endpoints :badges, :member_badges, :members

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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