volunteermatch 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05fce463f09212a4f232e51426b0f2f2f86f159b
4
+ data.tar.gz: 3e6acefe9f38c2c0daf3be8183b699780b71f196
5
+ SHA512:
6
+ metadata.gz: 3d870c1af980855c6464df22a070ba55e2bb3f585d691b249d73b7410c4e80051949e8d02ad0013494641f25281313265393efa8dcba0a7dbc7c3c7c251cf19a
7
+ data.tar.gz: 29f869e4a5c19d577d6ba02ac64810ba30d281db2929f386c311785bd89343dc3c806716ddbe9a06239ff4e4200b21ba5806858a36e0ca0075070482c7037d37
data/.gitignore ADDED
@@ -0,0 +1,51 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ Gemfile.lock
46
+ .ruby-version
47
+ .ruby-gemset
48
+ .rspec_status
49
+
50
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
51
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ - 2.3.3
6
+ - 2.2.6
7
+ before_install: gem install bundler -v 1.14.3
@@ -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 evanscloud@users.noreply.github.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
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Evan Ng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # The VolunteerMatch Public-Use API Gem
2
+
3
+ VolunteerMatch is a lightweight Ruby wrapper that queries VolunteerMatch's Public-Use API for searching information on nonprofit organizations and active volunteering opportunities.
4
+
5
+ This gem is inspired by the Ruby API example provided in the [vm-contrib repo](https://github.com/volunteermatch/vm-contrib). Queries are configured based on the attributes applied and return a collection of JSON results.
6
+
7
+ The Official documentation on using the API can be found at [VolunteerMatch.org](http://cdn.volunteermatch.org/www/legal/VM-Public-use-API-user-manual.pdf).
8
+
9
+ ### Before Continuing
10
+
11
+ To use VolunteerMatch's Public-Use API, you need to be validated for full access. Complete an online application [here](https://www.volunteermatch.org/legal/publicuseapi) in order to get approved for a unique Public-Use key. Until then, you are only able to test `helloWorld` calls.
12
+
13
+ ## Getting Started
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'volunteermatch'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install volunteermatch
28
+
29
+
30
+ ## Setting Your API Key
31
+
32
+ Concealing your API username and key is important. I recommend using [dotenv](https://github.com/bkeepers/dotenv) to do so.
33
+
34
+ ```ruby
35
+ client = Volunteermatch::Client.new('username', 'key')
36
+ ```
37
+
38
+ After setting a `client`, you are able to access all methods below.
39
+
40
+ ## Basic Usage Examples
41
+
42
+ **Test API Connectivity**
43
+ ```ruby
44
+ vm = client.test("John")
45
+ vm.result #=> "Hello John!"
46
+ ```
47
+
48
+ **Get API Key Status**
49
+ ```ruby
50
+ client.key_status
51
+ ```
52
+
53
+ **Search Opportunities (location required)**
54
+ ```ruby
55
+ client.search_opportunities(location: "New York", orgNames: ["red cross"], fieldsToDisplay: ["title", "description"])
56
+ ```
57
+
58
+ **Search Organizations (location required)**
59
+ ```ruby
60
+ client.search_organizations(location: "San Francisco", categoryIds: [23], fieldsToDisplay: ["name", "mission"])
61
+ ```
62
+
63
+ **Get Metadata (defaults to current version)**
64
+ ```ruby
65
+ client.metadata
66
+ ```
67
+
68
+ **Get Service Status**
69
+ ```ruby
70
+ client.service_status
71
+ ```
72
+
73
+ ## API Access Agreement
74
+
75
+ All data obtained through this gem belongs to VolunteerMatch. Please review the [Public-Use API Access Agreement](http://cdn.volunteermatch.org/www/legal/Public-Use%20API%20Access%20Agreement.pdf) for all terms, limitations and restrictions.
76
+
77
+ ## Development
78
+
79
+ 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.
80
+
81
+ 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).
82
+
83
+ ## Contributing
84
+
85
+ Suggestions, bug reports and pull requests are encouraged for those who would like to take part in improving this gem. 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).
86
+
87
+ ## License
88
+
89
+ Copyright (c) 2017, Evan Ng
90
+
91
+ The VolunteerMatch gem is available as open source under the terms of the [MIT license](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "volunteermatch"
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require 'volunteermatch/version'
2
+ require 'volunteermatch/client'
@@ -0,0 +1,9 @@
1
+ module Volunteermatch
2
+ module API
3
+ module HelloWorld
4
+ def test(name)
5
+ call(:helloWorld, {:name => name}.to_json)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Volunteermatch
2
+ module API
3
+ module KeyStatus
4
+ def key_status
5
+ call(:getKeyStatus, {}.to_json)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Volunteermatch
2
+ module API
3
+ module Metadata
4
+ def metadata(version = nil)
5
+ call(:getMetaData, {:version => version}.to_json)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Volunteermatch
2
+ module API
3
+ module SearchOpportunities
4
+ def search_opportunities(parameters = {})
5
+ raise ArgumentError, 'location needs to be defined' if parameters[:location].nil? || parameters[:location].empty?
6
+ parameters[:location] = parameters[:location] || nil
7
+ call(:searchOrganizations, parameters.to_json)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Volunteermatch
2
+ module API
3
+ module SearchOrganizations
4
+ def search_organizations(parameters = {})
5
+ raise ArgumentError, 'location needs to be defined' if parameters[:location].nil? || parameters[:location].empty?
6
+ parameters[:location] = parameters[:location] || nil
7
+ call(:searchOrganizations, parameters.to_json)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Volunteermatch
2
+ module API
3
+ module ServiceStatus
4
+ def service_status
5
+ call(:getServiceStatus, {}.to_json)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,52 @@
1
+ require 'base64'
2
+ require 'digest/sha2'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+ require 'ostruct'
7
+
8
+ require 'volunteermatch/api/hello_world'
9
+ require 'volunteermatch/api/key_status'
10
+ require 'volunteermatch/api/metadata'
11
+ require 'volunteermatch/api/service_status'
12
+ require 'volunteermatch/api/search_organizations'
13
+ require 'volunteermatch/api/search_opportunities'
14
+
15
+ module Volunteermatch
16
+ class Client
17
+ attr_accessor :api_username, :api_key
18
+
19
+ include Volunteermatch::API::HelloWorld
20
+ include Volunteermatch::API::KeyStatus
21
+ include Volunteermatch::API::Metadata
22
+ include Volunteermatch::API::ServiceStatus
23
+ include Volunteermatch::API::SearchOrganizations
24
+ include Volunteermatch::API::SearchOpportunities
25
+
26
+ def initialize(api_username, api_key)
27
+ raise ArgumentError, 'username and key need to be defined' if api_username.nil? || api_username.empty? || api_key.nil? || api_key.empty?
28
+ @api_username = api_username
29
+ @api_key = api_key
30
+ end
31
+
32
+ protected
33
+
34
+ def call(action, json_query)
35
+ nonce = Digest::SHA2.hexdigest(rand.to_s)[0, 20]
36
+ creation_time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S%z")
37
+ password_digest = Base64.encode64(Digest::SHA2.digest(nonce + creation_time + @api_key)).chomp
38
+ url = URI.parse("http://www.volunteermatch.org/api/call?action=#{action.to_s}&query=" + URI.encode(json_query))
39
+
40
+ req = Net::HTTP::Get.new(url.request_uri)
41
+
42
+ req.add_field('Content-Type', 'application/json')
43
+ req.add_field('Authorization', 'WSSE profile="UsernameToken"')
44
+ req.add_field('X-WSSE', 'UsernameToken Username="' + @api_username + '", PasswordDigest="' + password_digest + '", ' +
45
+ 'Nonce="' + nonce + '", Created="' + creation_time + '"')
46
+
47
+ res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
48
+ raise "HTTP error code #{res.code}" unless res.code == "200"
49
+ OpenStruct.new(JSON.parse res.body)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module Volunteermatch
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'volunteermatch/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "volunteermatch"
8
+ spec.version = Volunteermatch::VERSION
9
+ spec.authors = ["Evan Ng"]
10
+ spec.email = ["evan.ng@outlook.com"]
11
+
12
+ spec.summary = %q{A Ruby wrapper for VolunteerMatch's Public-Use API.}
13
+ spec.description = %q{A lightweight Ruby wrapper that queries VolunteerMatch's Public-Use API for searching information on nonprofit organizations and active volunteering opportunities.}
14
+ spec.homepage = "https://github.com/evanscloud/vm_public_api"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "webmock", "~> 2.3"
28
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: volunteermatch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Evan Ng
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.3'
69
+ description: A lightweight Ruby wrapper that queries VolunteerMatch's Public-Use API
70
+ for searching information on nonprofit organizations and active volunteering opportunities.
71
+ email:
72
+ - evan.ng@outlook.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - LICENSE
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/volunteermatch.rb
88
+ - lib/volunteermatch/api/hello_world.rb
89
+ - lib/volunteermatch/api/key_status.rb
90
+ - lib/volunteermatch/api/metadata.rb
91
+ - lib/volunteermatch/api/search_opportunities.rb
92
+ - lib/volunteermatch/api/search_organizations.rb
93
+ - lib/volunteermatch/api/service_status.rb
94
+ - lib/volunteermatch/client.rb
95
+ - lib/volunteermatch/version.rb
96
+ - volunteermatch.gemspec
97
+ homepage: https://github.com/evanscloud/vm_public_api
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.6.8
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: A Ruby wrapper for VolunteerMatch's Public-Use API.
121
+ test_files: []