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
- #add_state(route, state = nil) ⇒ Object
- #apply_pagination(route, limit, offset) ⇒ Object
- #client ⇒ Object
- #configuration ⇒ Object
- #map_objects(records, klass, klass_args = []) ⇒ Object
- #routes ⇒ Object
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 |
#client ⇒ Object
13 14 15 |
# File 'lib/wes/data/api/base.rb', line 13 def client Client.new end |
#configuration ⇒ Object
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 |
#routes ⇒ Object
25 26 27 |
# File 'lib/wes/data/api/base.rb', line 25 def routes configuration.routes end |