Class: Wes::Data::API::Brief

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

Class Method Summary collapse

Methods included from Base

add_state, apply_pagination, client, configuration, map_objects, routes

Class Method Details

.all(state = nil, not_hidden = false) ⇒ Object



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

def all(state = nil, not_hidden = false)
  route = add_state(routes.briefs, state)
  route = format('%s?not_hidden', route) if not_hidden
  map_objects(client.get(route), model_klass)
end

.brand_category(not_hidden: false) ⇒ Object



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

def brand_category(not_hidden: false)
  route = format('%s/brand', routes.briefs)
  retrieve_brefs_for_category(route, not_hidden, '?')
end

.create(data) ⇒ Object



33
34
35
36
# File 'lib/wes/data/api/brief.rb', line 33

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

.find(key, value) ⇒ Object



38
39
40
41
# File 'lib/wes/data/api/brief.rb', line 38

def find(key, value)
  attributes = client.get(find_route(key, value)).first
  attributes.nil? ? nil : model_klass.new(attributes)
end

.questionsObject



43
44
45
46
47
48
# File 'lib/wes/data/api/brief.rb', line 43

def questions
  route = [routes.brief, routes.questions].join('/')
  map_objects(
    client.get(route), Wes::Data::API::Model::BriefQuestion
  )
end

.squad_category(user_id:, not_hidden: false) ⇒ Object



28
29
30
31
# File 'lib/wes/data/api/brief.rb', line 28

def squad_category(user_id:, not_hidden: false)
  route = format('%s/squad?user_id=%s', routes.briefs, user_id)
  retrieve_brefs_for_category(route, not_hidden, '&')
end

.vidsy_category(not_hidden: false) ⇒ Object



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

def vidsy_category(not_hidden: false)
  route = format('%s/vidsy', routes.briefs)
  retrieve_brefs_for_category(route, not_hidden, '?')
end