Class: Candid::ExpectedNetworkStatus::V2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candid/expected_network_status/v_2/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Candid::ExpectedNetworkStatus::V2::Client



8
9
10
# File 'lib/candid/expected_network_status/v_2/client.rb', line 8

def initialize(client:)
  @client = client
end

Instance Method Details

#compute_all_in_network_providers(request_options: {}, **params) ⇒ Candid::ExpectedNetworkStatus::V2::Types::ComputeAllInNetworkProvidersResponse

Computes all the in network providers for a given set of inputs. This endpoint is not available to all customers. Reach out to the Candid sales team to discuss enabling this endpoint if it is not available for your organization.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/candid/expected_network_status/v_2/client.rb', line 43

def compute_all_in_network_providers(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "POST",
    path: "/api/expected-network-status/v2/compute",
    body: Candid::ExpectedNetworkStatus::V2::Types::ComputeAllInNetworkProvidersRequest.new(params).to_h
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::ExpectedNetworkStatus::V2::Types::ComputeAllInNetworkProvidersResponse.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end

#compute_for_rendering_provider(request_options: {}, **params) ⇒ Candid::ExpectedNetworkStatus::V2::Types::ExpectedNetworkStatusResponseV2

Computes the expected network status for a given rendering provider. This endpoint is not available to all customers. Reach out to the Candid sales team to discuss enabling this endpoint if it is not available for your organization.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/candid/expected_network_status/v_2/client.rb', line 17

def compute_for_rendering_provider(request_options: {}, **params)
  _request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Candid::Environment::PRODUCTION,
    method: "POST",
    path: "/api/expected-network-status/v2/compute/#{params[:rendering_provider_id]}",
    body: Candid::ExpectedNetworkStatus::V2::Types::ExpectedNetworkStatusRequestV2.new(params).to_h
  )
  begin
    _response = @client.send(_request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = _response.code.to_i
  if code.between?(200, 299)
    Candid::ExpectedNetworkStatus::V2::Types::ExpectedNetworkStatusResponseV2.load(_response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end