class ActionNetworkRest::Petitions

Attributes

petition_id[RW]

Public Class Methods

new(petition_id = nil, client:) click to toggle source

Without a petition_id, this class is used for Petition creation/update endpoints. With a petition_id, this class is used to initialise the Signatures class, like client.petitions(123).signatures

Calls superclass method
# File lib/action_network_rest/petitions.rb, line 10
def initialize(petition_id = nil, client:)
  super(client: client, petition_id: petition_id)
end

Public Instance Methods

base_path() click to toggle source
# File lib/action_network_rest/petitions.rb, line 18
def base_path
  'petitions/'
end
create(petition_data, creator_person_id: nil) click to toggle source
# File lib/action_network_rest/petitions.rb, line 22
def create(petition_data, creator_person_id: nil)
  post_body = petition_data
  if creator_person_id.present?
    creator_person_url = action_network_url("/people/#{url_escape(creator_person_id)}")
    post_body['_links'] = { 'osdi:creator' => { href: creator_person_url } }
  end

  response = client.post_request base_path, post_body
  object_from_response(response)
end
signatures() click to toggle source
# File lib/action_network_rest/petitions.rb, line 14
def signatures
  @_signatures ||= ActionNetworkRest::Signatures.new(client: client, petition_id: petition_id)
end
update(id, petition_data) click to toggle source
# File lib/action_network_rest/petitions.rb, line 33
def update(id, petition_data)
  petition_path = "#{base_path}#{url_escape(id)}"
  response = client.put_request petition_path, petition_data
  object_from_response(response)
end

Private Instance Methods

osdi_key() click to toggle source
# File lib/action_network_rest/petitions.rb, line 41
def osdi_key
  'osdi:petitions'
end