action_network_rest 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc85d83854d521199b82e855ee4369c66c076a8487753756cc454010a0a22907
4
- data.tar.gz: 684db90a396a39ebbdc54ffec3fcdba678a2338fbc334052786f7422d4990eb9
3
+ metadata.gz: 2c7052276bcde7acbbc808912711dd160a2ec75b13905dac5cd11d25555deadd
4
+ data.tar.gz: acc6e54314b4671d2969fb91065185f249c073d6371999648d0016bcef868383
5
5
  SHA512:
6
- metadata.gz: fa5f2ece5e76ef8bfbffd96349eb0c545c423da441a318fab71458d86f7ebfd483a4bc7f512f25df73ad9a5f1acfc32a1f60e1acb69770f5b0c75b8b695420ec
7
- data.tar.gz: '0897288683f87fc8a9a273d360bf01bbbcf0da24bf7d90ffbb1176299a79f376a01d55e57af7a7680a771c8787579f78353eb5d32a08b0691d131b76f4431b45'
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
@@ -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__)
@@ -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")
@@ -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")
@@ -18,3 +18,5 @@ require 'action_network_rest/entry_point'
18
18
  require 'action_network_rest/people'
19
19
  require 'action_network_rest/petitions'
20
20
  require 'action_network_rest/signatures'
21
+ require 'action_network_rest/taggings'
22
+ require 'action_network_rest/tags'
@@ -32,7 +32,23 @@ module ActionNetworkRest
32
32
  end
33
33
 
34
34
  def petitions(petition_id=nil)
35
- @_petitions ||= ActionNetworkRest::Petitions.new(petition_id, client: self)
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
@@ -1,3 +1,3 @@
1
1
  module ActionNetworkRest
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  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.2.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: