luminate 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODQ1ZTc2ZWYyZDU1ODkxZWVmMmI5NzI3NzM1MWQwYTAwNTIxZDBjYg==
5
+ data.tar.gz: !binary |-
6
+ Mjk3NjYxYzE5ZWI5NjYzNjVlMjdkZDZmMzAyOGFiMDhmNGFhNGFkYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ N2Q2MTUyZWUyZWM5NTk0NmIwNWRiMDdlODZmNTUzNmRmMjQ4Y2EyMDIwODMy
10
+ MGJmOGVmOWIyYzk2MjMwNWQ5NGU2YmQzODhkNGQ2ODg1MjRiZTIxMzk5OWNl
11
+ NzBhM2JkOGJmZDM2MDhhMzRmZDQ3ZGE5M2FlYjk2OTRiYTZkMzE=
12
+ data.tar.gz: !binary |-
13
+ OWY0NjU2MzkyMmI5YzdiYWY1NTZmZjYzMDc3OTBkYmFhMzQ5ODk3NWE5MmI2
14
+ ZGIzMzQ5NzhjYzI1NzgyYTMyNjVhZDQwZTMwMWNlM2U1MWM2NzUzZTUwNDA2
15
+ MmJlY2EyNDc5NzE2ZDllYWE4NjZkOGFlNjEyODE3N2UyMTFiZDk=
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .ruby-*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in luminate.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Spike Ilacqua
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,99 @@
1
+ # Luminate
2
+
3
+ This gem provides Ruby bindings for the
4
+ [Luminate Online Server APIs](http://open.convio.com/api/#main).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'luminate'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install luminate
19
+
20
+ ## Usage
21
+
22
+ Require the gem (or let bundler do it for you) and configure as
23
+ follows:
24
+
25
+ ```ruby
26
+ require 'luminate'
27
+ Luminate.configure do |config|
28
+ config.url = 'https://secure3.convio.net'
29
+ config.organization = 'your-organization'
30
+ config.api_key = 'your-api-key'
31
+ config.api_login = 'your-api-login-name'
32
+ config.api_password = 'your-api-password'
33
+ end
34
+ ```
35
+
36
+ The URL is typically https://secure2.convio.net or
37
+ https://secure3.convio.net. The organization is the short name Convio
38
+ uses to identify you. Both of these can be extracted from the URL of
39
+ your Admin panel:
40
+
41
+ ```
42
+ https://secure2.convio.net/<organization>/admin...
43
+ ```
44
+
45
+ You will need to configure the API key, login name, and password in
46
+ the Admin. Some endpoints are disabled by default, so be sure to check
47
+ the documentation.
48
+
49
+ The bindings are implemented as class level methods with one class per
50
+ API. The method names are underscorized version of Luminate's names.
51
+
52
+ To test your settings try the
53
+ [Constituent isEmailValid method](http://open.convio.com/api/#constituent_api.isEmailValid_method.html) (which simply checks the pattern of an email for validity):
54
+
55
+ ```ruby
56
+ constituent = Luminate::Constituent
57
+ response = constituent.is_email_valid(email: 'spike@example.com')
58
+ => {"isEmailValidResponse"=>{"valid"=>"true"}}
59
+ ```
60
+
61
+ The response value is a [Map](https://github.com/ahoward/map), a
62
+ hash-like object that also provides methods to access the values.
63
+
64
+ ```ruby
65
+ response['isEmailValidResponse']
66
+ => {"valid"=>"true"}
67
+ response.isEmailValidResponse
68
+ => {"valid"=>"true"}
69
+ response.isEmailValidResponse.valid
70
+ => "true"
71
+ ```
72
+
73
+ ## Currently implemented methods
74
+
75
+ See (Contributing)[#contributing] for how to add more.
76
+
77
+ * [Constituent: getUser](http://open.convio.com/api/#constituent_api.getUser_method.html)
78
+ * [Constituent: getUserTransactions](http://open.convio.com/api/#constituent_api.getUserTransactions_method.html)
79
+ * [Constituent: isEmailValid](http://open.convio.com/api/#constituent_api.isEmailValid_method.html)
80
+ * [Donation: addOfflineDonation](http://open.convio.com/api/#donation_api.addOfflineDonation_method.html)
81
+
82
+ ## Contributing
83
+
84
+ This is version 0.1.0, I have only implement endpoints I'm actually
85
+ using and have (manually) tested. Since the interface is simple and
86
+ consistent, endpoints can be implement with a bit of
87
+ meta-programming. ```Luminate::Base``` provides a helper method,
88
+ ```def_endpoints``` to do this. It takes the API's *Server Servlet*
89
+ name and the list of methods. See
90
+ [lib/luminate/constituent.rb](https://github.com/spikex/luminate/blob/master/lib/luminate/constituent.rb)
91
+ for an example.
92
+
93
+ Got changes?
94
+
95
+ 1. Fork it ( http://github.com/spike/luminate/fork )
96
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
97
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
98
+ 4. Push to the branch (`git push origin my-new-feature`)
99
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ require 'luminate/version'
2
+ require 'luminate/config'
3
+ require 'luminate/base'
4
+
5
+ module Luminate
6
+
7
+ autoload :Donation, 'luminate/donation'
8
+ autoload :Constituent, 'luminate/constituent'
9
+
10
+ class << self
11
+ attr_accessor :config
12
+ end
13
+
14
+ self.config ||= Config.new
15
+
16
+ def self.configure
17
+ yield config
18
+ config
19
+ end
20
+ end
@@ -0,0 +1,50 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'multi_json'
5
+ require 'map'
6
+
7
+ module Luminate
8
+ class Base
9
+
10
+ def self.def_endpoints(api,*endpoints)
11
+ endpoints.each do |endpoint|
12
+ method_name = endpoint.gsub(/(.)([A-Z])/,'\1_\2').downcase
13
+ define_singleton_method method_name do |params|
14
+ send_request(api,params.merge({method: endpoint}))
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.send_request(api = '', params = {})
20
+ raise 'No API specified' if api.empty?
21
+ raise 'No method specified' if params[:method].nil?
22
+
23
+ config = Luminate.config
24
+ params.merge!(response_format: 'json',
25
+ v: '1.0',
26
+ api_key: config.api_key,
27
+ login_name: config.api_login,
28
+ login_password: config.api_password)
29
+
30
+ url = URI.join(config.url,"#{config.organization}/",'site/',api)
31
+
32
+ http = Net::HTTP.new(url.host, url.port)
33
+
34
+ if url.port == 443
35
+ http.use_ssl = true
36
+ end
37
+
38
+ req = Net::HTTP::Post.new(url.path)
39
+ req.set_form_data(params)
40
+ res = http.start { |http| http.request(req) }
41
+ Map.for(parse_response(res.body))
42
+ end
43
+
44
+ # Converts the API response to a Hash
45
+ def self.parse_response(raw)
46
+ return {} if raw.to_s.empty?
47
+ ::MultiJson.decode(raw)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,9 @@
1
+ module Luminate
2
+ class Config
3
+ attr_accessor :url
4
+ attr_accessor :organization
5
+ attr_accessor :api_key
6
+ attr_accessor :api_login
7
+ attr_accessor :api_password
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Luminate
2
+ class Constituent < Base
3
+ def_endpoints('SRConsAPI','getUser','isEmailValid','getUserTransactions')
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Luminate
2
+ class Donation < Base
3
+ def_endpoints('SRDonationAPI','addOfflineDonation')
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Luminate
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'luminate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "luminate"
8
+ spec.version = Luminate::VERSION
9
+ spec.authors = ["Spike Ilacqua"]
10
+ spec.email = ["spike@indra.com"]
11
+ spec.summary = %q{Ruby Gem for accessing the Convio's Luminate Online Server APIs}
12
+ spec.description = %q{Access the Convio's Luminate Online Server APIs http://open.convio.com/api}
13
+ spec.homepage = "https://github.com/spike/luminate"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'multi_json'
22
+ spec.add_runtime_dependency 'map'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.5"
25
+ spec.add_development_dependency "rake"
26
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: luminate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Spike Ilacqua
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: multi_json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: map
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Access the Convio's Luminate Online Server APIs http://open.convio.com/api
70
+ email:
71
+ - spike@indra.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/luminate.rb
82
+ - lib/luminate/base.rb
83
+ - lib/luminate/config.rb
84
+ - lib/luminate/constituent.rb
85
+ - lib/luminate/donation.rb
86
+ - lib/luminate/version.rb
87
+ - luminate.gemspec
88
+ homepage: https://github.com/spike/luminate
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Ruby Gem for accessing the Convio's Luminate Online Server APIs
112
+ test_files: []