action_network_rest 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/bin/console +14 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/lib/action_network_rest.rb +2 -0
- data/lib/action_network_rest/client.rb +17 -1
- data/lib/action_network_rest/signatures.rb +0 -5
- data/lib/action_network_rest/taggings.rb +23 -0
- data/lib/action_network_rest/tags.rb +26 -0
- data/lib/action_network_rest/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c7052276bcde7acbbc808912711dd160a2ec75b13905dac5cd11d25555deadd
|
4
|
+
data.tar.gz: acc6e54314b4671d2969fb91065185f249c073d6371999648d0016bcef868383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8065e41e4a565188ad1a2b6c24bb67c2858d4ea9d793b03082c4fd2cc0764ceba51f69df7481fa3e8ba6a961217cd3e769caa6c88fbcd90c286bbc9fdf5fef30
|
7
|
+
data.tar.gz: c4644fd81aba749b33a2871b4f776e182464c25f3be8f754d8d9209666aa98ea19ca1385d4fe977407a0e5e9ab0749224ee5211e2355891fba22d725e9635be2
|
data/README.md
CHANGED
@@ -63,6 +63,23 @@ puts signature.created_date
|
|
63
63
|
|
64
64
|
# Update a Signature
|
65
65
|
client.petitions(petition_id).signatures.update(signature_id, {comments: 'new comments'})
|
66
|
+
|
67
|
+
# Create a Tag
|
68
|
+
tag = client.tags.create('Volunteers')
|
69
|
+
tag_id = tag.action_network_id
|
70
|
+
|
71
|
+
# Retrieve a Tag
|
72
|
+
tag = client.tags.get(tag_id)
|
73
|
+
|
74
|
+
# Apply a Tag to a Person
|
75
|
+
tagging = client.tags(tag_id).create({identifiers: ['external:123']}, person_id: person_id)
|
76
|
+
tagging_id = tagging.action_network_id
|
77
|
+
|
78
|
+
# Retrieve a Tagging
|
79
|
+
tagging = client.tags(tag_id).taggings.get(tagging_id)
|
80
|
+
|
81
|
+
# Delete a Tagging
|
82
|
+
client.tags(tag_id).taggings.delete(tagging_id)
|
66
83
|
```
|
67
84
|
|
68
85
|
## Development
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "action_network_rest"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/lib/action_network_rest.rb
CHANGED
@@ -32,7 +32,23 @@ module ActionNetworkRest
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def petitions(petition_id=nil)
|
35
|
-
@_petitions
|
35
|
+
if @_petitions&.send(:[], petition_id).nil?
|
36
|
+
@_petitions = {} if @_petitions.nil?
|
37
|
+
|
38
|
+
@_petitions[petition_id] = ActionNetworkRest::Petitions.new(petition_id, client: self)
|
39
|
+
end
|
40
|
+
|
41
|
+
@_petitions[petition_id]
|
42
|
+
end
|
43
|
+
|
44
|
+
def tags(tag_id=nil)
|
45
|
+
if @_tags&.send(:[], tag_id).nil?
|
46
|
+
@_tags = {} if @_tags.nil?
|
47
|
+
|
48
|
+
@_tags[tag_id] = ActionNetworkRest::Tags.new(tag_id, client: self)
|
49
|
+
end
|
50
|
+
|
51
|
+
@_tags[tag_id]
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
@@ -6,11 +6,6 @@ module ActionNetworkRest
|
|
6
6
|
"petitions/#{url_escape(petition_id)}/signatures/"
|
7
7
|
end
|
8
8
|
|
9
|
-
def get(id)
|
10
|
-
response = client.get_request "#{base_path}#{url_escape(id)}"
|
11
|
-
object_from_response(response)
|
12
|
-
end
|
13
|
-
|
14
9
|
def create(signature_data, tags: [])
|
15
10
|
post_body = signature_data
|
16
11
|
if tags.any?
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActionNetworkRest
|
2
|
+
class Taggings < Base
|
3
|
+
attr_accessor :tag_id
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"tags/#{url_escape(tag_id)}/taggings/"
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(tagging_data, person_id:)
|
10
|
+
post_body = tagging_data
|
11
|
+
person_url = action_network_url("/people/#{url_escape(person_id)}")
|
12
|
+
post_body['_links'] = {'osdi:person' => {href: person_url}}
|
13
|
+
|
14
|
+
response = client.post_request base_path, post_body
|
15
|
+
object_from_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete(id)
|
19
|
+
response = client.delete_request "#{base_path}#{url_escape(id)}"
|
20
|
+
object_from_response(response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActionNetworkRest
|
2
|
+
class Tags < Base
|
3
|
+
attr_accessor :tag_id
|
4
|
+
|
5
|
+
# Without a tag_id, this class is used for the Tag creation endpoint.
|
6
|
+
# With a tag_id, this class is used to initialise the Taggings class,
|
7
|
+
# like client.tags(123).taggings
|
8
|
+
def initialize(tag_id=nil, client:)
|
9
|
+
super(client: client, tag_id: tag_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def taggings
|
13
|
+
@_taggings ||= ActionNetworkRest::Taggings.new(client: client, tag_id: tag_id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_path
|
17
|
+
'tags/'
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(name)
|
21
|
+
post_body = {name: name}
|
22
|
+
response = client.post_request base_path, post_body
|
23
|
+
object_from_response(response)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grey Moore
|
@@ -96,6 +96,9 @@ files:
|
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
98
|
- action_network_rest.gemspec
|
99
|
+
- bin/console
|
100
|
+
- bin/rake
|
101
|
+
- bin/rspec
|
99
102
|
- lib/action_network_rest.rb
|
100
103
|
- lib/action_network_rest/base.rb
|
101
104
|
- lib/action_network_rest/client.rb
|
@@ -103,6 +106,8 @@ files:
|
|
103
106
|
- lib/action_network_rest/people.rb
|
104
107
|
- lib/action_network_rest/petitions.rb
|
105
108
|
- lib/action_network_rest/signatures.rb
|
109
|
+
- lib/action_network_rest/taggings.rb
|
110
|
+
- lib/action_network_rest/tags.rb
|
106
111
|
- lib/action_network_rest/version.rb
|
107
112
|
homepage: https://github.com/controlshift/action-network-rest
|
108
113
|
licenses:
|