Class: Mailarchiva::RestClient
- Inherits:
-
Base
- Object
- Base
- Mailarchiva::RestClient
show all
- Defined in:
- lib/mailarchiva/rest_client.rb
Instance Attribute Summary
Attributes inherited from Base
#app_name, #client, #host, #pass, #port, #ssl, #user
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RestClient.
7
8
9
10
|
# File 'lib/mailarchiva/rest_client.rb', line 7
def initialize(args)
super(args)
raise "RestClient is not supported yet b/c it does not work on Mailarchiva as of 4.5.8"
end
|
Class Method Details
.basic_auth(app_name, user, pass) ⇒ Object
29
30
31
|
# File 'lib/mailarchiva/rest_client.rb', line 29
def self.basic_auth(app_name, user, pass)
Base64.strict_encode64("#{app_name}:#{user}:#{pass}")
end
|
.client(host, user, pass, ssl, port, app_name) ⇒ Object
23
24
25
26
27
|
# File 'lib/mailarchiva/rest_client.rb', line 23
def self.client(host, user, pass, ssl, port, app_name)
connection = Faraday.new(url: url(ssl, host, port))
connection. = {'Authorization' => basic_auth(app_name, user, pass), 'Accept' => 'application/json'}
connection
end
|
.url(ssl, host, port) ⇒ Object
33
34
35
|
# File 'lib/mailarchiva/rest_client.rb', line 33
def self.url(ssl, host, port)
"%s://%s:%s" % [ssl ? 'https' : 'http', host, port]
end
|
Instance Method Details
#api ⇒ Object
19
20
21
|
# File 'lib/mailarchiva/rest_client.rb', line 19
def api
"/archiva3/api/blob"
end
|
#search(params = {}) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/mailarchiva/rest_client.rb', line 12
def search(params={})
response = @client.get api, params
parsed_response = JSON.parse(response.body, symbolize_names: true)
parsed_response[:results]
parsed_response.map{|field_values| Message.new(field_values)}
end
|