actionkit_connector 0.0.2 → 0.1.0
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/actionkit_connector.gemspec +1 -0
- data/lib/actionkit_connector.rb +72 -12
- data/lib/actionkit_connector/version.rb +1 -1
- data/test/connector_spec.rb +21 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51bad1dd8382c738ff52aeee2276b6fbc5136ae7
|
4
|
+
data.tar.gz: 80db19e48df8f18c9ff5cc9e52011f5ae32244ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac037266a94ae054753a6ce1373202d23b1c99852b0bcb9f6cea8df686cdc4ede718c9376f52f4f186a996bda916cbf0c94c0f1e9e917d9e9d1cc572424e21bd
|
7
|
+
data.tar.gz: 6f9a8ce758a7a4b3e1d4c88eaaf5380ca3c68f78b5f3c0c6417a69b53d44a6f0534cc4c489e82376473b0924e7af2adcaa3dcef47b12e5171f36cdf690018f8e
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/actionkit_connector.gemspec
CHANGED
data/lib/actionkit_connector.rb
CHANGED
@@ -1,18 +1,39 @@
|
|
1
|
-
|
1
|
+
require_relative 'actionkit_connector/version'
|
2
|
+
require 'httparty'
|
2
3
|
|
3
4
|
module ActionKitConnector
|
4
5
|
class Connector
|
5
6
|
include HTTParty
|
6
7
|
|
8
|
+
attr_accessor :username
|
9
|
+
attr_accessor :password
|
10
|
+
attr_accessor :base_url
|
11
|
+
|
12
|
+
# Initializes a connector to the ActionKit API.
|
13
|
+
# A new connection is created on each call, so there
|
14
|
+
# no need to worry about resource utilization.
|
15
|
+
#
|
16
|
+
# @param [String] username The username of your ActionKit user.
|
17
|
+
# @param [String] password The password for your ActionKit user.
|
18
|
+
# @param [String] base_url The base url of your ActionKit instance.
|
7
19
|
def initialize(username, password, base_url)
|
8
|
-
|
9
|
-
|
20
|
+
self.username = username
|
21
|
+
self.password = password
|
22
|
+
self.base_url = base_url
|
23
|
+
end
|
24
|
+
|
25
|
+
def auth
|
26
|
+
{username: self.username, password: self.password}
|
10
27
|
end
|
11
28
|
|
29
|
+
# Lists petition pages in your instance.
|
30
|
+
#
|
31
|
+
# @param [Int] offset The number of records to skip.
|
32
|
+
# @param [Int] limit The maximum number of results to return.
|
12
33
|
def list_petition_pages(offset=0, limit=20)
|
13
|
-
target = "#{
|
34
|
+
target = "#{self.base_url}/petitionpage/"
|
14
35
|
options = {
|
15
|
-
basic_auth:
|
36
|
+
basic_auth: self.auth,
|
16
37
|
query: {
|
17
38
|
_limit: limit,
|
18
39
|
_offset: offset
|
@@ -21,20 +42,55 @@ module ActionKitConnector
|
|
21
42
|
self.class.get(target, options)
|
22
43
|
end
|
23
44
|
|
45
|
+
# Returns the information for a single PetitionPage.
|
46
|
+
#
|
47
|
+
# @param [Int] id The ID of the page to return.
|
24
48
|
def petition_page(id)
|
25
|
-
target = "#{
|
26
|
-
self.class.get(target, {basic_auth:
|
49
|
+
target = "#{self.base_url}/petitionpage/#{id}/"
|
50
|
+
self.class.get(target, {basic_auth: self.auth})
|
27
51
|
end
|
28
52
|
|
53
|
+
# Create a petition page in your ActionKit instance.
|
54
|
+
#
|
55
|
+
# @param [String] name The name of the page.
|
56
|
+
# @param [String] title The title of the page.
|
57
|
+
# @param [URI] lang The URI string for the language of this page in the form of /rest/v1/language/{id}
|
58
|
+
# @param [URL] canonical_url The canonical URL for this page.
|
29
59
|
def create_petition_page(name, title, lang, canonical_url)
|
30
|
-
target = "#{
|
60
|
+
target = "#{self.base_url}/petitionpage/"
|
61
|
+
options = {
|
62
|
+
basic_auth: self.auth,
|
63
|
+
headers: {
|
64
|
+
'Content-type' => 'application/json'
|
65
|
+
},
|
66
|
+
:body => {
|
67
|
+
:type => 'petitionpage',
|
68
|
+
:hidden => false,
|
69
|
+
:name => name,
|
70
|
+
:title => title,
|
71
|
+
:lang => lang,
|
72
|
+
:canonical_url => canonical_url
|
73
|
+
}.to_json,
|
74
|
+
format: :json
|
75
|
+
}
|
76
|
+
self.class.post(target, options)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create a donation page in your ActionKit instance.
|
80
|
+
#
|
81
|
+
# @param [String] name The name of the page.
|
82
|
+
# @param [String] title The title of the page.
|
83
|
+
# @param [URI] lang The URI string for the language of this page in the form of /rest/v1/language/{id}
|
84
|
+
# @param [URL] canonical_url The canonical URL for this page.
|
85
|
+
def create_donation_page(name, title, lang, canonical_url)
|
86
|
+
target = "#{self.base_url}/donationpage/"
|
31
87
|
options = {
|
32
|
-
basic_auth:
|
88
|
+
basic_auth: self.auth,
|
33
89
|
headers: {
|
34
90
|
'Content-type' => 'application/json'
|
35
91
|
},
|
36
92
|
:body => {
|
37
|
-
:type =>
|
93
|
+
:type => 'donationpage',
|
38
94
|
:hidden => false,
|
39
95
|
:name => name,
|
40
96
|
:title => title,
|
@@ -46,10 +102,14 @@ module ActionKitConnector
|
|
46
102
|
self.class.post(target, options)
|
47
103
|
end
|
48
104
|
|
105
|
+
# Creates an action which associates a user with a page.
|
106
|
+
#
|
107
|
+
# @param [String] page_name The ActionKit name of the page on which the action is being taken.
|
108
|
+
# @param [String] email The email address of the person taking action.
|
49
109
|
def create_action(page_name, email)
|
50
|
-
target = "#{
|
110
|
+
target = "#{self.base_url}/action/"
|
51
111
|
options = {
|
52
|
-
basic_auth:
|
112
|
+
basic_auth: self.auth,
|
53
113
|
body: {
|
54
114
|
page: page_name,
|
55
115
|
email: email
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require_relative '../lib/actionkit_connector'
|
3
|
+
|
4
|
+
describe 'Connector' do
|
5
|
+
before :each do
|
6
|
+
@connector = ActionKitConnector::Connector.new 'username', 'password', 'url'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should create auth' do
|
10
|
+
expect(@connector.auth).to eql({username: 'username', password: 'password'})
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should change auth' do
|
14
|
+
@connector.password = 'new_password'
|
15
|
+
expect(@connector.auth).to eql({username: 'username', password: 'new_password'})
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should create base url' do
|
19
|
+
expect(@connector.base_url).to eql 'url'
|
20
|
+
end
|
21
|
+
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.0
|
4
|
+
version: 0.1.0
|
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-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
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'
|
55
69
|
description: ''
|
56
70
|
email:
|
57
71
|
- eric.boersma@gmail.com
|
@@ -68,6 +82,7 @@ files:
|
|
68
82
|
- actionkit_connector.gemspec
|
69
83
|
- lib/actionkit_connector.rb
|
70
84
|
- lib/actionkit_connector/version.rb
|
85
|
+
- test/connector_spec.rb
|
71
86
|
homepage: https://github.com/EricBoersma/actionkit_connector
|
72
87
|
licenses:
|
73
88
|
- MIT
|
@@ -92,4 +107,5 @@ rubygems_version: 2.4.3
|
|
92
107
|
signing_key:
|
93
108
|
specification_version: 4
|
94
109
|
summary: A gem for interacting with the ActionKit API.
|
95
|
-
test_files:
|
110
|
+
test_files:
|
111
|
+
- test/connector_spec.rb
|