Class: TLAW::API

Inherits:
Namespace show all
Defined in:
lib/tlaw/api.rb

Overview

API is just a top-level Namespace.

Basically, you start creating your endpoint by descending from API and defining namespaces and endpoints through a DSL like this:

class MyCoolAPI < TLAW::API
  define do
    base 'http://api.mycool.com'

    namespace :awesome do
      # ...and so on
    end
  end
end

And then, you use it:

api = MyCoolAPI.new
api.awesome.cool(param: 'value')

See DSL for explanation of API definition, Namespace for explanation of possible usages and Endpoint for real calls performing.

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Methods inherited from Namespace

#describe, endpoints, inspect, #inspect, namespaces

Methods inherited from APIPath

#initialize, param_set

Constructor Details

This class inherits a constructor from TLAW::APIPath

Class Method Details

.define(&block) ⇒ Object

Runs the DSL inside your API wrapper class.



37
38
39
# File 'lib/tlaw/api.rb', line 37

def define(&block)
  DSL::APIWrapper.new(self).define(&block)
end

.describeObject

Returns detailed description of an API, like this:

MyCoolAPI.describe
# MyCoolAPI.new()
#   This is cool API.
#
#   Namespaces:
#   .awesome()
#     This is awesome.


53
54
55
# File 'lib/tlaw/api.rb', line 53

def describe(*)
  super.sub(/\A./, '')
end