Class: ClientSuccess::Connection
- Inherits:
-
Object
- Object
- ClientSuccess::Connection
show all
- Defined in:
- lib/client_success/connection.rb
Defined Under Namespace
Classes: BadRequest, Error, Failed, NotFound, ParsingError, Unauthorised
Class Method Summary
collapse
Instance Method Summary
collapse
-
#access_token ⇒ Object
-
#access_token=(access_token) ⇒ Object
-
#delete(path, headers = {}, &block) ⇒ Object
-
#get(path, headers = {}, &block) ⇒ Object
-
#head(path, headers = {}, &block) ⇒ Object
-
#logger ⇒ Object
-
#options(path, headers = {}, &block) ⇒ Object
-
#patch(path, body = nil, headers = {}, &block) ⇒ Object
-
#post(path, body = nil, headers = {}, &block) ⇒ Object
-
#put(path, body = nil, headers = {}, &block) ⇒ Object
Class Method Details
.authorised(access_token) ⇒ Object
16
17
18
|
# File 'lib/client_success/connection.rb', line 16
def authorised(access_token)
new.tap { |conn| conn.access_token = access_token }
end
|
Instance Method Details
#access_token ⇒ Object
28
29
30
|
# File 'lib/client_success/connection.rb', line 28
def access_token
["Authorization"]
end
|
#access_token=(access_token) ⇒ Object
32
33
34
|
# File 'lib/client_success/connection.rb', line 32
def access_token=(access_token)
["Authorization"] = access_token
end
|
#delete(path, headers = {}, &block) ⇒ Object
56
57
58
|
# File 'lib/client_success/connection.rb', line 56
def delete(path, = {}, &block)
request { adapter.delete(path, , &block) }
end
|
#get(path, headers = {}, &block) ⇒ Object
36
37
38
|
# File 'lib/client_success/connection.rb', line 36
def get(path, = {}, &block)
request { adapter.get(path, , &block) }
end
|
#head(path, headers = {}, &block) ⇒ Object
40
41
42
|
# File 'lib/client_success/connection.rb', line 40
def head(path, = {}, &block)
raise NotImplementedError
end
|
#logger ⇒ Object
21
22
23
24
25
26
|
# File 'lib/client_success/connection.rb', line 21
def logger
Logger.new(STDOUT).tap do |l|
l.level = Logger::WARN
end
end
|
#options(path, headers = {}, &block) ⇒ Object
60
61
62
|
# File 'lib/client_success/connection.rb', line 60
def options(path, = {}, &block)
raise NotImplementedError
end
|
#patch(path, body = nil, headers = {}, &block) ⇒ Object
52
53
54
|
# File 'lib/client_success/connection.rb', line 52
def patch(path, body = nil, = {}, &block)
request { adapter.patch(path, body, , &block) }
end
|
#post(path, body = nil, headers = {}, &block) ⇒ Object
44
45
46
|
# File 'lib/client_success/connection.rb', line 44
def post(path, body = nil, = {}, &block)
request { adapter.post(path, body, , &block) }
end
|
#put(path, body = nil, headers = {}, &block) ⇒ Object
48
49
50
|
# File 'lib/client_success/connection.rb', line 48
def put(path, body = nil, = {}, &block)
request { adapter.put(path, body, , &block) }
end
|