Class: Quovo::Api::Challenges

Inherits:
Base
  • Object
show all
Defined in:
lib/quovo/api/challenges.rb

Instance Attribute Summary

Attributes inherited from Base

#token

Instance Method Summary collapse

Methods inherited from Base

#api, #initialize

Methods included from Request

#request

Constructor Details

This class inherits a constructor from Quovo::Api::Base

Instance Method Details

#answer!(challenge_id, answer) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/quovo/api/challenges.rb', line 34

def answer!(challenge_id, answer)
  challenge_id.require!(as: 'challenge_id')
  answer.require!(as: 'answer')

  params = { answer: answer.to_json }
  api(:put, "/challenges/#{challenge_id}", params)
    .fetch('challenge')
    .cast(Challenge)
end

#answers!(account_id, answers) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/quovo/api/challenges.rb', line 14

def answers!(, answers)
  .require!(as: 'account_id')
  answers.require!(as: 'answers')
  answers.each do |answer|
    answer.require!(:answer, :question)
  end

  params = { questions: answers.to_json }
  api(:put, "/accounts/#{}/challenges", params)
    .fetch('challenges')
    .cast(Challenge)
end

#find(challenge_id) ⇒ Object



27
28
29
30
31
32
# File 'lib/quovo/api/challenges.rb', line 27

def find(challenge_id)
  challenge_id.require!(as: 'challenge_id')
  api(:get, "/challenges/#{challenge_id}")
    .fetch('challenge')
    .cast(Challenge)
end

#for_account(id) ⇒ Object



7
8
9
10
11
12
# File 'lib/quovo/api/challenges.rb', line 7

def (id)
  id.require!(as: :id)
  api(:get, "/accounts/#{id}/challenges")
    .fetch('challenges')
    .cast(Challenge)
end