vivid-seat-api 0.0.5
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +63 -0
- data/lib/vivid_seat_api.rb +12 -0
- data/lib/vivid_seat_api/base.rb +80 -0
- data/lib/vivid_seat_api/fulfillment.rb +102 -0
- data/lib/vivid_seat_api/listing.rb +45 -0
- data/lib/vivid_seat_api/response.rb +27 -0
- data/lib/vivid_seat_api/upload_filter.rb +26 -0
- data/lib/vivid_seat_api/version.rb +3 -0
- data/test/fulfillment_spec.rb +80 -0
- data/test/helper.rb +3 -0
- data/test/listing_spec.rb +127 -0
- data/vivid_seat_api.gemspec +27 -0
- metadata +166 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 47769200fe5bc1635b4814d67718448be58b557d
|
4
|
+
data.tar.gz: 64b070b1560546ad2e5287b13376aa83d0aa0092
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58c45f34109b5e74db6d6c4fb9bd1f70a5468bd231840850f7b25fc83e0e1f15ff52992e9256cc0cc4e503a8feee3dc53f1ea7c0813eeabaa02aac13a8cca6be
|
7
|
+
data.tar.gz: 89d0089526fb6b11b0fda99a8f8ea0b662109f5f2bd66fb50c54beb438732318e445a39f0aa6e72d048ee131f44f07260d974b7259cba3a3f7bab9825a0fbd89
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 chebyte
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# VividSeatApi [](https://codeclimate.com/github/hashdog/vivid_seat_api) [](http://badge.fury.io/rb/vivid_seat_api)
|
2
|
+
|
3
|
+
This gem provides access to add, edit and delete listings appearing on Vivid Seats and it’s affiliates.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'vivid_seat_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install vivid_seat_api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
client = VividSeatApi::Client.new("your-api-key")
|
22
|
+
|
23
|
+
client.get_listings(options)
|
24
|
+
|
25
|
+
client.insert_listing(options)
|
26
|
+
|
27
|
+
client.update(options)
|
28
|
+
|
29
|
+
client.delete(options)
|
30
|
+
|
31
|
+
client.insert_or_update(options)
|
32
|
+
|
33
|
+
note: options params you can check here: https://brokers.vividseats.com/ListingWebServices_v1.pdf
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( https://github.com/hashdog/vivid_seat_api/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'faker'
|
4
|
+
require_relative "lib/vivid_seat_api"
|
5
|
+
|
6
|
+
task default: 'test'
|
7
|
+
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.pattern = "test/*_spec.rb"
|
10
|
+
t.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Launch a console with the gem binding"
|
14
|
+
task :console do
|
15
|
+
exec 'irb -r vivid_seat_api -I ./lib'
|
16
|
+
end
|
17
|
+
|
18
|
+
namespace :seed do
|
19
|
+
SANDBOX_TOKEN = 'e4845f92-2610-4ca7-ae13-66015e27ec53'
|
20
|
+
DISCLAIMER_FOR_TEST = "Hashdog listing for test porpouses"
|
21
|
+
|
22
|
+
desc "Push an Inventory on sanbox"
|
23
|
+
task :new do
|
24
|
+
puts "Seeding for a new listing ..."
|
25
|
+
options = {
|
26
|
+
ticketId: rand(800000000..1100000000), # [String](Required) Your unique id associated with the listing.
|
27
|
+
eventName: "Hashdog - #{Faker::Name.name}", # [String](Required) The event Name.
|
28
|
+
venueName: Faker::Name.name, # [String](Required) The venue the event is taking place.
|
29
|
+
eventDateTime: Faker::Time.forward(30).strftime("%Y-%m-%d %T"), # [String](Required) The event date and time in yyyy-MM-dd HH:mm:ss format.
|
30
|
+
quantity: Faker::Number.digit, # [Integer](Required) The quantity of tickets available.
|
31
|
+
section: Faker::Commerce.department(1), # [String] (Required) The section of the listing.
|
32
|
+
row: Faker::Number.digit, # [String] (Required) The row of the listing.
|
33
|
+
price: Faker::Commerce.price.round(2), # [Double] (Required) The unit price of the listing.
|
34
|
+
seatFrom: nil, # [String] (Optional) The starting seat of the listing.
|
35
|
+
seatThru: nil, # [String] (Optional) The ending seat of the listing.
|
36
|
+
notes: DISCLAIMER_FOR_TEST, # [String] (Optional) Notes associated with the listing, displayed to buyres.
|
37
|
+
electronic: nil, # [Boolean] (Optional) Boolean indicating whether the tickets can be delivered electronically.
|
38
|
+
inHandDate: nil, # [String] (Optional) Date the listing can ship in yyyy-MM-dd format.
|
39
|
+
splitType: nil, # [TicketSplitType] (Optional) One of DEFAULT, ANY, or CUSTOM. Indicates how the listing can be split.
|
40
|
+
splitValue: nil # Comma-delimted split values if CUSTOM splitType is selected.
|
41
|
+
}
|
42
|
+
|
43
|
+
puts "Create a new listing for #{options[:eventName]} (#{options[:ticketId]} )"
|
44
|
+
client = VividSeatApi::Listing.new(SANDBOX_TOKEN, sandboxed: true)
|
45
|
+
doc = client.create(options.delete_if {|_,v|v.nil?})
|
46
|
+
puts doc.at_xpath("/response/message").content
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "List sandbox listing"
|
50
|
+
task :list do
|
51
|
+
client = VividSeatApi::Listing.new(SANDBOX_TOKEN, sandboxed: true)
|
52
|
+
puts client.list
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Show a sandbox listing"
|
56
|
+
task :show do
|
57
|
+
fail("You must provide LISTING_ID env variable") unless ENV["LISTING_ID"]
|
58
|
+
client = VividSeatApi::Listing.new(SANDBOX_TOKEN, sandboxed: true)
|
59
|
+
puts client.list(ticketId: ENV["LISTING_ID"])
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#gems
|
2
|
+
require 'faraday'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
#libs
|
6
|
+
require_relative "vivid_seat_api/version"
|
7
|
+
require_relative "vivid_seat_api/response"
|
8
|
+
require_relative "vivid_seat_api/base"
|
9
|
+
require_relative "vivid_seat_api/listing"
|
10
|
+
require_relative "vivid_seat_api/fulfillment"
|
11
|
+
|
12
|
+
module VividSeatApi;end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module VividSeatApi
|
4
|
+
|
5
|
+
CSV_FILENAME = "inventories.csv"
|
6
|
+
|
7
|
+
class BaseUrlMissing < NotImplementedError; end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.configure
|
14
|
+
self.configuration ||= Configuration.new
|
15
|
+
yield(configuration)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configure_required!
|
19
|
+
raise ArgumentError, "You must configure VividSeatApi" if VividSeatApi.configuration.instance_variables.size < 4
|
20
|
+
end
|
21
|
+
|
22
|
+
class Configuration
|
23
|
+
attr_accessor :ftp_host
|
24
|
+
attr_accessor :ftp_user
|
25
|
+
attr_accessor :ftp_pass
|
26
|
+
attr_accessor :api_token
|
27
|
+
end
|
28
|
+
|
29
|
+
class Base
|
30
|
+
|
31
|
+
def initialize(options={})
|
32
|
+
@sandboxed = options.fetch(:sandboxed, false)
|
33
|
+
end
|
34
|
+
|
35
|
+
def base_url
|
36
|
+
raise BaseUrlMissing, "#{self}.fetch not implemented" #"https://brokers.vividseats.com/webservices/listings/v1/"
|
37
|
+
end
|
38
|
+
|
39
|
+
def make_request_url url, options
|
40
|
+
"#{url}?#{builder_options(options)}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def builder_options options
|
44
|
+
options.merge!(apiToken: VividSeatApi.configuration.api_token)
|
45
|
+
to_query(options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_query_api url, options
|
49
|
+
session.get(make_request_url(url, options)).body
|
50
|
+
end
|
51
|
+
|
52
|
+
def post_query_api url, options
|
53
|
+
builder_options(options)
|
54
|
+
session.post(url, builder_options(options)).body
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_query(options)
|
58
|
+
Faraday::Utils.build_nested_query(options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def session
|
62
|
+
@connection ||= ::Faraday.new base_url do |conn|
|
63
|
+
conn.use Faraday::Response::VividSeat
|
64
|
+
conn.adapter Faraday.default_adapter
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
def sandboxed?
|
71
|
+
!!@sandboxed
|
72
|
+
end
|
73
|
+
|
74
|
+
def transform!(doc, &block)
|
75
|
+
result = ::OpenStruct.new
|
76
|
+
result.instance_exec doc, &block
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module VividSeatApi
|
2
|
+
class Fulfillment < Base
|
3
|
+
def base_url
|
4
|
+
if sandboxed?
|
5
|
+
"http://brokers-test.vividseats.com/webservices/v1/"
|
6
|
+
else
|
7
|
+
"https://brokers.vividseats.com/webservices/v1/"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_orders(options = {})
|
12
|
+
transform!(get_query_api("getOrders", options)) do |doc|
|
13
|
+
fields = %w(orderId orderToken brokerTicketId section row notes quantity cost event venue eventDate electronicDelivery mercuryOrderId purchaseOrderId)
|
14
|
+
self.orders = []
|
15
|
+
xml.xpath("//orders").each do |xml|
|
16
|
+
order = OpenStruct.new
|
17
|
+
fields.each do |attr|
|
18
|
+
order.send("#{attr}=", xml.at_xpath(attr).content)
|
19
|
+
end
|
20
|
+
self.orders.push(listing)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_completed_orders(options = {})
|
26
|
+
transform!(get_query_api("getCompletedOrders", options)) do |doc|
|
27
|
+
fields = %w(orderId orderToken brokerTicketId section row notes quantity cost event venue eventDate electronicDelivery mercuryOrderId purchaseOrderId)
|
28
|
+
self.orders = []
|
29
|
+
xml.xpath("//orders").each do |xml|
|
30
|
+
order = OpenStruct.new
|
31
|
+
fields.each do |attr|
|
32
|
+
order.send("#{attr}=", xml.at_xpath(attr).content)
|
33
|
+
end
|
34
|
+
self.orders.push(listing)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_order(options = {})
|
41
|
+
transform!(get_query_api("getOrder", options)) do |xml|
|
42
|
+
fields = %w(orderId orderToken brokerTicketId section row notes quantity cost event venue eventDate electronicDelivery purchaseOrderId)
|
43
|
+
fields.each do |attr|
|
44
|
+
self.send("#{attr}=", xml.at_xpath("//#{attr}").content)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def confirm_order(options = {})
|
50
|
+
transform!(post_query_api("confirmOrder", options)) do |xml|
|
51
|
+
fields = %w(success message trackingNumber purchaseOrderId)
|
52
|
+
fields.each do |attr|
|
53
|
+
self.send("#{attr}=", xml.at_xpath("//#{attr}").content)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def ship_order(options = {})
|
59
|
+
transform!(post_query_api("shipOrder", options)) do |xml|
|
60
|
+
fields = %w(success message trackingNumber airbillBase64String)
|
61
|
+
fields.each do |attr|
|
62
|
+
self.send("#{attr}=", xml.at_xpath("//#{attr}").content)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def reject_order(options = {})
|
68
|
+
transform!(post_query_api("rejectOrder", options)) do |xml|
|
69
|
+
fields = %w(success message)
|
70
|
+
fields.each do |attr|
|
71
|
+
self.send("#{attr}=", xml.at_xpath("//#{attr}").content)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_airbill(options = {})
|
77
|
+
transform!(get_query_api("getAirbill", options)) do |xml|
|
78
|
+
fields = %w(success message trackingNumber airbillBase64String)
|
79
|
+
fields.each do |attr|
|
80
|
+
self.send("#{attr}=", xml.at_xpath("//#{attr}").content)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def download_airbill(options = {})
|
86
|
+
get_query_api("downloadAirbill", options)
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_purchase_order(options = {})
|
90
|
+
transform!(get_query_api("getPurchaseOrder", options)) do |xml|
|
91
|
+
fields = %w(success message purchaseOrderId poBase64String)
|
92
|
+
fields.each do |attr|
|
93
|
+
self.send("#{attr}=", xml.at_xpath("//#{attr}").content)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def download_purchase_order(options = {})
|
99
|
+
get_query_api("downloadPurchaseOrder", options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative "upload_filter"
|
2
|
+
require "net/ftp"
|
3
|
+
require "tempfile"
|
4
|
+
|
5
|
+
module VividSeatApi
|
6
|
+
class PublishError < ArgumentError
|
7
|
+
attr_reader :errors
|
8
|
+
|
9
|
+
def initialize(erros)
|
10
|
+
@errors = errors
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Listing
|
15
|
+
extend self
|
16
|
+
|
17
|
+
def publish(records)
|
18
|
+
VividSeatApi.configure_required!
|
19
|
+
record_with_errors = records.detect{|record| !UploadFilter.new(attrs).valid?}
|
20
|
+
if record_with_errors
|
21
|
+
uploader = UploadFilter.new(record_with_errors)
|
22
|
+
raise PublishError.new(uploader.errors), "Invalid params" unless uploader.valid?
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
file = Tempfile.new("TicketMonsterApi")
|
27
|
+
file.write("#{UploadFilter::FIELDS.join(",")}\n")
|
28
|
+
records.each do |record|
|
29
|
+
ordered_values = UploadFilter::FIELDS.map do |field|
|
30
|
+
record[field]
|
31
|
+
end
|
32
|
+
file.write("#{ordered_values.join(",")}\n")
|
33
|
+
end
|
34
|
+
file.flush
|
35
|
+
Net::FTP.open(VividSeatApi.configuration.ftp_host) do |ftp|
|
36
|
+
ftp.passive = true
|
37
|
+
ftp.login(VividSeatApi.configuration.ftp_user, VividSeatApi.configuration.ftp_pass)
|
38
|
+
ftp.putbinaryfile(file.path, "#{VividSeatApi::CSV_FILENAME}")
|
39
|
+
end
|
40
|
+
ensure
|
41
|
+
file.close!
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#api exception
|
2
|
+
class ApiException < StandardError;end
|
3
|
+
|
4
|
+
module Faraday
|
5
|
+
class Response::VividSeat < Response::Middleware
|
6
|
+
def parse_body(body)
|
7
|
+
Nokogiri::XML(body)
|
8
|
+
end
|
9
|
+
|
10
|
+
def check_status(env)
|
11
|
+
status = env[:status].to_s
|
12
|
+
if status =~ /^5/
|
13
|
+
raise ApiException.new("Bad Token, status #{status}")
|
14
|
+
elsif status =~ /^4/
|
15
|
+
raise ApiException.new("Error #{status}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(environment)
|
20
|
+
@app.call(environment).on_complete do |env|
|
21
|
+
check_status(env)
|
22
|
+
env[:body] = parse_body(env[:body])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'scrivener'
|
2
|
+
|
3
|
+
module VividSeatApi
|
4
|
+
class UploadFilter < Scrivener
|
5
|
+
FIELDS = [
|
6
|
+
:Event,
|
7
|
+
:Venue,
|
8
|
+
:EventDate,
|
9
|
+
:EventTime,
|
10
|
+
:Quantity,
|
11
|
+
:Section,
|
12
|
+
:Row,
|
13
|
+
:SeatFrom,
|
14
|
+
:SeatThru,
|
15
|
+
:Notes,
|
16
|
+
:Cost,
|
17
|
+
:TicketID,
|
18
|
+
:Edelivery_ind,
|
19
|
+
:InHandDate
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
FIELDS.each do |attribute|
|
23
|
+
attr_accessor attribute
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
describe "Fulfillment" do
|
5
|
+
let(:fake_token){"31f502d-801c-4bd6-ac53-a8e0f68bdede"}
|
6
|
+
|
7
|
+
let(:default_headers) do
|
8
|
+
{"Content-Type" => "application/xml; charset=UTF-8"}
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:http_success_code){200}
|
12
|
+
|
13
|
+
let(:get_orders_response) do
|
14
|
+
<<-EOF
|
15
|
+
<orders>
|
16
|
+
<order>
|
17
|
+
<brokerTicketId>4762069</brokerTicketId>
|
18
|
+
<cost>127.85</cost>
|
19
|
+
<event>Chicago Blackhawks vs. Anaheim Ducks</event>
|
20
|
+
<orderId>296275</orderId>
|
21
|
+
<orderToken>aecc0c52-f5a1-4684-ade2-063b6c9e91f5</orderToken>
|
22
|
+
<quantity>2</quantity>
|
23
|
+
<row>5</row>
|
24
|
+
<section>301</section>
|
25
|
+
<status>UNCONFIRMED</status>
|
26
|
+
<venue>United Center - Chicago, IL</venue>
|
27
|
+
</order>
|
28
|
+
<order>
|
29
|
+
<brokerTicketId>4359430</brokerTicketId>
|
30
|
+
<cost>231.95</cost>
|
31
|
+
<event>Philadelphia 76ers at Miami Heat</event>
|
32
|
+
<orderId>296304</orderId>
|
33
|
+
<orderToken>73439cd8-73ea-48f4-aae4-030d209b85d2</orderToken>
|
34
|
+
<quantity>1</quantity>
|
35
|
+
<row>5</row>
|
36
|
+
<section>121</section>
|
37
|
+
<status>UNCONFIRMED</status>
|
38
|
+
<venue>American Airlines Arena - FL - Miami, FL</venue>
|
39
|
+
</order>
|
40
|
+
</orders>
|
41
|
+
EOF
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:success_response) do
|
45
|
+
<<-EOF
|
46
|
+
<response>
|
47
|
+
<success>true</success>
|
48
|
+
<message>Success.</message>
|
49
|
+
</response>
|
50
|
+
EOF
|
51
|
+
end
|
52
|
+
|
53
|
+
let(:http_connection) {
|
54
|
+
Faraday.new do |builder|
|
55
|
+
builder.use Faraday::Response::VividSeat
|
56
|
+
builder.adapter :test, http_stubs
|
57
|
+
end
|
58
|
+
}
|
59
|
+
|
60
|
+
let(:http_stubs) { Faraday::Adapter::Test::Stubs.new }
|
61
|
+
|
62
|
+
let(:client) do
|
63
|
+
fetcher = VividSeatApi::Fulfillment.new(fake_token, sandboxed: true)
|
64
|
+
fetcher.instance_variable_set(:@connection, http_connection)
|
65
|
+
fetcher
|
66
|
+
end
|
67
|
+
|
68
|
+
let(:verify_stubbings){true}
|
69
|
+
|
70
|
+
it "Get orders" do
|
71
|
+
http_stubs.get("/getOrders?apiToken=#{fake_token}") {[http_success_code, default_headers, get_orders_response]}
|
72
|
+
|
73
|
+
doc = client.get_orders
|
74
|
+
|
75
|
+
http_stubs.verify_stubbed_calls if verify_stubbings
|
76
|
+
assert_equal 2, doc.xpath("//order").size
|
77
|
+
assert_equal "127.85", doc.at_xpath("/orders/order/cost").content
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
describe "Listing" do
|
5
|
+
let(:fake_token){"31f502d-801c-4bd6-ac53-a8e0f68bdede"}
|
6
|
+
|
7
|
+
let(:default_headers) do
|
8
|
+
{"Content-Type" => "application/xml; charset=UTF-8"}
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:http_success_code){200}
|
12
|
+
|
13
|
+
let(:listing_response) do
|
14
|
+
<<-EOF
|
15
|
+
<brokerListings>
|
16
|
+
<brokerListing>
|
17
|
+
<electronic>false</electronic>
|
18
|
+
<id>201572363</id>
|
19
|
+
<inHandDate>2012-04-25T00:00:00-05:00</inHandDate>
|
20
|
+
<notes/>
|
21
|
+
<price>2.00</price>
|
22
|
+
<quantity>4</quantity>
|
23
|
+
<row>P</row>
|
24
|
+
<seatFrom/>
|
25
|
+
<seatThru/>
|
26
|
+
<section>503</section>
|
27
|
+
<splitType>DEFAULT</splitType>
|
28
|
+
<splitValue/>
|
29
|
+
<ticketId>492632</ticketId>
|
30
|
+
</brokerListing>
|
31
|
+
</brokerListings>
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:success_response) do
|
36
|
+
<<-EOF
|
37
|
+
<response>
|
38
|
+
<success>true</success>
|
39
|
+
<message>Success.</message>
|
40
|
+
</response>
|
41
|
+
EOF
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:http_connection) {
|
45
|
+
Faraday.new do |builder|
|
46
|
+
builder.use Faraday::Response::VividSeat
|
47
|
+
builder.adapter :test, http_stubs
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
let(:http_stubs) { Faraday::Adapter::Test::Stubs.new }
|
52
|
+
|
53
|
+
let(:client) do
|
54
|
+
fetcher = VividSeatApi::Listing.new(fake_token, sandboxed: true)
|
55
|
+
fetcher.instance_variable_set(:@connection, http_connection)
|
56
|
+
fetcher
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:verify_stubbings){true}
|
60
|
+
|
61
|
+
it "listing" do
|
62
|
+
http_stubs.get("/getListings?apiToken=#{fake_token}") {[http_success_code, default_headers, listing_response]}
|
63
|
+
|
64
|
+
doc = client.get_listings
|
65
|
+
|
66
|
+
http_stubs.verify_stubbed_calls if verify_stubbings
|
67
|
+
assert_equal 1, doc.xpath("//brokerListing").size
|
68
|
+
assert_equal "492632", doc.at_xpath("/brokerListings/brokerListing/ticketId").content
|
69
|
+
end
|
70
|
+
|
71
|
+
it "update" do
|
72
|
+
http_stubs.post("/updateListing?apiToken=#{fake_token}§ion=504") {[http_success_code, default_headers, success_response]}
|
73
|
+
|
74
|
+
doc = client.update_listing(section: 504)
|
75
|
+
|
76
|
+
http_stubs.verify_stubbed_calls if verify_stubbings
|
77
|
+
assert_equal "true", doc.at_xpath("/response/success").content
|
78
|
+
end
|
79
|
+
|
80
|
+
it "delete" do
|
81
|
+
http_stubs.post("/deleteListing?apiToken=#{fake_token}&ticketId=201572363") {[http_success_code, default_headers, success_response]}
|
82
|
+
|
83
|
+
doc = client.delete_listing(ticketId: 201572363)
|
84
|
+
|
85
|
+
http_stubs.verify_stubbed_calls if verify_stubbings
|
86
|
+
assert_equal "true", doc.at_xpath("/response/success").content
|
87
|
+
end
|
88
|
+
|
89
|
+
it "insert_listing" do
|
90
|
+
http_stubs.post("/insertListing?apiToken=#{fake_token}§ion=504") {[http_success_code, default_headers, success_response]}
|
91
|
+
|
92
|
+
attrs = {
|
93
|
+
ticketId: 201572363,
|
94
|
+
eventName: "Sample event",
|
95
|
+
venueName: "Sample venue",
|
96
|
+
eventDateTime: Time.now.iso8601,
|
97
|
+
quantity: 4,
|
98
|
+
section: 504,
|
99
|
+
row: 4,
|
100
|
+
price: 80.49
|
101
|
+
}
|
102
|
+
doc = client.insert_listing(attrs)
|
103
|
+
|
104
|
+
http_stubs.verify_stubbed_calls if verify_stubbings
|
105
|
+
assert_equal "true", doc.at_xpath("/response/success").content
|
106
|
+
end
|
107
|
+
|
108
|
+
it "insert or update" do
|
109
|
+
http_stubs.post("/insertOrUpdateListing?apiToken=#{fake_token}§ion=504") {[http_success_code, default_headers, success_response]}
|
110
|
+
|
111
|
+
attrs = {
|
112
|
+
ticketId: 201572363,
|
113
|
+
eventName: "Sample event",
|
114
|
+
venueName: "Sample venue",
|
115
|
+
eventDateTime: Time.now.iso8601,
|
116
|
+
quantity: 4,
|
117
|
+
section: 504,
|
118
|
+
row: 4,
|
119
|
+
price: 80.49
|
120
|
+
}
|
121
|
+
doc = client.insert_or_update_listing(attrs)
|
122
|
+
|
123
|
+
http_stubs.verify_stubbed_calls if verify_stubbings
|
124
|
+
assert_equal "true", doc.at_xpath("/response/success").content
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vivid_seat_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vivid-seat-api"
|
8
|
+
spec.version = VividSeatApi::VERSION
|
9
|
+
spec.authors = ["chebyte"]
|
10
|
+
spec.email = ["mauro@hashdog.com"]
|
11
|
+
spec.summary = %q{Ruby Gem API for vividseats.com.}
|
12
|
+
spec.description = %q{This gem provides access to add, edit and delete listings appearing on Vivid Seats and it’s affiliates.}
|
13
|
+
spec.homepage = "http://hashdog.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency 'rake', '~> 0'
|
23
|
+
spec.add_runtime_dependency 'faraday', '~> 0.9', '>= 0.9.0'
|
24
|
+
spec.add_runtime_dependency 'json', '~> 1.8.1', '>= 1.8.1'
|
25
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.6.1', '>= 1.6.1'
|
26
|
+
spec.add_dependency 'scrivener', '0.3.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vivid-seat-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chebyte
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-19 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.9.0
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.9'
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.9.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: json
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.8.1
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.8.1
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.1
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.8.1
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: nokogiri
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.6.1
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.6.1
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.6.1
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.6.1
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: scrivener
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 0.3.0
|
108
|
+
type: :runtime
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 0.3.0
|
115
|
+
description: This gem provides access to add, edit and delete listings appearing on
|
116
|
+
Vivid Seats and it’s affiliates.
|
117
|
+
email:
|
118
|
+
- mauro@hashdog.com
|
119
|
+
executables: []
|
120
|
+
extensions: []
|
121
|
+
extra_rdoc_files: []
|
122
|
+
files:
|
123
|
+
- .gitignore
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- lib/vivid_seat_api.rb
|
129
|
+
- lib/vivid_seat_api/base.rb
|
130
|
+
- lib/vivid_seat_api/fulfillment.rb
|
131
|
+
- lib/vivid_seat_api/listing.rb
|
132
|
+
- lib/vivid_seat_api/response.rb
|
133
|
+
- lib/vivid_seat_api/upload_filter.rb
|
134
|
+
- lib/vivid_seat_api/version.rb
|
135
|
+
- test/fulfillment_spec.rb
|
136
|
+
- test/helper.rb
|
137
|
+
- test/listing_spec.rb
|
138
|
+
- vivid_seat_api.gemspec
|
139
|
+
homepage: http://hashdog.com
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.2.2
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Ruby Gem API for vividseats.com.
|
163
|
+
test_files:
|
164
|
+
- test/fulfillment_spec.rb
|
165
|
+
- test/helper.rb
|
166
|
+
- test/listing_spec.rb
|