Class: Fanfeedr::Client
- Inherits:
-
Object
- Object
- Fanfeedr::Client
- Includes:
- HTTParty
- Defined in:
- lib/fanfeedr/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#tier ⇒ Object
readonly
Returns the value of attribute tier.
Instance Method Summary collapse
- #conferences(options = {}) ⇒ Object
- #content(options = {}, secondary = nil) ⇒ Object
- #divisions(options = {}) ⇒ Object
- #events(options = {}, secondary = nil) ⇒ Object
- #geo(options = {}, secondary = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #leagues(options = {}) ⇒ Object
- #persons(options = {}) ⇒ Object
- #sources(options = {}) ⇒ Object
- #teams(options = {}, secondary = nil) ⇒ Object
- #trending(options = {}, secondary = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/fanfeedr/client.rb', line 7 def api_key @api_key end |
#tier ⇒ Object (readonly)
Returns the value of attribute tier.
8 9 10 |
# File 'lib/fanfeedr/client.rb', line 8 def tier @tier end |
Instance Method Details
#conferences(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fanfeedr/client.rb', line 25 def conferences(={}) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) if id response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/conferences/#{id}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/conferences", :query => .merge(self.), :format => :json) end end |
#content(options = {}, secondary = nil) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/fanfeedr/client.rb', line 106 def content(={}, secondary=nil) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) content_filter = .delete(:filter) || nil if id && secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/content/#{id}", :query => .merge(self.), :format => :json) elsif id && !secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}}/content/#{id}/#{secondary}", :query => .merge(self.), :format => :json) elsif id.nil? && secondary.nil? && !content_filter.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/content/#{filter}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/content", :query => .merge(self.), :format => :json) end end |
#divisions(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fanfeedr/client.rb', line 37 def divisions(={}) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) if id response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/divisions/#{id}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/divisions", :query => .merge(self.), :format => :json) end end |
#events(options = {}, secondary = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/fanfeedr/client.rb', line 87 def events(={}, secondary=nil) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) season_type = .delete(:season_type) || nil if id && secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/events/#{id}", :query => .merge(self.), :format => :json) elsif id && !secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/events/#{id}/#{secondary}", :query => .merge(self.), :format => :json) elsif id.nil? && !secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/events/#{secondary}", :query => .merge(self.), :format => :json) elsif id.nil? && secondary.nil? && [:season_type] response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/events/#{season_type}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/events", :query => .merge(self.), :format => :json) end end |
#geo(options = {}, secondary = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fanfeedr/client.rb', line 75 def geo(={}, secondary=nil) id = .delete(:id) if id && secondary.nil? response = self.class.get("/#{@tier}/api/geo/#{id}", :query => .merge(self.), :format => :json) elsif id && !secondary.nil? response = self.class.get("/#{@tier}/api/geo/#{id}/#{secondary}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/geo", :query => .merge(self.), :format => :json) end end |
#leagues(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/fanfeedr/client.rb', line 15 def leagues(={}) id = .delete(:id) if id response = self.class.get("/#{@tier}/api/leagues/#{id}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/leagues", :query => .merge(self.), :format => :json) end end |
#persons(options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fanfeedr/client.rb', line 63 def persons(={}) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) if id response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/persons/#{id}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/persons", :query => .merge(self.), :format => :json) end end |
#sources(options = {}) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/fanfeedr/client.rb', line 123 def sources(={}) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) if id response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/sources/#{id}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/sources", :query => .merge(self.), :format => :json) end end |
#teams(options = {}, secondary = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fanfeedr/client.rb', line 49 def teams(={}, secondary=nil) id = .delete(:id) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) if id && secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/teams/#{id}", :query => .merge(self.), :format => :json) elsif id && !secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/teams/#{id}/#{secondary}", :query => .merge(self.), :format => :json) else response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/teams", :query => .merge(self.), :format => :json) end end |
#trending(options = {}, secondary = nil) ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/fanfeedr/client.rb', line 135 def trending(={}, secondary=nil) parent_resource = .delete(:parent_resource) resource_id = .delete(:resource_id) if !secondary.nil? response = self.class.get("/#{@tier}/api/#{parent_resource}/#{resource_id}/#{secondary}", :query => .merge(self.), :format => :json) end end |