actionkit_connector 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51bad1dd8382c738ff52aeee2276b6fbc5136ae7
4
- data.tar.gz: 80db19e48df8f18c9ff5cc9e52011f5ae32244ce
3
+ metadata.gz: eec0e47ee88d3971089fea33a3407f4feeae77d1
4
+ data.tar.gz: f6a77c88b518134005fddae863af79d56c7e0bf2
5
5
  SHA512:
6
- metadata.gz: ac037266a94ae054753a6ce1373202d23b1c99852b0bcb9f6cea8df686cdc4ede718c9376f52f4f186a996bda916cbf0c94c0f1e9e917d9e9d1cc572424e21bd
7
- data.tar.gz: 6f9a8ce758a7a4b3e1d4c88eaaf5380ca3c68f78b5f3c0c6417a69b53d44a6f0534cc4c489e82376473b0924e7af2adcaa3dcef47b12e5171f36cdf690018f8e
6
+ metadata.gz: 3e9d192f31d3b7d92e8e127e833eb709a1f56538f7a32c9f3d8512a9b37efeb85c03a132c0fbad156435997eb080399a53cc0053321368a910d9ef065aab658a
7
+ data.tar.gz: 30153a190b452b47a5b4cb6e8ca2b04836b87c9ff5301045fecbf0bde3f400fbf94398d190fe101d6920a6df54adb559cf791492ee2d33ad999bc9a8fb782794
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ActionkitConnector
2
2
 
3
- TODO: Write a gem description
3
+ A basic ruby wrapper for ActionKit's API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ActionkitConnector
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -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.0
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-03-09 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty