Class: Wes::Data::API::Challenge

Inherits:
Object
  • Object
show all
Extended by:
Base
Defined in:
lib/wes/data/api/challenge.rb

Class Method Summary collapse

Methods included from Base

add_state, client, configuration, map_objects, routes

Class Method Details

.all(state = nil) ⇒ Object



11
12
13
14
15
16
# File 'lib/wes/data/api/challenge.rb', line 11

def all(state = nil)
  route = add_state(routes.challenges, state)
  map_objects(
    client.get(route), model_klass
  )
end

.create(data) ⇒ Object



18
19
20
21
# File 'lib/wes/data/api/challenge.rb', line 18

def create(data)
  attributes = client.post(routes.challenge, data).first
  attributes.nil? ? nil : model_klass.new(attributes)
end

.find(_key, value) ⇒ Object



23
24
25
26
27
# File 'lib/wes/data/api/challenge.rb', line 23

def find(_key, value)
  route = [routes.challenge, value].join("/")
  attributes = client.get(route).first
  attributes.nil? ? nil : model_klass.new(attributes)
end