seeclickfix 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gemtest +0 -0
- data/.gitignore +41 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/.yardopts +3 -0
- data/Gemfile +10 -0
- data/LICENSE.md +10 -0
- data/README.md +72 -0
- data/Rakefile +18 -0
- data/lib/seeclickfix.rb +23 -0
- data/lib/seeclickfix/client.rb +31 -0
- data/lib/seeclickfix/client/comments.rb +38 -0
- data/lib/seeclickfix/client/issues.rb +83 -0
- data/lib/seeclickfix/client/service_request_questions.rb +19 -0
- data/lib/seeclickfix/client/service_request_types.rb +21 -0
- data/lib/seeclickfix/client/watch_areas.rb +26 -0
- data/lib/seeclickfix/configuration.rb +53 -0
- data/lib/seeclickfix/connection.rb +24 -0
- data/lib/seeclickfix/request.rb +26 -0
- data/lib/seeclickfix/version.rb +3 -0
- data/seeclickfix.gemspec +30 -0
- data/spec/fixtures/comments.json +1 -0
- data/spec/fixtures/create_comment.json +1 -0
- data/spec/fixtures/create_issue.json +1 -0
- data/spec/fixtures/issue_details_1050.json +1 -0
- data/spec/fixtures/issues_sf.json +1 -0
- data/spec/fixtures/request_type_questions.json +1 -0
- data/spec/fixtures/request_types.json +1 -0
- data/spec/fixtures/watchers.json +1 -0
- data/spec/helper.rb +51 -0
- data/spec/seeclickfix/client/comments_spec.rb +38 -0
- data/spec/seeclickfix/client/issues_spec.rb +50 -0
- data/spec/seeclickfix/client/service_request_question_spec.rb +24 -0
- data/spec/seeclickfix/client/service_request_types_spec.rb +24 -0
- data/spec/seeclickfix/client/watch_areas_spec.rb +23 -0
- data/spec/seeclickfix_spec.rb +15 -0
- metadata +228 -0
data/.autotest
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'autotest/bundler'
|
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
!.gitignore
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
*.sw[a-p]
|
5
|
+
*.tmproj
|
6
|
+
*.tmproject
|
7
|
+
*.un~
|
8
|
+
*~
|
9
|
+
.DS_Store
|
10
|
+
.Spotlight-V100
|
11
|
+
.Trashes
|
12
|
+
._*
|
13
|
+
.bundle
|
14
|
+
.config
|
15
|
+
.directory
|
16
|
+
.elc
|
17
|
+
.redcar
|
18
|
+
.yardoc
|
19
|
+
/.emacs.desktop
|
20
|
+
/.emacs.desktop.lock
|
21
|
+
Desktop.ini
|
22
|
+
Gemfile.lock
|
23
|
+
Icon?
|
24
|
+
InstalledFiles
|
25
|
+
Session.vim
|
26
|
+
Thumbs.db
|
27
|
+
\#*\#
|
28
|
+
_yardoc
|
29
|
+
auto-save-list
|
30
|
+
coverage
|
31
|
+
doc/
|
32
|
+
lib/bundler/man
|
33
|
+
pkg
|
34
|
+
pkg/*
|
35
|
+
rdoc
|
36
|
+
spec/reports
|
37
|
+
test/tmp
|
38
|
+
test/version_tmp
|
39
|
+
tmp
|
40
|
+
tmtags
|
41
|
+
tramp
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Copyright (c) 2011, Code for America
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
* Neither the name of Code for America nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
SeeClickFix API
|
2
|
+
=======
|
3
|
+
A Ruby wrapper for the SeeClickFix APIs at [http://help.seeclickfix.com/kb/api/api-overview](http://help.seeclickfix.com/kb/api/api-overview)
|
4
|
+
|
5
|
+
Does your project or organization use this gem?
|
6
|
+
------------------------------------------
|
7
|
+
Add it to the [apps](http://github.com/codeforamerica/seeclickfix_rb/wiki/apps) wiki!
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
$ gem install seeclickfix
|
12
|
+
|
13
|
+
Documentation
|
14
|
+
-------------
|
15
|
+
[http://rdoc.info/gems/seeclickfix](http://rdoc.info/gems/seeclickfix)
|
16
|
+
|
17
|
+
Continuous Integration
|
18
|
+
----------------------
|
19
|
+
[![Build Status](https://secure.travis-ci.org/codeforamerica/seeclickfix_rb.png)](http://travis-ci.org/codeforamerica/seeclickfix_rb)
|
20
|
+
|
21
|
+
Usage Examples
|
22
|
+
--------------
|
23
|
+
require 'seeclickfix'
|
24
|
+
|
25
|
+
@client = SeeClickFix::Client::New
|
26
|
+
a = @client.list_issues("San Francisco")
|
27
|
+
a.first.issue_id # => 108657
|
28
|
+
|
29
|
+
|
30
|
+
Contributing
|
31
|
+
------------
|
32
|
+
In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
|
33
|
+
|
34
|
+
Here are some ways *you* can contribute:
|
35
|
+
|
36
|
+
* by using alpha, beta, and prerelease versions
|
37
|
+
* by reporting bugs
|
38
|
+
* by suggesting new features
|
39
|
+
* by writing or editing documentation
|
40
|
+
* by writing specifications
|
41
|
+
* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
|
42
|
+
* by refactoring code
|
43
|
+
* by resolving [issues](http://github.com/codeforamerica/seeclickfix_rb/issues)
|
44
|
+
* by reviewing patches
|
45
|
+
|
46
|
+
Submitting an Issue
|
47
|
+
-------------------
|
48
|
+
We use the [GitHub issue tracker](http://github.com/codeforamerica/seeclickfix_rb/issues) to track bugs and
|
49
|
+
features. Before submitting a bug report or feature request, check to make sure it hasn't already
|
50
|
+
been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
|
51
|
+
bug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any
|
52
|
+
details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
|
53
|
+
operating system. Ideally, a bug report should include a pull request with failing specs.
|
54
|
+
|
55
|
+
Submitting a Pull Request
|
56
|
+
-------------------------
|
57
|
+
1. Fork the project.
|
58
|
+
2. Create a topic branch.
|
59
|
+
3. Implement your feature or bug fix.
|
60
|
+
4. Add documentation for your feature or bug fix.
|
61
|
+
5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
|
62
|
+
6. Add specs for your feature or bug fix.
|
63
|
+
7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
|
64
|
+
8. Commit and push your changes.
|
65
|
+
9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
|
66
|
+
|
67
|
+
Copyright
|
68
|
+
---------
|
69
|
+
Copyright (c) 2010 Code for America Laboratories
|
70
|
+
See [LICENSE](https://github.com/cfalabs/seeclickfix_rb/blob/master/LICENSE.md) for details.
|
71
|
+
|
72
|
+
[![Code for America Tracker](http://stats.codeforamerica.org/codeforamerica/seeclickfix_rb.png)](http://stats.codeforamerica.org/projects/seeclickfix_rb)
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
task :default => :spec
|
10
|
+
task :test => :spec
|
11
|
+
|
12
|
+
require 'yard'
|
13
|
+
namespace :doc do
|
14
|
+
YARD::Rake::YardocTask.new do |task|
|
15
|
+
task.files = ['LICENSE.md', 'lib/**/*.rb']
|
16
|
+
task.options = ['--markup', 'markdown']
|
17
|
+
end
|
18
|
+
end
|
data/lib/seeclickfix.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'seeclickfix/configuration'
|
2
|
+
require 'seeclickfix/client'
|
3
|
+
|
4
|
+
module SeeClickFix
|
5
|
+
extend Configuration
|
6
|
+
|
7
|
+
# Alias for SeeClickFix::Client.new
|
8
|
+
#
|
9
|
+
# @return [SeeClickFix::Client]
|
10
|
+
def self.client(options={})
|
11
|
+
SeeClickFix::Client.new(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Delegate to SeeClickFix::Client.new
|
15
|
+
def self.method_missing(method, *args, &block)
|
16
|
+
return super unless client.respond_to?(method)
|
17
|
+
client.send(method, *args, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.respond_to?(method, include_private=false)
|
21
|
+
client.respond_to?(method, include_private) || super(method, include_private)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'seeclickfix/connection'
|
2
|
+
require 'seeclickfix/request'
|
3
|
+
|
4
|
+
require 'seeclickfix/client/comments'
|
5
|
+
require 'seeclickfix/client/issues'
|
6
|
+
require 'seeclickfix/client/service_request_questions'
|
7
|
+
require 'seeclickfix/client/service_request_types'
|
8
|
+
require 'seeclickfix/client/watch_areas'
|
9
|
+
|
10
|
+
module SeeClickFix
|
11
|
+
class Client
|
12
|
+
attr_accessor *Configuration::VALID_OPTIONS_KEYS
|
13
|
+
|
14
|
+
def initialize(options={})
|
15
|
+
options = SeeClickFix.options.merge(options)
|
16
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
17
|
+
send("#{key}=", options[key])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
include SeeClickFix::Client::Connection
|
22
|
+
include SeeClickFix::Request
|
23
|
+
|
24
|
+
include SeeClickFix::Client::Comments
|
25
|
+
include SeeClickFix::Client::Issues
|
26
|
+
include SeeClickFix::Client::ServiceRequestQuestions
|
27
|
+
include SeeClickFix::Client::ServiceRequestTypes
|
28
|
+
include SeeClickFix::Client::WatchAreas
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module SeeClickFix
|
2
|
+
class Client
|
3
|
+
module Comments
|
4
|
+
|
5
|
+
# Use this query the comments and history of a single issue.
|
6
|
+
#
|
7
|
+
# @param issue [String] The issue number for the query
|
8
|
+
# @param options [Hash] A customizable set of options.
|
9
|
+
# @return [Array<Hashie::Mash>]
|
10
|
+
# @see http://help.seeclickfix.com/kb/api/listing-comments-and-issue-history
|
11
|
+
# @example
|
12
|
+
# SeeClickFix.list_comments("1050")
|
13
|
+
def list_comments(issue, options={})
|
14
|
+
get("api/issues/#{issue}/comments.json", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Add a comment to an issue
|
18
|
+
#
|
19
|
+
# @param issue [String] The issue number for the query
|
20
|
+
# @param api_key [String] API Key
|
21
|
+
# @param comment [String] Comment to add
|
22
|
+
# @param comment_email [String] Email of the person making the comment
|
23
|
+
# @param options [Hash] A customizable set of options.
|
24
|
+
# @options options comment[name] Name of the person making the comment.
|
25
|
+
# @options options comment[send_email] Subscribe the email added to all comments.
|
26
|
+
# @options options comment[youtube_url] URL of a youtube video to add.
|
27
|
+
# @options options comment[comment_image_attributes][uploaded_data] Image to add to the comment.
|
28
|
+
# @return [Array<Hashie::Mash>]
|
29
|
+
# @see http://help.seeclickfix.com/kb/api/adding-a-comment
|
30
|
+
# @example
|
31
|
+
# SeeClickFix.create_comment("7000", "hello", "joe@myemail.com")
|
32
|
+
def create_comment(issue, comment, comment_email, options={})
|
33
|
+
post("api/issues/#{issue}/comments.json?comment[comment]=#{comment}&comment[email]=#{comment_email}", options)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module SeeClickFix
|
2
|
+
class Client
|
3
|
+
module Issues
|
4
|
+
|
5
|
+
# Returns a list of issues for the location Data is returned in chunks of num_results. You can increment the page parameter to get the next group of results. If page exceeds the total number of pages the result will be an empty array
|
6
|
+
#
|
7
|
+
# @param location [String] Geocodable street address. e.g. zipcode, city, state or 123 state st. new haven, ct.
|
8
|
+
# @option options zoom [String] Integer level from 0 to 19 based on google maps.
|
9
|
+
# @param options [Hash] A customizable set of options.
|
10
|
+
# @option options lat [String] Lattitude
|
11
|
+
# @option options lon [String] Longitude
|
12
|
+
# @option options lat_min [String] Minimum lattitude
|
13
|
+
# @option options lon_min [String] Minimum longitude
|
14
|
+
# @option options lat_max [String] Maximum lattitude
|
15
|
+
# @option options lon_max [String] Maximum longitude
|
16
|
+
# @option options status [String] Open Set equal to "true" to see open issues. If status is not set the API returns Open, Closed, and Acknowledged issues.
|
17
|
+
# @option options status [String] Closed Set equal to "true" to see closed issues. If status is not set the API returns Open, Closed, and Acknowledged issues.
|
18
|
+
# @option options status [String] Acknowledged Set equal to "true" to see acknowledged issues. If status is not set the API returns Open, Closed, and Acknowledged issues.
|
19
|
+
# @option options status [String] Archived Set equal to "true" to see archived issues. If status is not set the API returns Open, Closed, and Acknowledged issues.
|
20
|
+
# @option options start [String] The number of hours ago the oldest issue can be. Partial hours can be in decimal format, for example 0.25 shows reports in the last 15min.
|
21
|
+
# @option options end [String] The number of hours ago the youngest issue can be.
|
22
|
+
# @option options num_results [Integer] The maximum number of results to return (default 10, maximum 1000).
|
23
|
+
# @option options page [Integer] If the number of results exceeds num_results, page can increment the range.
|
24
|
+
# @option options search [String] A query string to limit the results by.
|
25
|
+
# @option options sort [String] A parameter to sort the results by. Possible values include: issues.updated_at - Date last updated
|
26
|
+
# @option options Issues.created_at [String] Date Created
|
27
|
+
# @option options Issues.rating [String] Issue Rating
|
28
|
+
# @option options Issues.hot [String] Issue Hotness
|
29
|
+
# @option options direction [String] Sort direction. Possible values include: ASC - Ascending
|
30
|
+
# @option options DESC [String] Descending.
|
31
|
+
# @option options request_tags [String] Limit results to issues with service request tags. Service request tags are automatically added to issues when issues are reported to a specific service request. Multiple request tags can be found using the form "request_type_[request_type_id],request_type_[request_type_id],request_type_[request_type_id]".
|
32
|
+
# @return [Array<Hashie::Mash>]
|
33
|
+
# @see http://help.seeclickfix.com/kb/api/listing-issues
|
34
|
+
# @example
|
35
|
+
# SeeClickFix.list_issues("San Francisco")
|
36
|
+
def list_issues(location, options={})
|
37
|
+
get("api/issues.json?at=#{location}", options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Use this query to get details on a single issue. There may be more information in this query than the issue listing query.
|
41
|
+
#
|
42
|
+
# @param issue [String] The issue number for the query
|
43
|
+
# @param options [Hash] A customizable set of options.
|
44
|
+
# @return [Array<Hashie::Mash>]
|
45
|
+
# @see http://help.seeclickfix.com/kb/api/querying-an-issue
|
46
|
+
# @example
|
47
|
+
# SeeClickFix.issue_details("1050")
|
48
|
+
def issue_details(issue, options={})
|
49
|
+
get("api/issues/#{issue}.json", options)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Use this query to get details on a single issue. There may be more information in this query than the issue listing query.
|
53
|
+
#
|
54
|
+
# @param summary [String] Summary of the problem
|
55
|
+
# @param lat [String] Latitude of the issue.
|
56
|
+
# @param lng [String] Longitude of the issue.
|
57
|
+
# @param api_key [String] Api key
|
58
|
+
# @param options [Hash] A customizable set of options.
|
59
|
+
# @option options issue[description] [String] Longer text describing the problem.
|
60
|
+
# @option options issue[address] [String] Text representation of the location of the issue.
|
61
|
+
# @option options issue[reporter_email] [String] Email of the person reporting the issue.
|
62
|
+
# @option options issue[reporter_display] [String] Text display of the person reporting the issue.
|
63
|
+
# @option options issue[issue_image_attributes][uploaded_data] [String] Attach an image to the issue. Form data must be sent as "multipart/form-data".
|
64
|
+
# @option options issue[request_type_id] [String] If submitting to a service request, specify the service request ID here. By adding this attribute, additional validations are required, including: 1. Making sure the service request can be within the given boundaries. 2. Making sure all of the required additional questions are completed.
|
65
|
+
# For each service request question provide the following parameters.
|
66
|
+
# @option options issue[request_type_answers_attributes][][request_type_question_primary_key] [String] Primary key of the service request question.
|
67
|
+
# @option options issue[request_type_answers_attributes][][answer] [String] Answer to the service request question.
|
68
|
+
# @return [Array<Hashie::Mash>]
|
69
|
+
# @see http://help.seeclickfix.com/kb/api/creating-an-issue
|
70
|
+
# @example
|
71
|
+
# SeeClickFix.issue_details("1050")
|
72
|
+
#
|
73
|
+
# @return [Array<Hashie::Mash>]
|
74
|
+
# @see http://help.seeclickfix.com/kb/api/querying-an-issue
|
75
|
+
# @example
|
76
|
+
# SeeClickFix.create_details("foo","41.3103725899427", "-72.9241595114853") http://seeclickfix.com/api/issues.xml
|
77
|
+
def create_issue(summary, lat, lng, options={})
|
78
|
+
post("api/issues.json?issue[summary]=#{summary}&issue[lat]=#{lat}&issue[lng]=#{lng}")
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SeeClickFix
|
2
|
+
class Client
|
3
|
+
module ServiceRequestQuestions
|
4
|
+
|
5
|
+
# Given a service request ID (chosen from the list of valid service request types), list the additional questions that need to be asked.
|
6
|
+
#
|
7
|
+
# @param request_type_id [String] Service request ID. A valid service request type ID
|
8
|
+
# @option api_key [String] API Key
|
9
|
+
# @param options [Hash] A customizable set of options.
|
10
|
+
# @return [Array<Hashie::Mash>]
|
11
|
+
# @see http://help.seeclickfix.com/kb/api/list-service-request-type-questions
|
12
|
+
# @example
|
13
|
+
# SeeClickFix.service_request_types("1")
|
14
|
+
def service_request_type_questions(request_type_id,options={})
|
15
|
+
get("api/request_types/#{request_type_id}/request_type_questions.json", options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SeeClickFix
|
2
|
+
class Client
|
3
|
+
module ServiceRequestTypes
|
4
|
+
|
5
|
+
# Use this query to list valid service request types (things like pothole, graffiti, street light out etc.) for a given location.
|
6
|
+
#
|
7
|
+
# @param lat [String] Latitude to check for service request types.
|
8
|
+
# @param long [String] Longitude to check for service request types.
|
9
|
+
# @option api_key [String] API Key
|
10
|
+
# @param options [Hash] A customizable set of options.
|
11
|
+
# @return [Array<Hashie::Mash>]
|
12
|
+
# @see http://help.seeclickfix.com/kb/api/list-service-request-types
|
13
|
+
# @example
|
14
|
+
# SeeClickFix.service_request_types("32.1610815588945","-110.87677001953125")
|
15
|
+
def service_request_types(lat,lng,options={})
|
16
|
+
get("api/request_types/at.json?lat=#{lat}&lng=#{lng}", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SeeClickFix
|
2
|
+
class Client
|
3
|
+
module WatchAreas
|
4
|
+
|
5
|
+
# Use this query to list public watch areas at a given location.
|
6
|
+
#
|
7
|
+
# @param options [Hash] A customizable set of options.
|
8
|
+
# @option options at [String] Geocodable street address. e.g. zipcode, city, state or 123 state st. new haven, ct.
|
9
|
+
# @option options zoom [String] Integer level from 0 to 19 based on google maps.
|
10
|
+
# @option options lat [String] Lattitude
|
11
|
+
# @option options lon [String] Longitude
|
12
|
+
# @option options lon [String] Longitude
|
13
|
+
# @option options radius [String] Radius to search for watch areas by. Radius is in units of degrees. Default is 1.
|
14
|
+
# @option options watcher_search [String] Search terms to limit the results by.
|
15
|
+
# @option options page [String] Page to display the results as. Results are sorted by distance from the required parameter area's center. Default is 1.
|
16
|
+
# @option options num_results [Integer] Number of results to return. Default is 20
|
17
|
+
# @return [Array<Hashie::Mash>]
|
18
|
+
# @see http://help.seeclickfix.com/kb/api/list-watch-areas
|
19
|
+
# @example
|
20
|
+
# SeeClickFix.watch_areas({:at => "San Francisco"})
|
21
|
+
def watch_areas(options={})
|
22
|
+
get("api/watchers/list.json", options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'seeclickfix/version'
|
3
|
+
|
4
|
+
module SeeClickFix
|
5
|
+
module Configuration
|
6
|
+
VALID_OPTIONS_KEYS = [
|
7
|
+
:adapter,
|
8
|
+
:api_key,
|
9
|
+
:api_version,
|
10
|
+
:login,
|
11
|
+
:password,
|
12
|
+
:proxy,
|
13
|
+
:token,
|
14
|
+
:oauth_token,
|
15
|
+
:user_agent].freeze
|
16
|
+
|
17
|
+
DEFAULT_ADAPTER = Faraday.default_adapter
|
18
|
+
DEFAULT_API_KEY = nil
|
19
|
+
DEFAULT_API_VERSION = nil
|
20
|
+
DEFAULT_LOGIN = nil
|
21
|
+
DEFAULT_PASSWORD = nil
|
22
|
+
DEFAULT_PROXY = nil
|
23
|
+
DEFAULT_TOKEN = nil
|
24
|
+
DEFAULT_OAUTH_TOKEN = nil
|
25
|
+
DEFAULT_USER_AGENT = "SeeClickFix Ruby Gem #{SeeClickFix::VERSION}".freeze
|
26
|
+
|
27
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
28
|
+
|
29
|
+
def self.extended(base)
|
30
|
+
base.reset
|
31
|
+
end
|
32
|
+
|
33
|
+
def configure
|
34
|
+
yield self
|
35
|
+
end
|
36
|
+
|
37
|
+
def options
|
38
|
+
VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def reset
|
42
|
+
self.adapter = DEFAULT_ADAPTER
|
43
|
+
self.api_key = DEFAULT_API_KEY
|
44
|
+
self.api_version = DEFAULT_API_VERSION
|
45
|
+
self.login = DEFAULT_LOGIN
|
46
|
+
self.password = DEFAULT_PASSWORD
|
47
|
+
self.proxy = DEFAULT_PROXY
|
48
|
+
self.token = DEFAULT_TOKEN
|
49
|
+
self.oauth_token = DEFAULT_OAUTH_TOKEN
|
50
|
+
self.user_agent = DEFAULT_USER_AGENT
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|