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

#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/#{account_id}/challenges", params)
    .fetch('challenges')
    .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