actionkit_connector 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/actionkit_connector.rb +21 -5
- data/lib/actionkit_connector/version.rb +1 -1
- data/test/connector_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec0e47ee88d3971089fea33a3407f4feeae77d1
|
4
|
+
data.tar.gz: f6a77c88b518134005fddae863af79d56c7e0bf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e9d192f31d3b7d92e8e127e833eb709a1f56538f7a32c9f3d8512a9b37efeb85c03a132c0fbad156435997eb080399a53cc0053321368a910d9ef065aab658a
|
7
|
+
data.tar.gz: 30153a190b452b47a5b4cb6e8ca2b04836b87c9ff5301045fecbf0bde3f400fbf94398d190fe101d6920a6df54adb559cf791492ee2d33ad999bc9a8fb782794
|
data/README.md
CHANGED
data/lib/actionkit_connector.rb
CHANGED
@@ -106,17 +106,33 @@ module ActionKitConnector
|
|
106
106
|
#
|
107
107
|
# @param [String] page_name The ActionKit name of the page on which the action is being taken.
|
108
108
|
# @param [String] email The email address of the person taking action.
|
109
|
-
def create_action(page_name, email)
|
109
|
+
def create_action(page_name, email, options={})
|
110
110
|
target = "#{self.base_url}/action/"
|
111
|
+
body = { page: page_name, email: email }.merge self.parse_action_options(options)
|
111
112
|
options = {
|
112
113
|
basic_auth: self.auth,
|
113
|
-
body:
|
114
|
-
page: page_name,
|
115
|
-
email: email
|
116
|
-
},
|
114
|
+
body: body,
|
117
115
|
format: :json
|
118
116
|
}
|
119
117
|
self.class.post(target, options)
|
120
118
|
end
|
119
|
+
|
120
|
+
def parse_action_options(options)
|
121
|
+
included_options = {}
|
122
|
+
acceptable_options = [
|
123
|
+
:ip_address, :is_forwarded, :link,
|
124
|
+
:mailing, :referring_mailing, :referring_user
|
125
|
+
]
|
126
|
+
options.each_key do |key|
|
127
|
+
if acceptable_options.include? key.to_sym
|
128
|
+
included_options[key.to_sym] = options[key]
|
129
|
+
elsif key.to_s.start_with? 'action_'
|
130
|
+
# ActionKit allows for custom fields to be entered into an action by prepending
|
131
|
+
# their name with 'action_'
|
132
|
+
included_options[key.to_sym] = options[key]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
included_options
|
136
|
+
end
|
121
137
|
end
|
122
138
|
end
|
data/test/connector_spec.rb
CHANGED
@@ -18,4 +18,12 @@ describe 'Connector' do
|
|
18
18
|
it 'should create base url' do
|
19
19
|
expect(@connector.base_url).to eql 'url'
|
20
20
|
end
|
21
|
+
|
22
|
+
it 'parses action options for inclusion into AK' do
|
23
|
+
expect(@connector.parse_action_options({ip_address: '1010', bad_result: 'foo'})).to eq({ip_address: '1010'})
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'converts action_ fields to be included with AK' do
|
27
|
+
expect(@connector.parse_action_options({'action_foo' => 'test', not_an_action: 'bad'})).to eq({action_foo: 'test'})
|
28
|
+
end
|
21
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionkit_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Boersma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|