tessitura 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e2b0799e1886152ab18d2e2f7c853d90a9811a0e
4
+ data.tar.gz: 6764aa2a18deb25deb24f9b10fbe3e706a6af976
5
+ SHA512:
6
+ metadata.gz: f45fe3f30fad7347027da13ff887244ff97745ebff10510ab94f6fa948d5d405efcfa99e1148daeb34cd2573da6a77996069818241a3865b056ba32f1e8cc95e
7
+ data.tar.gz: a3cc65503010d10e87a365502bd351fb17024f9991ce53298286d3d933fa1c6413fc30cff7c62a2d8add8a40dce6b664edbe3b006990ac10389624417971d69a
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.5
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tessitura_api.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tomas Celizna
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.
@@ -0,0 +1,49 @@
1
+ # Tessitura
2
+
3
+ [![Build Status](https://travis-ci.org/tomasc/tessitura.svg)](https://travis-ci.org/tomasc/tessitura) [![Gem Version](https://badge.fury.io/rb/tessitura.svg)](http://badge.fury.io/rb/tessitura) [![Coverage Status](https://img.shields.io/coveralls/tomasc/tessitura.svg)](https://coveralls.io/r/tomasc/tessitura)
4
+
5
+ Simple wrapper of [Tessitura](http://www.tessituranetwork.com) API.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tessitura'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tessitura_api
22
+
23
+ ## Usage
24
+
25
+ Consume the performance API:
26
+
27
+ ```ruby
28
+ base_uri = 'https://testapp.tessituranetworkramp.com'
29
+ tessitura_api_call = Tessitura::ApiCall.new(base_uri: base_uri)
30
+ performance_id = 1234
31
+ performance = tessitura_api_call.performance(performance_id) # => Tessitura::Performance
32
+ ```
33
+
34
+ See the `Performance`, `AllPrice` and `PriceType` classes and tests for list of available methods.
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tomasc/tessitura.
45
+
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tessitura_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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require 'tessitura/version'
2
+
3
+ require 'tessitura/attr_accessor_of_type'
4
+
5
+ require 'tessitura/all_price'
6
+ require 'tessitura/api_call'
7
+ require 'tessitura/performance'
8
+ require 'tessitura/price_type'
@@ -0,0 +1,36 @@
1
+ require 'httparty'
2
+ require 'oga'
3
+
4
+ module Tessitura
5
+ class AllPrice < Struct.new(:xml_data)
6
+ include AttrAccessorOfType
7
+
8
+ attr_accessor :doc
9
+
10
+ attr_accessor_of_type :avail_count, type: Integer
11
+ attr_accessor_of_type :available, type: TrueClass
12
+ attr_accessor_of_type :base_price, type: Float
13
+ attr_accessor_of_type :def_price_type, type: Integer
14
+ attr_accessor_of_type :description
15
+ attr_accessor_of_type :price, type: Float
16
+ attr_accessor_of_type :price_type, type: Integer
17
+ attr_accessor_of_type :price_type_desc
18
+ attr_accessor_of_type :rank, type: Integer
19
+ attr_accessor_of_type :zone_no, type: Integer
20
+
21
+ def initialize(xml_data)
22
+ super(xml_data)
23
+ self.doc = Oga.parse_xml(xml_data)
24
+ end
25
+
26
+ def id
27
+ return unless att = doc.at_xpath('//AllPrice').attribute('diffgr:id')
28
+ att.value
29
+ end
30
+
31
+ def sold_out
32
+ !available?
33
+ end
34
+ alias sold_out? sold_out
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require 'httparty'
2
+ require 'oga'
3
+
4
+ module Tessitura
5
+ class ApiCall < Struct.new(:options)
6
+ include HTTParty
7
+
8
+ default_options.update(verify: false)
9
+
10
+ def initialize(options = {})
11
+ super(options)
12
+ self.class.base_uri base_uri
13
+ end
14
+
15
+ # TODO: raise error when not found
16
+ def performance(id)
17
+ request_query = { 'iPerf_no' => id.to_s, 'iModeOfSale' => '10' }
18
+ response = self.class.get(performance_detail_path, query: request_query)
19
+
20
+ case response.code
21
+ when 200 then Performance.new(response.body)
22
+ else false
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def base_uri
29
+ options.fetch :base_uri
30
+ end
31
+
32
+ def performance_detail_path
33
+ '/LiveAPI/Tessitura.asmx/GetPerformanceDetail'
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ module Tessitura
2
+ module AttrAccessorOfType
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def attr_accessor_of_type(name, options = {})
9
+ xpath = options.fetch :xpath, "//#{name}"
10
+ type = options.fetch :type, String
11
+
12
+ define_method name do
13
+ return unless el = doc.at_xpath(xpath)
14
+ case type.to_s
15
+ when 'Integer' then el.text.to_i
16
+ when 'Float' then el.text.to_f
17
+ when 'DateTime' then DateTime.parse(el.text)
18
+ when 'TrueClass' then el.text == 'Y'
19
+ else el.text
20
+ end
21
+ end
22
+
23
+ alias_method("#{name}?".to_sym, name) if type == TrueClass
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,60 @@
1
+ require 'httparty'
2
+ require 'oga'
3
+
4
+ module Tessitura
5
+ class Performance < Struct.new(:xml_data)
6
+ include AttrAccessorOfType
7
+
8
+ attr_accessor :doc
9
+
10
+ attr_accessor_of_type :description
11
+ attr_accessor_of_type :end_dt, type: DateTime
12
+ attr_accessor_of_type :facility_desc
13
+ attr_accessor_of_type :facility_no, type: Integer
14
+ attr_accessor_of_type :ga_ind, type: TrueClass
15
+ attr_accessor_of_type :inv_no, type: Integer
16
+ attr_accessor_of_type :on_sale_ind, type: TrueClass
17
+ attr_accessor_of_type :perf_dt, type: DateTime
18
+ attr_accessor_of_type :perf_status, type: Integer
19
+ attr_accessor_of_type :perf_status_desc
20
+ attr_accessor_of_type :perf_type_id, type: Integer
21
+ attr_accessor_of_type :performance_type
22
+ attr_accessor_of_type :print_ind, type: TrueClass
23
+ attr_accessor_of_type :prod_season_no, type: Integer
24
+ attr_accessor_of_type :season_desc
25
+ attr_accessor_of_type :season_no, type: Integer
26
+ attr_accessor_of_type :seat_ind, type: TrueClass
27
+ attr_accessor_of_type :start_dt, type: DateTime
28
+ attr_accessor_of_type :time_slot, type: Integer
29
+ attr_accessor_of_type :time_slot_desc
30
+ attr_accessor_of_type :type
31
+ attr_accessor_of_type :zmap_no, type: Integer
32
+
33
+ alias facility_description facility_desc
34
+ alias facility_number facility_no
35
+ alias production_season_number prod_season_no
36
+ alias season_description season_desc
37
+ alias season_number season_no
38
+ alias status perf_status
39
+ alias status_description perf_status_desc
40
+ alias tessitura_id inv_no
41
+
42
+ def initialize(xml_data)
43
+ super(xml_data)
44
+ self.doc = Oga.parse_xml(xml_data).at_xpath('//Performance')
45
+ end
46
+
47
+ def id
48
+ return unless att = doc.at_xpath('//Performance').attribute('diffgr:id')
49
+ att.value
50
+ end
51
+
52
+ def all_prices
53
+ doc.xpath('//AllPrice').map { |xml| AllPrice.new(xml.to_xml) }
54
+ end
55
+
56
+ def price_types
57
+ doc.xpath('//PriceType').map { |xml| PriceType.new(xml.to_xml) }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,30 @@
1
+ require 'httparty'
2
+ require 'oga'
3
+
4
+ module Tessitura
5
+ class PriceType < Struct.new(:xml_data)
6
+ include AttrAccessorOfType
7
+
8
+ attr_accessor :doc
9
+
10
+ attr_accessor_of_type :category, type: String
11
+ attr_accessor_of_type :def_price_type, type: TrueClass
12
+ attr_accessor_of_type :description, type: String
13
+ attr_accessor_of_type :price_type, type: Integer
14
+ attr_accessor_of_type :promo, type: TrueClass
15
+ attr_accessor_of_type :promo_max, type: Integer
16
+ attr_accessor_of_type :promo_override_default, type: TrueClass
17
+ attr_accessor_of_type :promo_rank, type: Integer
18
+ attr_accessor_of_type :short_desc, type: String
19
+
20
+ def initialize(xml_data)
21
+ super(xml_data)
22
+ self.doc = Oga.parse_xml(xml_data)
23
+ end
24
+
25
+ def id
26
+ return unless att = doc.at_xpath('//PriceType').attribute('diffgr:id')
27
+ att.value
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module Tessitura
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tessitura/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'tessitura'
8
+ spec.version = Tessitura::VERSION
9
+ spec.authors = ['Tomáš Celizna', 'Asger Behncke Jacobsen']
10
+ spec.email = ['mail@tomascelizna.com', 'asger@8kilo.com']
11
+
12
+ spec.summary = 'Simple wrapper of Tessitura API.'
13
+ spec.homepage = 'https://github.com/tomasc/tessitura'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'httparty'
22
+ spec.add_dependency 'oga'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.12'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'minitest', '~> 5.0'
27
+ spec.add_development_dependency 'minitest-vcr'
28
+ spec.add_development_dependency 'webmock'
29
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tessitura
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomáš Celizna
8
+ - Asger Behncke Jacobsen
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: oga
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.12'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.12'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: minitest
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '5.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '5.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: minitest-vcr
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: webmock
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ description:
113
+ email:
114
+ - mail@tomascelizna.com
115
+ - asger@8kilo.com
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/tessitura.rb
129
+ - lib/tessitura/all_price.rb
130
+ - lib/tessitura/api_call.rb
131
+ - lib/tessitura/attr_accessor_of_type.rb
132
+ - lib/tessitura/performance.rb
133
+ - lib/tessitura/price_type.rb
134
+ - lib/tessitura/version.rb
135
+ - tessitura.gemspec
136
+ homepage: https://github.com/tomasc/tessitura
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Simple wrapper of Tessitura API.
160
+ test_files: []