Class: Foxynews::PresskitSetter
- Inherits:
-
Object
- Object
- Foxynews::PresskitSetter
- Defined in:
- app/services/foxynews/presskit_setter.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#paging ⇒ Object
Returns the value of attribute paging.
Class Method Summary collapse
-
.all(pagination_options = {}) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/presskits.json pagination options take page and limit parameters.
-
.find(id) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/presskits/:id.json.
Instance Method Summary collapse
-
#initialize(data, paging) ⇒ PresskitSetter
constructor
A new instance of PresskitSetter.
Constructor Details
#initialize(data, paging) ⇒ PresskitSetter
Returns a new instance of PresskitSetter.
4 5 6 7 |
# File 'app/services/foxynews/presskit_setter.rb', line 4 def initialize(data, paging) @data = data @paging = paging end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'app/services/foxynews/presskit_setter.rb', line 2 def data @data end |
#paging ⇒ Object
Returns the value of attribute paging.
2 3 4 |
# File 'app/services/foxynews/presskit_setter.rb', line 2 def paging @paging end |
Class Method Details
.all(pagination_options = {}) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/presskits.json pagination options take page and limit parameters
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/foxynews/presskit_setter.rb', line 12 def all( = {}) = {query: } begin presskits = Foxynews::Parser.data('/presskits.json', ) rescue StandardError => error raise GenericError(error.) end if presskits.has_key?('data') return Foxynews::PresskitSetter.new( presskits['data'].each_with_object(data = []) {|pk| data << Foxynews::Presskit.new(pk) }, Foxynews::Paging.new(presskits['paging']) ) else return false end end |
.find(id) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/presskits/:id.json
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/services/foxynews/presskit_setter.rb', line 32 def find(id) begin presskit = Foxynews::Parser.data("/presskits/#{id}.json") rescue StandardError => error raise GenericError(error.) end if presskit.has_key?('data') return Foxynews::Presskit.new(presskit['data']) else return false end end |