Class: Phabricator::ConduitClient
- Inherits:
-
Object
- Object
- Phabricator::ConduitClient
- Includes:
- Singleton
- Defined in:
- lib/phabricator/conduit_client.rb
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize ⇒ ConduitClient
constructor
A new instance of ConduitClient.
- #request(http_method, method, data = {}) ⇒ Object
Constructor Details
#initialize ⇒ ConduitClient
Returns a new instance of ConduitClient.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/phabricator/conduit_client.rb', line 9 def initialize @host = Phabricator.host @credentials = { user: Phabricator.user, cert: Phabricator.cert } # The config is incomplete; try to get the credentials off the ~/.arcrc # file instead. if @host.nil? || @credentials.values.any? {|v| v.nil?} get_credentials_from_file end connect end |
Instance Method Details
#connect ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/phabricator/conduit_client.rb', line 25 def connect token = Time.now.to_i data = { client: 'phabricator-ruby', clientVersion: Phabricator::VERSION, user: @credentials[:user], host: @host, authToken: token, authSignature: Digest::SHA1.hexdigest("#{token}#{@credentials[:cert]}") } response = JSON.parse(post('conduit.connect', data, __conduit__: true)) # TODO: Something something error handling @conduit = { connectionID: response['result']['connectionID'], sessionKey: response['result']['sessionKey'] } end |
#request(http_method, method, data = {}) ⇒ Object
47 48 49 50 |
# File 'lib/phabricator/conduit_client.rb', line 47 def request(http_method, method, data={}) # TODO: validation on http_method self.send(http_method, method, data.merge(__conduit__: @conduit)) end |