Class: ActionNetworkRest::Client
- Inherits:
-
Vertebrae::API
- Object
- Vertebrae::API
- 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
- #default_options ⇒ Object
-
#entry_point ⇒ Object
Helpers to let users do things like ‘an_client.people.create(params)`.
- #extract_data_from_params(params) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Client
constructor
A new instance of Client.
- #people ⇒ Object
- #petitions(petition_id = nil) ⇒ Object
- #tags(tag_id = nil) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/action_network_rest/client.rb', line 5 def initialize(={}, &block) self.api_key = [:api_key] super(, &block) end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/action_network_rest/client.rb', line 3 def api_key @api_key end |
Instance Method Details
#default_options ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/action_network_rest/client.rb', line 10 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
Helpers to let users do things like ‘an_client.people.create(params)`
26 27 28 |
# File 'lib/action_network_rest/client.rb', line 26 def entry_point @_entry_point ||= ActionNetworkRest::EntryPoint.new(client: self) end |
#extract_data_from_params(params) ⇒ Object
20 21 22 |
# File 'lib/action_network_rest/client.rb', line 20 def extract_data_from_params(params) params.to_json end |
#people ⇒ Object
30 31 32 |
# File 'lib/action_network_rest/client.rb', line 30 def people @_people ||= ActionNetworkRest::People.new(client: self) end |
#petitions(petition_id = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/action_network_rest/client.rb', line 34 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
44 45 46 47 48 49 50 51 52 |
# File 'lib/action_network_rest/client.rb', line 44 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 |