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
22
23
24
|
# File 'lib/wes/data/api/model/brief.rb', line 22
def add_answers(answers)
client.post(answers_route, answers)
end
|
#answers(fetch: false) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/wes/data/api/model/brief.rb', line 15
def answers(fetch: false)
records = fetch ? client.get(answers_route) : @attributes.answers
map_objects(
records, Wes::Data::API::Model::BriefAnswer
)
end
|
#briefing_answers ⇒ Object
26
27
28
29
30
31
|
# File 'lib/wes/data/api/model/brief.rb', line 26
def briefing_answers
records = client.get(briefing_answers_route)
map_objects(
records, Wes::Data::API::Model::BriefingAnswer
)
end
|
#create_rewards(data) ⇒ Object
33
34
35
36
37
|
# File 'lib/wes/data/api/model/brief.rb', line 33
def create_rewards(data)
route = [routes.brief, id, routes.brief_rewards].join('/')
records = client.post(route, data)
map_objects(records, Wes::Data::API::Model::BriefRewards).first
end
|
#insights(type) ⇒ Object
39
40
41
42
43
|
# File 'lib/wes/data/api/model/brief.rb', line 39
def insights(type)
data = insight_data(type)
return nil unless data
JSON.parse(data)
end
|
#rewards(fetch: false) ⇒ Object
45
46
47
48
|
# File 'lib/wes/data/api/model/brief.rb', line 45
def rewards(fetch: false)
records = fetch ? fetch_brief_rewards : @attributes.brief_rewards
map_objects(records, Wes::Data::API::Model::BriefRewards).first
end
|
#transactions(limit = 50, offset = nil) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/wes/data/api/model/brief.rb', line 50
def transactions(limit = 50, offset = nil)
route = (
[routes.payments, routes.brief, id, routes.transactions].join('/'),
limit,
offset
)
records = client.get(route)
records.map_results(Wes::Data::API::Model::Transaction)
end
|
#update(changes) ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/wes/data/api/model/brief.rb', line 68
def update(changes)
route = [routes.brief, id].join('/')
@attributes = client.put(
route, @attributes.to_h.merge(changes)
).first
self
end
|
#update_answers(answers) ⇒ Object
77
78
79
|
# File 'lib/wes/data/api/model/brief.rb', line 77
def update_answers(answers)
client.put(answers_route, answers)
end
|
#update_status(s) ⇒ Object
81
82
83
|
# File 'lib/wes/data/api/model/brief.rb', line 81
def update_status(s)
update(status: s)
end
|
#users(state: nil, fetch: false) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/wes/data/api/model/brief.rb', line 60
def users(state: nil, fetch: false)
records = fetch || !state.nil? ? fetch_users(state)
: @attributes.users
map_objects(
records, Wes::Data::API::Model::CreatorUser
)
end
|
#video_partner_assets ⇒ Object
93
94
95
96
97
98
|
# File 'lib/wes/data/api/model/brief.rb', line 93
def video_partner_assets
records = fetch_video_partner_assets
map_objects(
records, Wes::Data::API::Model::VideoPartnerAsset
)
end
|
#videos(fetch: false, state: nil, not_under_nda: false) ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/wes/data/api/model/brief.rb', line 85
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
|