Module: PatientZero::Client
- Included in:
- Analytics::Base, Authorization, Monitoring::Twitter, Organization, Profile, Source
- Defined in:
- lib/patient_zero/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
- #get(*args) ⇒ Object
- #parse(request) ⇒ Object
- #post(*args) ⇒ Object
- #put(*args) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/patient_zero/client.rb', line 3 def self.included base base.extend self end |
Instance Method Details
#connection ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/patient_zero/client.rb', line 7 def connection PatientZero.connection ||= Faraday.new(PatientZero.url) do |faraday| faraday.request :url_encoded faraday.response :logger faraday.adapter Faraday.default_adapter end end |
#get(*args) ⇒ Object
21 22 23 |
# File 'lib/patient_zero/client.rb', line 21 def get *args parse connection.get *args end |
#parse(request) ⇒ Object
15 16 17 18 19 |
# File 'lib/patient_zero/client.rb', line 15 def parse request response = JSON.parse request.body raise Error, response['error'] unless response['error'].nil? response end |
#post(*args) ⇒ Object
25 26 27 |
# File 'lib/patient_zero/client.rb', line 25 def post *args parse connection.post *args end |
#put(*args) ⇒ Object
29 30 31 |
# File 'lib/patient_zero/client.rb', line 29 def put *args parse connection.put *args end |