Class: ActionNetworkRest::Signatures
- Defined in:
- lib/action_network_rest/signatures.rb
Defined Under Namespace
Classes: CreateError
Instance Attribute Summary collapse
-
#petition_id ⇒ Object
Returns the value of attribute petition_id.
Instance Method Summary collapse
Methods inherited from Base
Instance Attribute Details
#petition_id ⇒ Object
Returns the value of attribute petition_id.
7 8 9 |
# File 'lib/action_network_rest/signatures.rb', line 7 def petition_id @petition_id end |
Instance Method Details
#base_path ⇒ Object
9 10 11 |
# File 'lib/action_network_rest/signatures.rb', line 9 def base_path "petitions/#{url_escape(petition_id)}/signatures/" end |
#create(signature_data, tags: []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/action_network_rest/signatures.rb', line 13 def create(signature_data, tags: []) post_body = signature_data post_body['add_tags'] = if .any? response = client.post_request(base_path, post_body) new_signature = object_from_response(response) # Action Network treats the signature create helper endpoint as an unauthenticated # "blind" POST (see https://actionnetwork.org/docs/v2/unauthenticated-post/). For this # reason they don't return a status code with error to avoid leaking private data. Instead # they return 200 OK with an empty body (vs. the newly created signature's data for successful calls) raise CreateError if new_signature.empty? new_signature end |
#update(id, signature_data) ⇒ Object
29 30 31 32 |
# File 'lib/action_network_rest/signatures.rb', line 29 def update(id, signature_data) response = client.put_request("#{base_path}#{url_escape(id)}", signature_data) object_from_response(response) end |