Class: Foxynews::PressReleaseSetter
- Inherits:
-
Object
- Object
- Foxynews::PressReleaseSetter
- Defined in:
- app/services/foxynews/press_release_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(includes = nil, order = nil, locales = nil) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/press_releases.json Note: all parameters must be strings.
-
.find(id, includes = nil) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/press_releases/:id.json.
Instance Method Summary collapse
-
#initialize(data = {}, paging = {}) ⇒ PressReleaseSetter
constructor
A new instance of PressReleaseSetter.
Constructor Details
#initialize(data = {}, paging = {}) ⇒ PressReleaseSetter
Returns a new instance of PressReleaseSetter.
4 5 6 7 |
# File 'app/services/foxynews/press_release_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/press_release_setter.rb', line 2 def data @data end |
#paging ⇒ Object
Returns the value of attribute paging.
2 3 4 |
# File 'app/services/foxynews/press_release_setter.rb', line 2 def paging @paging end |
Class Method Details
.all(includes = nil, order = nil, locales = nil) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/press_releases.json Note: all parameters must be strings
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/foxynews/press_release_setter.rb', line 12 def all(includes = nil, order = nil, locales = nil) = {query: {includes: includes, order: order, locales: locales}} begin press_releases = Foxynews::Parser.data('/press_releases.json', ) rescue StandardError => error raise GenericError(error.) end if press_releases.has_key?('data') return Foxynews::PressReleaseSetter.new( press_releases['data'].each_with_object(data = []) {|pr| data << Foxynews::PressRelease.new(pr) }, Foxynews::Paging.new(press_releases['paging']) ) else return false end end |
.find(id, includes = nil) ⇒ Object
maps to /v1/pressrooms/:pressroom_id/press_releases/:id.json
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/services/foxynews/press_release_setter.rb', line 33 def find(id, includes = nil) = {query: {includes: includes}} begin press_release = Foxynews::Parser.data("/press_releases/#{id}.json", ) rescue StandardError => error raise GenericError(error.) end if press_release.has_key?('data') # return the hash in open struct to allow for @press_release.body_html calls return Foxynews::PressRelease.new(press_release['data']) else return false end end |