Class: ActionNetworkRest::Client
- Defined in:
- lib/action_network_rest/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#advocacy_campaigns ⇒ Object
Helpers to let users do things like ‘an_client.people.create(params)`.
- #campaigns ⇒ Object
- #default_options ⇒ Object
- #entry_point ⇒ Object
- #event_campaigns(event_campaign_id = nil) ⇒ Object
- #events(event_id = nil) ⇒ Object
- #extract_data_from_params(params) ⇒ Object
- #forms ⇒ Object
-
#initialize(options = {}, &block) ⇒ Client
constructor
A new instance of Client.
- #people ⇒ Object
- #petitions(petition_id = nil) ⇒ Object
- #tags(tag_id = nil) ⇒ Object
Methods inherited from API
Constructor Details
#initialize(options = {}, &block) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/action_network_rest/client.rb', line 7 def initialize( = {}, &block) self.api_key = [:api_key] super(, &block) end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/action_network_rest/client.rb', line 5 def api_key @api_key end |
Instance Method Details
#advocacy_campaigns ⇒ Object
Helpers to let users do things like ‘an_client.people.create(params)`
28 29 30 |
# File 'lib/action_network_rest/client.rb', line 28 def advocacy_campaigns @_advocacy_campaigns ||= ActionNetworkRest::AdvocacyCampaigns.new(client: self) end |
#campaigns ⇒ Object
32 33 34 |
# File 'lib/action_network_rest/client.rb', line 32 def campaigns @_campaigns ||= ActionNetworkRest::Campaigns.new(client: self) end |
#default_options ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/action_network_rest/client.rb', line 12 def { host: 'actionnetwork.org', prefix: '/api/v2', content_type: 'application/json', additional_headers: { 'OSDI-API-Token' => api_key }, user_agent: 'ruby: ActionNetworkRest' } end |
#entry_point ⇒ Object
56 57 58 |
# File 'lib/action_network_rest/client.rb', line 56 def entry_point @_entry_point ||= ActionNetworkRest::EntryPoint.new(client: self) end |
#event_campaigns(event_campaign_id = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/action_network_rest/client.rb', line 46 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) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/action_network_rest/client.rb', line 36 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) ⇒ Object
22 23 24 |
# File 'lib/action_network_rest/client.rb', line 22 def extract_data_from_params(params) params.to_json end |
#forms ⇒ Object
60 61 62 |
# File 'lib/action_network_rest/client.rb', line 60 def forms @_forms ||= ActionNetworkRest::Forms.new(client: self) end |
#people ⇒ Object
64 65 66 |
# File 'lib/action_network_rest/client.rb', line 64 def people @_people ||= ActionNetworkRest::People.new(client: self) end |
#petitions(petition_id = nil) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/action_network_rest/client.rb', line 68 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) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/action_network_rest/client.rb', line 78 def (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 |