pollster 0.2.3 → 2.0.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.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +68 -111
- data/example.rb +128 -0
- data/lib/pollster.rb +46 -4
- data/lib/pollster/api.rb +655 -0
- data/lib/pollster/api_client.rb +400 -0
- data/lib/pollster/api_error.rb +26 -0
- data/lib/pollster/configuration.rb +184 -0
- data/lib/pollster/models/chart.rb +239 -0
- data/lib/pollster/models/chart_estimate.rb +226 -0
- data/lib/pollster/models/chart_estimate_lowess_parameters.rb +197 -0
- data/lib/pollster/models/chart_pollster_estimate_summary.rb +217 -0
- data/lib/pollster/models/chart_pollster_trendlines.rb +41 -0
- data/lib/pollster/models/inline_response_200.rb +208 -0
- data/lib/pollster/models/inline_response_200_3.rb +206 -0
- data/lib/pollster/models/inline_response_200_4.rb +208 -0
- data/lib/pollster/models/poll.rb +279 -0
- data/lib/pollster/models/poll_question.rb +198 -0
- data/lib/pollster/models/poll_question_responses.rb +197 -0
- data/lib/pollster/models/poll_question_sample_subpopulations.rb +209 -0
- data/lib/pollster/models/pollster_chart_poll_questions.rb +92 -0
- data/lib/pollster/models/question.rb +253 -0
- data/lib/pollster/models/question_poll_responses_clean.rb +93 -0
- data/lib/pollster/models/question_poll_responses_raw.rb +86 -0
- data/lib/pollster/models/question_responses.rb +207 -0
- data/lib/pollster/models/tag.rb +207 -0
- data/lib/pollster/version.rb +1 -1
- data/pollster.gemspec +17 -16
- metadata +85 -65
- data/.gitignore +0 -2
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -19
- data/Rakefile +0 -8
- data/lib/pollster/base.rb +0 -45
- data/lib/pollster/chart.rb +0 -69
- data/lib/pollster/poll.rb +0 -47
- data/lib/pollster/question.rb +0 -19
- data/test/test_pollster.rb +0 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c6eaa6fad77bf8e90e533e5ec269cc1701815808
|
4
|
+
data.tar.gz: 8c95537346a56210703d764613e6e592b3d3e279
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9866ecb3fbf43f9ecc0d67c9b5670feefd9be8da1f75639befe4b65c3d616964566c989af9b90cd5b94a2091e5a1e7e9c7ac8f053164597c6d42a76b47bdc407
|
7
|
+
data.tar.gz: 0d20b5802448d4658308581bf92b996aa7e2e405bb5064b7604da4abc6b190aa75d3169433c7e3b0eed6e79ddd9d8bb56e2c841f88b4b13e803e0ae2f4df3444
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,151 +1,108 @@
|
|
1
|
-
|
2
|
-
:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: | ,*
|
3
|
-
+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ | ,*,*
|
4
|
-
+#++:++#+ +#+ +:+ +#+ +#+ +#++:++#++ +#+ +#++:++# +#++:++#: | ,*, ,*
|
5
|
-
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ | ,* *,*
|
6
|
-
#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# | ,*
|
7
|
-
### ######## ########## ########## ######## ### ########## ### ### |*
|
8
|
-
- - - - - - - - - - -
|
9
|
-
|
1
|
+
# pollster
|
10
2
|
|
11
|
-
|
12
|
-
which provides access to political opinion polling data and trend estimates from The Huffington Post.
|
3
|
+
Pollster - the Ruby gem for the Pollster API
|
13
4
|
|
14
|
-
|
5
|
+
Download election-related polling data from Pollster.
|
15
6
|
|
16
|
-
|
17
|
-
|
18
|
-
gem install pollster
|
19
|
-
|
20
|
-
## Getting Started
|
21
|
-
|
22
|
-
require 'pollster'
|
23
|
-
include Pollster
|
7
|
+
[HuffPost Pollster](https://elections.huffingtonpost.com/pollster) is a website that tracks public opinion. Pollster's editors enter polling data for the \"Questions\" they care about -- questions the public answers in \"Polls\".
|
24
8
|
|
25
|
-
|
9
|
+
The Pollster website is organized into \"Charts\" and Pollster-calculated trendlines (descriptions of how the public felt each day, based on the polls and public algorithms). Each Chart is based on a single Question. The Pollster API provides every point plotted on all the \"Charts\" on the Pollster website. Furthermore, it provides the raw polling data that went into those charts: every response to every Question, at whichever level of detail the developer requests.
|
26
10
|
|
27
|
-
|
11
|
+
This SDK was originally generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
28
12
|
|
29
|
-
|
13
|
+
- API version: 2.0.0
|
14
|
+
- Package version: 2.0.0
|
15
|
+
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
30
16
|
|
31
|
-
|
17
|
+
For more information, please visit [https://groups.google.com/forum/#!forum/pollster-users](https://groups.google.com/forum/#!forum/pollster-users)
|
32
18
|
|
33
|
-
|
34
|
-
|
35
|
-
Chart.where(:state => 'WI')
|
36
|
-
|
37
|
-
Calculate the margin between Obama and Romney from a recent general election poll
|
38
|
-
|
39
|
-
poll = Poll.where(:chart => '2012-general-election-romney-vs-obama').first
|
40
|
-
responses = poll.questions.detect { |question| question.chart == '2012-general-election-romney-vs-obama' }.responses
|
41
|
-
obama = responses.detect { |response| response[:choice] == "Obama" }
|
42
|
-
romney = responses.detect { |response| response[:choice] == "Romney" }
|
43
|
-
obama[:value] - romney[:value]
|
19
|
+
## Installation
|
44
20
|
|
45
|
-
|
21
|
+
In short: add `gem 'pollster', '~> 2.0.0'` to your Gemfile.
|
46
22
|
|
47
|
-
|
48
|
-
chart.polls.map { |poll| [poll.pollster, poll.method] }
|
23
|
+
Full installation options:
|
49
24
|
|
50
|
-
|
25
|
+
### Build a gem
|
51
26
|
|
52
|
-
|
27
|
+
To build the Ruby code into a gem:
|
53
28
|
|
54
|
-
|
29
|
+
```shell
|
30
|
+
gem build pollster.gemspec
|
31
|
+
```
|
55
32
|
|
56
|
-
|
33
|
+
Then either install the gem locally:
|
57
34
|
|
58
|
-
|
35
|
+
```shell
|
36
|
+
gem install ./pollster-2.0.0.gem
|
37
|
+
```
|
38
|
+
(for development, run `gem install --dev ./pollster-1.0.0.gem` to install the development dependencies)
|
59
39
|
|
60
|
-
|
40
|
+
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
61
41
|
|
62
|
-
|
42
|
+
Finally add this to the Gemfile:
|
63
43
|
|
64
|
-
|
44
|
+
gem 'pollster', '~> 2.0.0'
|
65
45
|
|
66
|
-
###
|
46
|
+
### Install from Git
|
67
47
|
|
68
|
-
|
48
|
+
If the Ruby gem is hosted at a git repository: https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO, then add the following in the Gemfile:
|
69
49
|
|
70
|
-
|
71
|
-
=> [<Pollster::Chart: 2012 Iowa GOP Primary>,
|
72
|
-
<Pollster::Chart: 2012 New Hampshire GOP Primary>,
|
73
|
-
<Pollster::Chart: 2012 South Carolina GOP Primary>,
|
74
|
-
<Pollster::Chart: 2012 Florida GOP Primary>,
|
75
|
-
<Pollster::Chart: 2012 Nevada GOP Primary>,
|
76
|
-
...]
|
50
|
+
gem 'pollster', :git => 'https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO.git'
|
77
51
|
|
78
|
-
|
52
|
+
### Include the Ruby code directly
|
79
53
|
|
80
|
-
|
54
|
+
Include the Ruby code directly using `-I` as follows:
|
81
55
|
|
82
|
-
|
83
|
-
|
56
|
+
```shell
|
57
|
+
ruby -Ilib script.rb
|
58
|
+
```
|
84
59
|
|
85
|
-
|
60
|
+
## Getting Started
|
86
61
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
62
|
+
Please follow the [installation](#installation) procedure and then run the following code:
|
63
|
+
```ruby
|
64
|
+
# Load the gem
|
65
|
+
require 'pollster'
|
91
66
|
|
92
|
-
|
93
|
-
=> [<Pollster::Chart: 2012 Massachusetts Senate: Brown vs Warren>,
|
94
|
-
<Pollster::Chart: 2012 Ohio Senate: Brown vs Mandel>,
|
95
|
-
<Pollster::Chart: 2012 Arizona Senate: Flake vs. Carmona>,
|
96
|
-
<Pollster::Chart: 2012 Florida Senate: Mack vs. Nelson>,
|
97
|
-
...]
|
67
|
+
api = Pollster::Api.new
|
98
68
|
|
99
|
-
|
100
|
-
|
69
|
+
opts = {
|
70
|
+
cursor: nil, # Special string to index into the Array
|
71
|
+
tags: "2016-president", # Comma-separated list of tag slugs
|
72
|
+
election_date: Date.parse("2013-10-20") # Date of an election
|
73
|
+
}
|
101
74
|
|
102
|
-
|
75
|
+
begin
|
76
|
+
result = api.charts_get(opts)
|
77
|
+
p result
|
78
|
+
rescue Pollster::ApiError => e
|
79
|
+
puts "Exception when calling Api->charts_get: #{e}"
|
80
|
+
end
|
103
81
|
|
104
|
-
|
105
|
-
>> chart.polls
|
106
|
-
=> [#<Pollster::Poll:...
|
107
|
-
@start_date=#<Date: 2012-01-01 (4911855/2,0,2299161)>>,
|
108
|
-
@end_date=#<Date: 2012-01-01 (4911855/2,0,2299161)>,
|
109
|
-
@id=12385,
|
110
|
-
@method="Automated Phone",
|
111
|
-
@pollster="InsiderAdvantage",
|
112
|
-
@questions=
|
113
|
-
[{:name=>"2012 Iowa GOP Primary",
|
114
|
-
:chart=>"2012-iowa-gop-primary",
|
115
|
-
:topic=>"2012-gop-primary",
|
116
|
-
:state=>"IA",
|
117
|
-
:subpopulations=>
|
118
|
-
[{:name=>"Likely Voters",
|
119
|
-
:observations=>729,
|
120
|
-
:margin_of_error=>nil,
|
121
|
-
:responses=>
|
122
|
-
[{:choice=>"Romney", :value=>23},
|
123
|
-
{:choice=>"Bachmann", :value=>6},
|
124
|
-
{:choice=>"Gingrich", :value=>16},
|
125
|
-
{:choice=>"Huntsman", :value=>2},
|
126
|
-
{:choice=>"Paul", :value=>22},
|
127
|
-
{:choice=>"Perry", :value=>10},
|
128
|
-
{:choice=>"Santorum", :value=>18},
|
129
|
-
{:choice=>"Other", :value=>1},
|
130
|
-
{:choice=>"Undecided", :value=>2}]}]}],
|
131
|
-
@source= "http://www.realclearpolitics.com/docs/2012/InsiderAdvantage_Iowa_0102.pdf",
|
132
|
-
...]
|
82
|
+
```
|
133
83
|
|
84
|
+
## API documentation
|
134
85
|
|
135
|
-
|
86
|
+
Perhaps the best documentation is `example.rb`: it shows how to use all API
|
87
|
+
endpoints and how to paginate.
|
136
88
|
|
137
|
-
|
89
|
+
See https://elections.huffingtonpost.com/pollster/api/v2/help for more details.
|
138
90
|
|
139
|
-
|
91
|
+
See https://app.swaggerhub.com/api/huffpostdata/pollster-api/2.0.0 for full API
|
92
|
+
documentation. The Ruby-specific warts:
|
140
93
|
|
141
|
-
|
94
|
+
* For the TSV endpoints `questions/{slug}/poll-responses-clean.tsv` and
|
95
|
+
`charts/{slug}/pollster-chart-poll-questions.tsv`, the return values include a
|
96
|
+
`responses` Hash that maps from `label` (String) to `value` (Float).
|
97
|
+
* Ruby API method names are snake-cased versions of the API endpoints and end
|
98
|
+
with `_get`. For example, the Ruby method to access
|
99
|
+
`questions/{slug}/poll-responses-clean.tsv` is
|
100
|
+
`api.questions_slug_poll_responses_clean_tsv_get(slug)`.
|
142
101
|
|
143
|
-
##
|
102
|
+
## Author
|
144
103
|
|
145
|
-
|
146
|
-
- Jay Boice, jay.boice@huffingtonpost.com
|
147
|
-
- Andrei Scheinkman, andrei@huffingtonpost.com
|
104
|
+
Adam Hooper, adam.hooper@huffingtonpost.com.
|
148
105
|
|
149
106
|
## Copyright
|
150
107
|
|
151
|
-
Copyright ©
|
108
|
+
Copyright © 2016 The Huffington Post. See LICENSE for details.
|
data/example.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pollster'
|
4
|
+
|
5
|
+
api = Pollster::Api.new
|
6
|
+
|
7
|
+
# GET /tags
|
8
|
+
puts "GET /tags..."
|
9
|
+
|
10
|
+
tags = api.tags_get()
|
11
|
+
|
12
|
+
puts " Found #{tags.count} tags"
|
13
|
+
puts " First tag: #{tags.first.slug} (#{tags.first.n_charts} charts)"
|
14
|
+
|
15
|
+
# GET /charts
|
16
|
+
puts "GET /charts..."
|
17
|
+
|
18
|
+
charts = api.charts_get({
|
19
|
+
cursor: nil, # String | Special string to index into the Array
|
20
|
+
tags: "2016-president", # String | Comma-separated list of tag slugs
|
21
|
+
election_date: Date.parse("2016-11-08") # Date | Date of an election
|
22
|
+
})
|
23
|
+
|
24
|
+
puts " Found #{charts.count} charts; our reults page has #{charts.items.length} charts"
|
25
|
+
|
26
|
+
# GET /charts/:slug
|
27
|
+
puts "GET /charts/:slug..."
|
28
|
+
chart_slug = charts.items.first.slug
|
29
|
+
puts " First chart has slug `#{chart_slug}`"
|
30
|
+
|
31
|
+
chart = api.charts_slug_get(chart_slug)
|
32
|
+
|
33
|
+
puts " Found chart `#{chart.slug}`"
|
34
|
+
puts " Tags: #{chart.tags.join(', ')}"
|
35
|
+
puts " Question: #{chart.question.slug}"
|
36
|
+
puts " Polls that answer Question: #{chart.question.n_polls}"
|
37
|
+
|
38
|
+
# GET /polls, and pagination
|
39
|
+
puts "GET /polls..."
|
40
|
+
# Pick a question that has enough polls that we'll need to paginate
|
41
|
+
question_slug = charts.items.find{ |c| c.question.n_polls > 30 }.question.slug
|
42
|
+
|
43
|
+
polls = api.polls_get({
|
44
|
+
cursor: nil,
|
45
|
+
question: question_slug,
|
46
|
+
tags: nil,
|
47
|
+
sort: 'created_at'
|
48
|
+
})
|
49
|
+
|
50
|
+
puts " Found #{polls.count} polls; our results page has #{polls.items.count} polls and begins with #{polls.items.first.slug}"
|
51
|
+
puts " next_cursor is #{polls.next_cursor}; using it in another GET request...."
|
52
|
+
|
53
|
+
polls2 = api.polls_get({
|
54
|
+
cursor: polls.next_cursor,
|
55
|
+
question: question_slug,
|
56
|
+
tags: nil,
|
57
|
+
sort: 'created_at'
|
58
|
+
})
|
59
|
+
|
60
|
+
puts " Got another #{polls2.items.count} polls, such as #{polls2.items.first.slug}"
|
61
|
+
|
62
|
+
# GET /polls/:slug -- unnecessary here, since a Poll's data shows up in GET /polls
|
63
|
+
puts "GET /polls/:slug..."
|
64
|
+
poll_slug = polls.items.first.slug
|
65
|
+
puts " First poll has slug `#{poll_slug}`"
|
66
|
+
|
67
|
+
poll = api.polls_slug_get(poll_slug)
|
68
|
+
|
69
|
+
puts " Found poll `#{poll.slug}`"
|
70
|
+
puts " Poll conducted from: #{poll.start_date} to: #{poll.end_date}, entered into Pollster: #{poll.created_at}"
|
71
|
+
puts " Questions: #{poll.poll_questions.length}"
|
72
|
+
puts " First question name: #{poll.poll_questions[0].question.name}"
|
73
|
+
puts " First question options: #{poll.poll_questions[0].question.responses.map(&:label).join(', ')}"
|
74
|
+
puts " First question first sample subpopulation: #{poll.poll_questions[0].sample_subpopulations[0].name}"
|
75
|
+
puts " First question responses: #{poll.poll_questions[0].sample_subpopulations[0].responses.map { |r| "#{r.text} (#{r.pollster_label}): #{r.value}" }.join('; ')}"
|
76
|
+
|
77
|
+
# GET /charts/:slug/pollster-trendlines.tsv
|
78
|
+
puts "GET /charts/:slug/pollster-trendlines.tsv..."
|
79
|
+
|
80
|
+
trendlines = api.charts_slug_pollster_trendlines_tsv_get(chart_slug)
|
81
|
+
|
82
|
+
puts " Found #{trendlines.points.length} trendline points"
|
83
|
+
first_label = chart.question.responses[0].label
|
84
|
+
first_trendline = trendlines.by_label[first_label]
|
85
|
+
puts " Trendline for #{first_label} has #{first_trendline.length} points"
|
86
|
+
puts " Most recent points: #{first_trendline.last(5).map{ |p| "#{p.date.to_s}:#{p.value}" }.join(', ')}"
|
87
|
+
|
88
|
+
# GET /charts/:slug/pollster-chart-poll-questions.tsv
|
89
|
+
puts "GET /charts/:slug/pollster-chart-poll-questions.tsv..."
|
90
|
+
|
91
|
+
chart_poll_questions = api.charts_slug_pollster_chart_poll_questions_tsv_get(chart_slug)
|
92
|
+
|
93
|
+
puts " Found #{chart_poll_questions.count} poll questions plotted on chart"
|
94
|
+
puts " Most recent poll: #{chart_poll_questions.first.poll_slug} (#{chart_poll_questions.first.start_date.to_s} to #{chart_poll_questions.first.end_date.to_s})"
|
95
|
+
puts " Responses (as plotted on the chart): #{chart_poll_questions.first.responses.map{ |k, v| "#{k} #{v}" }.join(', ')}"
|
96
|
+
|
97
|
+
# GET /questions
|
98
|
+
puts "GET /questions..."
|
99
|
+
|
100
|
+
questions = api.questions_get({
|
101
|
+
cursor: nil, # String | Special string to index into the Array
|
102
|
+
tags: "2016-president", # String | Comma-separated list of tag slugs (most Questions are not tagged)
|
103
|
+
election_date: Date.parse("2016-11-08") # Date | Date of an election
|
104
|
+
})
|
105
|
+
|
106
|
+
puts " Found #{questions.count} Questions matching request"
|
107
|
+
puts " First Question: #{questions.items.first.slug} (#{questions.items.first.name})"
|
108
|
+
puts " Responses Pollster tracks: #{questions.items.first.responses.map(&:label).join(", ")}"
|
109
|
+
|
110
|
+
# GET /question/:slug/poll_responses_clean.tsv
|
111
|
+
puts "GET /question/:slug/poll_responses_clean.tsv..."
|
112
|
+
|
113
|
+
responses_clean = api.questions_slug_poll_responses_clean_tsv_get(question_slug)
|
114
|
+
|
115
|
+
puts " Found #{responses_clean.count} responses to Question #{question_slug}"
|
116
|
+
puts " Most recent poll: #{responses_clean.first.poll_slug} (#{responses_clean.first.start_date.to_s} to #{responses_clean.first.end_date.to_s})"
|
117
|
+
puts " Responses (as aggregated by Pollster): #{responses_clean.first.responses.map{ |k, v| "#{k} #{v}" }.join(', ')}"
|
118
|
+
|
119
|
+
# GET /question/:slug/poll_responses_raw.tsv
|
120
|
+
puts "GET /question/:slug/poll_responses_raw.tsv..."
|
121
|
+
|
122
|
+
responses_raw = api.questions_slug_poll_responses_raw_tsv_get(question_slug)
|
123
|
+
|
124
|
+
puts " Found #{responses_raw.count} response data points to Question #{question_slug}"
|
125
|
+
puts " Most recent for label #{first_label}:"
|
126
|
+
for r in responses_raw.select{ |r| r.pollster_label == first_label }.first(5)
|
127
|
+
puts " #{r.poll_slug} on #{r.end_date.to_s}, prompting #{r.sample_subpopulation} for #{r.response_text}: #{r.value}"
|
128
|
+
end
|
data/lib/pollster.rb
CHANGED
@@ -1,4 +1,46 @@
|
|
1
|
-
|
2
|
-
require 'pollster/
|
3
|
-
require 'pollster/
|
4
|
-
require 'pollster/
|
1
|
+
# Common files
|
2
|
+
require 'pollster/api_client'
|
3
|
+
require 'pollster/api_error'
|
4
|
+
require 'pollster/version'
|
5
|
+
require 'pollster/configuration'
|
6
|
+
|
7
|
+
# Models
|
8
|
+
require 'pollster/models/chart'
|
9
|
+
require 'pollster/models/chart_estimate'
|
10
|
+
require 'pollster/models/chart_estimate_lowess_parameters'
|
11
|
+
require 'pollster/models/chart_pollster_estimate_summary'
|
12
|
+
require 'pollster/models/inline_response_200'
|
13
|
+
require 'pollster/models/chart_pollster_trendlines'
|
14
|
+
require 'pollster/models/pollster_chart_poll_questions'
|
15
|
+
require 'pollster/models/question_poll_responses_clean'
|
16
|
+
require 'pollster/models/question_poll_responses_raw'
|
17
|
+
require 'pollster/models/inline_response_200_3'
|
18
|
+
require 'pollster/models/inline_response_200_4'
|
19
|
+
require 'pollster/models/poll'
|
20
|
+
require 'pollster/models/poll_question'
|
21
|
+
require 'pollster/models/poll_question_responses'
|
22
|
+
require 'pollster/models/poll_question_sample_subpopulations'
|
23
|
+
require 'pollster/models/question'
|
24
|
+
require 'pollster/models/question_responses'
|
25
|
+
require 'pollster/models/tag'
|
26
|
+
|
27
|
+
# APIs
|
28
|
+
require 'pollster/api'
|
29
|
+
|
30
|
+
module Pollster
|
31
|
+
class << self
|
32
|
+
# Customize default settings for the SDK using block.
|
33
|
+
# Pollster.configure do |config|
|
34
|
+
# config.username = "xxx"
|
35
|
+
# config.password = "xxx"
|
36
|
+
# end
|
37
|
+
# If no block given, return the default Configuration object.
|
38
|
+
def configure
|
39
|
+
if block_given?
|
40
|
+
yield(Configuration.default)
|
41
|
+
else
|
42
|
+
Configuration.default
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/pollster/api.rb
ADDED
@@ -0,0 +1,655 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
module Pollster
|
4
|
+
class Api
|
5
|
+
attr_accessor :api_client
|
6
|
+
|
7
|
+
def initialize(api_client = ApiClient.default)
|
8
|
+
@api_client = api_client
|
9
|
+
end
|
10
|
+
|
11
|
+
# Charts
|
12
|
+
# Returns a list of Charts, ordered by creation date (newest first). A Chart is chosen by Pollster editors. One example is \"Obama job approval - Democrats\". It is always based upon a single Question. Users should strongly consider basing their analysis on Questions instead. Charts are derived data; Pollster editors publish them and change them as editorial priorities change.
|
13
|
+
# @param [Hash] opts the optional parameters
|
14
|
+
# @option opts [String] :cursor Special string to index into the Array
|
15
|
+
# @option opts [String] :tags Comma-separated list of tag slugs. Only Charts with one or more of these tags and Charts based on Questions with one or more of these tags will be returned.
|
16
|
+
# @option opts [Date] :election_date Date of an election, in YYYY-MM-DD format. Only Charts based on Questions pertaining to an election on this date will be returned.
|
17
|
+
# @return [InlineResponse200]
|
18
|
+
def charts_get(opts = {})
|
19
|
+
data, _status_code, _headers = charts_get_with_http_info(opts)
|
20
|
+
return data
|
21
|
+
end
|
22
|
+
|
23
|
+
# Charts
|
24
|
+
# Returns a list of Charts, ordered by creation date (newest first). A Chart is chosen by Pollster editors. One example is \"Obama job approval - Democrats\". It is always based upon a single Question. Users should strongly consider basing their analysis on Questions instead. Charts are derived data; Pollster editors publish them and change them as editorial priorities change.
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @option opts [String] :cursor Special string to index into the Array
|
27
|
+
# @option opts [String] :tags Comma-separated list of tag slugs. Only Charts with one or more of these tags and Charts based on Questions with one or more of these tags will be returned.
|
28
|
+
# @option opts [Date] :election_date Date of an election, in YYYY-MM-DD format. Only Charts based on Questions pertaining to an election on this date will be returned.
|
29
|
+
# @return [Array<(InlineResponse200, Fixnum, Hash)>] InlineResponse200 data, response status code and response headers
|
30
|
+
def charts_get_with_http_info(opts = {})
|
31
|
+
if @api_client.config.debugging
|
32
|
+
@api_client.config.logger.debug "Calling API: Api.charts_get ..."
|
33
|
+
end
|
34
|
+
# resource path
|
35
|
+
local_var_path = "/charts".sub('{format}','json')
|
36
|
+
|
37
|
+
# query parameters
|
38
|
+
query_params = {}
|
39
|
+
query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
|
40
|
+
query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
|
41
|
+
query_params[:'election_date'] = opts[:'election_date'] if !opts[:'election_date'].nil?
|
42
|
+
|
43
|
+
# header parameters
|
44
|
+
header_params = {}
|
45
|
+
|
46
|
+
# HTTP header 'Accept' (if needed)
|
47
|
+
local_header_accept = ['application/json', 'application/xml']
|
48
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
49
|
+
|
50
|
+
# HTTP header 'Content-Type'
|
51
|
+
local_header_content_type = []
|
52
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
53
|
+
|
54
|
+
# form parameters
|
55
|
+
form_params = {}
|
56
|
+
|
57
|
+
# http body (model)
|
58
|
+
post_body = nil
|
59
|
+
auth_names = []
|
60
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
61
|
+
:header_params => header_params,
|
62
|
+
:query_params => query_params,
|
63
|
+
:form_params => form_params,
|
64
|
+
:body => post_body,
|
65
|
+
:auth_names => auth_names,
|
66
|
+
:return_type => 'InlineResponse200')
|
67
|
+
if @api_client.config.debugging
|
68
|
+
@api_client.config.logger.debug "API called: Api#charts_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
69
|
+
end
|
70
|
+
return data, status_code, headers
|
71
|
+
end
|
72
|
+
|
73
|
+
# Chart
|
74
|
+
# A Chart is chosen by Pollster editors. One example is \"Obama job approval - Democrats\". It is always based upon a single Question. Users should strongly consider basing their analysis on Questions instead. Charts are derived data; Pollster editors publish them and change them as editorial priorities change.
|
75
|
+
# @param slug Unique identifier for a Chart
|
76
|
+
# @param [Hash] opts the optional parameters
|
77
|
+
# @return [Chart]
|
78
|
+
def charts_slug_get(slug, opts = {})
|
79
|
+
data, _status_code, _headers = charts_slug_get_with_http_info(slug, opts)
|
80
|
+
return data
|
81
|
+
end
|
82
|
+
|
83
|
+
# Chart
|
84
|
+
# A Chart is chosen by Pollster editors. One example is \"Obama job approval - Democrats\". It is always based upon a single Question. Users should strongly consider basing their analysis on Questions instead. Charts are derived data; Pollster editors publish them and change them as editorial priorities change.
|
85
|
+
# @param slug Unique identifier for a Chart
|
86
|
+
# @param [Hash] opts the optional parameters
|
87
|
+
# @return [Array<(Chart, Fixnum, Hash)>] Chart data, response status code and response headers
|
88
|
+
def charts_slug_get_with_http_info(slug, opts = {})
|
89
|
+
if @api_client.config.debugging
|
90
|
+
@api_client.config.logger.debug "Calling API: Api.charts_slug_get ..."
|
91
|
+
end
|
92
|
+
# verify the required parameter 'slug' is set
|
93
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.charts_slug_get" if slug.nil?
|
94
|
+
# resource path
|
95
|
+
local_var_path = "/charts/{slug}".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
96
|
+
|
97
|
+
# query parameters
|
98
|
+
query_params = {}
|
99
|
+
|
100
|
+
# header parameters
|
101
|
+
header_params = {}
|
102
|
+
|
103
|
+
# HTTP header 'Accept' (if needed)
|
104
|
+
local_header_accept = ['application/json', 'application/xml']
|
105
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
106
|
+
|
107
|
+
# HTTP header 'Content-Type'
|
108
|
+
local_header_content_type = []
|
109
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
110
|
+
|
111
|
+
# form parameters
|
112
|
+
form_params = {}
|
113
|
+
|
114
|
+
# http body (model)
|
115
|
+
post_body = nil
|
116
|
+
auth_names = []
|
117
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
118
|
+
:header_params => header_params,
|
119
|
+
:query_params => query_params,
|
120
|
+
:form_params => form_params,
|
121
|
+
:body => post_body,
|
122
|
+
:auth_names => auth_names,
|
123
|
+
:return_type => 'Chart')
|
124
|
+
if @api_client.config.debugging
|
125
|
+
@api_client.config.logger.debug "API called: Api#charts_slug_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
126
|
+
end
|
127
|
+
return data, status_code, headers
|
128
|
+
end
|
129
|
+
|
130
|
+
# One row per poll plotted on a Chart
|
131
|
+
# Derived data presented on a Pollster Chart. Rules for which polls and responses are plotted on a chart can shift over time. Here are some examples of behaviors Pollster has used in the past: * We've omitted \"Registered Voters\" from a chart when \"Likely Voters\" responded to the same poll question. * We've omitted poll questions that asked about Gary Johnson on a chart about Trump v Clinton. * We've omitted polls when their date ranges overlapped. * We've omitted labels (and their responses) for dark-horse candidates. In short: this endpoint is about Pollster, not the polls. For complete data, use a TSV from the Questions API. The response follows the exact same format as `questions/{slug}/poll-responses-clean.tsv`, which you should strongly consider before settling on the Chart TSV.
|
132
|
+
# @param slug Unique Chart identifier. For example: `obama-job-approval`
|
133
|
+
# @param [Hash] opts the optional parameters
|
134
|
+
# @return [PollsterChartPollQuestions]
|
135
|
+
def charts_slug_pollster_chart_poll_questions_tsv_get(slug, opts = {})
|
136
|
+
data, _status_code, _headers = charts_slug_pollster_chart_poll_questions_tsv_get_with_http_info(slug, opts)
|
137
|
+
return data
|
138
|
+
end
|
139
|
+
|
140
|
+
# One row per poll plotted on a Chart
|
141
|
+
# Derived data presented on a Pollster Chart. Rules for which polls and responses are plotted on a chart can shift over time. Here are some examples of behaviors Pollster has used in the past: * We've omitted \"Registered Voters\" from a chart when \"Likely Voters\" responded to the same poll question. * We've omitted poll questions that asked about Gary Johnson on a chart about Trump v Clinton. * We've omitted polls when their date ranges overlapped. * We've omitted labels (and their responses) for dark-horse candidates. In short: this endpoint is about Pollster, not the polls. For complete data, use a TSV from the Questions API. The response follows the exact same format as `questions/{slug}/poll-responses-clean.tsv`, which you should strongly consider before settling on the Chart TSV.
|
142
|
+
# @param slug Unique Chart identifier. For example: `obama-job-approval`
|
143
|
+
# @param [Hash] opts the optional parameters
|
144
|
+
# @return [Array<(PollsterChartPollQuestions, Fixnum, Hash)>] PollsterChartPollQuestions data, response status code and response headers
|
145
|
+
def charts_slug_pollster_chart_poll_questions_tsv_get_with_http_info(slug, opts = {})
|
146
|
+
if @api_client.config.debugging
|
147
|
+
@api_client.config.logger.debug "Calling API: Api.charts_slug_pollster_chart_poll_questions_tsv_get ..."
|
148
|
+
end
|
149
|
+
# verify the required parameter 'slug' is set
|
150
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.charts_slug_pollster_chart_poll_questions_tsv_get" if slug.nil?
|
151
|
+
# resource path
|
152
|
+
local_var_path = "/charts/{slug}/pollster-chart-poll-questions.tsv".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
153
|
+
|
154
|
+
# query parameters
|
155
|
+
query_params = {}
|
156
|
+
|
157
|
+
# header parameters
|
158
|
+
header_params = {}
|
159
|
+
|
160
|
+
# HTTP header 'Accept' (if needed)
|
161
|
+
local_header_accept = ['text/tab-separated-values']
|
162
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
163
|
+
|
164
|
+
# HTTP header 'Content-Type'
|
165
|
+
local_header_content_type = []
|
166
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
167
|
+
|
168
|
+
# form parameters
|
169
|
+
form_params = {}
|
170
|
+
|
171
|
+
# http body (model)
|
172
|
+
post_body = nil
|
173
|
+
auth_names = []
|
174
|
+
data, status_code, headers = @api_client.call_api_tsv(:GET, local_var_path,
|
175
|
+
:header_params => header_params,
|
176
|
+
:query_params => query_params,
|
177
|
+
:form_params => form_params,
|
178
|
+
:body => post_body,
|
179
|
+
:auth_names => auth_names,
|
180
|
+
:return_type => 'PollsterChartPollQuestions')
|
181
|
+
if @api_client.config.debugging
|
182
|
+
@api_client.config.logger.debug "API called: Api#charts_slug_pollster_chart_poll_questions_tsv_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
183
|
+
end
|
184
|
+
return data, status_code, headers
|
185
|
+
end
|
186
|
+
|
187
|
+
# Estimates of what the polls suggest about trends
|
188
|
+
# Derived data presented on a Pollster Chart. The trendlines on a Pollster chart don't add up to 100: we calculate each label's trendline separately. Use the `charts/{slug}` response's `chart.pollster_estimates[0].algorithm` to find the algorithm Pollster used to generate these estimates. Pollster recalculates trendlines every time a new poll is entered. It also recalculates trendlines daily if they use the `bayesian-kallman` algorithm, because that algorithm's output changes depending on the end date.
|
189
|
+
# @param slug Unique Chart identifier. For example: `obama-job-approval`
|
190
|
+
# @param [Hash] opts the optional parameters
|
191
|
+
# @return [ChartPollsterTrendlines]
|
192
|
+
def charts_slug_pollster_trendlines_tsv_get(slug, opts = {})
|
193
|
+
data, _status_code, _headers = charts_slug_pollster_trendlines_tsv_get_with_http_info(slug, opts)
|
194
|
+
return data
|
195
|
+
end
|
196
|
+
|
197
|
+
# Estimates of what the polls suggest about trends
|
198
|
+
# Derived data presented on a Pollster Chart. The trendlines on a Pollster chart don't add up to 100: we calculate each label's trendline separately. Use the `charts/{slug}` response's `chart.pollster_estimates[0].algorithm` to find the algorithm Pollster used to generate these estimates. Pollster recalculates trendlines every time a new poll is entered. It also recalculates trendlines daily if they use the `bayesian-kallman` algorithm, because that algorithm's output changes depending on the end date.
|
199
|
+
# @param slug Unique Chart identifier. For example: `obama-job-approval`
|
200
|
+
# @param [Hash] opts the optional parameters
|
201
|
+
# @return [Array<(ChartPollsterTrendlines, Fixnum, Hash)>] ChartPollsterTrendlines data, response status code and response headers
|
202
|
+
def charts_slug_pollster_trendlines_tsv_get_with_http_info(slug, opts = {})
|
203
|
+
if @api_client.config.debugging
|
204
|
+
@api_client.config.logger.debug "Calling API: Api.charts_slug_pollster_trendlines_tsv_get ..."
|
205
|
+
end
|
206
|
+
# verify the required parameter 'slug' is set
|
207
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.charts_slug_pollster_trendlines_tsv_get" if slug.nil?
|
208
|
+
# resource path
|
209
|
+
local_var_path = "/charts/{slug}/pollster-trendlines.tsv".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
210
|
+
|
211
|
+
# query parameters
|
212
|
+
query_params = {}
|
213
|
+
|
214
|
+
# header parameters
|
215
|
+
header_params = {}
|
216
|
+
|
217
|
+
# HTTP header 'Accept' (if needed)
|
218
|
+
local_header_accept = ['text/tab-separated-values']
|
219
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
220
|
+
|
221
|
+
# HTTP header 'Content-Type'
|
222
|
+
local_header_content_type = []
|
223
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
224
|
+
|
225
|
+
# form parameters
|
226
|
+
form_params = {}
|
227
|
+
|
228
|
+
# http body (model)
|
229
|
+
post_body = nil
|
230
|
+
auth_names = []
|
231
|
+
data, status_code, headers = @api_client.call_api_tsv(:GET, local_var_path,
|
232
|
+
:header_params => header_params,
|
233
|
+
:query_params => query_params,
|
234
|
+
:form_params => form_params,
|
235
|
+
:body => post_body,
|
236
|
+
:auth_names => auth_names,
|
237
|
+
:return_type => 'ChartPollsterTrendlines')
|
238
|
+
if @api_client.config.debugging
|
239
|
+
@api_client.config.logger.debug "API called: Api#charts_slug_pollster_trendlines_tsv_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
240
|
+
end
|
241
|
+
return data, status_code, headers
|
242
|
+
end
|
243
|
+
|
244
|
+
# Polls
|
245
|
+
# A Poll on Pollster is a collection of questions and responses published by a reputable survey house. This endpoint provides raw data from the survey house, plus Pollster-provided metadata about each question. Pollster editors don't include every question when they enter Polls, and they don't necessarily enter every subpopulation for the responses they _do_ enter. They make editorial decisions about which questions belong in the database. The response will contain a maximum of 25 Poll objects, even if the database contains more than 25 polls. Use the `next_cursor` parameter to fetch the rest, 25 Polls at a time.
|
246
|
+
# @param [Hash] opts the optional parameters
|
247
|
+
# @option opts [String] :cursor Special string to index into the Array
|
248
|
+
# @option opts [String] :tags Comma-separated list of Question tag names; only Polls containing Questions with any of the given tags will be returned.
|
249
|
+
# @option opts [String] :question Question slug; only Polls that ask that Question will be returned.
|
250
|
+
# @option opts [String] :sort If `updated_at`, sort the most recently updated Poll first. (This can cause race conditions when used with `cursor`.) Otherwise, sort by most recently _entered_ Poll first. (default to created_at)
|
251
|
+
# @return [InlineResponse2003]
|
252
|
+
def polls_get(opts = {})
|
253
|
+
data, _status_code, _headers = polls_get_with_http_info(opts)
|
254
|
+
return data
|
255
|
+
end
|
256
|
+
|
257
|
+
# Polls
|
258
|
+
# A Poll on Pollster is a collection of questions and responses published by a reputable survey house. This endpoint provides raw data from the survey house, plus Pollster-provided metadata about each question. Pollster editors don't include every question when they enter Polls, and they don't necessarily enter every subpopulation for the responses they _do_ enter. They make editorial decisions about which questions belong in the database. The response will contain a maximum of 25 Poll objects, even if the database contains more than 25 polls. Use the `next_cursor` parameter to fetch the rest, 25 Polls at a time.
|
259
|
+
# @param [Hash] opts the optional parameters
|
260
|
+
# @option opts [String] :cursor Special string to index into the Array
|
261
|
+
# @option opts [String] :tags Comma-separated list of Question tag names; only Polls containing Questions with any of the given tags will be returned.
|
262
|
+
# @option opts [String] :question Question slug; only Polls that ask that Question will be returned.
|
263
|
+
# @option opts [String] :sort If `updated_at`, sort the most recently updated Poll first. (This can cause race conditions when used with `cursor`.) Otherwise, sort by most recently _entered_ Poll first.
|
264
|
+
# @return [Array<(InlineResponse2003, Fixnum, Hash)>] InlineResponse2003 data, response status code and response headers
|
265
|
+
def polls_get_with_http_info(opts = {})
|
266
|
+
if @api_client.config.debugging
|
267
|
+
@api_client.config.logger.debug "Calling API: Api.polls_get ..."
|
268
|
+
end
|
269
|
+
if opts[:'sort'] && !['created_at', 'updated_at'].include?(opts[:'sort'])
|
270
|
+
fail ArgumentError, 'invalid value for "sort", must be one of created_at, updated_at'
|
271
|
+
end
|
272
|
+
# resource path
|
273
|
+
local_var_path = "/polls".sub('{format}','json')
|
274
|
+
|
275
|
+
# query parameters
|
276
|
+
query_params = {}
|
277
|
+
query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
|
278
|
+
query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
|
279
|
+
query_params[:'question'] = opts[:'question'] if !opts[:'question'].nil?
|
280
|
+
query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
|
281
|
+
|
282
|
+
# header parameters
|
283
|
+
header_params = {}
|
284
|
+
|
285
|
+
# HTTP header 'Accept' (if needed)
|
286
|
+
local_header_accept = ['application/json', 'application/xml']
|
287
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
288
|
+
|
289
|
+
# HTTP header 'Content-Type'
|
290
|
+
local_header_content_type = []
|
291
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
292
|
+
|
293
|
+
# form parameters
|
294
|
+
form_params = {}
|
295
|
+
|
296
|
+
# http body (model)
|
297
|
+
post_body = nil
|
298
|
+
auth_names = []
|
299
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
300
|
+
:header_params => header_params,
|
301
|
+
:query_params => query_params,
|
302
|
+
:form_params => form_params,
|
303
|
+
:body => post_body,
|
304
|
+
:auth_names => auth_names,
|
305
|
+
:return_type => 'InlineResponse2003')
|
306
|
+
if @api_client.config.debugging
|
307
|
+
@api_client.config.logger.debug "API called: Api#polls_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
308
|
+
end
|
309
|
+
return data, status_code, headers
|
310
|
+
end
|
311
|
+
|
312
|
+
# Poll
|
313
|
+
# A Poll on Pollster is a collection of questions and responses published by a reputable survey house. This endpoint provides raw data from the survey house, plus Pollster-provided metadata about each question. Pollster editors don't include every question when they enter Polls, and they don't necessarily enter every subpopulation for the responses they _do_ enter. They make editorial decisions about which questions belong in the database.
|
314
|
+
# @param slug Unique Poll identifier. For example: `gallup-26892`.
|
315
|
+
# @param [Hash] opts the optional parameters
|
316
|
+
# @return [Poll]
|
317
|
+
def polls_slug_get(slug, opts = {})
|
318
|
+
data, _status_code, _headers = polls_slug_get_with_http_info(slug, opts)
|
319
|
+
return data
|
320
|
+
end
|
321
|
+
|
322
|
+
# Poll
|
323
|
+
# A Poll on Pollster is a collection of questions and responses published by a reputable survey house. This endpoint provides raw data from the survey house, plus Pollster-provided metadata about each question. Pollster editors don't include every question when they enter Polls, and they don't necessarily enter every subpopulation for the responses they _do_ enter. They make editorial decisions about which questions belong in the database.
|
324
|
+
# @param slug Unique Poll identifier. For example: `gallup-26892`.
|
325
|
+
# @param [Hash] opts the optional parameters
|
326
|
+
# @return [Array<(Poll, Fixnum, Hash)>] Poll data, response status code and response headers
|
327
|
+
def polls_slug_get_with_http_info(slug, opts = {})
|
328
|
+
if @api_client.config.debugging
|
329
|
+
@api_client.config.logger.debug "Calling API: Api.polls_slug_get ..."
|
330
|
+
end
|
331
|
+
# verify the required parameter 'slug' is set
|
332
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.polls_slug_get" if slug.nil?
|
333
|
+
# resource path
|
334
|
+
local_var_path = "/polls/{slug}".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
335
|
+
|
336
|
+
# query parameters
|
337
|
+
query_params = {}
|
338
|
+
|
339
|
+
# header parameters
|
340
|
+
header_params = {}
|
341
|
+
|
342
|
+
# HTTP header 'Accept' (if needed)
|
343
|
+
local_header_accept = ['application/json', 'application/xml']
|
344
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
345
|
+
|
346
|
+
# HTTP header 'Content-Type'
|
347
|
+
local_header_content_type = []
|
348
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
349
|
+
|
350
|
+
# form parameters
|
351
|
+
form_params = {}
|
352
|
+
|
353
|
+
# http body (model)
|
354
|
+
post_body = nil
|
355
|
+
auth_names = []
|
356
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
357
|
+
:header_params => header_params,
|
358
|
+
:query_params => query_params,
|
359
|
+
:form_params => form_params,
|
360
|
+
:body => post_body,
|
361
|
+
:auth_names => auth_names,
|
362
|
+
:return_type => 'Poll')
|
363
|
+
if @api_client.config.debugging
|
364
|
+
@api_client.config.logger.debug "API called: Api#polls_slug_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
365
|
+
end
|
366
|
+
return data, status_code, headers
|
367
|
+
end
|
368
|
+
|
369
|
+
# Questions
|
370
|
+
# Returns a list of Questions. A Question is chosen by Pollster editors. One example is \"Obama job approval\". Different survey houses may publish varying phrasings (\"Do you approve or disapprove\" vs \"What do you think of the job\") and prompt readers with varying responses (one poll might have \"Approve\" and \"Disapprove\"; another poll might have \"Strongly approve\" and \"Somewhat approve\"). Those variations do not appear in this API endpoint.
|
371
|
+
# @param [Hash] opts the optional parameters
|
372
|
+
# @option opts [String] :cursor Special string to index into the Array
|
373
|
+
# @option opts [String] :tags Comma-separated list of Question tag names. Only Questions with one or more of these tags will be returned.
|
374
|
+
# @option opts [Date] :election_date Date of an election, in YYYY-MM-DD format. Only Questions pertaining to an election on this date will be returned.
|
375
|
+
# @return [InlineResponse2004]
|
376
|
+
def questions_get(opts = {})
|
377
|
+
data, _status_code, _headers = questions_get_with_http_info(opts)
|
378
|
+
return data
|
379
|
+
end
|
380
|
+
|
381
|
+
# Questions
|
382
|
+
# Returns a list of Questions. A Question is chosen by Pollster editors. One example is \"Obama job approval\". Different survey houses may publish varying phrasings (\"Do you approve or disapprove\" vs \"What do you think of the job\") and prompt readers with varying responses (one poll might have \"Approve\" and \"Disapprove\"; another poll might have \"Strongly approve\" and \"Somewhat approve\"). Those variations do not appear in this API endpoint.
|
383
|
+
# @param [Hash] opts the optional parameters
|
384
|
+
# @option opts [String] :cursor Special string to index into the Array
|
385
|
+
# @option opts [String] :tags Comma-separated list of Question tag names. Only Questions with one or more of these tags will be returned.
|
386
|
+
# @option opts [Date] :election_date Date of an election, in YYYY-MM-DD format. Only Questions pertaining to an election on this date will be returned.
|
387
|
+
# @return [Array<(InlineResponse2004, Fixnum, Hash)>] InlineResponse2004 data, response status code and response headers
|
388
|
+
def questions_get_with_http_info(opts = {})
|
389
|
+
if @api_client.config.debugging
|
390
|
+
@api_client.config.logger.debug "Calling API: Api.questions_get ..."
|
391
|
+
end
|
392
|
+
# resource path
|
393
|
+
local_var_path = "/questions".sub('{format}','json')
|
394
|
+
|
395
|
+
# query parameters
|
396
|
+
query_params = {}
|
397
|
+
query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
|
398
|
+
query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
|
399
|
+
query_params[:'election_date'] = opts[:'election_date'] if !opts[:'election_date'].nil?
|
400
|
+
|
401
|
+
# header parameters
|
402
|
+
header_params = {}
|
403
|
+
|
404
|
+
# HTTP header 'Accept' (if needed)
|
405
|
+
local_header_accept = ['application/json', 'application/xml']
|
406
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
407
|
+
|
408
|
+
# HTTP header 'Content-Type'
|
409
|
+
local_header_content_type = []
|
410
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
411
|
+
|
412
|
+
# form parameters
|
413
|
+
form_params = {}
|
414
|
+
|
415
|
+
# http body (model)
|
416
|
+
post_body = nil
|
417
|
+
auth_names = []
|
418
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
419
|
+
:header_params => header_params,
|
420
|
+
:query_params => query_params,
|
421
|
+
:form_params => form_params,
|
422
|
+
:body => post_body,
|
423
|
+
:auth_names => auth_names,
|
424
|
+
:return_type => 'InlineResponse2004')
|
425
|
+
if @api_client.config.debugging
|
426
|
+
@api_client.config.logger.debug "API called: Api#questions_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
427
|
+
end
|
428
|
+
return data, status_code, headers
|
429
|
+
end
|
430
|
+
|
431
|
+
# Question
|
432
|
+
# A Question is chosen by Pollster editors. One example is \"Obama job approval\". Different survey houses may publish varying phrasings (\"Do you approve or disapprove\" vs \"What do you think of the job\") and prompt readers with varying responses (one poll might have \"Approve\" and \"Disapprove\"; another poll might have \"Strongly approve\" and \"Somewhat approve\"). Those variations do not appear in this API endpoint.
|
433
|
+
# @param slug Unique Question identifier. For example: `00c -Pres (44) Obama - Job Approval - National`. (Remember to URL-encode this parameter when querying.)
|
434
|
+
# @param [Hash] opts the optional parameters
|
435
|
+
# @return [Question]
|
436
|
+
def questions_slug_get(slug, opts = {})
|
437
|
+
data, _status_code, _headers = questions_slug_get_with_http_info(slug, opts)
|
438
|
+
return data
|
439
|
+
end
|
440
|
+
|
441
|
+
# Question
|
442
|
+
# A Question is chosen by Pollster editors. One example is \"Obama job approval\". Different survey houses may publish varying phrasings (\"Do you approve or disapprove\" vs \"What do you think of the job\") and prompt readers with varying responses (one poll might have \"Approve\" and \"Disapprove\"; another poll might have \"Strongly approve\" and \"Somewhat approve\"). Those variations do not appear in this API endpoint.
|
443
|
+
# @param slug Unique Question identifier. For example: `00c -Pres (44) Obama - Job Approval - National`. (Remember to URL-encode this parameter when querying.)
|
444
|
+
# @param [Hash] opts the optional parameters
|
445
|
+
# @return [Array<(Question, Fixnum, Hash)>] Question data, response status code and response headers
|
446
|
+
def questions_slug_get_with_http_info(slug, opts = {})
|
447
|
+
if @api_client.config.debugging
|
448
|
+
@api_client.config.logger.debug "Calling API: Api.questions_slug_get ..."
|
449
|
+
end
|
450
|
+
# verify the required parameter 'slug' is set
|
451
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.questions_slug_get" if slug.nil?
|
452
|
+
# resource path
|
453
|
+
local_var_path = "/questions/{slug}".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
454
|
+
|
455
|
+
# query parameters
|
456
|
+
query_params = {}
|
457
|
+
|
458
|
+
# header parameters
|
459
|
+
header_params = {}
|
460
|
+
|
461
|
+
# HTTP header 'Accept' (if needed)
|
462
|
+
local_header_accept = ['application/json', 'application/xml']
|
463
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
464
|
+
|
465
|
+
# HTTP header 'Content-Type'
|
466
|
+
local_header_content_type = []
|
467
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
468
|
+
|
469
|
+
# form parameters
|
470
|
+
form_params = {}
|
471
|
+
|
472
|
+
# http body (model)
|
473
|
+
post_body = nil
|
474
|
+
auth_names = []
|
475
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
476
|
+
:header_params => header_params,
|
477
|
+
:query_params => query_params,
|
478
|
+
:form_params => form_params,
|
479
|
+
:body => post_body,
|
480
|
+
:auth_names => auth_names,
|
481
|
+
:return_type => 'Question')
|
482
|
+
if @api_client.config.debugging
|
483
|
+
@api_client.config.logger.debug "API called: Api#questions_slug_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
484
|
+
end
|
485
|
+
return data, status_code, headers
|
486
|
+
end
|
487
|
+
|
488
|
+
# One row of response values per PollQuestion+Subpopulation concerning the given Question
|
489
|
+
# We include one TSV column per response label. See `questions/{slug}` for the Question's list of response labels, which are chosen by Pollster editors. Each row represents a single PollQuestion+Subpopulation. The value for each label column is the sum of the PollQuestion+Subpopulation responses that map to that `pollster_label`. For instance, on a hypothetical row, the `Approve` column might be the sum of that poll's `Strongly Approve` and `Somewhat Approve`. After the first TSV columns -- which are always response labels -- the next column will be `poll_slug`. `poll_slug` and subsequent columns are described in this API documentation. During the lifetime of a Question, Pollster editors may add, rename or reorder response labels. Such edits will change the TSV column headers. Column headers after `poll_slug` are never reordered or edited (but we may add new column headers). Sometimes a Poll may ask the same Question twice, leading to two similar rows with different values. Those rows will differ by `question_text` or by the set of response labels that have values.
|
490
|
+
# @param slug Unique Question identifier. For example: `00c -Pres (44) Obama - Job Approval - National`. (Remember to URL-encode this parameter when querying.)
|
491
|
+
# @param [Hash] opts the optional parameters
|
492
|
+
# @return [QuestionPollResponsesClean]
|
493
|
+
def questions_slug_poll_responses_clean_tsv_get(slug, opts = {})
|
494
|
+
data, _status_code, _headers = questions_slug_poll_responses_clean_tsv_get_with_http_info(slug, opts)
|
495
|
+
return data
|
496
|
+
end
|
497
|
+
|
498
|
+
# One row of response values per PollQuestion+Subpopulation concerning the given Question
|
499
|
+
# We include one TSV column per response label. See `questions/{slug}` for the Question's list of response labels, which are chosen by Pollster editors. Each row represents a single PollQuestion+Subpopulation. The value for each label column is the sum of the PollQuestion+Subpopulation responses that map to that `pollster_label`. For instance, on a hypothetical row, the `Approve` column might be the sum of that poll's `Strongly Approve` and `Somewhat Approve`. After the first TSV columns -- which are always response labels -- the next column will be `poll_slug`. `poll_slug` and subsequent columns are described in this API documentation. During the lifetime of a Question, Pollster editors may add, rename or reorder response labels. Such edits will change the TSV column headers. Column headers after `poll_slug` are never reordered or edited (but we may add new column headers). Sometimes a Poll may ask the same Question twice, leading to two similar rows with different values. Those rows will differ by `question_text` or by the set of response labels that have values.
|
500
|
+
# @param slug Unique Question identifier. For example: `00c -Pres (44) Obama - Job Approval - National`. (Remember to URL-encode this parameter when querying.)
|
501
|
+
# @param [Hash] opts the optional parameters
|
502
|
+
# @return [Array<(QuestionPollResponsesClean, Fixnum, Hash)>] QuestionPollResponsesClean data, response status code and response headers
|
503
|
+
def questions_slug_poll_responses_clean_tsv_get_with_http_info(slug, opts = {})
|
504
|
+
if @api_client.config.debugging
|
505
|
+
@api_client.config.logger.debug "Calling API: Api.questions_slug_poll_responses_clean_tsv_get ..."
|
506
|
+
end
|
507
|
+
# verify the required parameter 'slug' is set
|
508
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.questions_slug_poll_responses_clean_tsv_get" if slug.nil?
|
509
|
+
# resource path
|
510
|
+
local_var_path = "/questions/{slug}/poll-responses-clean.tsv".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
511
|
+
|
512
|
+
# query parameters
|
513
|
+
query_params = {}
|
514
|
+
|
515
|
+
# header parameters
|
516
|
+
header_params = {}
|
517
|
+
|
518
|
+
# HTTP header 'Accept' (if needed)
|
519
|
+
local_header_accept = ['text/tab-separated-values']
|
520
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
521
|
+
|
522
|
+
# HTTP header 'Content-Type'
|
523
|
+
local_header_content_type = []
|
524
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
525
|
+
|
526
|
+
# form parameters
|
527
|
+
form_params = {}
|
528
|
+
|
529
|
+
# http body (model)
|
530
|
+
post_body = nil
|
531
|
+
auth_names = []
|
532
|
+
data, status_code, headers = @api_client.call_api_tsv(:GET, local_var_path,
|
533
|
+
:header_params => header_params,
|
534
|
+
:query_params => query_params,
|
535
|
+
:form_params => form_params,
|
536
|
+
:body => post_body,
|
537
|
+
:auth_names => auth_names,
|
538
|
+
:return_type => 'QuestionPollResponsesClean')
|
539
|
+
if @api_client.config.debugging
|
540
|
+
@api_client.config.logger.debug "API called: Api#questions_slug_poll_responses_clean_tsv_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
541
|
+
end
|
542
|
+
return data, status_code, headers
|
543
|
+
end
|
544
|
+
|
545
|
+
# One row per PollQuestion+Subpopulation+Response concerning the given Question (Large)
|
546
|
+
# Raw data from which we derived `poll-responses-clean.tsv`. Each row represents a single PollQuestion+Subpopulation+Response. See the Poll API for a description of these terms. Group results by `(poll_slug, subpopulation, question_text)`: that's how the survey houses group them. This response can be several megabytes large. We encourage you to consider `poll-responses-clean.tsv` instead.
|
547
|
+
# @param slug Unique Question identifier. For example: `00c -Pres (44) Obama - Job Approval - National`. (Remember to URL-encode this parameter when querying.)
|
548
|
+
# @param [Hash] opts the optional parameters
|
549
|
+
# @return [QuestionPollResponsesRaw]
|
550
|
+
def questions_slug_poll_responses_raw_tsv_get(slug, opts = {})
|
551
|
+
data, _status_code, _headers = questions_slug_poll_responses_raw_tsv_get_with_http_info(slug, opts)
|
552
|
+
return data
|
553
|
+
end
|
554
|
+
|
555
|
+
# One row per PollQuestion+Subpopulation+Response concerning the given Question (Large)
|
556
|
+
# Raw data from which we derived `poll-responses-clean.tsv`. Each row represents a single PollQuestion+Subpopulation+Response. See the Poll API for a description of these terms. Group results by `(poll_slug, subpopulation, question_text)`: that's how the survey houses group them. This response can be several megabytes large. We encourage you to consider `poll-responses-clean.tsv` instead.
|
557
|
+
# @param slug Unique Question identifier. For example: `00c -Pres (44) Obama - Job Approval - National`. (Remember to URL-encode this parameter when querying.)
|
558
|
+
# @param [Hash] opts the optional parameters
|
559
|
+
# @return [Array<(QuestionPollResponsesRaw, Fixnum, Hash)>] QuestionPollResponsesRaw data, response status code and response headers
|
560
|
+
def questions_slug_poll_responses_raw_tsv_get_with_http_info(slug, opts = {})
|
561
|
+
if @api_client.config.debugging
|
562
|
+
@api_client.config.logger.debug "Calling API: Api.questions_slug_poll_responses_raw_tsv_get ..."
|
563
|
+
end
|
564
|
+
# verify the required parameter 'slug' is set
|
565
|
+
fail ArgumentError, "Missing the required parameter 'slug' when calling Api.questions_slug_poll_responses_raw_tsv_get" if slug.nil?
|
566
|
+
# resource path
|
567
|
+
local_var_path = "/questions/{slug}/poll-responses-raw.tsv".sub('{format}','json').sub('{' + 'slug' + '}', slug.to_s)
|
568
|
+
|
569
|
+
# query parameters
|
570
|
+
query_params = {}
|
571
|
+
|
572
|
+
# header parameters
|
573
|
+
header_params = {}
|
574
|
+
|
575
|
+
# HTTP header 'Accept' (if needed)
|
576
|
+
local_header_accept = ['text/tab-separated-values']
|
577
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
578
|
+
|
579
|
+
# HTTP header 'Content-Type'
|
580
|
+
local_header_content_type = []
|
581
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
582
|
+
|
583
|
+
# form parameters
|
584
|
+
form_params = {}
|
585
|
+
|
586
|
+
# http body (model)
|
587
|
+
post_body = nil
|
588
|
+
auth_names = []
|
589
|
+
data, status_code, headers = @api_client.call_api_tsv(:GET, local_var_path,
|
590
|
+
:header_params => header_params,
|
591
|
+
:query_params => query_params,
|
592
|
+
:form_params => form_params,
|
593
|
+
:body => post_body,
|
594
|
+
:auth_names => auth_names,
|
595
|
+
:return_type => 'QuestionPollResponsesRaw')
|
596
|
+
if @api_client.config.debugging
|
597
|
+
@api_client.config.logger.debug "API called: Api#questions_slug_poll_responses_raw_tsv_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
598
|
+
end
|
599
|
+
return data, status_code, headers
|
600
|
+
end
|
601
|
+
|
602
|
+
# Tags
|
603
|
+
# Returns the list of Tags. A Tag can apply to any number of Charts and Questions; Charts and Questions, in turn, can have any number of Tags. Tags all look `like-this`: lowercase letters, numbers and hyphens.
|
604
|
+
# @param [Hash] opts the optional parameters
|
605
|
+
# @return [Array<Tag>]
|
606
|
+
def tags_get(opts = {})
|
607
|
+
data, _status_code, _headers = tags_get_with_http_info(opts)
|
608
|
+
return data
|
609
|
+
end
|
610
|
+
|
611
|
+
# Tags
|
612
|
+
# Returns the list of Tags. A Tag can apply to any number of Charts and Questions; Charts and Questions, in turn, can have any number of Tags. Tags all look `like-this`: lowercase letters, numbers and hyphens.
|
613
|
+
# @param [Hash] opts the optional parameters
|
614
|
+
# @return [Array<(Array<Tag>, Fixnum, Hash)>] Array<Tag> data, response status code and response headers
|
615
|
+
def tags_get_with_http_info(opts = {})
|
616
|
+
if @api_client.config.debugging
|
617
|
+
@api_client.config.logger.debug "Calling API: Api.tags_get ..."
|
618
|
+
end
|
619
|
+
# resource path
|
620
|
+
local_var_path = "/tags".sub('{format}','json')
|
621
|
+
|
622
|
+
# query parameters
|
623
|
+
query_params = {}
|
624
|
+
|
625
|
+
# header parameters
|
626
|
+
header_params = {}
|
627
|
+
|
628
|
+
# HTTP header 'Accept' (if needed)
|
629
|
+
local_header_accept = ['application/json', 'application/xml']
|
630
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
631
|
+
|
632
|
+
# HTTP header 'Content-Type'
|
633
|
+
local_header_content_type = []
|
634
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
635
|
+
|
636
|
+
# form parameters
|
637
|
+
form_params = {}
|
638
|
+
|
639
|
+
# http body (model)
|
640
|
+
post_body = nil
|
641
|
+
auth_names = []
|
642
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
643
|
+
:header_params => header_params,
|
644
|
+
:query_params => query_params,
|
645
|
+
:form_params => form_params,
|
646
|
+
:body => post_body,
|
647
|
+
:auth_names => auth_names,
|
648
|
+
:return_type => 'Array<Tag>')
|
649
|
+
if @api_client.config.debugging
|
650
|
+
@api_client.config.logger.debug "API called: Api#tags_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
651
|
+
end
|
652
|
+
return data, status_code, headers
|
653
|
+
end
|
654
|
+
end
|
655
|
+
end
|