mobilize-america-client 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mobilize_america_client.rb +9 -0
- data/lib/mobilize_america_client/client.rb +16 -0
- data/lib/mobilize_america_client/client/events.rb +32 -0
- data/lib/mobilize_america_client/request.rb +29 -0
- data/mobilize-america-client.gemspec +70 -0
- data/spec/client/events_spec.rb +54 -0
- data/spec/spec_helper.rb +29 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b117cee8af822cab72b97313c0ed7308cc36172dfd12ddab7780e24a3162475e
|
4
|
+
data.tar.gz: 8c3f8ac61a4e80d89caa744dd3429bbb08a681a0e9fb213d5bb518ed5d173ed3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e031b5195b8571b03b975df4e55a591c781e909c21f799f2b427044155743e5a125b5fa6fdbec6b31ac060471a0c6f1939464eabcff4bb9a2f7a9b77a328fb6a
|
7
|
+
data.tar.gz: 337c481793e7e8f57116af8176dfdffe4f1bf6c2343a452e460a6731934eb8ac069fb3b11b3105d94346cd3a30634d578bc206d21af020123ea4e027af42dd6c
|
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jacinda@controlshiftlabs.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 ControlShift
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Jacinda Moore
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# MobilizeAmericaClient::Client
|
2
|
+
|
3
|
+
A minimalist API client for the [MobilizeAmerica API](https://github.com/mobilizeamerica/api):
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'mobilize-america-client'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mobilize-america-client
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
For now, the gem only supports listing an organization's events.
|
24
|
+
|
25
|
+
`MobilizeAmericaClient.new.organization_events(organization_id: 123)`
|
26
|
+
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/controlshift/mobilize-america-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the MobilizeAmericaClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/controlshift/mobilize-america-client/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
require 'juwelier'
|
14
|
+
Juwelier::Tasks.new do |gem|
|
15
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
16
|
+
gem.name = "mobilize-america-client"
|
17
|
+
gem.homepage = "http://github.com/controlshift/mobilize_america_client"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = %Q{Client gem for the MobilizeAmerica API}
|
20
|
+
gem.email = "jacinda@controlshiftlabs.com"
|
21
|
+
gem.authors = ["Jacinda Moore"]
|
22
|
+
|
23
|
+
# dependencies defined in Gemfile
|
24
|
+
end
|
25
|
+
Juwelier::RubygemsDotOrgTasks.new
|
26
|
+
require 'rake/testtask'
|
27
|
+
Rake::TestTask.new(:test) do |test|
|
28
|
+
test.libs << 'lib' << 'test'
|
29
|
+
test.pattern = 'test/**/test_*.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Code coverage detail"
|
34
|
+
task :simplecov do
|
35
|
+
ENV['COVERAGE'] = "true"
|
36
|
+
Rake::Task['test'].execute
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :test
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "mobilize-america-client #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mobilizeamerica/client"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'mobilize_america_client/client/events'
|
3
|
+
require 'mobilize_america_client/request'
|
4
|
+
|
5
|
+
module MobilizeAmericaClient
|
6
|
+
class Client
|
7
|
+
attr_reader :connection
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@connection = Faraday.new(url: "https://#{API_DOMAIN}")
|
11
|
+
end
|
12
|
+
|
13
|
+
include MobilizeAmericaClient::Request
|
14
|
+
include MobilizeAmericaClient::Client::Events
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MobilizeAmericaClient
|
2
|
+
class Client
|
3
|
+
module Events
|
4
|
+
def organization_events(organization_id:, updated_since: nil, max_distance_miles: nil, page: nil, per_page: nil,
|
5
|
+
zipcode: nil)
|
6
|
+
params = {}
|
7
|
+
|
8
|
+
unless page.nil?
|
9
|
+
params[:page] = page
|
10
|
+
end
|
11
|
+
|
12
|
+
unless per_page.nil?
|
13
|
+
params[:per_page] = per_page
|
14
|
+
end
|
15
|
+
|
16
|
+
unless updated_since.nil?
|
17
|
+
params[:updated_since] = updated_since.to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
unless zipcode.nil?
|
21
|
+
params[:zipcode] = zipcode
|
22
|
+
|
23
|
+
unless max_distance_miles.nil?
|
24
|
+
params[:max_dist] = max_distance_miles
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
get(path: "/organizations/#{esc(organization_id)}/events", params: params)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module MobilizeAmericaClient
|
4
|
+
module Request
|
5
|
+
API_DOMAIN = 'events.mobilizeamerica.io'.freeze
|
6
|
+
API_BASE_PATH = '/api/v1'.freeze
|
7
|
+
|
8
|
+
def get(path:, params: {})
|
9
|
+
request(method: :get, path: path, params: params)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def esc(untrusted)
|
15
|
+
CGI.escape(untrusted.to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
def request(method:, path:, params: {}, body: {})
|
19
|
+
response = connection.send(method) do |req|
|
20
|
+
req.path = "#{API_BASE_PATH}#{path}"
|
21
|
+
req.params = params
|
22
|
+
req.headers['Content-Type'] = 'application/json'
|
23
|
+
req.body = ::JSON.generate(body) unless body.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
JSON.parse(response.body)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: mobilize-america-client 0.3.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "mobilize-america-client".freeze
|
9
|
+
s.version = "0.3.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Jacinda Moore".freeze]
|
14
|
+
s.date = "2019-03-05"
|
15
|
+
s.email = "jacinda@controlshiftlabs.com".freeze
|
16
|
+
s.executables = ["console".freeze, "setup".freeze]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.md"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".rspec",
|
24
|
+
"CODE_OF_CONDUCT.md",
|
25
|
+
"Gemfile",
|
26
|
+
"LICENSE",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bin/console",
|
32
|
+
"bin/setup",
|
33
|
+
"lib/mobilize_america_client.rb",
|
34
|
+
"lib/mobilize_america_client/client.rb",
|
35
|
+
"lib/mobilize_america_client/client/events.rb",
|
36
|
+
"lib/mobilize_america_client/request.rb",
|
37
|
+
"mobilize-america-client.gemspec",
|
38
|
+
"spec/client/events_spec.rb",
|
39
|
+
"spec/spec_helper.rb"
|
40
|
+
]
|
41
|
+
s.homepage = "http://github.com/controlshift/mobilize_america_client".freeze
|
42
|
+
s.licenses = ["MIT".freeze]
|
43
|
+
s.rubygems_version = "3.0.3".freeze
|
44
|
+
s.summary = "Client gem for the MobilizeAmerica API".freeze
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 4
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<faraday>.freeze, ["~> 0.15"])
|
51
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
|
52
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.4"])
|
53
|
+
s.add_development_dependency(%q<rake>.freeze, ["~> 10.0"])
|
54
|
+
s.add_development_dependency(%q<webmock>.freeze, ["~> 3.4"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<faraday>.freeze, ["~> 0.15"])
|
57
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
|
58
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4"])
|
59
|
+
s.add_dependency(%q<rake>.freeze, ["~> 10.0"])
|
60
|
+
s.add_dependency(%q<webmock>.freeze, ["~> 3.4"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<faraday>.freeze, ["~> 0.15"])
|
64
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
|
65
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4"])
|
66
|
+
s.add_dependency(%q<rake>.freeze, ["~> 10.0"])
|
67
|
+
s.add_dependency(%q<webmock>.freeze, ["~> 3.4"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe MobilizeAmericaClient::Client::Events do
|
4
|
+
let(:standard_headers) { {'Content-Type' => 'application/json'} }
|
5
|
+
|
6
|
+
subject { MobilizeAmericaClient::Client.new }
|
7
|
+
|
8
|
+
describe '#organization_events' do
|
9
|
+
let(:org_id) { 123 }
|
10
|
+
let(:events_url) { "https://#{MobilizeAmericaClient::Client::API_DOMAIN}/api/v1/organizations/#{org_id}/events" }
|
11
|
+
let(:response) { {'data' => [{'id' => 1, 'description' => 'event 1'}, {'id' => 2, 'description' => 'event 2'}]} }
|
12
|
+
|
13
|
+
it 'should call the endpoint and return JSON' do
|
14
|
+
stub_request(:get, events_url).with(headers: standard_headers).to_return(body: response.to_json)
|
15
|
+
expect(subject.organization_events(organization_id: org_id)).to eq response
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should escape the organization ID' do
|
19
|
+
expected_url = "https://#{MobilizeAmericaClient::Client::API_DOMAIN}/api/v1/organizations/foo%2Fbar/events"
|
20
|
+
stub_request(:get, expected_url).with(headers: standard_headers).to_return(body: response.to_json)
|
21
|
+
expect(subject.organization_events(organization_id: 'foo/bar')).to eq response
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should support an updated_since parameter' do
|
25
|
+
updated_since = Time.new
|
26
|
+
stub_request(:get, events_url)
|
27
|
+
.with(headers: standard_headers, query: {updated_since: updated_since.to_i})
|
28
|
+
.to_return(body: response.to_json)
|
29
|
+
expect(subject.organization_events(organization_id: org_id, updated_since: updated_since)).to eq response
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should support a zipcode parameter' do
|
33
|
+
zipcode = '23456'
|
34
|
+
stub_request(:get, events_url)
|
35
|
+
.with(headers: standard_headers, query: {zipcode: zipcode})
|
36
|
+
.to_return(body: response.to_json)
|
37
|
+
expect(subject.organization_events(organization_id: org_id, zipcode: zipcode)).to eq response
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should support a max_dist parameter to go with zipcode' do
|
41
|
+
stub_request(:get, events_url)
|
42
|
+
.with(headers: standard_headers, query: {zipcode: '23456', max_dist: 100})
|
43
|
+
.to_return(body: response.to_json)
|
44
|
+
expect(subject.organization_events(organization_id: org_id, zipcode: '23456', max_distance_miles: 100)).to eq response
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should support pagination parameters' do
|
48
|
+
stub_request(:get, events_url)
|
49
|
+
.with(headers: standard_headers, query: {page: 2, per_page: 100})
|
50
|
+
.to_return(body: response.to_json)
|
51
|
+
expect(subject.organization_events(organization_id: org_id, page: 2, per_page: 100)).to eq response
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'rspec'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
|
5
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
+
|
7
|
+
require "mobilize_america_client"
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
# Enable flags like --only-failures and --next-failure
|
11
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
12
|
+
|
13
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
14
|
+
config.disable_monkey_patching!
|
15
|
+
|
16
|
+
config.expect_with :rspec do |c|
|
17
|
+
c.syntax = :expect
|
18
|
+
end
|
19
|
+
|
20
|
+
config.include WebMock::API
|
21
|
+
|
22
|
+
config.before :each do
|
23
|
+
WebMock.reset!
|
24
|
+
end
|
25
|
+
|
26
|
+
config.after :each do
|
27
|
+
WebMock.reset!
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobilize-america-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacinda Moore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: juwelier
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
description:
|
84
|
+
email: jacinda@controlshiftlabs.com
|
85
|
+
executables:
|
86
|
+
- console
|
87
|
+
- setup
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
files:
|
94
|
+
- ".rspec"
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- VERSION
|
102
|
+
- bin/console
|
103
|
+
- bin/setup
|
104
|
+
- lib/mobilize_america_client.rb
|
105
|
+
- lib/mobilize_america_client/client.rb
|
106
|
+
- lib/mobilize_america_client/client/events.rb
|
107
|
+
- lib/mobilize_america_client/request.rb
|
108
|
+
- mobilize-america-client.gemspec
|
109
|
+
- spec/client/events_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
homepage: http://github.com/controlshift/mobilize_america_client
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubygems_version: 3.0.3
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Client gem for the MobilizeAmerica API
|
134
|
+
test_files: []
|