Class: ApiMapper::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/api_mapper/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url) ⇒ Client

Returns a new instance of Client.



6
7
8
9
# File 'lib/api_mapper/client.rb', line 6

def initialize(base_url)
  @base_url = base_url
  @router = Router.new
end

Instance Attribute Details

#router=(value) ⇒ Object (writeonly)

Sets the attribute router

Parameters:

  • value

    the value to set the attribute router to.



4
5
6
# File 'lib/api_mapper/client.rb', line 4

def router=(value)
  @router = value
end

Instance Method Details

#authorization(authorization) ⇒ Object



23
24
25
# File 'lib/api_mapper/client.rb', line 23

def authorization(authorization)
  @authorization = authorization
end

#get(path) ⇒ Object



11
12
13
# File 'lib/api_mapper/client.rb', line 11

def get(path)
  mapper(:get, path).call(response(:get, path).body)
end

#patch(path, body) ⇒ Object



15
16
17
# File 'lib/api_mapper/client.rb', line 15

def patch(path, body)
  mapper(:patch, path).call(response(:patch, path, body).body)
end

#post(path, body) ⇒ Object



19
20
21
# File 'lib/api_mapper/client.rb', line 19

def post(path, body)
  mapper(:post, path).call(response(:post, path, body).body)
end