tiqets 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +5 -0
- data/README.md +28 -4
- data/lib/tiqets.rb +7 -1
- data/lib/tiqets/client.rb +33 -0
- data/lib/tiqets/error.rb +18 -0
- data/lib/tiqets/resources/product.rb +41 -0
- data/lib/tiqets/version.rb +1 -1
- data/tiqets.gemspec +5 -1
- metadata +50 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a9128f0eeb3fe9c16aa58845a7e4b718cbd323
|
4
|
+
data.tar.gz: d4a69be377f0f1466f6b18820ba2d47c74d3f23e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca4a3bac7a153c4564ecf7caac312aa03d8592903bb11dd187bceeec7592adeac112df59dcd81b20fab685a5486563a2c234eb0aac1d22db719af317e784465
|
7
|
+
data.tar.gz: 598997ab957416a90145790dc88a5944c45e83a382819a6d04a3ddd7bff2e7e0969fd6d4b9750e37e161532a38afb64ddae78751b5d7a514a7482131b09e0ca2
|
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
# Tiqets
|
1
|
+
# 🎢 Tiqets
|
2
2
|
|
3
|
-
|
3
|
+
A simple (unofficial) Ruby wrapper for the [Tiqets](https://www.tiqets.com) [API](https://api.tiqets.com/v2/docs/).
|
4
4
|
|
5
|
-
|
5
|
+
[![Travis CI status](https://img.shields.io/travis/richardvenneman/tiqets.svg?style=flat-square)](https://travis-ci.org/richardvenneman/tiqets)
|
6
|
+
[![RubyGem](https://img.shields.io/gem/v/tiqets.svg?style=flat-square)](https://rubygems.org/gems/tiqets)
|
7
|
+
|
8
|
+
|
9
|
+
Full 100% API coverage is not a direct goal as we're primarily developing this for our needs at [CitySpotters](https://www.cityspotters.com). Pull requests are definitely welcome.
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -22,7 +26,27 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
You must be in possession of a Tiqets API key. Use this key to initialize a new API client:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
@client = Tiqets::Client.new(api_key: 'my-api-key')
|
33
|
+
```
|
34
|
+
|
35
|
+
Alternatively you can set the `TIQETS_API_KEY` environment variable and use the shared API instance with:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
@client = Tiqets.default_api
|
39
|
+
```
|
40
|
+
|
41
|
+
### Products
|
42
|
+
|
43
|
+
#### Get a single product
|
44
|
+
Finds a product by Product ID. Returns an object with the properties [described in the API documentation](https://api.tiqets.com/v2/docs/#the-product-object).
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
@client.find_product(973698)
|
48
|
+
# => #<Tiqets::Resources::Product::Product:0x007fe9c8438a00>
|
49
|
+
```
|
26
50
|
|
27
51
|
## Contributing
|
28
52
|
|
data/lib/tiqets.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
|
3
|
+
require 'tiqets/resources/product'
|
4
|
+
|
5
|
+
module Tiqets
|
6
|
+
class Client
|
7
|
+
include Resources::Product
|
8
|
+
|
9
|
+
V2_ROOT = 'https://api.tiqets.com/v2/'.freeze
|
10
|
+
|
11
|
+
def initialize(root: V2_ROOT, api_key:)
|
12
|
+
@root = root
|
13
|
+
@api_key = api_key
|
14
|
+
end
|
15
|
+
|
16
|
+
def connection
|
17
|
+
@connection ||= HTTP.auth("Authorization: Token #{@api_key}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(url, response_key)
|
21
|
+
response = connection.get(@root + url)
|
22
|
+
|
23
|
+
handle_response(response, response_key)
|
24
|
+
end
|
25
|
+
|
26
|
+
def handle_response(response, response_key)
|
27
|
+
response = JSON.parse(response)
|
28
|
+
return response[response_key] if response['success'] == true
|
29
|
+
|
30
|
+
raise Error.new(response['status'], response['message'])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/tiqets/error.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Tiqets
|
2
|
+
class Error < Exception
|
3
|
+
attr_reader :code, :error
|
4
|
+
|
5
|
+
def initialize(code, error)
|
6
|
+
@code = code
|
7
|
+
@error = error
|
8
|
+
|
9
|
+
super(message)
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
message = "Tiqets API Error: #{@error}"
|
14
|
+
message += " (code: #{@code})" unless @code.nil?
|
15
|
+
message
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Tiqets
|
2
|
+
module Resources
|
3
|
+
module Product
|
4
|
+
SLUG = 'products'.freeze
|
5
|
+
|
6
|
+
def find_product(id)
|
7
|
+
response = get("products/#{id}", 'product')
|
8
|
+
Product.new(response)
|
9
|
+
end
|
10
|
+
|
11
|
+
class Product
|
12
|
+
attr_reader :id, :language, :languages, :title, :tagline, :price,
|
13
|
+
:sale_status, :country_name, :country_id, :city_name,
|
14
|
+
:city_id, :tag_ids, :images, :ratings, :geolocation,
|
15
|
+
:distance, :venue, :product_url, :product_checkout_url
|
16
|
+
|
17
|
+
def initialize(attributes)
|
18
|
+
@id = attributes['id']
|
19
|
+
@language = attributes['language']
|
20
|
+
@languages = attributes['languages']
|
21
|
+
@title = attributes['title']
|
22
|
+
@tagline = attributes['tagline']
|
23
|
+
@price = attributes['price']
|
24
|
+
@sale_status = attributes['sale_status']
|
25
|
+
@country_name = attributes['country_name']
|
26
|
+
@country_id = attributes['country_id']
|
27
|
+
@city_name = attributes['city_name']
|
28
|
+
@city_id = attributes['city_id']
|
29
|
+
@tag_ids = attributes['tag_ids']
|
30
|
+
@images = attributes['images']
|
31
|
+
@ratings = attributes['ratings']
|
32
|
+
@geolocation = attributes['geolocation']
|
33
|
+
@distance = attributes['distance']
|
34
|
+
@venue = attributes['venue']
|
35
|
+
@product_url = attributes['product_url']
|
36
|
+
@product_checkout_url = attributes['product_checkout_url']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/tiqets/version.rb
CHANGED
data/tiqets.gemspec
CHANGED
@@ -20,7 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
end
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
+
spec.add_runtime_dependency 'http', '~> 2'
|
24
|
+
|
23
25
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
26
|
+
spec.add_development_dependency 'guard', '~> 2'
|
27
|
+
spec.add_development_dependency 'guard-minitest', '~> 2'
|
24
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
-
spec.add_development_dependency '
|
29
|
+
spec.add_development_dependency 'webmock', '~> 3.0'
|
26
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiqets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Venneman
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,34 @@ dependencies:
|
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: rake
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +81,19 @@ dependencies:
|
|
39
81
|
- !ruby/object:Gem::Version
|
40
82
|
version: '10.0'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
84
|
+
name: webmock
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
44
86
|
requirements:
|
45
87
|
- - "~>"
|
46
88
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
89
|
+
version: '3.0'
|
48
90
|
type: :development
|
49
91
|
prerelease: false
|
50
92
|
version_requirements: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
94
|
- - "~>"
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
96
|
+
version: '3.0'
|
55
97
|
description: Ruby Tiqets API wrapper.
|
56
98
|
email:
|
57
99
|
- richardvenneman@me.com
|
@@ -63,12 +105,16 @@ files:
|
|
63
105
|
- ".ruby-version"
|
64
106
|
- ".travis.yml"
|
65
107
|
- Gemfile
|
108
|
+
- Guardfile
|
66
109
|
- LICENSE.txt
|
67
110
|
- README.md
|
68
111
|
- Rakefile
|
69
112
|
- bin/console
|
70
113
|
- bin/setup
|
71
114
|
- lib/tiqets.rb
|
115
|
+
- lib/tiqets/client.rb
|
116
|
+
- lib/tiqets/error.rb
|
117
|
+
- lib/tiqets/resources/product.rb
|
72
118
|
- lib/tiqets/version.rb
|
73
119
|
- tiqets.gemspec
|
74
120
|
homepage: https://github.com/richardvenneman/tiqets
|