Class: Wes::Data::API::Model::Brief
- Inherits:
-
Base
- Object
- Base
- Wes::Data::API::Model::Brief
show all
- Defined in:
- lib/wes/data/api/model/brief.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes
Instance Method Summary
collapse
Methods inherited from Base
#exist?, #id, #initialize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Wes::Data::API::Model::Base
Instance Method Details
#add_answers(answers) ⇒ Object
19
20
21
|
# File 'lib/wes/data/api/model/brief.rb', line 19
def add_answers(answers)
client.post(answers_route, answers)
end
|
#answers(fetch: false) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/wes/data/api/model/brief.rb', line 12
def answers(fetch: false)
records = fetch ? client.get(answers_route) : @attributes.answers
map_objects(
records, Wes::Data::API::Model::BriefAnswer
)
end
|
#insights(type) ⇒ Object
63
64
65
66
67
|
# File 'lib/wes/data/api/model/brief.rb', line 63
def insights(type)
data = insight_data(type)
return nil unless data
JSON.parse(data)
end
|
#rewards(fetch: false) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/wes/data/api/model/brief.rb', line 27
def rewards(fetch: false)
records = fetch ? fetch_rewards : @attributes.rewards
map_objects(
records, Wes::Data::API::Model::Reward
)
end
|
#update(changes) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/wes/data/api/model/brief.rb', line 42
def update(changes)
route = [routes.brief, id].join('/')
@attributes = client.put(
route, @attributes.to_h.merge(changes)
).first
self
end
|
#update_answers(answers) ⇒ Object
23
24
25
|
# File 'lib/wes/data/api/model/brief.rb', line 23
def update_answers(answers)
client.put(answers_route, answers)
end
|
#update_status(s) ⇒ Object
51
52
53
|
# File 'lib/wes/data/api/model/brief.rb', line 51
def update_status(s)
update(status: s)
end
|
#users(state: nil, fetch: false) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/wes/data/api/model/brief.rb', line 34
def users(state: nil, fetch: false)
records = fetch || !state.nil? ? fetch_users(state)
: @attributes.users
map_objects(
records, Wes::Data::API::Model::CreatorUser
)
end
|
#videos(fetch: false, state: nil, not_under_nda: false) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/wes/data/api/model/brief.rb', line 55
def videos(fetch: false, state: nil, not_under_nda: false)
records = fetch || !state.nil? ? fetch_videos(state, not_under_nda)
: @attributes.videos
map_objects(
records, Wes::Data::API::Model::Video
)
end
|