Class: Wes::Data::API::Model::CreatorUser
- Inherits:
-
Base
- Object
- Base
- Wes::Data::API::Model::CreatorUser
show all
- Defined in:
- lib/wes/data/api/model/creator_user.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes
Instance Method Summary
collapse
Methods inherited from Base
#exist?, #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
#address(fetch: false) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/wes/data/api/model/creator_user.rb', line 13
def address(fetch: false)
route = [
routes.creator_user, id, routes.address
].join('/')
records = fetch ? client.get(route) : @attributes.addresses
map_objects(
records, Wes::Data::API::Model::Address, [false]
)
end
|
#assign_collectives(collective_ids) ⇒ Object
24
25
26
27
28
|
# File 'lib/wes/data/api/model/creator_user.rb', line 24
def assign_collectives(collective_ids)
validate_collectives(collective_ids)
records = create_collectives(collective_ids)
map_objects(records, Wes::Data::API::Model::Collective)
end
|
#submissions(state: nil, fetch: false) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/wes/data/api/model/creator_user.rb', line 30
def submissions(state: nil, fetch: false)
records = fetch || !state.nil? ? fetch_submissions(state)
: @attributes.submissions
map_objects(
records, Wes::Data::API::Model::Submission
)
end
|
#transactions(limit = 40, offset = nil) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/wes/data/api/model/creator_user.rb', line 64
def transactions(limit = 40, offset = nil)
route = [routes.payments, routes.creator_user, @attributes.external_id, routes.transactions].join('/')
delimiter = route.include?("?") ? '&' : '?'
paginatedRoute = format('%s%slimit=%s', route, delimiter, limit)
if offset != nil
paginatedRoute = format('%s&cursor=%s', paginatedRoute, offset)
end
records = client.get(paginatedRoute)
records.map_results(Wes::Data::API::Model::Transaction)
end
|
#update(changes) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/wes/data/api/model/creator_user.rb', line 38
def update(changes)
route = [routes.creator_user, id].join('/')
@attributes = client.put(
route, @attributes.to_h.merge(changes)
).first
self
end
|
#videos(fetch: false, state: nil, not_under_nda: false, limit: 12, offset: 0) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/wes/data/api/model/creator_user.rb', line 47
def videos(fetch: false, state: nil, not_under_nda: false, limit: 12, offset: 0)
route = [
routes.creator_user, id, routes.videos, state
].compact.join('/')
route = format('%s?not_under_nda', route) if not_under_nda
if state == 'not-pending'
route = (route, limit, offset)
attributes = client.get(route)
attributes.map_results(Wes::Data::API::Model::Video)
else
records = fetch ? client.get(route) : @attributes.videos
map_objects(records, Wes::Data::API::Model::Video)
end
end
|