Module: Wes::Data::API::Base

Included in:
Address, Brand, BrandUser, Brief, Collective, CreatorUser, Showcase, Submission, Video, VideoTranscodingState, VideoVersion
Defined in:
lib/wes/data/api/base.rb

Instance Method Summary collapse

Instance Method Details

#add_state(route, state = nil) ⇒ Object



8
9
10
11
# File 'lib/wes/data/api/base.rb', line 8

def add_state(route, state = nil)
  return route unless state
  "#{route}/#{state}"
end

#apply_pagination(route, limit, offset) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/wes/data/api/base.rb', line 29

def apply_pagination(route, limit, offset)
  delimiter = route.include?("?") ? '&' : '?'
  format(
    '%s%slimit=%s&offset=%s',
    route, delimiter, limit, offset
  )
end

#clientObject



13
14
15
# File 'lib/wes/data/api/base.rb', line 13

def client
  Client.new
end

#configurationObject



17
18
19
# File 'lib/wes/data/api/base.rb', line 17

def configuration
  Configuration
end

#map_objects(records, klass, klass_args = []) ⇒ Object



21
22
23
# File 'lib/wes/data/api/base.rb', line 21

def map_objects(records, klass, klass_args = [])
  records.map { |r| klass.new(*[r] + klass_args) }
end

#routesObject



25
26
27
# File 'lib/wes/data/api/base.rb', line 25

def routes
  configuration.routes
end