thrillcall-api 0.0.6 → 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.
- data/lib/thrillcall-api.rb +50 -4
- data/lib/thrillcall-api/result.rb +6 -2
- data/lib/thrillcall-api/version.rb +1 -1
- metadata +25 -24
- data/.autotest +0 -10
- data/.gitignore +0 -10
- data/.rspec +0 -4
- data/.rvmrc +0 -2
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -64
- data/README.md +0 -1389
- data/Rakefile +0 -12
- data/autotest/discover.rb +0 -1
- data/docs/API.html +0 -1526
- data/docs/API.md +0 -1272
- data/docs/README.html +0 -1646
- data/docs/WRAPPER.html +0 -182
- data/docs/WRAPPER.md +0 -115
- data/script/convert_readme.rb +0 -119
- data/spec/spec_helper.rb +0 -11
- data/spec/thrillcall-api/thrillcall-api_spec.rb +0 -688
- data/thrillcall-api.gemspec +0 -36
data/docs/WRAPPER.html
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
|
2
|
-
<style type="text/css">
|
3
|
-
.highlight .hll { background-color: #ffffcc }
|
4
|
-
.highlight { background: #dddddd; }
|
5
|
-
.highlight .c { color: #408080; font-style: italic } /* Comment */
|
6
|
-
.highlight .err { border: 1px solid #FF0000 } /* Error */
|
7
|
-
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
|
8
|
-
.highlight .o { color: #666666 } /* Operator */
|
9
|
-
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
10
|
-
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
|
11
|
-
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
12
|
-
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
|
13
|
-
.highlight .gd { color: #A00000 } /* Generic.Deleted */
|
14
|
-
.highlight .ge { font-style: italic } /* Generic.Emph */
|
15
|
-
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
16
|
-
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
17
|
-
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
18
|
-
.highlight .go { color: #808080 } /* Generic.Output */
|
19
|
-
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
20
|
-
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
21
|
-
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
22
|
-
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
|
23
|
-
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
24
|
-
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
25
|
-
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
26
|
-
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
|
27
|
-
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
28
|
-
.highlight .kt { color: #B00040 } /* Keyword.Type */
|
29
|
-
.highlight .m { color: #666666 } /* Literal.Number */
|
30
|
-
.highlight .s { color: #BA2121 } /* Literal.String */
|
31
|
-
.highlight .na { color: #7D9029 } /* Name.Attribute */
|
32
|
-
.highlight .nb { color: #008000 } /* Name.Builtin */
|
33
|
-
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
34
|
-
.highlight .no { color: #880000 } /* Name.Constant */
|
35
|
-
.highlight .nd { color: #AA22FF } /* Name.Decorator */
|
36
|
-
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
37
|
-
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
38
|
-
.highlight .nf { color: #0000FF } /* Name.Function */
|
39
|
-
.highlight .nl { color: #A0A000 } /* Name.Label */
|
40
|
-
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
41
|
-
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
|
42
|
-
.highlight .nv { color: #19177C } /* Name.Variable */
|
43
|
-
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
44
|
-
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
45
|
-
.highlight .mf { color: #666666 } /* Literal.Number.Float */
|
46
|
-
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
|
47
|
-
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
|
48
|
-
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
|
49
|
-
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
|
50
|
-
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
|
51
|
-
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
52
|
-
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
|
53
|
-
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
54
|
-
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
|
55
|
-
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
56
|
-
.highlight .sx { color: #008000 } /* Literal.String.Other */
|
57
|
-
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
|
58
|
-
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
|
59
|
-
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
|
60
|
-
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
|
61
|
-
.highlight .vc { color: #19177C } /* Name.Variable.Class */
|
62
|
-
.highlight .vg { color: #19177C } /* Name.Variable.Global */
|
63
|
-
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
|
64
|
-
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
|
65
|
-
</style><h1>Thrillcall API</h1>
|
66
|
-
|
67
|
-
<p>This document describes the Thrillcall API v3, and usage for the provided Ruby API wrapper gem.</p>
|
68
|
-
|
69
|
-
<h1>Ruby API Wrapper</h1>
|
70
|
-
|
71
|
-
<h3>Usage:</h3>
|
72
|
-
|
73
|
-
<div class="highlight">
|
74
|
-
<pre> <span class="c1">#---------------------------------------------------------------#</span>
|
75
|
-
<span class="c1"># First, require the gem:</span>
|
76
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
77
|
-
<span class="nb">require</span> <span class="s1">'rubygems'</span>
|
78
|
-
<span class="nb">require</span> <span class="s1">'thrillcall-api'</span>
|
79
|
-
|
80
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
81
|
-
<span class="c1"># Instantiate with your Thrillcall API key:</span>
|
82
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
83
|
-
<span class="no">MY_API_KEY</span> <span class="o">=</span> <span class="s2">"1234567890abcdef"</span>
|
84
|
-
<span class="n">tc</span> <span class="o">=</span> <span class="no">ThrillcallAPI</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="no">MY_API_KEY</span><span class="p">)</span>
|
85
|
-
|
86
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
87
|
-
<span class="c1"># Access any endpoint directly from the instance</span>
|
88
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
89
|
-
<span class="c1"># This is like calling GET "/events"</span>
|
90
|
-
<span class="n">tc</span><span class="o">.</span><span class="n">events</span>
|
91
|
-
<span class="c1"># => [ {"id" => ... }, {...}, ...]</span>
|
92
|
-
|
93
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
94
|
-
<span class="c1"># Provide IDs as arguments</span>
|
95
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
96
|
-
<span class="c1"># GET "/event/1"</span>
|
97
|
-
<span class="n">tc</span><span class="o">.</span><span class="n">event</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
98
|
-
<span class="c1"># => {"id" => 1, ...}</span>
|
99
|
-
|
100
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
101
|
-
<span class="c1"># Provide parameters as arguments</span>
|
102
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
103
|
-
<span class="c1"># GET "/events?limit=5"</span>
|
104
|
-
<span class="n">events</span> <span class="o">=</span> <span class="n">tc</span><span class="o">.</span><span class="n">events</span><span class="p">(</span><span class="ss">:limit</span> <span class="o">=></span> <span class="mi">5</span><span class="p">)</span>
|
105
|
-
<span class="c1"># => [ {"id" => ... }, {...}, ...]</span>
|
106
|
-
<span class="n">events</span><span class="o">.</span><span class="n">length</span>
|
107
|
-
<span class="c1"># => 5</span>
|
108
|
-
|
109
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
110
|
-
<span class="c1"># Chain methods together for nested routes</span>
|
111
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
112
|
-
<span class="c1"># GET "/search/venues/warfield?postalcode=94101&radius=20"</span>
|
113
|
-
<span class="n">venues</span> <span class="o">=</span> <span class="n">tc</span><span class="o">.</span><span class="n">search</span><span class="o">.</span><span class="n">venues</span><span class="p">(</span><span class="s2">"warfield"</span><span class="p">,</span> <span class="ss">:postalcode</span> <span class="o">=></span> <span class="s2">"94101"</span><span class="p">,</span> <span class="ss">:radius</span> <span class="o">=></span> <span class="mi">20</span><span class="p">)</span>
|
114
|
-
<span class="c1"># => [{"name" => "The Warfield", ...}]</span>
|
115
|
-
</pre>
|
116
|
-
</div>
|
117
|
-
|
118
|
-
|
119
|
-
<h3>Advanced Usage:</h3>
|
120
|
-
|
121
|
-
<p>Provide additional instantiation options:</p>
|
122
|
-
|
123
|
-
<div class="highlight">
|
124
|
-
<pre> <span class="c1">#---------------------------------------------------------------#</span>
|
125
|
-
<span class="c1"># The default SSL endpoint is "https://api.thrillcall.com/api/".</span>
|
126
|
-
<span class="c1"># The default API version is 3.</span>
|
127
|
-
<span class="c1"># By default, Faraday access logging is turned off.</span>
|
128
|
-
<span class="c1"># Override if necessary:</span>
|
129
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
130
|
-
<span class="n">tc</span> <span class="o">=</span> <span class="no">ThrillcallAPI</span><span class="o">.</span><span class="n">new</span><span class="p">(</span>
|
131
|
-
<span class="no">MY_API_KEY</span><span class="p">,</span>
|
132
|
-
<span class="ss">:base_url</span> <span class="o">=></span> <span class="s2">"https://api.thrillcall.com/custom/"</span><span class="p">,</span>
|
133
|
-
<span class="ss">:version</span> <span class="o">=></span> <span class="mi">3</span><span class="p">,</span>
|
134
|
-
<span class="ss">:logger</span> <span class="o">=></span> <span class="kp">true</span>
|
135
|
-
<span class="p">)</span>
|
136
|
-
</pre>
|
137
|
-
</div>
|
138
|
-
|
139
|
-
|
140
|
-
<p>Internally, the wrapper returns a ThrillcallAPI::Result class for any call. Data for the request is fetched only when used. This allows you to build requests piecemeal before executing them.</p>
|
141
|
-
|
142
|
-
<div class="highlight">
|
143
|
-
<pre> <span class="c1">#---------------------------------------------------------------#</span>
|
144
|
-
<span class="c1"># Build a partial request, add on to it later</span>
|
145
|
-
<span class="c1">#---------------------------------------------------------------#</span>
|
146
|
-
<span class="n">request</span> <span class="o">=</span> <span class="n">tc</span><span class="o">.</span><span class="n">artist</span><span class="p">(</span><span class="mi">22210</span><span class="p">)</span> <span class="c1"># Lady Gaga</span>
|
147
|
-
|
148
|
-
<span class="c1"># GET "/artist/22210/events?limit=2"</span>
|
149
|
-
<span class="n">artist_events</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">events</span><span class="p">(</span><span class="ss">:limit</span> <span class="o">=></span> <span class="mi">2</span><span class="p">)</span>
|
150
|
-
|
151
|
-
<span class="n">artist_events</span><span class="o">.</span><span class="n">length</span>
|
152
|
-
<span class="c1"># => 2</span>
|
153
|
-
</pre>
|
154
|
-
</div>
|
155
|
-
|
156
|
-
|
157
|
-
<p>This gem is a convenience wrapper around the excellent Faraday project. If more complicated use cases are necessary, consider using Faraday directly.</p>
|
158
|
-
|
159
|
-
<div class="highlight">
|
160
|
-
<pre> <span class="nb">require</span> <span class="s1">'faraday'</span>
|
161
|
-
<span class="nb">require</span> <span class="s1">'json'</span>
|
162
|
-
|
163
|
-
<span class="no">MY_API_KEY</span> <span class="o">=</span> <span class="s2">"1234567890abcdef"</span>
|
164
|
-
<span class="no">BASE_URL</span> <span class="o">=</span> <span class="s2">"https://api.thrillcall.com/api/v3/"</span>
|
165
|
-
<span class="no">HEADERS</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">:accept</span> <span class="o">=></span> <span class="s1">'application/json'</span> <span class="p">}</span>
|
166
|
-
|
167
|
-
<span class="n">connection</span> <span class="o">=</span> <span class="no">Faraday</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> <span class="ss">:url</span> <span class="o">=></span> <span class="no">BASE_URL</span><span class="p">,</span> <span class="ss">:headers</span> <span class="o">=></span> <span class="no">HEADERS</span> <span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">builder</span><span class="o">|</span>
|
168
|
-
<span class="n">builder</span><span class="o">.</span><span class="n">adapter</span> <span class="no">Faraday</span><span class="o">.</span><span class="n">default_adapter</span>
|
169
|
-
<span class="n">builder</span><span class="o">.</span><span class="n">response</span> <span class="ss">:logger</span>
|
170
|
-
<span class="n">builder</span><span class="o">.</span><span class="n">response</span> <span class="ss">:raise_error</span>
|
171
|
-
<span class="k">end</span>
|
172
|
-
|
173
|
-
<span class="n">request</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">get</span> <span class="k">do</span> <span class="o">|</span><span class="n">req</span><span class="o">|</span>
|
174
|
-
<span class="n">req</span><span class="o">.</span><span class="n">url</span> <span class="s2">"artist/22210"</span><span class="p">,</span> <span class="p">{</span> <span class="ss">:api_key</span> <span class="o">=></span> <span class="no">MY_API_KEY</span> <span class="p">}</span>
|
175
|
-
<span class="k">end</span>
|
176
|
-
|
177
|
-
<span class="n">artist</span> <span class="o">=</span> <span class="no">JSON</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">body</span><span class="p">)</span>
|
178
|
-
|
179
|
-
<span class="n">artist</span><span class="o">[</span><span class="s2">"name"</span><span class="o">]</span>
|
180
|
-
<span class="c1"># => "Lady Gaga"</span>
|
181
|
-
</pre>
|
182
|
-
</div>
|
data/docs/WRAPPER.md
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
# Thrillcall API
|
2
|
-
This document describes the Thrillcall API v3, and usage for the provided Ruby API wrapper gem.
|
3
|
-
|
4
|
-
# Ruby API Wrapper
|
5
|
-
### Usage:
|
6
|
-
|
7
|
-
``` ruby
|
8
|
-
#---------------------------------------------------------------#
|
9
|
-
# First, require the gem:
|
10
|
-
#---------------------------------------------------------------#
|
11
|
-
require 'rubygems'
|
12
|
-
require 'thrillcall-api'
|
13
|
-
|
14
|
-
#---------------------------------------------------------------#
|
15
|
-
# Instantiate with your Thrillcall API key:
|
16
|
-
#---------------------------------------------------------------#
|
17
|
-
MY_API_KEY = "1234567890abcdef"
|
18
|
-
tc = ThrillcallAPI.new(MY_API_KEY)
|
19
|
-
|
20
|
-
#---------------------------------------------------------------#
|
21
|
-
# Access any endpoint directly from the instance
|
22
|
-
#---------------------------------------------------------------#
|
23
|
-
# This is like calling GET "/events"
|
24
|
-
tc.events
|
25
|
-
# => [ {"id" => ... }, {...}, ...]
|
26
|
-
|
27
|
-
#---------------------------------------------------------------#
|
28
|
-
# Provide IDs as arguments
|
29
|
-
#---------------------------------------------------------------#
|
30
|
-
# GET "/event/1"
|
31
|
-
tc.event(1)
|
32
|
-
# => {"id" => 1, ...}
|
33
|
-
|
34
|
-
#---------------------------------------------------------------#
|
35
|
-
# Provide parameters as arguments
|
36
|
-
#---------------------------------------------------------------#
|
37
|
-
# GET "/events?limit=5"
|
38
|
-
events = tc.events(:limit => 5)
|
39
|
-
# => [ {"id" => ... }, {...}, ...]
|
40
|
-
events.length
|
41
|
-
# => 5
|
42
|
-
|
43
|
-
#---------------------------------------------------------------#
|
44
|
-
# Chain methods together for nested routes
|
45
|
-
#---------------------------------------------------------------#
|
46
|
-
# GET "/search/venues/warfield?postalcode=94101&radius=20"
|
47
|
-
venues = tc.search.venues("warfield", :postalcode => "94101", :radius => 20)
|
48
|
-
# => [{"name" => "The Warfield", ...}]
|
49
|
-
```
|
50
|
-
|
51
|
-
### Advanced Usage:
|
52
|
-
|
53
|
-
Provide additional instantiation options:
|
54
|
-
|
55
|
-
``` ruby
|
56
|
-
|
57
|
-
#---------------------------------------------------------------#
|
58
|
-
# The default SSL endpoint is "https://api.thrillcall.com/api/".
|
59
|
-
# The default API version is 3.
|
60
|
-
# By default, Faraday access logging is turned off.
|
61
|
-
# Override if necessary:
|
62
|
-
#---------------------------------------------------------------#
|
63
|
-
tc = ThrillcallAPI.new(
|
64
|
-
MY_API_KEY,
|
65
|
-
:base_url => "https://api.thrillcall.com/custom/",
|
66
|
-
:version => 3,
|
67
|
-
:logger => true
|
68
|
-
)
|
69
|
-
|
70
|
-
```
|
71
|
-
|
72
|
-
Internally, the wrapper returns a ThrillcallAPI::Result class for any call. Data for the request is fetched only when used. This allows you to build requests piecemeal before executing them.
|
73
|
-
|
74
|
-
``` ruby
|
75
|
-
|
76
|
-
#---------------------------------------------------------------#
|
77
|
-
# Build a partial request, add on to it later
|
78
|
-
#---------------------------------------------------------------#
|
79
|
-
request = tc.artist(22210) # Lady Gaga
|
80
|
-
|
81
|
-
# GET "/artist/22210/events?limit=2"
|
82
|
-
artist_events = request.events(:limit => 2)
|
83
|
-
|
84
|
-
artist_events.length
|
85
|
-
# => 2
|
86
|
-
|
87
|
-
```
|
88
|
-
|
89
|
-
This gem is a convenience wrapper around the excellent Faraday project. If more complicated use cases are necessary, consider using Faraday directly.
|
90
|
-
|
91
|
-
``` ruby
|
92
|
-
|
93
|
-
require 'faraday'
|
94
|
-
require 'json'
|
95
|
-
|
96
|
-
MY_API_KEY = "1234567890abcdef"
|
97
|
-
BASE_URL = "https://api.thrillcall.com/api/v3/"
|
98
|
-
HEADERS = { :accept => 'application/json' }
|
99
|
-
|
100
|
-
connection = Faraday.new( :url => BASE_URL, :headers => HEADERS ) do |builder|
|
101
|
-
builder.adapter Faraday.default_adapter
|
102
|
-
builder.response :logger
|
103
|
-
builder.response :raise_error
|
104
|
-
end
|
105
|
-
|
106
|
-
request = connection.get do |req|
|
107
|
-
req.url "artist/22210", { :api_key => MY_API_KEY }
|
108
|
-
end
|
109
|
-
|
110
|
-
artist = JSON.parse(request.body)
|
111
|
-
|
112
|
-
artist["name"]
|
113
|
-
# => "Lady Gaga"
|
114
|
-
|
115
|
-
```
|
data/script/convert_readme.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# USAGE:
|
4
|
-
# INSTALL FIRST! : You must have the Python Pygments lib installed
|
5
|
-
# before this will run. See : http://pygments.org/docs/installation/
|
6
|
-
#
|
7
|
-
# Install with:
|
8
|
-
#
|
9
|
-
# sudo easy_install Pygments
|
10
|
-
#
|
11
|
-
# Run me with : 'bundle install' and 'cd script' and 'bundle exec ruby convert_readme.rb'
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler'
|
15
|
-
Bundler.setup
|
16
|
-
Bundler.require(:development)
|
17
|
-
|
18
|
-
css = "
|
19
|
-
<style type='text/css'>
|
20
|
-
.highlight .hll { background-color: #ffffcc }
|
21
|
-
.highlight { background: #dddddd; }
|
22
|
-
.highlight .c { color: #408080; font-style: italic } /* Comment */
|
23
|
-
.highlight .err { border: 1px solid #FF0000 } /* Error */
|
24
|
-
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
|
25
|
-
.highlight .o { color: #666666 } /* Operator */
|
26
|
-
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
27
|
-
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
|
28
|
-
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
29
|
-
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
|
30
|
-
.highlight .gd { color: #A00000 } /* Generic.Deleted */
|
31
|
-
.highlight .ge { font-style: italic } /* Generic.Emph */
|
32
|
-
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
33
|
-
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
34
|
-
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
35
|
-
.highlight .go { color: #808080 } /* Generic.Output */
|
36
|
-
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
37
|
-
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
38
|
-
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
39
|
-
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
|
40
|
-
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
41
|
-
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
42
|
-
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
43
|
-
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
|
44
|
-
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
45
|
-
.highlight .kt { color: #B00040 } /* Keyword.Type */
|
46
|
-
.highlight .m { color: #666666 } /* Literal.Number */
|
47
|
-
.highlight .s { color: #BA2121 } /* Literal.String */
|
48
|
-
.highlight .na { color: #7D9029 } /* Name.Attribute */
|
49
|
-
.highlight .nb { color: #008000 } /* Name.Builtin */
|
50
|
-
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
51
|
-
.highlight .no { color: #880000 } /* Name.Constant */
|
52
|
-
.highlight .nd { color: #AA22FF } /* Name.Decorator */
|
53
|
-
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
54
|
-
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
55
|
-
.highlight .nf { color: #0000FF } /* Name.Function */
|
56
|
-
.highlight .nl { color: #A0A000 } /* Name.Label */
|
57
|
-
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
58
|
-
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
|
59
|
-
.highlight .nv { color: #19177C } /* Name.Variable */
|
60
|
-
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
61
|
-
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
62
|
-
.highlight .mf { color: #666666 } /* Literal.Number.Float */
|
63
|
-
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
|
64
|
-
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
|
65
|
-
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
|
66
|
-
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
|
67
|
-
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
|
68
|
-
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
69
|
-
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
|
70
|
-
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
71
|
-
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
|
72
|
-
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
73
|
-
.highlight .sx { color: #008000 } /* Literal.String.Other */
|
74
|
-
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
|
75
|
-
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
|
76
|
-
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
|
77
|
-
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
|
78
|
-
.highlight .vc { color: #19177C } /* Name.Variable.Class */
|
79
|
-
.highlight .vg { color: #19177C } /* Name.Variable.Global */
|
80
|
-
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
|
81
|
-
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
|
82
|
-
</style>
|
83
|
-
"
|
84
|
-
|
85
|
-
puts "Combining API.md and WRAPPER.md"
|
86
|
-
|
87
|
-
api = File.open(File.expand_path("../../docs/API.md", __FILE__)).read
|
88
|
-
wrapper = File.open(File.expand_path("../../docs/WRAPPER.md", __FILE__)).read
|
89
|
-
combined = wrapper + "\n\n" + api
|
90
|
-
|
91
|
-
File.open(File.expand_path("../../README.md", __FILE__),"w+") { |f|
|
92
|
-
f.write(combined)
|
93
|
-
}
|
94
|
-
|
95
|
-
convert = {
|
96
|
-
"API" => api,
|
97
|
-
"WRAPPER" => wrapper,
|
98
|
-
"README" => combined
|
99
|
-
}
|
100
|
-
|
101
|
-
convert.each do |name, doc|
|
102
|
-
rc = Redcarpet.new(doc, :fenced_code, :space_header, :gh_blockcode)
|
103
|
-
|
104
|
-
rc = css + rc.to_html
|
105
|
-
|
106
|
-
doc = Nokogiri::HTML.fragment(rc)
|
107
|
-
|
108
|
-
doc.search('pre').each do |node|
|
109
|
-
next unless lang = node['lang']
|
110
|
-
html = Albino.colorize(node.inner_text, lang)
|
111
|
-
node.replace(html)
|
112
|
-
end
|
113
|
-
|
114
|
-
File.open(File.expand_path("../../docs/#{name}.html", __FILE__),"w+") { |f|
|
115
|
-
f.write(doc.to_s)
|
116
|
-
}
|
117
|
-
end
|
118
|
-
|
119
|
-
puts "Done"
|
data/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
5
|
-
# in spec/support/ and its subdirectories.
|
6
|
-
#Dir["spec/support/**/*.rb"].each {|f| require f}
|
7
|
-
|
8
|
-
RSpec.configure do |c|
|
9
|
-
c.fail_fast = true
|
10
|
-
# ....
|
11
|
-
end
|
@@ -1,688 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'thrillcall-api'
|
3
|
-
require 'ap'
|
4
|
-
require 'faker'
|
5
|
-
require 'tzinfo'
|
6
|
-
|
7
|
-
# Set to one of :development, :staging, :production
|
8
|
-
TEST_ENV = :development
|
9
|
-
|
10
|
-
# For the environment specified in TEST_ENV, you must have set a few system environment variables.
|
11
|
-
# For example, if your TEST_ENV is :development, you need:
|
12
|
-
# TC_DEVELOPMENT_API_KEY : your API key
|
13
|
-
# TC_DEVELOPMENT_EMAIL : the email address (login) for the test account if testing the Person endpoint
|
14
|
-
# TC_DEVELOPMENT_PASSWORD : the password for the test account if testing the Person endpoint
|
15
|
-
# TC_DEVELOPMENT_KNOWN_UID : a facebook user ID that is known in the database
|
16
|
-
# TC_DEVELOPMENT_KNOWN_TOKEN : a facebook oauth token matching the above ID which is in the database
|
17
|
-
# TC_DEVELOPMENT_KNOWN_EMAIL : an email address matching the above ID which is in the database
|
18
|
-
# TC_DEVELOPMENT_UNKNOWN_UID : a facebook user ID that is not known in the database
|
19
|
-
# TC_DEVELOPMENT_UNKNOWN_TOKEN : a facebook oauth token matching the above ID which is not in the database
|
20
|
-
# TC_DEVELOPMENT_UNKNOWN_EMAIL : an email address matching the above ID which is not in the database
|
21
|
-
|
22
|
-
# Place something like this in your bash_login script:
|
23
|
-
# export TC_DEVELOPMENT_API_KEY="1234567890abcdef"
|
24
|
-
# export TC_DEVELOPMENT_EMAIL="some_account@thrillcall.com"
|
25
|
-
# export TC_DEVELOPMENT_PASSWORD="some_password"
|
26
|
-
# export TC_DEVELOPMENT_KNOWN_UID="12345679"
|
27
|
-
# export TC_DEVELOPMENT_KNOWN_TOKEN="AAC93tkWRL4BAFzv8mYYZCEqbZCwvZBJGQ6rbCwwZCXhlcDMj4lI3lJRJzhd7FQPb9bK3J9155eVI0jIACZCoympMm1SYoEJajaRULY"
|
28
|
-
# export TC_DEVELOPMENT_UNKNOWN_UID="123123bogus"
|
29
|
-
# export TC_DEVELOPMENT_UNKNOWN_TOKEN="123123bogus"
|
30
|
-
|
31
|
-
# You should not have to edit anything below this line.
|
32
|
-
#####################################################################
|
33
|
-
|
34
|
-
env_prefix = TEST_ENV.to_s.upcase
|
35
|
-
|
36
|
-
TEST_KEY = ENV["TC_#{env_prefix}_API_KEY"]
|
37
|
-
PERSON_EMAIL = ENV["TC_#{env_prefix}_EMAIL"]
|
38
|
-
PERSON_PASSWORD = ENV["TC_#{env_prefix}_PASSWORD"]
|
39
|
-
|
40
|
-
PERSON_KNOWN_ID = ENV["TC_#{env_prefix}_KNOWN_ID"]
|
41
|
-
PERSON_KNOWN_UID = ENV["TC_#{env_prefix}_KNOWN_UID"]
|
42
|
-
PERSON_KNOWN_TOKEN = ENV["TC_#{env_prefix}_KNOWN_TOKEN"]
|
43
|
-
PERSON_KNOWN_EMAIL = ENV["TC_#{env_prefix}_KNOWN_EMAIL"]
|
44
|
-
PERSON_UNKNOWN_UID = ENV["TC_#{env_prefix}_UNKNOWN_UID"]
|
45
|
-
PERSON_UNKNOWN_TOKEN = ENV["TC_#{env_prefix}_UNKNOWN_TOKEN"]
|
46
|
-
PERSON_UNKNOWN_EMAIL = ENV["TC_#{env_prefix}_UNKNOWN_EMAIL"]
|
47
|
-
|
48
|
-
HOST = "http://localhost:3000/api/" if TEST_ENV == :development
|
49
|
-
HOST = "https://secure-zion.thrillcall.com:443/api/" if TEST_ENV == :staging # SSL!
|
50
|
-
HOST = "https://api.thrillcall.com:443/api/" if TEST_ENV == :production # SSL!
|
51
|
-
|
52
|
-
MAX_LIMIT = 175
|
53
|
-
LIMIT = 14
|
54
|
-
TINY_LIMIT = 3
|
55
|
-
|
56
|
-
POSTAL_CODE = "94108"
|
57
|
-
|
58
|
-
PERSON_PROVIDER = :facebook
|
59
|
-
PERSON_CREATE_FIRSTNAME = Faker::Name.first_name
|
60
|
-
PERSON_CREATE_LASTNAME = Faker::Name.last_name
|
61
|
-
PERSON_CREATE_EMAIL = Faker::Internet.email
|
62
|
-
PERSON_CREATE_PASSWORD = Faker::Lorem.words(2).join('')
|
63
|
-
PERSON_CREATE_LOCATION = "San Francisco, CA"
|
64
|
-
PERSON_CREATE_LAT = 38.5
|
65
|
-
PERSON_CREATE_LONG = -123.0
|
66
|
-
PERSON_CREATE_POSTALCODE = POSTAL_CODE
|
67
|
-
|
68
|
-
FLUSH_CACHE = true # false
|
69
|
-
|
70
|
-
describe "ThrillcallAPI" do
|
71
|
-
|
72
|
-
def setup_key
|
73
|
-
@tc = ThrillcallAPI.new(TEST_KEY, :base_url => HOST)
|
74
|
-
|
75
|
-
@tc_permissions = @tc.api_key.permissions
|
76
|
-
@tc_permissions.length
|
77
|
-
@tc_permissions = @tc_permissions.data
|
78
|
-
|
79
|
-
# api_auth permission allows you to access the Person endpoints.
|
80
|
-
# api_read permission allows you to access all other endpoints.
|
81
|
-
end
|
82
|
-
|
83
|
-
def has_permission?(p=:api_read)
|
84
|
-
(@tc_permissions.include? p.to_s)
|
85
|
-
end
|
86
|
-
|
87
|
-
def mark_pending_if_no_permission(p = :api_read)
|
88
|
-
unless has_permission? p
|
89
|
-
pending "TEST_KEY permissions #{@tc_permissions} do not include #{p}"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def mark_pending_if_nil_value(h)
|
94
|
-
h.each do |k, v|
|
95
|
-
if v.nil?
|
96
|
-
pending "Required parameter #{k} is nil!"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def setup_read
|
102
|
-
if has_permission? :api_read
|
103
|
-
day_buffer = 0
|
104
|
-
range = 365
|
105
|
-
|
106
|
-
@beginning_of_time = (Time.now - 60*60*24*((range*5)+day_buffer)).to_date.to_s
|
107
|
-
@min_date = (Time.now - 60*60*24*(range+day_buffer)).to_date.to_s
|
108
|
-
@max_date = (Time.now - 60*60*24*day_buffer).to_date.to_s
|
109
|
-
|
110
|
-
event_finder = {
|
111
|
-
:must_have_tickets => true,
|
112
|
-
:postalcode => POSTAL_CODE,
|
113
|
-
:radius => 10,
|
114
|
-
:limit => TINY_LIMIT
|
115
|
-
}
|
116
|
-
|
117
|
-
events = @tc.events(event_finder)
|
118
|
-
events.length
|
119
|
-
|
120
|
-
@event = events.first
|
121
|
-
@event_id = @event["id"]
|
122
|
-
|
123
|
-
@ticket = @tc.event(@event_id).tickets.first
|
124
|
-
@artist = @tc.event(@event_id).artists.first
|
125
|
-
@venue = @tc.event(@event_id).venue
|
126
|
-
|
127
|
-
@artist_id = @artist["id"]
|
128
|
-
@artist_norm_name = @artist["name"]
|
129
|
-
|
130
|
-
@venue_id = @venue["id"]
|
131
|
-
@venue_norm_name = @venue["name"]
|
132
|
-
@venue_zip = @venue["postalcode"]
|
133
|
-
|
134
|
-
@event_zip = @venue_zip
|
135
|
-
|
136
|
-
@ticket_id = @ticket["id"]
|
137
|
-
|
138
|
-
@lat = @venue["latitude"]
|
139
|
-
@long = @venue["longitude"]
|
140
|
-
|
141
|
-
@genre_id = @artist["primary_genre_id"]
|
142
|
-
@metro_area_id = @venue["metro_area_id"]
|
143
|
-
@metro_area_time_zone = @tc.metro_area(@metro_area_id)["time_zone"]
|
144
|
-
|
145
|
-
puts "Using Thrillcall objects:"
|
146
|
-
puts "Event: #{@event_id}"
|
147
|
-
puts "Artist: #{@artist_id} #{@artist_norm_name}"
|
148
|
-
puts "Venue: #{@venue_id} #{@venue_norm_name}"
|
149
|
-
puts "Ticket: #{@ticket_id}"
|
150
|
-
puts "Metro: #{@metro_area_id}"
|
151
|
-
puts "Genre: #{@genre_id}"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
# Flush memcache results
|
156
|
-
before :all do
|
157
|
-
if TEST_ENV == :development
|
158
|
-
if FLUSH_CACHE
|
159
|
-
fork do
|
160
|
-
exec "echo 'flush_all' | nc localhost 11211"
|
161
|
-
end
|
162
|
-
|
163
|
-
Process.wait
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
it "the test suite should be able to retrieve the environment variables correctly" do
|
169
|
-
TEST_KEY.should_not be_nil
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should initialize properly with faraday" do
|
173
|
-
tc = nil
|
174
|
-
lambda { tc = ThrillcallAPI.new(TEST_KEY, :base_url => HOST) }.should_not raise_error
|
175
|
-
puts tc.inspect
|
176
|
-
tc.conn.class.should == Faraday::Connection
|
177
|
-
end
|
178
|
-
|
179
|
-
it "should be able to retrieve the permissions for the api key" do
|
180
|
-
tc = ThrillcallAPI.new(TEST_KEY, :base_url => HOST)
|
181
|
-
tc_permissions = tc.api_key.permissions
|
182
|
-
tc_permissions.length
|
183
|
-
tc_permissions = tc_permissions.data
|
184
|
-
tc_permissions.class.should == Array
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should return a 401 error if using an invalid API key" do
|
188
|
-
tc = ThrillcallAPI.new("bogus key", :base_url => HOST)
|
189
|
-
|
190
|
-
tc_permissions = tc.api_key.permissions
|
191
|
-
lambda {
|
192
|
-
tc_permissions.length
|
193
|
-
}.should raise_error
|
194
|
-
end
|
195
|
-
|
196
|
-
context "an authenticated user with get permission" do
|
197
|
-
|
198
|
-
before :all do
|
199
|
-
setup_key
|
200
|
-
setup_read
|
201
|
-
end
|
202
|
-
|
203
|
-
before :each do
|
204
|
-
mark_pending_if_no_permission(:api_read)
|
205
|
-
end
|
206
|
-
|
207
|
-
it "should be able to handle a method with a block used on fresh data" do
|
208
|
-
e = @tc.events(:limit => LIMIT)
|
209
|
-
c = 0
|
210
|
-
e.each do |ev|
|
211
|
-
c += 1
|
212
|
-
end
|
213
|
-
c.should == e.length
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should be able to make multiple requests after initialization" do
|
217
|
-
a = @tc.artist(@artist_id)
|
218
|
-
b = @tc.events(:limit => LIMIT)
|
219
|
-
a["id"].should == @artist_id
|
220
|
-
b.length.should == LIMIT
|
221
|
-
end
|
222
|
-
|
223
|
-
# This is the only remaining limitation of the wrapper
|
224
|
-
it "should not be able to make an additional request after using the data from an intermediate request" do
|
225
|
-
a = @tc.artist(@artist_id)
|
226
|
-
a["id"].should == @artist_id
|
227
|
-
lambda { e = a.events }.should raise_error
|
228
|
-
end
|
229
|
-
|
230
|
-
# This behavior cannot be iterated due to the previous limitation
|
231
|
-
it "should be able to build a nested request from a preexisting intermediate unfetched request" do
|
232
|
-
venue_intermediate_request = @tc.event(@event_id)
|
233
|
-
v = venue_intermediate_request.venue
|
234
|
-
v["id"].should == @venue_id
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should fetch data when responding to an array or a hash method" do
|
238
|
-
a = @tc.artists(:limit => LIMIT)
|
239
|
-
r = a.pop
|
240
|
-
r["id"].should_not be_nil
|
241
|
-
|
242
|
-
e = @tc.artist(r["id"])
|
243
|
-
(e.has_key? "genre_tags").should be_true
|
244
|
-
end
|
245
|
-
|
246
|
-
it "should respond to methods from Enumerable" do
|
247
|
-
a = @tc.artists(:limit => LIMIT)
|
248
|
-
c = 0
|
249
|
-
a.each do |artist|
|
250
|
-
artist["id"].should_not be_nil
|
251
|
-
c += 1
|
252
|
-
end
|
253
|
-
c.should == LIMIT
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should raise NoMethodError when given a method the data doesn't respond to after fetched" do
|
257
|
-
a = @tc.artists(:limit => LIMIT)
|
258
|
-
a.length.should == LIMIT
|
259
|
-
lambda { a.bazooka }.should raise_error NoMethodError
|
260
|
-
end
|
261
|
-
|
262
|
-
it "should not return filtered attributes" do
|
263
|
-
v = @tc.venue(@venue_id)
|
264
|
-
v["alt_city"].should be_nil
|
265
|
-
end
|
266
|
-
|
267
|
-
context "accessing the event endpoint" do
|
268
|
-
it "should get a list of events" do
|
269
|
-
# This call sets up the Result object and returns an instance of ThrillcallAPI
|
270
|
-
e = @tc.events(:limit => LIMIT)
|
271
|
-
|
272
|
-
# This call executes fetch_data because @data responds_to .length
|
273
|
-
e.length.should == LIMIT
|
274
|
-
|
275
|
-
# Now e behaves as a hash
|
276
|
-
end
|
277
|
-
|
278
|
-
it "should get a specific event" do
|
279
|
-
e = @tc.event(@event_id)
|
280
|
-
e["id"].should == @event_id
|
281
|
-
end
|
282
|
-
|
283
|
-
it "should get tickets for a specific event" do
|
284
|
-
e = @tc.event(@event_id).tickets
|
285
|
-
# FIXME: "product" here should be "ticket"
|
286
|
-
e.first["id"].should == @ticket_id
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should get artists for a specific event" do
|
290
|
-
e = @tc.event(@event_id).artists
|
291
|
-
e.first["id"].should == @artist_id
|
292
|
-
end
|
293
|
-
|
294
|
-
it "should get the venue for a specific event" do
|
295
|
-
e = @tc.event(@event_id).venue
|
296
|
-
e["id"].should == @venue_id
|
297
|
-
end
|
298
|
-
|
299
|
-
it "should verify the behavior of the limit maximum" do
|
300
|
-
e = @tc.events(:limit => MAX_LIMIT, :min_date => @beginning_of_time)
|
301
|
-
|
302
|
-
e.length.should == MAX_LIMIT
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should verify the behavior of the min_date param" do
|
306
|
-
e = @tc.events(:limit => TINY_LIMIT, :min_date => @min_date)
|
307
|
-
e.length.should == TINY_LIMIT
|
308
|
-
e.each do |ev|
|
309
|
-
DateTime.parse(ev["starts_at"]).should >= DateTime.parse(@min_date)
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
it "should verify the behavior of the max_date param" do
|
314
|
-
e = @tc.events(:limit => TINY_LIMIT, :min_date => @min_date, :max_date => @max_date)
|
315
|
-
e.length.should == TINY_LIMIT
|
316
|
-
e.each do |ev|
|
317
|
-
DateTime.parse(ev["starts_at"]).should < (DateTime.parse(@max_date) + 1)
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
it "should verify the behavior of the min_updated_at param" do
|
322
|
-
e = @tc.events(:limit => TINY_LIMIT, :min_updated_at => @min_date)
|
323
|
-
e.length.should == TINY_LIMIT
|
324
|
-
e.each do |ev|
|
325
|
-
DateTime.parse(ev["updated_at"]).should >= DateTime.parse(@min_date)
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
it "should verify the behavior of the max_updated_at param" do
|
330
|
-
e = @tc.events(:limit => TINY_LIMIT, :min_updated_at => @min_date, :max_updated_at => @max_date)
|
331
|
-
e.length.should == TINY_LIMIT
|
332
|
-
e.each do |ev|
|
333
|
-
DateTime.parse(ev["updated_at"]).should < (DateTime.parse(@max_date) + 1)
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
it "should verify the behavior of the time_zone param" do
|
338
|
-
tz = "Asia/Tokyo"
|
339
|
-
offset = 9/24.0
|
340
|
-
e = @tc.events(:limit => TINY_LIMIT, :min_date => @min_date, :max_date => @max_date, :time_zone => tz)
|
341
|
-
e.length.should == TINY_LIMIT
|
342
|
-
|
343
|
-
after = DateTime.parse(@min_date).new_offset(offset) - offset # should be 15:00 utc
|
344
|
-
before = (DateTime.parse(@max_date).new_offset(offset) + 1) - offset # should be 15:00 utc
|
345
|
-
|
346
|
-
puts "min_date: #{@min_date} (#{after})"
|
347
|
-
puts "max_date: #{@max_date} (#{before})"
|
348
|
-
|
349
|
-
e.each do |ev|
|
350
|
-
d = DateTime.parse(ev["starts_at_local"])
|
351
|
-
|
352
|
-
puts "Checking #{ev["starts_at_local"]} : #{d}"
|
353
|
-
|
354
|
-
d.should >= after
|
355
|
-
d.should < before
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
it "should verify the behavior of the page param" do
|
360
|
-
offset = 1
|
361
|
-
e = @tc.events(:limit => TINY_LIMIT * 2)
|
362
|
-
o = @tc.events(:limit => TINY_LIMIT, :page => 1)
|
363
|
-
e.length.should == TINY_LIMIT * 2
|
364
|
-
o.length.should == TINY_LIMIT
|
365
|
-
(e - o).length.should == TINY_LIMIT
|
366
|
-
end
|
367
|
-
|
368
|
-
it "should verify the behavior of the show_disabled_events param" do
|
369
|
-
e = @tc.events(:limit => MAX_LIMIT, :show_disabled_events => false)
|
370
|
-
e.each do |ev|
|
371
|
-
ev["status"].should_not == :disabled
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
it "should verify the behavior of the confirmed_events_only param" do
|
376
|
-
e = @tc.events(:limit => LIMIT, :confirmed_events_only => true)
|
377
|
-
e.each do |ev|
|
378
|
-
ev["unconfirmed_location"].should == 0
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
it "should verify the behavior of the must_have_tickets param" do
|
383
|
-
e = @tc.events(:limit => TINY_LIMIT, :must_have_tickets => true)
|
384
|
-
e.length.should == TINY_LIMIT
|
385
|
-
e.each do |ev|
|
386
|
-
t = @tc.event(ev["id"]).tickets
|
387
|
-
t.length.should_not == 0
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
it "should verify the behavior of the lat long params" do
|
392
|
-
e = @tc.events(:limit => TINY_LIMIT, :lat => @lat, :long => @long, :radius => 0)
|
393
|
-
e.each do |ev|
|
394
|
-
(@tc.event(ev["id"]).venue["latitude"].to_f - @lat).should <= 1.0
|
395
|
-
(@tc.event(ev["id"]).venue["longitude"].to_f - @long).should <= 1.0
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
it "should verify the behavior of the postalcode param" do
|
400
|
-
pending "Need to be able to access the ZipCodes table externally from Rails"
|
401
|
-
e = @tc.events(:limit => TINY_LIMIT, :postalcode => POSTAL_CODE)
|
402
|
-
e.length.should <= TINY_LIMIT
|
403
|
-
e.each do |ev|
|
404
|
-
ev["venue_id"].should_not be_nil
|
405
|
-
v = @tc.venue(ev["venue_id"])
|
406
|
-
|
407
|
-
v["postalcode"].should == POSTAL_CODE
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
it "should verify the behavior of the radius param" do
|
412
|
-
pending
|
413
|
-
end
|
414
|
-
|
415
|
-
#############
|
416
|
-
# Can't verify the behavior below without more access to data on the Rails side
|
417
|
-
it "should verify the behavior of the ticket_type param" do
|
418
|
-
pending "Need to be able to access the Merchants table externally from Rails"
|
419
|
-
e = @tc.events(:limit => TINY_LIMIT, :must_have_tickets => true)
|
420
|
-
e.length.should == TINY_LIMIT
|
421
|
-
e.each do |ev|
|
422
|
-
t = @tc.event(ev["id"]).tickets(:ticket_type => "primary")
|
423
|
-
t.each do |ticket|
|
424
|
-
ticket
|
425
|
-
end
|
426
|
-
t.length.should be_empty
|
427
|
-
end
|
428
|
-
end
|
429
|
-
#################
|
430
|
-
|
431
|
-
end
|
432
|
-
|
433
|
-
context "accessing the artist endpoint" do
|
434
|
-
it "should get a list of artists" do
|
435
|
-
a = @tc.artists(:limit => LIMIT)
|
436
|
-
a.length.should == LIMIT
|
437
|
-
end
|
438
|
-
|
439
|
-
it "should get a specific artist" do
|
440
|
-
a = @tc.artist(@artist_id)
|
441
|
-
a["id"].should == @artist_id
|
442
|
-
end
|
443
|
-
|
444
|
-
it "should get a list of events for a specific artist" do
|
445
|
-
a = @tc.artist(@artist_id).events
|
446
|
-
found = false
|
447
|
-
a.each do |event|
|
448
|
-
found = found || (event["id"] == @event_id)
|
449
|
-
break if found
|
450
|
-
end
|
451
|
-
found.should be_true
|
452
|
-
end
|
453
|
-
end
|
454
|
-
|
455
|
-
context "accessing the venue endpoint" do
|
456
|
-
it "should get a list of venues" do
|
457
|
-
v = @tc.venues(:limit => LIMIT)
|
458
|
-
v.length.should == LIMIT
|
459
|
-
end
|
460
|
-
|
461
|
-
it "should get a specific venue" do
|
462
|
-
v = @tc.venue(@venue_id)
|
463
|
-
v["id"].should == @venue_id
|
464
|
-
end
|
465
|
-
|
466
|
-
it "should directly return a postalcode" do
|
467
|
-
v = @tc.venue(@venue_id)
|
468
|
-
v["postalcode"].should == @venue_zip
|
469
|
-
end
|
470
|
-
|
471
|
-
it "should return a list of events for a specific venue" do
|
472
|
-
e = @tc.venue(@venue_id).events
|
473
|
-
e.length.should > 0
|
474
|
-
end
|
475
|
-
|
476
|
-
end
|
477
|
-
|
478
|
-
context "accessing the ticket endpoint" do
|
479
|
-
it "should get a list of tickets" do
|
480
|
-
p = @tc.tickets(:limit => LIMIT)
|
481
|
-
p.length.should == LIMIT
|
482
|
-
end
|
483
|
-
|
484
|
-
it "should get a specific ticket" do
|
485
|
-
p = @tc.ticket(@ticket_id)
|
486
|
-
p["id"].should == @ticket_id
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
context "searching for an object with a term" do
|
491
|
-
it "should find the right artists" do
|
492
|
-
a = @tc.search.artists(@artist_norm_name)
|
493
|
-
found = false
|
494
|
-
a.each do |artist|
|
495
|
-
if artist["id"] == @artist_id
|
496
|
-
found = true
|
497
|
-
break
|
498
|
-
end
|
499
|
-
end
|
500
|
-
found.should be_true
|
501
|
-
end
|
502
|
-
|
503
|
-
it "should find the right venues" do
|
504
|
-
v = @tc.search.venues(@venue_norm_name)
|
505
|
-
found = false
|
506
|
-
v.each do |venue|
|
507
|
-
if venue["id"] == @venue_id
|
508
|
-
found = true
|
509
|
-
break
|
510
|
-
end
|
511
|
-
end
|
512
|
-
found.should be_true
|
513
|
-
end
|
514
|
-
|
515
|
-
end
|
516
|
-
|
517
|
-
context "accessing the metro area endpoint" do
|
518
|
-
it "should get a specific metro area" do
|
519
|
-
m = @tc.metro_area(@metro_area_id)
|
520
|
-
m["id"].should == @metro_area_id
|
521
|
-
end
|
522
|
-
|
523
|
-
it "should get a list of metro areas" do
|
524
|
-
m = @tc.metro_areas(:limit => LIMIT)
|
525
|
-
m.length.should == LIMIT
|
526
|
-
end
|
527
|
-
|
528
|
-
it "should get a list of events for a specific metro" do
|
529
|
-
e = @tc.metro_area(@metro_area_id).events
|
530
|
-
cur_venue_id = e.first["venue_id"]
|
531
|
-
|
532
|
-
@tc.venue(cur_venue_id)["metro_area_id"].should == @metro_area_id
|
533
|
-
end
|
534
|
-
|
535
|
-
it "should get events based on the time zone of the metro" do
|
536
|
-
tz = TZInfo::Timezone.get(@metro_area_time_zone)
|
537
|
-
offset = (tz.current_period.offset.utc_offset / (60 * 60)) / 24.0
|
538
|
-
puts "Time zone is: #{@metro_area_time_zone}, offset #{offset}"
|
539
|
-
|
540
|
-
e = @tc.metro_area(@metro_area_id).events(:min_date => @min_date, :max_date => @max_date, :limit => TINY_LIMIT)
|
541
|
-
e.first["venue_id"]
|
542
|
-
|
543
|
-
after = DateTime.parse(@min_date).new_offset(offset) - offset
|
544
|
-
before = (DateTime.parse(@max_date).new_offset(offset) + 1) - offset
|
545
|
-
|
546
|
-
puts "min_date: #{@min_date} (#{after})"
|
547
|
-
puts "max_date: #{@max_date} (#{before})"
|
548
|
-
|
549
|
-
e.each do |ev|
|
550
|
-
d = DateTime.parse(ev["starts_at_local"])
|
551
|
-
|
552
|
-
puts "Checking #{ev["starts_at_local"]} : #{d}"
|
553
|
-
|
554
|
-
d.should >= after
|
555
|
-
d.should < before
|
556
|
-
end
|
557
|
-
end
|
558
|
-
end
|
559
|
-
|
560
|
-
context "accesing the genre endpoint" do
|
561
|
-
it "should get a specific genre" do
|
562
|
-
g = @tc.genre(@genre_id)
|
563
|
-
g["id"].should == @genre_id
|
564
|
-
end
|
565
|
-
|
566
|
-
it "should get a list of genres" do
|
567
|
-
g = @tc.genres(:limit => LIMIT)
|
568
|
-
g.length.should == LIMIT
|
569
|
-
end
|
570
|
-
|
571
|
-
it "should get a list of artists for a specific genre" do
|
572
|
-
g = @tc.genre(@genre_id).artists
|
573
|
-
g.first["primary_genre_id"].should == @genre_id
|
574
|
-
end
|
575
|
-
end
|
576
|
-
|
577
|
-
end
|
578
|
-
|
579
|
-
context "an authenticated user with api_auth permission" do
|
580
|
-
before :all do
|
581
|
-
setup_key
|
582
|
-
end
|
583
|
-
|
584
|
-
before :each do
|
585
|
-
mark_pending_if_no_permission(:api_auth)
|
586
|
-
end
|
587
|
-
|
588
|
-
context "accesing the person endpoint" do
|
589
|
-
it "should be able to GET a person using ID" do
|
590
|
-
# Don't forget to change the credentials in your environment variables
|
591
|
-
params = {
|
592
|
-
:email => PERSON_KNOWN_EMAIL,
|
593
|
-
:id => PERSON_KNOWN_ID
|
594
|
-
}
|
595
|
-
mark_pending_if_nil_value(params)
|
596
|
-
p = @tc.person(params[:id])
|
597
|
-
(p["email"] || p["login"]).should == PERSON_KNOWN_EMAIL
|
598
|
-
end
|
599
|
-
|
600
|
-
it "should be able to login a person using login/password credentials" do
|
601
|
-
# Don't forget to change the credentials in your environment variables
|
602
|
-
params = {
|
603
|
-
:email => PERSON_EMAIL,
|
604
|
-
:password => PERSON_PASSWORD
|
605
|
-
}
|
606
|
-
mark_pending_if_nil_value(params)
|
607
|
-
p = @tc.person.signin.post(params)
|
608
|
-
(p["email"] || p["login"]).should == PERSON_EMAIL
|
609
|
-
end
|
610
|
-
|
611
|
-
it "should be able to login a person using provider/uid/token credentials" do
|
612
|
-
params = {
|
613
|
-
:provider => PERSON_PROVIDER,
|
614
|
-
:uid => PERSON_KNOWN_UID,
|
615
|
-
:token => PERSON_KNOWN_TOKEN
|
616
|
-
}
|
617
|
-
mark_pending_if_nil_value(params)
|
618
|
-
p = @tc.person.signin.post(params)
|
619
|
-
(p["email"] || p["login"]).should == PERSON_KNOWN_EMAIL
|
620
|
-
end
|
621
|
-
|
622
|
-
it "should be able to create a person using the registration endpoint" do
|
623
|
-
params = {
|
624
|
-
:first_name => PERSON_CREATE_FIRSTNAME,
|
625
|
-
:email => PERSON_CREATE_EMAIL,
|
626
|
-
:password => PERSON_CREATE_PASSWORD,
|
627
|
-
:postalcode => PERSON_CREATE_POSTALCODE,
|
628
|
-
:test => true
|
629
|
-
}
|
630
|
-
mark_pending_if_nil_value(params)
|
631
|
-
p = @tc.person.signup.post(params)
|
632
|
-
p["first_name"].should == PERSON_CREATE_FIRSTNAME
|
633
|
-
end
|
634
|
-
|
635
|
-
it "should return a proper error message on failed login" do
|
636
|
-
params = {
|
637
|
-
:email => PERSON_EMAIL,
|
638
|
-
:password => rand(1000000)
|
639
|
-
}
|
640
|
-
lambda {
|
641
|
-
p = @tc.person.signin.post(params)
|
642
|
-
}.should raise_error
|
643
|
-
end
|
644
|
-
|
645
|
-
context "autoregistration for unknown provider/uid" do
|
646
|
-
it "should be able to create a person using location name" do
|
647
|
-
params = {
|
648
|
-
:provider => PERSON_PROVIDER,
|
649
|
-
:uid => PERSON_UNKNOWN_UID,
|
650
|
-
:token => PERSON_UNKNOWN_TOKEN,
|
651
|
-
:email => PERSON_UNKNOWN_EMAIL,
|
652
|
-
:first_name => PERSON_CREATE_FIRSTNAME,
|
653
|
-
:last_name => PERSON_CREATE_LASTNAME,
|
654
|
-
:location_name => PERSON_CREATE_LOCATION,
|
655
|
-
:test => true
|
656
|
-
}
|
657
|
-
|
658
|
-
mark_pending_if_nil_value(params)
|
659
|
-
|
660
|
-
p = @tc.person.signin.post(params)
|
661
|
-
|
662
|
-
p["first_name"].should == PERSON_CREATE_FIRSTNAME
|
663
|
-
end
|
664
|
-
|
665
|
-
it "should be able to create a person using (lat, long) for location" do
|
666
|
-
params = {
|
667
|
-
:provider => PERSON_PROVIDER,
|
668
|
-
:uid => PERSON_UNKNOWN_UID,
|
669
|
-
:token => PERSON_UNKNOWN_TOKEN,
|
670
|
-
:email => PERSON_UNKNOWN_EMAIL,
|
671
|
-
:first_name => PERSON_CREATE_FIRSTNAME,
|
672
|
-
:last_name => PERSON_CREATE_LASTNAME,
|
673
|
-
:lat => PERSON_CREATE_LAT,
|
674
|
-
:long => PERSON_CREATE_LONG,
|
675
|
-
:test => true
|
676
|
-
}
|
677
|
-
|
678
|
-
mark_pending_if_nil_value(params)
|
679
|
-
|
680
|
-
p = @tc.person.signin.post(params)
|
681
|
-
|
682
|
-
p["first_name"].should == PERSON_CREATE_FIRSTNAME
|
683
|
-
end
|
684
|
-
end
|
685
|
-
end
|
686
|
-
end
|
687
|
-
|
688
|
-
end
|