Class: Memair
- Inherits:
-
Object
- Object
- Memair
- Defined in:
- lib/memair.rb
Instance Method Summary collapse
-
#initialize(access_token) ⇒ Memair
constructor
A new instance of Memair.
- #query(query) ⇒ Object
Constructor Details
#initialize(access_token) ⇒ Memair
Returns a new instance of Memair.
4 5 6 7 |
# File 'lib/memair.rb', line 4 def initialize(access_token) validate(access_token) @access_token = access_token.downcase end |
Instance Method Details
#query(query) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/memair.rb', line 9 def query(query) raise KeyError, "query is not a string." unless query.is_a? String attempts = 0 begin sleep(attempts * 2) response = HTTParty.post("https://memair.com/graphql", body: query, headers: {access_token: @access_token}, timeout: 180) rescue retry if (attempts += 1) < 8 raise StandardError, "Can not connect to Memair" end response.to_h end |