Class: ActionNetworkRest::Attendances
- Defined in:
- lib/action_network_rest/attendances.rb
Defined Under Namespace
Classes: CreateError
Instance Attribute Summary collapse
-
#event_campaign_id ⇒ Object
Returns the value of attribute event_campaign_id.
-
#event_id ⇒ Object
Returns the value of attribute event_id.
Instance Method Summary collapse
Methods inherited from Base
Instance Attribute Details
#event_campaign_id ⇒ Object
Returns the value of attribute event_campaign_id.
7 8 9 |
# File 'lib/action_network_rest/attendances.rb', line 7 def event_campaign_id @event_campaign_id end |
#event_id ⇒ Object
Returns the value of attribute event_id.
7 8 9 |
# File 'lib/action_network_rest/attendances.rb', line 7 def event_id @event_id end |
Instance Method Details
#base_path ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/action_network_rest/attendances.rb', line 9 def base_path if event_campaign_id.present? "event_campaigns/#{url_escape(event_campaign_id)}/events/#{url_escape(event_id)}/attendances/" else "events/#{url_escape(event_id)}/attendances/" end end |
#create(attendance_data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/action_network_rest/attendances.rb', line 17 def create(attendance_data) response = client.post_request base_path, attendance_data new_attendance = object_from_response(response) # Action Network treats the attendance 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 attendance's data for successful calls) raise CreateError if new_attendance.empty? new_attendance end |
#update(id, attendance_data) ⇒ Object
30 31 32 33 |
# File 'lib/action_network_rest/attendances.rb', line 30 def update(id, attendance_data) response = client.put_request "#{base_path}#{url_escape(id)}", attendance_data object_from_response(response) end |