# Install the following gems beforehand and require them
require 'httparty'
require 'json'
# Setup the GraphQL API client in Ruby
class KanaGraphqlClient
def initialize(api_key)
@api_key = api_key
end
def execute(query:, variables: nil)
HTTParty.post(
"https://api.usekana.com/graphql",
headers: {
'Content-Type' => 'application/json',
'Authorization' => @api_key
},
body: {
query: query,
variables: variables
}.to_json
)
end
end