API docs and sample Ruby scripts
This commit is contained in:
26
doc/api/examples/ruby/example_1.rb
Normal file
26
doc/api/examples/ruby/example_1.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
require 'http'
|
||||
|
||||
API_ENDPOINT = 'https://decide.madrid.es/graphql'
|
||||
|
||||
def make_request(query_string)
|
||||
HTTP.headers('User-Agent' => 'Mozilla/5.0', accept: 'application/json')
|
||||
.get(
|
||||
API_ENDPOINT,
|
||||
params: { query: query_string.gsub("\n", '').gsub(" ", '') }
|
||||
)
|
||||
end
|
||||
|
||||
query = """
|
||||
{
|
||||
proposal(id: 1) {
|
||||
id,
|
||||
title,
|
||||
public_created_at
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
response = make_request(query)
|
||||
|
||||
puts "Response code: #{response.code}"
|
||||
puts "Response body: #{response.body}"
|
||||
Reference in New Issue
Block a user