flyticket 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +32 -36
- data/flyticket.gemspec +0 -1
- data/lib/flyticket.rb +4 -4
- data/lib/flyticket/Changelog.md +11 -0
- data/lib/flyticket/endpoint.rb +26 -5
- data/lib/flyticket/ticketfly_error.rb +21 -0
- data/lib/flyticket/util.rb +12 -0
- data/lib/flyticket/version.rb +1 -1
- metadata +5 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 186c7f03815762991f5fa89d04bea543912b8239
|
|
4
|
+
data.tar.gz: d6411ae46181b2a624e196f7d20f1772ca4968e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b099140a4f06e5d3b0806e268d374a28ab2f892c552cefa4eaeb8b2bd16ad71d3f388a0b97de291d06ae9f714473b5924546acc2b7a0fb69b9fa5eea8c899def
|
|
7
|
+
data.tar.gz: 8829e46170d8392537d74b54bcf690c1e8517e7d3fc70a9392ca05cc9a6582e78a338cd587ea4dfea8df3ae2487f9cfedda572cfcdee2640aba22a92f22cda28
|
data/README.md
CHANGED
|
@@ -3,62 +3,58 @@
|
|
|
3
3
|
A Ruby gem for communicating with the [Ticketfly REST API](http://start.ticketfly.com/api/), built
|
|
4
4
|
on [HTTParty](https://github.com/jnunemaker/httparty).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
gem 'flyticket'
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
And then execute:
|
|
15
|
-
|
|
16
|
-
$ bundle
|
|
17
|
-
|
|
18
|
-
Or install it yourself as:
|
|
19
|
-
|
|
20
|
-
$ gem install flyticket
|
|
6
|
+
I want to hear from you! Let me know if you're finding Flyticket useful, or if
|
|
7
|
+
you have suggestions on what would make it useful for your project. I'm
|
|
8
|
+
currently using it to develop a new website for a Ticketfly "org" so my use case
|
|
9
|
+
is pretty narrow. I just wanted a nice wrapper for the API, and the gems I
|
|
10
|
+
looked at were defunct.
|
|
21
11
|
|
|
22
12
|
## Example Usage
|
|
23
13
|
|
|
24
14
|
Flyticket is still a work in progress, however, to query for events,
|
|
25
15
|
use it like so:
|
|
26
16
|
|
|
17
|
+
```ruby
|
|
18
|
+
past = Flyticket::Events.past(venue_id: 1, max_results: 3)
|
|
19
|
+
past.first.facebook_event_id # --> FB event id for this venue's last show
|
|
27
20
|
```
|
|
28
|
-
upcoming = Flyticket::Events.upcoming(venueId: 1, maxResults: 3)
|
|
29
|
-
upcoming.first.venue.name # --> 'Brooklyn Bowl'
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
Flyticket is opinionated about the result format -- it discards Ticketfly's
|
|
23
|
+
outer wrapper (used for pagination) and converts the top-level event hashes into
|
|
24
|
+
OpenStructs, as well as the nested org and venue hashes, but leaves deeper
|
|
25
|
+
properties as hashes. Thus retrieving a deeply-nested attributes looks like
|
|
26
|
+
this:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
next_event = Flyticket::Events.upcoming(venue_id: 1, max_results: 1).first
|
|
30
|
+
next_event.image[:medium][:width] # --> 'Brooklyn Bowl'
|
|
31
|
+
|
|
32
|
+
upcoming = Flyticket::Events.upcoming(venue_id: 1, max_results: 3)
|
|
33
|
+
upcoming.first.venue.name # --> 'Brooklyn Bowl'
|
|
33
34
|
```
|
|
34
35
|
|
|
36
|
+
Note how in the first example, `image` is a method, but deeper properties are
|
|
37
|
+
accessed using hash keys. In the second example, because `venue` is a struct,
|
|
38
|
+
the venue name can be accessed using a method (although `[:name]` works too]).
|
|
39
|
+
|
|
35
40
|
#### Some useful properties:
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* org_id
|
|
42
|
+
* venue_id
|
|
43
|
+
* event_id
|
|
44
|
+
* max_results (capped by TicketFly at 1000)
|
|
45
|
+
* page_num (use when total results > max_results)
|
|
46
|
+
* from_date
|
|
47
|
+
* thru_date
|
|
43
48
|
|
|
44
49
|
## Notes
|
|
45
50
|
|
|
46
|
-
I haven't committed to an API just yet and won't attempt semantic versioning
|
|
47
|
-
until I do.
|
|
51
|
+
I haven't committed to an API just yet and won't attempt semantic versioning until I do.
|
|
48
52
|
|
|
49
53
|
#### TODO
|
|
50
|
-
* [ ] use snake case for options
|
|
51
|
-
* [ ] handle error response
|
|
52
54
|
* [ ] make original json available
|
|
53
55
|
* [ ] handle fields & fieldGroup
|
|
54
56
|
* [ ] specs
|
|
55
57
|
|
|
56
|
-
## Development
|
|
57
|
-
|
|
58
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
59
|
-
|
|
60
|
-
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).
|
|
61
|
-
|
|
62
58
|
## Contributing
|
|
63
59
|
|
|
64
60
|
Bug reports and pull requests are welcome on GitHub at https://github.com/johncip/flyticket.
|
data/flyticket.gemspec
CHANGED
|
@@ -36,7 +36,6 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
# racing stripes
|
|
37
37
|
spec.add_development_dependency "pry", "~> 0.10"
|
|
38
38
|
spec.add_development_dependency "pry-coolline", "~> 0.2"
|
|
39
|
-
spec.add_development_dependency "awesome_print", "~> 1.6"
|
|
40
39
|
|
|
41
40
|
spec.add_runtime_dependency "plissken", "~> 0.2"
|
|
42
41
|
spec.add_runtime_dependency "httparty", "~> 0.13"
|
data/lib/flyticket.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'ostruct'
|
|
2
|
+
|
|
2
3
|
require 'flyticket/events'
|
|
3
4
|
require 'flyticket/venues'
|
|
4
5
|
require 'flyticket/orgs'
|
|
6
|
+
require 'flyticket/version'
|
|
5
7
|
|
|
6
|
-
#
|
|
7
|
-
require 'ostruct'
|
|
8
|
-
|
|
8
|
+
# Monkey-patch OStruct to prevent original JSON from being included.
|
|
9
9
|
class OpenStruct
|
|
10
10
|
def as_json(options = nil)
|
|
11
11
|
@table.as_json(options)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
### 0.1.2 / February 28, 2016
|
|
2
|
+
|
|
3
|
+
* Add support for snake_case query arguments
|
|
4
|
+
* Implement error class
|
|
5
|
+
* Removed awesome_print from development dependencies
|
|
6
|
+
* Add deep attribute example to readme
|
|
7
|
+
* Added this changelog
|
|
8
|
+
|
|
9
|
+
### 0.1.1 / February 7, 2016
|
|
10
|
+
|
|
11
|
+
* Initial release
|
data/lib/flyticket/endpoint.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# TODO: handle error response
|
|
2
1
|
# TODO: handle fields & fieldGroup
|
|
3
2
|
# TODO: make original response available
|
|
4
3
|
# TODO: specs
|
|
@@ -7,26 +6,41 @@ require 'httparty'
|
|
|
7
6
|
require 'ostruct'
|
|
8
7
|
require 'plissken'
|
|
9
8
|
|
|
9
|
+
require 'flyticket/ticketfly_error'
|
|
10
|
+
require 'flyticket/util'
|
|
11
|
+
|
|
10
12
|
module Flyticket
|
|
11
13
|
class Endpoint
|
|
12
14
|
include HTTParty
|
|
13
15
|
|
|
16
|
+
# Returns the key used to get the list of entries from Ticketfly's response.
|
|
14
17
|
def self.key
|
|
15
18
|
base_uri.split('/').last
|
|
16
19
|
end
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
# Gets a single event
|
|
22
|
+
def self.get_many(fragment, options)
|
|
23
|
+
response = get fragment, query: query_string(options)
|
|
24
|
+
|
|
25
|
+
handle_error(response)
|
|
20
26
|
response[key].map { |hash| objectify(hash) }
|
|
21
27
|
end
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
# Gets a single event
|
|
30
|
+
def self.get_one(fragment, options)
|
|
31
|
+
response = get fragment, query: query_string(options)
|
|
32
|
+
|
|
33
|
+
handle_error(response)
|
|
25
34
|
objectify response[key].first
|
|
26
35
|
end
|
|
27
36
|
|
|
28
37
|
private
|
|
29
38
|
|
|
39
|
+
# Camelcases the given options hash.
|
|
40
|
+
def self.query_string(options)
|
|
41
|
+
options.map { |k, v| [Util.camelize(k, false), v] }.to_h
|
|
42
|
+
end
|
|
43
|
+
|
|
30
44
|
# Converts keys to snake case, then "semi-recursively" converts to OpenStruct.
|
|
31
45
|
def self.objectify(hash)
|
|
32
46
|
hash = hash.to_snake_keys
|
|
@@ -41,5 +55,12 @@ module Flyticket
|
|
|
41
55
|
return unless hash.has_key? key
|
|
42
56
|
hash[key] = OpenStruct.new(hash[key])
|
|
43
57
|
end
|
|
58
|
+
|
|
59
|
+
# Raises an error if the response indicates a problem.
|
|
60
|
+
def self.handle_error
|
|
61
|
+
if response['status'] == 'error'
|
|
62
|
+
raise TicketflyError.new(response)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
44
65
|
end
|
|
45
66
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Flyticket
|
|
2
|
+
class TicketflyError < StandardError
|
|
3
|
+
attr_reader :response
|
|
4
|
+
|
|
5
|
+
def initialize(response)
|
|
6
|
+
@response = response
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def code
|
|
10
|
+
response['code']
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def error_message
|
|
14
|
+
response['codeError']
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to_s
|
|
18
|
+
response.pretty_inspect
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Flyticket
|
|
2
|
+
class Util
|
|
3
|
+
# Adapted an old version of ActiveSupport.
|
|
4
|
+
def self.camelize(term, first_letter_in_uppercase = true)
|
|
5
|
+
if first_letter_in_uppercase
|
|
6
|
+
term.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
|
7
|
+
else
|
|
8
|
+
term[0] + camelize(term)[1..-1]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/flyticket/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flyticket
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Cipriano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-02-
|
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -94,20 +94,6 @@ dependencies:
|
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0.2'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: awesome_print
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - "~>"
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '1.6'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - "~>"
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '1.6'
|
|
111
97
|
- !ruby/object:Gem::Dependency
|
|
112
98
|
name: plissken
|
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -153,9 +139,12 @@ files:
|
|
|
153
139
|
- bin/setup
|
|
154
140
|
- flyticket.gemspec
|
|
155
141
|
- lib/flyticket.rb
|
|
142
|
+
- lib/flyticket/Changelog.md
|
|
156
143
|
- lib/flyticket/endpoint.rb
|
|
157
144
|
- lib/flyticket/events.rb
|
|
158
145
|
- lib/flyticket/orgs.rb
|
|
146
|
+
- lib/flyticket/ticketfly_error.rb
|
|
147
|
+
- lib/flyticket/util.rb
|
|
159
148
|
- lib/flyticket/venues.rb
|
|
160
149
|
- lib/flyticket/version.rb
|
|
161
150
|
homepage: https://github.com/johncip/flyticket
|