tmsapi 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.project +1 -0
- data/Readme.md +38 -5
- data/lib/tmsapi/model/organization.rb +13 -0
- data/lib/tmsapi/model/program.rb +2 -0
- data/lib/tmsapi/model/sport_info.rb +11 -0
- data/lib/tmsapi/model/sport_organization.rb +11 -0
- data/lib/tmsapi/model/team.rb +10 -0
- data/lib/tmsapi/model/university.rb +12 -0
- data/lib/tmsapi/resource/sports.rb +94 -2
- data/lib/tmsapi/resource/stations.rb +1 -1
- data/lib/tmsapi/version.rb +1 -1
- data/spec/api_spec.rb +180 -0
- data/spec/factories.rb +4 -8
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_details/should_find_details_and_organizations_for_all_sports.yml +222 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_event_airings/should_find_some_airings.yml +116 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_nonevent_airings/should_return_nonevent_airings.yml +3882 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_organization_airings/should_return_airings.yml +142 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_organization_teams/should_return_organization_information_and_teams_with_a_string_param.yml +107 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_organization_teams/should_return_organization_information_and_teams_with_an_int_param.yml +107 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_team_airings/should_return_airings.yml +73 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_team_details/should_have_team_information.yml +71 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_universities/should_return_all_universities.yml +2431 -0
- data/spec/vcr/cassettes/TMSAPI_API/_sports/_university_teams/should_return_teams_for_this_university.yml +147 -0
- data/tmsapi.gemspec +1 -1
- metadata +57 -9
- checksums.yaml +0 -7
data/.project
CHANGED
data/Readme.md
CHANGED
@@ -10,7 +10,23 @@ This is my first project in Ruby so I'm using [petems/riot_api](https://github.c
|
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
-
|
13
|
+
Add this line to your application's Gemfile
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'tmsapi'
|
17
|
+
```
|
18
|
+
|
19
|
+
and then execute:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
or install it yourself with:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem install tmsapi
|
29
|
+
```
|
14
30
|
|
15
31
|
## Usage:
|
16
32
|
|
@@ -24,15 +40,32 @@ movies.tv.airings
|
|
24
40
|
|
25
41
|
programs.new_shows
|
26
42
|
|
27
|
-
sports.event_airings
|
43
|
+
sports.event_airings
|
28
44
|
|
29
45
|
|
30
46
|
```ruby
|
31
47
|
require 'tmsapi'
|
32
48
|
|
33
49
|
# Create Instace of the API
|
34
|
-
|
35
|
-
|
50
|
+
tms = TMSAPI::API.new :api_key => 'API_KEY_HERE'
|
51
|
+
|
52
|
+
# Get all movie showtimes for Austin Texas
|
53
|
+
movie_showings = tms.movies.theatres.showings({ :zip => "78701" })
|
54
|
+
|
55
|
+
# Print out the movie name, theatre name, and date/time of the showing.
|
56
|
+
movie_showings.each do |movie|
|
57
|
+
movie.showtimes.each do |showing|
|
58
|
+
puts "#{movie.title} is playing at '#{showing.theatre.name}' at #{showing.date_time}."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# 12 Years a Slave is playing at 'Violet Crown Cinema' at 2013-12-23T12:45.
|
63
|
+
# A Christmas Story is playing at 'Alamo Drafthouse at the Ritz' at 2013-12-23T16:00.
|
64
|
+
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T11:00.
|
65
|
+
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T13:40.
|
66
|
+
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T16:20.
|
67
|
+
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T19:00.
|
68
|
+
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T21:40.
|
36
69
|
```
|
37
70
|
|
38
71
|
## Contributing
|
@@ -59,4 +92,4 @@ If running existing tests:
|
|
59
92
|
|
60
93
|
```shell
|
61
94
|
rspec
|
62
|
-
```
|
95
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'tmsapi/model/team'
|
2
|
+
require 'tmsapi/model/image'
|
3
|
+
|
4
|
+
module TMSAPI
|
5
|
+
module Model
|
6
|
+
class Organization < Base
|
7
|
+
attribute :organization_id, String
|
8
|
+
attribute :organization_name, String
|
9
|
+
attribute :preferred_image, TMSAPI::Model::Image
|
10
|
+
attribute :teams, Array[TMSAPI::Model::Team]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/tmsapi/model/program.rb
CHANGED
@@ -3,6 +3,7 @@ require "tmsapi/model/image"
|
|
3
3
|
require "tmsapi/model/person"
|
4
4
|
require "tmsapi/model/rating"
|
5
5
|
require "tmsapi/model/recommendation"
|
6
|
+
require "tmsapi/model/team"
|
6
7
|
|
7
8
|
module TMSAPI
|
8
9
|
module Model
|
@@ -30,6 +31,7 @@ module TMSAPI
|
|
30
31
|
attribute :total_seasons, Integer
|
31
32
|
attribute :total_episodes, Integer
|
32
33
|
attribute :entity_type, String
|
34
|
+
attribute :teams, Array[TMSAPI::Model::Team]
|
33
35
|
|
34
36
|
end
|
35
37
|
end
|
data/lib/tmsapi/model/team.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
+
require 'tmsapi/model/image'
|
2
|
+
require 'tmsapi/model/university'
|
3
|
+
|
1
4
|
module TMSAPI
|
2
5
|
module Model
|
3
6
|
class Team < Base
|
4
7
|
attribute :name, String
|
5
8
|
attribute :team_brand_id, Integer
|
9
|
+
attribute :team_brand_name, String
|
6
10
|
attribute :is_home, Boolean
|
11
|
+
attribute :abbreviation, String
|
12
|
+
attribute :nick_name, String
|
13
|
+
attribute :proper_name, String
|
14
|
+
attribute :sports_id, String
|
15
|
+
attribute :preferred_image, TMSAPI::Model::Image
|
16
|
+
attribute :university, TMSAPI::Model::University
|
7
17
|
end
|
8
18
|
end
|
9
19
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'tmsapi/model/image'
|
2
|
+
|
3
|
+
module TMSAPI
|
4
|
+
module Model
|
5
|
+
class University < Base
|
6
|
+
attribute :university_id, String
|
7
|
+
attribute :university_name, String
|
8
|
+
attribute :nick_name, String
|
9
|
+
attribute :preferred_image, TMSAPI::Model::Image
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'tmsapi/model/program'
|
2
|
+
require 'tmsapi/model/university'
|
3
|
+
require 'tmsapi/model/organization'
|
4
|
+
require 'tmsapi/model/sport_info'
|
2
5
|
|
3
6
|
module TMSAPI
|
4
7
|
module Resource
|
@@ -8,7 +11,17 @@ module TMSAPI
|
|
8
11
|
super(connection, "v1")
|
9
12
|
end
|
10
13
|
|
11
|
-
def
|
14
|
+
def details(sports_id = 'all', params = nil)
|
15
|
+
params = {} unless params
|
16
|
+
#Include organizations by defailt.
|
17
|
+
params[:includeOrg] = true unless params[:includeOrg]
|
18
|
+
|
19
|
+
get(details_path(sports_id), params).each do |sport|
|
20
|
+
TMSAPI::Model::SportInfo.new sport
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def event_airings(sports_id = 'all', params)
|
12
25
|
params[:startDateTime] = Time.now.strftime("%Y-%m-%dT%H:%MZ") unless params[:startDateTime]
|
13
26
|
|
14
27
|
get(event_airings_path(sports_id),params).each do |event|
|
@@ -16,6 +29,57 @@ module TMSAPI
|
|
16
29
|
end
|
17
30
|
end
|
18
31
|
|
32
|
+
def nonevent_airings(sports_id = 'all', params)
|
33
|
+
params[:startDateTime] = Time.now.strftime("%Y-%m-%dT%H:%MZ") unless params[:startDateTime]
|
34
|
+
|
35
|
+
get(nonevent_airings_path(sports_id), params).each do |airing|
|
36
|
+
TMSAPI::Model::Airing.new airing
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def universities(params = nil)
|
41
|
+
params = {} unless params
|
42
|
+
|
43
|
+
get(universities_path, params).each do |university|
|
44
|
+
TMSAPI::Model::University.new university
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def organization_teams(organization_id, params = nil)
|
49
|
+
get(organization_teams_path(organization_id), params).each do |org|
|
50
|
+
TMSAPI::Model::Organization.new org
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def university_teams(university_id, params = nil)
|
55
|
+
params = {} unless params
|
56
|
+
params[:includeTeam] = true unless params[:includeTeam]
|
57
|
+
|
58
|
+
get(university_teams_path(university_id),params).each do |team|
|
59
|
+
TMSAPI::Model::Team.new team
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def team_details(team_brand_id, params = nil)
|
64
|
+
get(team_details_path(team_brand_id), params).each do |team|
|
65
|
+
TMSAPI::Model::Team.new team
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def team_airings(team_brand_id, params)
|
70
|
+
params[:startDateTime] = Time.now.strftime("%Y-%m-%dT%H:%MZ") unless params[:startDateTime]
|
71
|
+
|
72
|
+
get(team_airings_path(team_brand_id), params).each do |airing|
|
73
|
+
TMSAPI::Model::Airing.new airing
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def organization_airings(organization_id, params)
|
78
|
+
get(organization_airings_path(organization_id), params).each do |airing|
|
79
|
+
TMSAPI::Model::Airing.new airing
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
19
83
|
private
|
20
84
|
|
21
85
|
def details_path(sports_id)
|
@@ -23,7 +87,35 @@ module TMSAPI
|
|
23
87
|
end
|
24
88
|
|
25
89
|
def event_airings_path(sports_id)
|
26
|
-
"#{details_path(sports_id)}/events"
|
90
|
+
"#{details_path(sports_id)}/events/airings"
|
91
|
+
end
|
92
|
+
|
93
|
+
def nonevent_airings_path(sports_id)
|
94
|
+
"#{details_path(sports_id)}/non-events/airings"
|
95
|
+
end
|
96
|
+
|
97
|
+
def universities_path
|
98
|
+
"#{base_path}/universities"
|
99
|
+
end
|
100
|
+
|
101
|
+
def organization_teams_path(organization_id)
|
102
|
+
"#{base_path}/organizations/#{organization_id}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def university_teams_path(university_id)
|
106
|
+
"#{base_path}/universities/#{university_id}"
|
107
|
+
end
|
108
|
+
|
109
|
+
def team_details_path(team_brand_id)
|
110
|
+
"#{base_path}/teams/#{team_brand_id}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def team_airings_path(team_brand_id)
|
114
|
+
"#{team_details_path(team_brand_id)}/airings"
|
115
|
+
end
|
116
|
+
|
117
|
+
def organization_airings_path(organization_id)
|
118
|
+
"#{organization_teams_path(organization_id)}/airings"
|
27
119
|
end
|
28
120
|
|
29
121
|
def base_path
|
data/lib/tmsapi/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -351,4 +351,184 @@ describe TMSAPI::API, :vcr do
|
|
351
351
|
|
352
352
|
end
|
353
353
|
|
354
|
+
describe '#sports' do
|
355
|
+
describe '#details' do
|
356
|
+
let(:details) {
|
357
|
+
subject.sports.details
|
358
|
+
}
|
359
|
+
|
360
|
+
it 'should find details and organizations for all sports' do
|
361
|
+
details.count.should be >= 10
|
362
|
+
|
363
|
+
details.first.respond_to?(:sports_id).should be_true
|
364
|
+
details.first.respond_to?(:sports_name).should be_true
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
describe '#event_airings' do
|
369
|
+
let(:airings) {
|
370
|
+
subject.sports.event_airings(59, { :lineupId => "USA-NY31586-X", :startDateTime => "2013-12-23T13:00Z" } )
|
371
|
+
}
|
372
|
+
|
373
|
+
it 'should find some airings' do
|
374
|
+
airings.count.should be >= 10
|
375
|
+
|
376
|
+
airings.first.respond_to?(:start_time).should be_true
|
377
|
+
airings.first.respond_to?(:end_time).should be_true
|
378
|
+
airings.first.respond_to?(:duration).should be_true
|
379
|
+
airings.first.respond_to?(:program).should be_true
|
380
|
+
airings.first.program.respond_to?(:tms_id).should be_true
|
381
|
+
airings.first.program.respond_to?(:game_date).should be_true
|
382
|
+
airings.first.program.respond_to?(:event_title).should be_true
|
383
|
+
airings.first.program.respond_to?(:root_id).should be_true
|
384
|
+
airings.first.program.respond_to?(:title).should be_true
|
385
|
+
airings.first.program.respond_to?(:teams).should be_true
|
386
|
+
airings.first.program.teams.last.respond_to?(:name).should be_true
|
387
|
+
airings.first.program.teams.last.respond_to?(:team_brand_id).should be_true
|
388
|
+
airings.first.program.teams.last.respond_to?(:is_home).should be_true
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
describe '#nonevent_airings' do
|
393
|
+
let(:airings) {
|
394
|
+
subject.sports.nonevent_airings({:lineupId => "USA-NY31586-X", :startDateTime => "2014-01-04T13:00Z"})
|
395
|
+
}
|
396
|
+
|
397
|
+
it 'should return nonevent airings' do
|
398
|
+
airings.count.should be >= 10
|
399
|
+
|
400
|
+
airings.first.respond_to?(:start_time).should be_true
|
401
|
+
airings.first.respond_to?(:end_time).should be_true
|
402
|
+
airings.first.respond_to?(:duration).should be_true
|
403
|
+
airings.first.respond_to?(:program).should be_true
|
404
|
+
|
405
|
+
airings.first.program.respond_to?(:tms_id).should be_true
|
406
|
+
airings.first.program.respond_to?(:root_id).should be_true
|
407
|
+
airings.first.program.respond_to?(:title).should be_true
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
describe '#universities' do
|
412
|
+
let(:universities) {
|
413
|
+
subject.sports.universities
|
414
|
+
}
|
415
|
+
|
416
|
+
it 'should return all universities' do
|
417
|
+
universities.count.should be >= 10
|
418
|
+
|
419
|
+
universities.first.respond_to?(:university_id).should be_true
|
420
|
+
universities.first.respond_to?(:university_name).should be_true
|
421
|
+
universities.first.respond_to?(:nick_name).should be_true
|
422
|
+
universities.first.respond_to?(:preferred_image).should be_true
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
describe '#organization_teams' do
|
427
|
+
let(:teams_i) {
|
428
|
+
subject.sports.organization_teams(17)
|
429
|
+
}
|
430
|
+
|
431
|
+
let(:teams_s) {
|
432
|
+
subject.sports.organization_teams("17")
|
433
|
+
}
|
434
|
+
|
435
|
+
it 'should return organization information and teams with an int param' do
|
436
|
+
teams_i.count.should be == 1
|
437
|
+
|
438
|
+
teams_i.first.respond_to?(:organization_name).should be_true
|
439
|
+
teams_i.first.respond_to?(:preferred_image).should be_true
|
440
|
+
teams_i.first.respond_to?(:teams).should be_true
|
441
|
+
teams_i.first.teams.first.respond_to?(:team_brand_id).should be_true
|
442
|
+
teams_i.first.teams.first.respond_to?(:team_brand_name).should be_true
|
443
|
+
end
|
444
|
+
|
445
|
+
it 'should return organization information and teams with a string param' do
|
446
|
+
teams_s.count.should be == 1
|
447
|
+
|
448
|
+
teams_s.first.respond_to?(:organization_name).should be_true
|
449
|
+
teams_s.first.respond_to?(:preferred_image).should be_true
|
450
|
+
teams_s.first.respond_to?(:teams).should be_true
|
451
|
+
teams_s.first.teams.first.respond_to?(:team_brand_id).should be_true
|
452
|
+
teams_s.first.teams.first.respond_to?(:team_brand_name).should be_true
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
describe '#university_teams' do
|
457
|
+
let(:teams) {
|
458
|
+
subject.sports.university_teams("1")
|
459
|
+
}
|
460
|
+
|
461
|
+
it 'should return teams for this university' do
|
462
|
+
teams.count.should be >= 10
|
463
|
+
|
464
|
+
teams.first.respond_to?(:team_brand_id).should be_true
|
465
|
+
teams.first.respond_to?(:team_brand_name).should be_true
|
466
|
+
teams.first.respond_to?(:university).should be_true
|
467
|
+
teams.first.university.respond_to?(:university_id).should be_true
|
468
|
+
teams.first.university.respond_to?(:university_name).should be_true
|
469
|
+
teams.first.respond_to?(:nick_name).should be_true
|
470
|
+
teams.first.respond_to?(:proper_name).should be_true
|
471
|
+
teams.first.respond_to?(:sports_id).should be_true
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
describe '#team_details' do
|
476
|
+
let(:team) {
|
477
|
+
subject.sports.team_details(1)
|
478
|
+
}
|
479
|
+
|
480
|
+
it 'should have team information' do
|
481
|
+
team.first.respond_to?(:team_brand_id).should be_true
|
482
|
+
team.first.respond_to?(:team_brand_name).should be_true
|
483
|
+
team.first.respond_to?(:abbreviation).should be_true
|
484
|
+
team.first.respond_to?(:nick_name).should be_true
|
485
|
+
team.first.respond_to?(:proper_name).should be_true
|
486
|
+
team.first.respond_to?(:sports_id).should be_true
|
487
|
+
team.first.respond_to?(:preferred_image).should be_true
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
describe '#team_airings' do
|
492
|
+
let(:airings) {
|
493
|
+
subject.sports.team_airings(37,{:lineupId => "USA-NY31586-X", :startDateTime => "2014-01-03T15:40Z", :endDateTime => "2014-01-14T15:00Z"})
|
494
|
+
}
|
495
|
+
|
496
|
+
it 'should return airings' do
|
497
|
+
airings.count.should be >= 1
|
498
|
+
|
499
|
+
airings.first.respond_to?(:start_time).should be_true
|
500
|
+
airings.first.respond_to?(:end_time).should be_true
|
501
|
+
airings.first.respond_to?(:qualifiers).should be_true
|
502
|
+
airings.first.qualifiers.count.should be >= 3
|
503
|
+
airings.first.respond_to?(:station_id).should be_true
|
504
|
+
airings.first.respond_to?(:program).should be_true
|
505
|
+
airings.first.program.respond_to?(:tms_id).should be_true
|
506
|
+
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
describe '#organization_airings' do
|
511
|
+
let(:airings) {
|
512
|
+
subject.sports.organization_airings("17,19",{:lineupId => "USA-TX42500-X", :startDateTime => "2014-01-03T15:40Z"})
|
513
|
+
}
|
514
|
+
|
515
|
+
it 'should return airings' do
|
516
|
+
airings.count.should be >= 3
|
517
|
+
|
518
|
+
airings.first.respond_to?(:start_time).should be_true
|
519
|
+
airings.first.respond_to?(:end_time).should be_true
|
520
|
+
airings.first.respond_to?(:duration).should be_true
|
521
|
+
airings.first.respond_to?(:channels).should be_true
|
522
|
+
airings.first.respond_to?(:station).should be_true
|
523
|
+
airings.first.station.respond_to?(:call_sign).should be_true
|
524
|
+
airings.first.respond_to?(:station_id).should be_true
|
525
|
+
airings.first.respond_to?(:program).should be_true
|
526
|
+
airings.first.program.respond_to?(:tms_id).should be_true
|
527
|
+
airings.first.program.respond_to?(:root_id).should be_true
|
528
|
+
airings.first.program.respond_to?(:title).should be_true
|
529
|
+
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
end
|
354
534
|
end
|