Class: Everdeen::Client
- Inherits:
-
Object
- Object
- Everdeen::Client
- Defined in:
- lib/everdeen/client.rb
Instance Attribute Summary collapse
-
#control_addr ⇒ Object
readonly
Returns the value of attribute control_addr.
Instance Method Summary collapse
- #create_expectations(expectations) ⇒ Object
-
#initialize(control_addr) ⇒ Client
constructor
A new instance of Client.
- #ping ⇒ Object
- #registered_expectations ⇒ Object
- #requests(expectation_uuid) ⇒ Object
Constructor Details
#initialize(control_addr) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/everdeen/client.rb', line 5 def initialize(control_addr) @control_addr = control_addr end |
Instance Attribute Details
#control_addr ⇒ Object (readonly)
Returns the value of attribute control_addr.
3 4 5 |
# File 'lib/everdeen/client.rb', line 3 def control_addr @control_addr end |
Instance Method Details
#create_expectations(expectations) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/everdeen/client.rb', line 23 def create_expectations(expectations) uri = build_uri('/expectations') request = Net::HTTP::Post.new(uri, { 'Content-Type' => 'application/json' }) request.body = { expectations: expectations.map(&:to_hash) }.to_json Net::HTTP.start(uri.host, uri.port) do |http| JSON.parse(http.request(request).body) end end |
#ping ⇒ Object
9 10 11 |
# File 'lib/everdeen/client.rb', line 9 def ping Net::HTTP.get build_uri('/ping') end |
#registered_expectations ⇒ Object
13 14 15 16 |
# File 'lib/everdeen/client.rb', line 13 def registered_expectations response = Net::HTTP.get build_uri('/expectations') JSON.parse(response) end |
#requests(expectation_uuid) ⇒ Object
18 19 20 21 |
# File 'lib/everdeen/client.rb', line 18 def requests(expectation_uuid) response = Net::HTTP.get build_uri("/expectations/#{expectation_uuid}/requests") JSON.parse(response) end |