nate63179-icontact 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +4 -0
- data/Rakefile +14 -0
- data/icontact.gemspec +34 -0
- data/lib/icontact.rb +68 -0
- metadata +71 -0
data/Manifest
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('icontact', '0.1.0') do |p|
|
6
|
+
p.description = "Interact with the iContact email subscription service."
|
7
|
+
p.url = "http://projects.urbaninfluence.com/gems"
|
8
|
+
p.author = "Nate Miller"
|
9
|
+
p.email = "nate@urbaninfluence.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = ['facets']
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/icontact.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{icontact}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Nate Miller"]
|
9
|
+
s.date = %q{2008-12-10}
|
10
|
+
s.description = %q{Interact with the iContact email subscription service.}
|
11
|
+
s.email = %q{nate@urbaninfluence.com}
|
12
|
+
s.extra_rdoc_files = ["lib/icontact.rb", "README.rdoc"]
|
13
|
+
s.files = ["lib/icontact.rb", "Rakefile", "README.rdoc", "Manifest", "icontact.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://projects.urbaninfluence.com/gems}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Icontact", "--main", "README"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{icontact}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Interact with the iContact email subscription service.}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<facets>, [">= 0"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<facets>, [">= 0"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<facets>, [">= 0"])
|
33
|
+
end
|
34
|
+
end
|
data/lib/icontact.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'facets'
|
3
|
+
require 'net/http'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
class Icontact
|
7
|
+
|
8
|
+
@@settings = { :url => nil,
|
9
|
+
:listid => nil,
|
10
|
+
:clientid => nil,
|
11
|
+
:formid => nil,
|
12
|
+
:specialid => nil,
|
13
|
+
:reallistid => nil,
|
14
|
+
:doubleopt => nil}
|
15
|
+
cattr_accessor :settings
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :form_vars
|
22
|
+
|
23
|
+
def settings
|
24
|
+
@settings || @@settings
|
25
|
+
end
|
26
|
+
|
27
|
+
def settings=(settings)
|
28
|
+
@settings = settings
|
29
|
+
end
|
30
|
+
|
31
|
+
def url
|
32
|
+
settings[:url]
|
33
|
+
end
|
34
|
+
|
35
|
+
def submit(options)
|
36
|
+
create_post_string(options)
|
37
|
+
uri = URI.parse(settings[:url])
|
38
|
+
req = Net::HTTP::Post.new(url)
|
39
|
+
req.set_form_data(@form_vars)
|
40
|
+
response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request(req) }
|
41
|
+
determine_success(response)
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_post_string(options = {})
|
45
|
+
data = {}
|
46
|
+
data.merge!(settings)
|
47
|
+
data.merge!(options)
|
48
|
+
data.stringify_keys!
|
49
|
+
|
50
|
+
# modify the specialid value that icontact expects to receive, converts "specialid" => "specialid:XXXX" where XXXX is the list id
|
51
|
+
specialid = settings[:specialid]
|
52
|
+
data.delete("specialid")
|
53
|
+
@form_vars = data.merge!({"specialid:#{settings[:listid]}" => specialid})
|
54
|
+
|
55
|
+
param_array = []
|
56
|
+
@form_vars.each { |k,v| param_array << "#{k}=#{v}"}
|
57
|
+
param_array.sort! # alphabetize for easier testing
|
58
|
+
pstring = "?" << param_array.join("&")
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
# As the service currently only utilizes an HTTP interface, we look for "THANK YOU" or "ERROR" and return 1 or 0 respectively
|
64
|
+
def determine_success(html_response)
|
65
|
+
html_response.body.scan(/ERROR/).empty?
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nate63179-icontact
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nate Miller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-10 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: facets
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: Interact with the iContact email subscription service.
|
25
|
+
email: nate@urbaninfluence.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- lib/icontact.rb
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- lib/icontact.rb
|
35
|
+
- Rakefile
|
36
|
+
- README.rdoc
|
37
|
+
- Manifest
|
38
|
+
- icontact.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://projects.urbaninfluence.com/gems
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --title
|
46
|
+
- Icontact
|
47
|
+
- --main
|
48
|
+
- README
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "1.2"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: icontact
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: Interact with the iContact email subscription service.
|
70
|
+
test_files: []
|
71
|
+
|