Class: Webex::Client

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

Constant Summary collapse

EXCEPTIONS =
[
  Webex::Errors::RequestTimeoutError,
  Webex::Errors::SecondBasedQuotaIsReachedError,
  Webex::Errors::BadGatewayError,
  Webex::Errors::ServiceUnavailableError,
  Webex::Errors::GatewayTimeoutError,
  Webex::Errors::ConflictError
].freeze

Class Method Summary collapse

Class Method Details

.do_introspection_queryWebex::Response

Parameters:

  • query (String)

    GraphQL query

  • operation_name (String)

    GraphQL Operation Name such as TracksConnection

Returns:



17
18
19
# File 'lib/webex/client.rb', line 17

def self.do_introspection_query
  query(query: Helpers.introspection_query, operation_name: 'IntrospectionQuery')
end

.query(query:, operation_name:, variables: {}, options: {}) ⇒ Webex::Response

Parameters:

  • query (String)

    GraphQL query

  • variables (Hash) (defaults to: {})

    Query variables

  • operation_name (String)

    GraphQL Operation Name such as TracksConnection

  • options (Hash) (defaults to: {})

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/webex/client.rb', line 26

def self.query(query:, operation_name:, variables: {}, options: {})
  Webex::Helpers.assert_access_token!

  logger = Events::Config.logger
  logger.info("Begin to HTTP request to #{Webex::Helpers.endpoint_url}...")
  retries = -1
  start_time = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
  response = Retriable.retriable(on: EXCEPTIONS, tries: Webex::Events::Config.max_retries) do
    retries += 1
    if retries > 0
      logger.info("Retrying the request. Retry count: #{retries}")
    end
    Request.execute(
      query: query,
      variables: variables,
      operation_name: operation_name,
      options: options
    )
  end

  end_time = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
  response.retry_count = retries
  response.time_spent_in_ms = end_time - start_time
  logger.info("The HTTP request is finished. The request took #{response.time_spent_in_ms} ms.")
  response
end