odeon_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b911dbf0f01020ec6ca4acb27a64cb4cfa14b340
4
+ data.tar.gz: 7586a0cc88a596ee1c0d5e92c3a6701bc6c812db
5
+ SHA512:
6
+ metadata.gz: 0bb04f0aa70a6af15fe1994f0b1bc6cab70432f15395074f016e89e8a81affcf05e0b6b27e432c0d511a8e423c64bb68d5e37202cb29e61fce27f0a18a8a7c6c
7
+ data.tar.gz: 50d184799a15cdea667fb1079406993595b503ed6e3dbfdff1fac60086d40b77e07ab01df0b182d6d3bc137e359483e34f6f94a36eabce96a1a604187145389c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in odeon_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ahmet Abdi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # OdeonApi
2
+
3
+ This gem wraps the unofficial odeon api, endpoints were found by proxying requests from the android mobile app.
4
+
5
+ ## Installation
6
+
7
+ $ gem install odeon_api
8
+
9
+ ## Usage
10
+
11
+
12
+ ## License
13
+
14
+ Do as you will.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "odeon_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ module OdeonApi
2
+ class Cinema < Resource
3
+
4
+ def self.all
5
+ build_collection(
6
+ OdeonApi::Requester.get('all-cinemas')["data"]["sites"].map {|x| x[1]},
7
+ CinemaRepresenter
8
+ )
9
+ end
10
+
11
+ def self.find(id)
12
+ end
13
+
14
+ def self.find_by_name(name)
15
+ end
16
+
17
+ # https://api.odeon.co.uk/android-2.1/api/get-rewards
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ module OdeonApi
2
+ class Film < Resource
3
+
4
+ def self.all
5
+ build_collection(
6
+ OdeonApi::Requester.get('app-init')["data"]["films"],
7
+ MultiFilmRepresenter
8
+ )
9
+ end
10
+
11
+ def self.find(id)
12
+ build_single_resource(
13
+ OdeonApi::Requester.get('film-details', m: id)["data"],
14
+ FilmRepresenter
15
+ )
16
+ end
17
+
18
+ def self.times(film_id, cinema_id)
19
+ ap build_collection(
20
+ OdeonApi::Requester.get('film-times', s: cinema_id, m: film_id)["data"],
21
+ FilmTimeRepresenter
22
+ )
23
+ # 102
24
+ # 15866
25
+ end
26
+
27
+ def self.find_by_name(name)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ module OdeonApi
2
+ class FilmType < Resource
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ require 'representable/json'
2
+
3
+ module CinemaRepresenter
4
+ include Representable::JSON
5
+
6
+ property :id, as: :siteId
7
+ property :name, as: :siteName
8
+ property :address_1, as: :siteAddress1
9
+ property :address_2, as: :siteAddress2
10
+ property :address_3, as: :siteAddress3
11
+ property :address_4, as: :siteAddress4
12
+ property :postcode, as: :sitePostcode
13
+ property :telephone, as: :siteTelephone
14
+ property :longitude, as: :siteLongitude
15
+ property :latitude, as: :siteLatitude
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'representable/json'
2
+
3
+ module FilmRepresenter
4
+ include Representable::JSON
5
+
6
+ property :certificate, as: :certificate
7
+ property :image_url, as: :imageUrl
8
+ property :rateable, as: :isRateable
9
+ property :is_bbf, as: :isBBF # http://www.odeon.co.uk/odeon-terms/bbf-voucher/
10
+ property :plot
11
+ property :customerAdvice, as: :customerAdvice
12
+ property :director, as: :director
13
+ property :casts, as: :casts
14
+ property :running_time, as: :runningTime
15
+ property :language, as: :language
16
+ property :country, as: :country
17
+ property :rating, as: :halfRating
18
+ end
@@ -0,0 +1,12 @@
1
+ require 'representable/json'
2
+
3
+ module FilmTimeRepresenter
4
+ include Representable::JSON
5
+
6
+ property :date, as: :date
7
+
8
+ collection :types, as: :attributes, class: OdeonApi::FilmType do
9
+ property :name, as: :attribute
10
+ collection :showtimes, parse_filter: lambda { |fragment, doc, *args| fragment.flatten }
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ require 'representable/json'
2
+
3
+ module MultiFilmRepresenter
4
+ include Representable::JSON
5
+
6
+ property :id, as: :filmMasterId
7
+ property :title, as: :title
8
+ property :rating, as: :halfRating
9
+ property :certificate, as: :certificate
10
+ property :image_url, as: :imageUrl
11
+ property :release_date, as: :releaseDate
12
+ property :genre, as: :genre
13
+ property :trailer_url, as: :trailerUrl
14
+ property :rateable, as: :isRateable
15
+ property :top_five, as: :topFive # Goes up to 12
16
+ property :now_booking, as: :nowBooking # Don't think this is used
17
+ property :coming_soon, as: :comingSoon # Is used 1/0 true false
18
+ property :future_release, as: :futureRelease # Not used?
19
+ property :recommended, as: :recommended # Used
20
+ property :is_bbf, as: :isBBF # http://www.odeon.co.uk/odeon-terms/bbf-voucher/
21
+ property :sites, as: :sites
22
+ end
@@ -0,0 +1,46 @@
1
+ require 'rest_client'
2
+
3
+ module OdeonApi
4
+ class Requester
5
+ class << self
6
+ def get(action, params = {})
7
+ url = url_for(action, params)
8
+ perform_request do
9
+ parse_response(RestClient.get(url, headers))
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def url_for(action, params = {})
16
+ base_url = "https://api.odeon.co.uk/android-2.1/api/"
17
+ url = URI.join(base_url, action)
18
+ url.query = URI.encode_www_form(params) if params
19
+ url.to_s
20
+ end
21
+
22
+ def perform_request(&block)
23
+ begin
24
+ block.call
25
+ rescue RestClient::Exception => e
26
+ puts e.message
27
+ end
28
+ end
29
+
30
+ def headers
31
+ {}.tap do |headers|
32
+ headers['Accept'] = 'application/json'
33
+ headers['Content-Type'] = 'application/json'
34
+ end
35
+ end
36
+
37
+ def parse_response(response_body)
38
+ begin
39
+ JSON.parse(response_body)
40
+ rescue JSON::ParserError => e
41
+ puts e.message
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,23 @@
1
+ require 'representable/json'
2
+ require 'ostruct'
3
+
4
+ module OdeonApi
5
+ class Resource < OpenStruct
6
+ private
7
+
8
+ def self.build_single_resource(response, representer)
9
+ return unless response
10
+ new.extend(representer).from_hash(response)
11
+ end
12
+
13
+ def self.build_collection(response, representer)
14
+ response.reduce([]) do |resources, res|
15
+ resources << new.extend(representer).from_hash(res)
16
+ end
17
+ end
18
+
19
+ def build_for_collection(response, representer)
20
+ [].extend(representer.for_collection).from_hash(response)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module OdeonApi
2
+ VERSION = "0.1.0"
3
+ end
data/lib/odeon_api.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'json'
2
+ require "awesome_print"
3
+ require 'odeon_api/resource'
4
+ require 'odeon_api/models/film_type'
5
+ require 'odeon_api/requester'
6
+ require 'odeon_api/representers/film_time_representer'
7
+ require 'odeon_api/representers/multi_film_representer'
8
+ require 'odeon_api/representers/film_representer'
9
+ require 'odeon_api/representers/cinema_representer'
10
+ require 'odeon_api/models/cinema'
11
+ require 'odeon_api/models/film'
12
+ require 'odeon_api/version'
data/odeon_api.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'odeon_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "odeon_api"
8
+ spec.version = OdeonApi::VERSION
9
+ spec.authors = ["Ahmet Abdi"]
10
+ spec.email = ["ahmetabdi@gmail.com"]
11
+
12
+ spec.summary = 'ODEON API (unofficial)'
13
+ spec.description = 'ODEON API (unofficial)'
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "awesome_print"
26
+
27
+ spec.add_runtime_dependency 'representable'
28
+ spec.add_runtime_dependency 'multi_json'
29
+ spec.add_runtime_dependency 'rest-client'
30
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: odeon_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ahmet Abdi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: representable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: multi_json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rest-client
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: ODEON API (unofficial)
112
+ email:
113
+ - ahmetabdi@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/odeon_api.rb
129
+ - lib/odeon_api/models/cinema.rb
130
+ - lib/odeon_api/models/film.rb
131
+ - lib/odeon_api/models/film_type.rb
132
+ - lib/odeon_api/representers/cinema_representer.rb
133
+ - lib/odeon_api/representers/film_representer.rb
134
+ - lib/odeon_api/representers/film_time_representer.rb
135
+ - lib/odeon_api/representers/multi_film_representer.rb
136
+ - lib/odeon_api/requester.rb
137
+ - lib/odeon_api/resource.rb
138
+ - lib/odeon_api/version.rb
139
+ - odeon_api.gemspec
140
+ homepage: ''
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.4.5.1
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: ODEON API (unofficial)
164
+ test_files: []