Class: AllSportDB

Inherits:
Object
  • Object
show all
Defined in:
lib/allsportdb_api.rb

Class Method Summary collapse

Class Method Details

.GetCalendar(key:, week: nil, dateFrom: nil, dateTo: nil, dateToday: nil, year: nil, eventId: nil, event: nil, locationId: nil, location: nil, competitionId: nil, competition: nil, sportId: nil, sport: nil, countryId: nil, country: nil, regionId: nil, region: nil, continentId: nil, continent: nil, locationContinentId: nil, locationContinent: nil, liveUrlExists: nil, filter: nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/allsportdb_api.rb', line 45

def self.GetCalendar(
        key:,
        week: nil,
        dateFrom: nil,
        dateTo: nil,
        dateToday: nil,
        year: nil,
        eventId: nil,
        event: nil,
        locationId: nil,
        location: nil,
        competitionId: nil,
        competition: nil,
        sportId: nil,
        sport: nil,
        countryId: nil,
        country: nil,
        regionId: nil,
        region: nil,
        continentId: nil,
        continent: nil,
        locationContinentId: nil,
        locationContinent: nil,
        liveUrlExists: nil,
        filter: nil
    )
    params = {
        :week => week,
        :dateFrom => dateFrom,
        :dateTo => dateTo,
        :dateToday => dateToday,
        :year => year,
        :eventId => eventId,
        :event => event,
        :locationId => locationId,
        :location => location,
        :competitionId => competitionId,
        :competition => competition,
        :sportId => sportId,
        :sport => sport,
        :countryId => countryId,
        :country => country,
        :regionId => regionId,
        :region => region,
        :continentId => continentId,
        :continent => continent,
        :locationContinentId => locationContinentId,
        :locationContinent => locationContinent,
        :liveUrlExists => liveUrlExists,
        :filter => filter
    }
    items = CallAPI('calendar', params, key)
    return items
end

.GetCompetition(key:, id: 0, name: nil) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/allsportdb_api.rb', line 160

def self.GetCompetition(
        key:,
        id: 0,
        name: nil
    )
    params = {
        :id => id,
        :name => name
    }
    items = CallAPI('competitions', params, key)
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetCompetitions(key:, sportId: nil, sport: nil, continentId: nil, continent: nil) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/allsportdb_api.rb', line 143

def self.GetCompetitions(
        key:,
        sportId: nil,
        sport: nil,
        continentId: nil,
        continent: nil
    )
    params = {
        :sportId => sportId,
        :sport => sport,
        :continentId => continentId,
        :continent => continent,
    }
    items = CallAPI('competitions', params, key)
    return items
end

.GetContinent(key:, id: 0, name: nil) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/allsportdb_api.rb', line 185

def self.GetContinent(
        key:,
        id: 0,
        name: nil
    )
    params = {
        :id => id,
        :name => name
    }
    items = CallAPI('continents', params, key)
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetContinents(key:) ⇒ Object



176
177
178
179
180
181
182
183
# File 'lib/allsportdb_api.rb', line 176

def self.GetContinents(
        key:
    )
    params = {
    }
    items = CallAPI('continents', params, key)
    return items
end

.GetCountries(key:, continentId: nil, continent: nil) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/allsportdb_api.rb', line 201

def self.GetCountries(
        key:,
        continentId: nil,
        continent: nil
    )
    params = {
        :continentId => continentId,
        :continent => continent,
    }
    items = CallAPI('countries', params, key)
    return items
end

.GetCountry(key:, id: 0, name: nil) ⇒ Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/allsportdb_api.rb', line 214

def self.GetCountry(
        key:,
        id: 0,
        name: nil
    )
    params = {
        :id => id,
        :name => name
    }
    items = CallAPI('countries', params, key)
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetEvent(key:, id: 0) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/allsportdb_api.rb', line 100

def self.GetEvent(
        key:,
        id: 0
    )
    params = {
        :eventId => id,
        :dateFrom => DateTime.new(2000, 1, 1),
        :dateTo => DateTime.new(2200, 1, 1)
    }
    items = CallAPI('calendar', params, key)
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetLocation(key:, id: 0, name: nil, countryId: nil, country: nil, regionId: nil, region: nil) ⇒ Object



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/allsportdb_api.rb', line 280

def self.GetLocation(
        key:,
        id: 0,
        name: nil,
        countryId: nil,
        country: nil,
        regionId: nil,
        region: nil
    )
    params = {
        :id => id,
        :name => name,
        :countryId => countryId,
        :country => country,
        :regionId => regionId,
        :region => region,
    }
    items = CallAPI('locations', params, key)
    if items.length() > 1
        raise Exception.new "API error: multiple items found (#{items.length()}). Provide countryId, country, regionId or region."
    end
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetLocations(key:, countryId: nil, country: nil, regionId: nil, region: nil) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/allsportdb_api.rb', line 263

def self.GetLocations(
        key:,
        countryId: nil,
        country: nil,
        regionId: nil,
        region: nil
    )
    params = {
        :countryId => countryId,
        :country => country,
        :regionId => regionId,
        :region => region,
    }
    items = CallAPI('locations', params, key)
    return items
end

.GetRegion(key:, id: 0, name: nil) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/allsportdb_api.rb', line 247

def self.GetRegion(
        key:,
        id: 0,
        name: nil
    )
    params = {
        :id => id,
        :name => name
    }
    items = CallAPI('regions', params, key)
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetRegions(key:, countryId: nil, country: nil, continentId: nil, continent: nil) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/allsportdb_api.rb', line 230

def self.GetRegions(
        key:,
        countryId: nil,
        country: nil,
        continentId: nil,
        continent: nil
    )
    params = {
        :countryId => countryId,
        :country => country,
        :continentId => continentId,
        :continent => continent,
    }
    items = CallAPI('regions', params, key)
    return items
end

.GetSport(key:, id: 0, name: nil) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/allsportdb_api.rb', line 127

def self.GetSport(
        key:,
        id: 0,
        name: nil
    )
    params = {
        :id => id,
        :name => name
    }
    items = CallAPI('sports', params, key)
    if items.length() == 0
        raise Exception.new "API error: item not found"
    end
    return items[0]
end

.GetSports(key:, season: nil) ⇒ Object



116
117
118
119
120
121
122
123
124
125
# File 'lib/allsportdb_api.rb', line 116

def self.GetSports(
        key:,
        season: nil
    )
    params = {
        :season => season
    }
    items = CallAPI('sports', params, key)
    return items
end