class ActionNetworkRest::Client

Attributes

api_key[RW]

Public Class Methods

new(options = {}, &block) click to toggle source
Calls superclass method
# File lib/action_network_rest/client.rb, line 7
def initialize(options = {}, &block)
  self.api_key = options[:api_key]
  super(options, &block)
end

Public Instance Methods

default_options() click to toggle source
# File lib/action_network_rest/client.rb, line 12
def default_options
  {
    host: 'actionnetwork.org',
    prefix: '/api/v2',
    content_type: 'application/json',
    additional_headers: { 'OSDI-API-Token' => api_key },
    user_agent: 'ruby: ActionNetworkRest'
  }
end
entry_point() click to toggle source
# File lib/action_network_rest/client.rb, line 48
def entry_point
  @_entry_point ||= ActionNetworkRest::EntryPoint.new(client: self)
end
event_campaigns(event_campaign_id = nil) click to toggle source
# File lib/action_network_rest/client.rb, line 38
def event_campaigns(event_campaign_id = nil)
  if @_event_campaigns&.send(:[], event_campaign_id).nil?
    @_event_campaigns = {} if @_event_campaigns.nil?

    @_event_campaigns[event_campaign_id] = ActionNetworkRest::EventCampaigns.new(event_campaign_id, client: self)
  end

  @_event_campaigns[event_campaign_id]
end
events(event_id = nil) click to toggle source

Helpers to let users do things like `an_client.people.create(params)`

# File lib/action_network_rest/client.rb, line 28
def events(event_id = nil)
  if @_events&.send(:[], event_id).nil?
    @_events = {} if @_events.nil?

    @_events[event_id] = ActionNetworkRest::Events.new(event_id: event_id, client: self)
  end

  @_events[event_id]
end
extract_data_from_params(params) click to toggle source
# File lib/action_network_rest/client.rb, line 22
def extract_data_from_params(params)
  params.to_json
end
people() click to toggle source
# File lib/action_network_rest/client.rb, line 52
def people
  @_people ||= ActionNetworkRest::People.new(client: self)
end
petitions(petition_id = nil) click to toggle source
# File lib/action_network_rest/client.rb, line 56
def petitions(petition_id = nil)
  if @_petitions&.send(:[], petition_id).nil?
    @_petitions = {} if @_petitions.nil?

    @_petitions[petition_id] = ActionNetworkRest::Petitions.new(petition_id, client: self)
  end

  @_petitions[petition_id]
end
tags(tag_id = nil) click to toggle source
# File lib/action_network_rest/client.rb, line 66
def tags(tag_id = nil)
  if @_tags&.send(:[], tag_id).nil?
    @_tags = {} if @_tags.nil?

    @_tags[tag_id] = ActionNetworkRest::Tags.new(tag_id, client: self)
  end

  @_tags[tag_id]
end