action_network_rest 0.4.0 → 0.5.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/README.md +14 -0
- data/lib/action_network_rest/base.rb +12 -2
- data/lib/action_network_rest/people.rb +8 -2
- data/lib/action_network_rest/petitions.rb +6 -0
- data/lib/action_network_rest/signatures.rb +6 -0
- data/lib/action_network_rest/taggings.rb +6 -0
- data/lib/action_network_rest/tags.rb +22 -0
- data/lib/action_network_rest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abb5c663b923a0f30bfcaf0b70fd43de40baf9f59752154eaead286acf7259a7
|
4
|
+
data.tar.gz: dbd808c9166b1047c70d87df247a5d624851f1e69a4271da6edb70ca578a9161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b0865b95a6d0ac618f6d9a35379b9998391c05dee7714c5b12dc0c8215e2ade7163cd8d2e81b3bd1a5d4743d6599207c22d48b22a7a5f9e724ccbc99ebe907
|
7
|
+
data.tar.gz: afac667e373e1ce51641edd1cde82d4269220ef95b847cc589fd9ffa079419e559f42c677210a87a91888e978a40ac07c5199179e684923f2feebc8c032849a8
|
data/README.md
CHANGED
@@ -35,6 +35,17 @@ client.entry_point.get
|
|
35
35
|
person = client.people.create(email_addresses: [{address: 'foo@example.com'}])
|
36
36
|
person_id = person.action_network_id
|
37
37
|
|
38
|
+
# List people
|
39
|
+
people = client.people.list
|
40
|
+
|
41
|
+
# Iterate over a list of people
|
42
|
+
page_number = 1
|
43
|
+
loop do
|
44
|
+
people = client.people.list(page: page_number)
|
45
|
+
break if people.empty?
|
46
|
+
page_number += 1
|
47
|
+
end
|
48
|
+
|
38
49
|
# Retrieve a Person's data
|
39
50
|
person = client.people.get(person_id)
|
40
51
|
puts person.email_addresses
|
@@ -78,6 +89,9 @@ tag_id = tag.action_network_id
|
|
78
89
|
# Retrieve a Tag
|
79
90
|
tag = client.tags.get(tag_id)
|
80
91
|
|
92
|
+
# Retrieve a Tag by name
|
93
|
+
tag = client.tags.find_by_name('Volunteers')
|
94
|
+
|
81
95
|
# Apply a Tag to a Person
|
82
96
|
tagging = client.tags(tag_id).create({identifiers: ['external:123']}, person_id: person_id)
|
83
97
|
tagging_id = tagging.action_network_id
|
@@ -5,13 +5,23 @@ module ActionNetworkRest
|
|
5
5
|
object_from_response(response)
|
6
6
|
end
|
7
7
|
|
8
|
+
def list(page: 1)
|
9
|
+
response = client.get_request "#{base_path}?page=#{page}"
|
10
|
+
objects = response.body.dig('_embedded', osdi_key)
|
11
|
+
return [] if objects.nil?
|
12
|
+
|
13
|
+
objects.each { |obj| set_action_network_id_on_object(obj) }
|
14
|
+
|
15
|
+
objects
|
16
|
+
end
|
17
|
+
|
8
18
|
private
|
9
19
|
|
10
20
|
def url_escape(string)
|
11
21
|
CGI.escape(string.to_s)
|
12
22
|
end
|
13
23
|
|
14
|
-
def
|
24
|
+
def set_action_network_id_on_object(obj)
|
15
25
|
# Takes an object which may contain an `identifiers` key, which may contain an action_network identifier
|
16
26
|
# If so, we pull out the action_network identifier and stick it in a top-level key "action_network_id",
|
17
27
|
# for the convenience of callers using the returned object.
|
@@ -33,7 +43,7 @@ module ActionNetworkRest
|
|
33
43
|
|
34
44
|
def object_from_response(response)
|
35
45
|
obj = response.body
|
36
|
-
|
46
|
+
set_action_network_id_on_object(obj)
|
37
47
|
end
|
38
48
|
|
39
49
|
def action_network_url(path)
|
@@ -35,10 +35,16 @@ module ActionNetworkRest
|
|
35
35
|
#
|
36
36
|
url_encoded_filter_string = url_escape("email_address eq '#{email}'")
|
37
37
|
response = client.get_request "#{base_path}?filter=#{url_encoded_filter_string}"
|
38
|
-
person_object = response.body[:_embedded][
|
38
|
+
person_object = response.body[:_embedded][osdi_key].first
|
39
39
|
if person_object.present?
|
40
|
-
|
40
|
+
set_action_network_id_on_object(person_object)
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def osdi_key
|
47
|
+
'osdi:people'
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
@@ -22,5 +22,27 @@ module ActionNetworkRest
|
|
22
22
|
response = client.post_request base_path, post_body
|
23
23
|
object_from_response(response)
|
24
24
|
end
|
25
|
+
|
26
|
+
def find_by_name(name)
|
27
|
+
# Action Network API doesn't support currently OData querying for tags
|
28
|
+
# (https://actionnetwork.org/docs/v2#odata) so we need to retrieve a list of
|
29
|
+
# all tags and iterate to find the one we're looking for.
|
30
|
+
page = 1
|
31
|
+
loop do
|
32
|
+
tags = self.list(page: page)
|
33
|
+
return nil if tags.empty?
|
34
|
+
|
35
|
+
found_tag = tags.find { |t| t.name == name }
|
36
|
+
return found_tag unless found_tag.nil?
|
37
|
+
|
38
|
+
page += 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def osdi_key
|
45
|
+
'osdi:tags'
|
46
|
+
end
|
25
47
|
end
|
26
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_network_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grey Moore
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
rubygems_version: 3.0.
|
177
|
+
rubygems_version: 3.0.8
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Ruby client for interacting with the ActionNetwork REST API
|