campminder 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d650e3a3d8889423e771f5f4523d300992d8afcf
4
+ data.tar.gz: 9c9808d33aff55edd932df3ec1154efaa2ef858e
5
+ SHA512:
6
+ metadata.gz: 59bd907f51740bb04f27894a453f577c23843e279e657935a17d383b111ac3ad2614be7c1ae4d316bea6c0024f83f670a2ddfe7195e47a508dcfa36b8517fcc8
7
+ data.tar.gz: 224c1dabe9e0ea8498913895ed5637271b737eac172661a6596e8ecd81494571a14d063bd73c2c981f6aebdfa2486660dccfe63cf3ecf57022d2983723bc1927
@@ -0,0 +1,38 @@
1
+ # OS X
2
+ .DS_Store
3
+ .AppleDouble
4
+ .LSOverride
5
+ Icon
6
+
7
+ # Thumbnails
8
+ ._*
9
+
10
+ # Files that might appear on external disk
11
+ .Spotlight-V100
12
+ .Trashes
13
+
14
+ # SublimeText project files
15
+ *.sublime-workspace
16
+
17
+ # Rails
18
+ *.rbc
19
+ *.sassc
20
+ .sass-cache
21
+ capybara-*.html
22
+ .rspec
23
+ .rvmrc
24
+ /.bundle
25
+ /vendor/bundle
26
+ /log/*
27
+ /tmp/*
28
+ /db/*.sqlite3
29
+ /public/system/*
30
+ /coverage/
31
+ /spec/tmp/*
32
+ **.orig
33
+ rerun.txt
34
+ pickle-email-*.html
35
+ .project
36
+ .sass-cache
37
+ node_modules
38
+ grunt-aws.json
@@ -0,0 +1 @@
1
+ 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ campminder (1.0.0)
5
+ httparty (~> 0.11)
6
+ json (~> 1.8, >= 1.8.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.6)
12
+ byebug (5.0.0)
13
+ columnize (= 0.9.0)
14
+ columnize (0.9.0)
15
+ crack (0.4.2)
16
+ safe_yaml (~> 1.0.0)
17
+ diff-lcs (1.2.5)
18
+ docile (1.1.5)
19
+ fuubar (2.0.0)
20
+ rspec (~> 3.0)
21
+ ruby-progressbar (~> 1.4)
22
+ httparty (0.13.5)
23
+ json (~> 1.8)
24
+ multi_xml (>= 0.5.2)
25
+ json (1.8.3)
26
+ multi_json (1.10.1)
27
+ multi_xml (0.5.5)
28
+ rake (10.3.2)
29
+ rspec (3.0.0)
30
+ rspec-core (~> 3.0.0)
31
+ rspec-expectations (~> 3.0.0)
32
+ rspec-mocks (~> 3.0.0)
33
+ rspec-core (3.0.2)
34
+ rspec-support (~> 3.0.0)
35
+ rspec-expectations (3.0.2)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.0.0)
38
+ rspec-mocks (3.0.2)
39
+ rspec-support (~> 3.0.0)
40
+ rspec-support (3.0.2)
41
+ ruby-progressbar (1.5.1)
42
+ safe_yaml (1.0.3)
43
+ simplecov (0.9.0)
44
+ docile (~> 1.1.0)
45
+ multi_json
46
+ simplecov-html (~> 0.8.0)
47
+ simplecov-html (0.8.0)
48
+ vcr (2.9.2)
49
+ webmock (1.18.0)
50
+ addressable (>= 2.3.6)
51
+ crack (>= 0.3.2)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ bundler (~> 1.6)
58
+ byebug
59
+ campminder!
60
+ fuubar (~> 2.0.0)
61
+ rake (~> 10.1, >= 10.1.0)
62
+ rspec (~> 3.0, >= 3.0.0)
63
+ simplecov (~> 0.9.0, >= 0.9.0)
64
+ vcr (~> 2.9, >= 2.9.2)
65
+ webmock (~> 1.18, >= 1.18.0)
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, cmd:"rspec" do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
@@ -0,0 +1,5 @@
1
+ # createsend-ruby history
2
+
3
+ ## v0.1, 21 July, 2014
4
+
5
+ * Initial commit of files.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andrew Anderson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # campminder-ruby
2
+
3
+ [ ![Codeship Status for ronningendesign/campminder-ruby](https://www.codeship.io/projects/af78d4e0-f3c6-0131-703c-46df43419009/status?branch=master)](https://www.codeship.io/projects/27961)
4
+
5
+ A wrapper for the CampMinder Web API for Ruby.
6
+
7
+ ## Built On
8
+
9
+ * [HTTParty](https://github.com/jnunemaker/httparty)
10
+
11
+ ## Tested With
12
+
13
+ * [RSpec](http://rspec.info/)
14
+ * [SimpleCov](https://github.com/colszowka/simplecov)
15
+ * [Fuubar](https://github.com/thekompanee/fuubar)
16
+ * [VCR](https://github.com/vcr/vcr)
17
+
18
+ ## Installation
19
+
20
+ Via a Gemfile:
21
+
22
+ ````
23
+ #!ruby
24
+ gem 'campminder', :git => 'https://bitbucket.org/ronningendesign/campminder-ruby.git'
25
+ ````
@@ -0,0 +1,53 @@
1
+ # Releasing campminder-ruby
2
+
3
+ ## Requirements
4
+
5
+ - You must have a [RubyGems.org](https://rubygems.org/) account and must be an owner of the [campminder](https://rubygems.org/gems/campminder) gem.
6
+
7
+ Owners can be added to the `campminder` gem like this:
8
+
9
+ ```
10
+ gem owner campminder -a newowner@example.com
11
+ ```
12
+
13
+ ## Prepare the release
14
+
15
+ - Increment the `VERSION` constant in the `lib/campminder/version.rb` file, ensuring that you use [Semantic Versioning](http://semver.org/).
16
+ - Add an entry to `HISTORY.md` which clearly explains the new release.
17
+ - Commit your changes:
18
+
19
+ ```
20
+ git commit -am "Version X.Y.Z"
21
+ ```
22
+
23
+ - Tag the new version:
24
+
25
+ ```
26
+ git tag -a vX.Y.Z -m "Version X.Y.Z"
27
+ ```
28
+
29
+ - Push your changes to GitHub, including the tag you just created:
30
+
31
+ ```
32
+ git push origin master --tags
33
+ ```
34
+
35
+ - Ensure that all [tests](https://travis-ci.org/GimliLongBow/campminder-ruby) pass, and that [coverage](https://coveralls.io/r/GimliLongBow/campminder-ruby) is maintained or improved.
36
+
37
+ - Add a new [GitHub Release](https://github.com/GimliLongBow/campminder-ruby/releases) using the newly created tag.
38
+
39
+ ## Build the gem
40
+
41
+ ```
42
+ rake build
43
+ ```
44
+
45
+ This builds the gem locally to a file named something like `campminder-X.Y.Z.gem`. You're now ready to release the gem.
46
+
47
+ ## Release the gem
48
+
49
+ ```
50
+ rake release
51
+ ```
52
+
53
+ This publishes the gem to [RubyGems.org](https://rubygems.org/gems/campminder). You should see the newly published version of the gem there. All done!
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require File.expand_path('lib/campminder/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "campminder"
7
+ spec.version = CampMinder::VERSION
8
+ spec.authors = ["Andrew Anderson"]
9
+ spec.email = ["andrew@websitesthatdostuff.com"]
10
+ spec.summary = %q{A library to wrap the CampMinder API in Ruby.}
11
+ spec.description = %q{Wrapper for CampMinder API.}
12
+ spec.homepage = "https://bitbucket.org/ronningendesign/campminder-ruby"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+ spec.licenses = ['MIT']
20
+
21
+ # Limit the version of Ruby to 1.9.3.
22
+ spec.required_ruby_version = '>= 1.9.3'
23
+
24
+ # Development
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake", '~> 10.1', '>= 10.1.0'
27
+ spec.add_development_dependency "rspec", '~> 3.0', '>= 3.0.0'
28
+ spec.add_development_dependency 'simplecov', '~> 0.9.0', '>= 0.9.0'
29
+ spec.add_development_dependency 'fuubar', '~> 2.0.0'
30
+ spec.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
31
+ spec.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.2'
32
+ spec.add_development_dependency 'byebug'
33
+
34
+ # Runtime
35
+ spec.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.1'
36
+ spec.add_runtime_dependency 'httparty', '~> 0.11'
37
+ end
@@ -0,0 +1,6 @@
1
+ libdir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
+
4
+ require 'campminder/version'
5
+ require 'campminder/parser'
6
+ require 'campminder/campminder'
@@ -0,0 +1,141 @@
1
+ require 'httparty'
2
+ require 'byebug'
3
+
4
+ module CampMinder
5
+ class CampMinder
6
+ include HTTParty
7
+
8
+ attr_accessor :camp_id, :token
9
+
10
+ @camp_id = ''
11
+ @token = ''
12
+
13
+ def initialize(camp_id, token)
14
+ @camp_id = camp_id
15
+ @token = token
16
+ end
17
+
18
+ def login(username, password)
19
+
20
+ request_body = {
21
+ i: username,
22
+ p: password,
23
+ c: 2,
24
+ apikey: generate_api_key,
25
+ callback: 'a'
26
+ }
27
+
28
+ response = CampMinderParty.get(
29
+ "https://webapi.campminder.com/api/security/user/GetRemoteLoginRedirect",
30
+ :query => request_body,
31
+ :headers => {
32
+ "Content-type" => 'application/javascript'
33
+ }
34
+ )
35
+
36
+ response.parsed_response
37
+ end
38
+
39
+ def add_new_lead(household1, household2, camper, lead_date, lead_source)
40
+ return {:Success => false, :message => 'Missing required info.'} unless household1["Parent1"]
41
+
42
+ request_body = {
43
+ Household1: household1,
44
+ Household2: household2,
45
+ Camper: camper,
46
+ LeadDate: lead_date,
47
+ LeadSource: lead_source
48
+ }
49
+
50
+ response = CampMinderParty.post(
51
+ "https://webapi.campminder.com/api/entity/person/camper/camper/addnewcamper",
52
+ :body => request_body.to_json,
53
+ :headers => {
54
+ 'Authorization-Token' => generate_api_key,
55
+ "Content-type" => 'application/json'
56
+ }
57
+ )
58
+
59
+ response.parsed_response
60
+ end
61
+
62
+ def add_custom_field_data(person_id, field_data)
63
+
64
+ request_body = [{
65
+ Data: field_data,
66
+ EntityTypeID: 1,
67
+ ObjectID: person_id
68
+ }]
69
+
70
+ response = CampMinderParty.post(
71
+ "https://webapi.campminder.com/api/entity/customfield/modifyentitydatafields",
72
+ :body => request_body.to_json,
73
+ :headers => {
74
+ 'Authorization-Token' => generate_api_key,
75
+ "Content-type" => 'application/json'
76
+ }
77
+ )
78
+
79
+ response.parsed_response
80
+ end
81
+
82
+ def get_telegraph_reports
83
+
84
+ response = CampMinderParty.get(
85
+ "https://webapi.campminder.com/api/customdata/telegraph/getsavedreports",
86
+ :headers => {
87
+ 'Authorization-Token' => generate_api_key,
88
+ "Content-type" => 'application/json'
89
+ }
90
+ )
91
+
92
+ response.parsed_response
93
+ end
94
+
95
+ def run_report(report_id)
96
+
97
+ response = CampMinderParty.get(
98
+ "https://webapi.campminder.com/api/customdata/telegraph/runsavedreportcsv?reportID=#{report_id}",
99
+ :headers => {
100
+ 'Authorization-Token' => generate_api_key,
101
+ "Content-type" => 'application/json'
102
+ }
103
+ )
104
+
105
+ response.parsed_response
106
+ end
107
+
108
+ def retrieve_person_id(email)
109
+ response = CampMinderParty.get(
110
+ "https://webapi.campminder.com/api/entity/person/getpersonidfromemail?email=#{email}",
111
+ :headers => {
112
+ 'Authorization-Token' => generate_api_key,
113
+ "Content-type" => 'application/json'
114
+ }
115
+ )
116
+ # byebug
117
+
118
+ response.parsed_response
119
+ end
120
+
121
+ def return_api_key
122
+ generate_api_key
123
+ end
124
+
125
+ private
126
+
127
+ def generate_api_key
128
+ now = Time.now.utc
129
+ now = now.strftime("%Y-%m-%dT%H:%M:%S.%LZ")
130
+ digested = Digest::SHA1.hexdigest("#{@camp_id}#{now}#{@token}")
131
+
132
+ "#{@camp_id}#{now}#{digested}"
133
+ end
134
+ end
135
+
136
+ class CampMinderParty
137
+ include HTTParty
138
+
139
+ parser JSONPParser
140
+ end
141
+ end
@@ -0,0 +1,17 @@
1
+ require 'httparty'
2
+
3
+ class JSONPParser < HTTParty::Parser
4
+ SupportedFormats = {
5
+ "application/javascript" => :jsonp,
6
+ "application/json" => :json
7
+ }
8
+
9
+ def jsonp
10
+ JSON.load(body.strip[2..-2], nil)
11
+ end
12
+
13
+ def json
14
+ JSON.load(body)
15
+ end
16
+
17
+ end