Class: Clerk::Api::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/clerk/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, auth_token) ⇒ Connection

Returns a new instance of Connection.



4
5
6
7
8
9
10
# File 'lib/clerk/api.rb', line 4

def initialize(url, auth_token)
  @c = Faraday.new(:url => url) do |conn|
    conn.authorization :Bearer, auth_token
    conn.headers['Content-Type'] = 'application/json'
    conn.adapter Faraday.default_adapter
  end
end

Instance Method Details

#delete(path, fields, &block) ⇒ Object



20
21
22
# File 'lib/clerk/api.rb', line 20

def delete(path, fields, &block)
  Clerk::Api::Response.new(@c.delete(path, fields.to_json, &block))
end

#get(*args, &block) ⇒ Object



24
25
26
# File 'lib/clerk/api.rb', line 24

def get(*args, &block)
  Clerk::Api::Response.new(@c.get(*args, &block))
end

#patch(path, fields, &block) ⇒ Object



16
17
18
# File 'lib/clerk/api.rb', line 16

def patch(path, fields, &block)
  Clerk::Api::Response.new(@c.patch(path, fields.to_json, &block))
end

#post(path, fields, &block) ⇒ Object



12
13
14
# File 'lib/clerk/api.rb', line 12

def post(path, fields, &block)
  Clerk::Api::Response.new(@c.post(path, fields.to_json, &block))
end