Class: Dboard::Api::Client

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientsObject

Returns the value of attribute clients.



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

def clients
  @clients
end

Class Method Details

.endpoints=(endpoints) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/api.rb', line 18

def self.endpoints=(endpoints)
  self.clients = endpoints.map { |config|
    Class.new {
      include HTTParty
      base_uri config.fetch(:base_uri)

      if config[:basic_auth]
        basic_auth *config.fetch(:basic_auth)
      end
    }
  }
end

.post(url, opts) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/api.rb', line 31

def self.post(url, opts)
  with_retries {
    self.clients.each do |client|
      client.post(url, opts)
    end
  }
end