class Foureyes::Resource
Constants
- CLIENT
- CONNECTION
- SCHEMA
Attributes
account_name[R]
created_at[R]
dealer_code[R]
id[R]
updated_at[R]
Public Class Methods
class_name()
click to toggle source
# File lib/foureyes/resource.rb, line 20 def self.class_name self.name.constantize end
execute_request(args = {})
click to toggle source
# File lib/foureyes/resource.rb, line 24 def self.execute_request(args = {}) arguments = { api_key: Foureyes.api_key } arguments.merge!(args) if args CLIENT.query("#{self.class_name}".constantize::QUERY, variables: arguments) end
list()
click to toggle source
# File lib/foureyes/resource.rb, line 31 def self.list response = self.execute_request edges = response.data.viewer.accounts.edges edges.map do |edge| attrs = edge.node.to_h instance = new attrs end end
new(attributes = {})
click to toggle source
# File lib/foureyes/resource.rb, line 11 def initialize(attributes = {}) attributes.map do |k, v| instance_variable_set "@#{k}".to_sym, v self.class_eval{ attr_reader "k".to_sym} end self end
retrieve(id)
click to toggle source
# File lib/foureyes/resource.rb, line 40 def self.retrieve(id) response = self.execute_request({id: id}) attrs = response.data.viewer.accounts.edges.first.node.to_h instance = new attrs end