Class: SBF::Client::FundraiserEndpoint

Inherits:
EntityEndpoint show all
Defined in:
lib/stbaldricks/endpoints/fundraiser.rb

Instance Attribute Summary

Attributes inherited from EntityEndpoint

#orig_target_class

Instance Method Summary collapse

Methods inherited from EntityEndpoint

#aggregate, #create, #delete, #find, #find_first, #get, #initialize, #save, #update

Constructor Details

This class inherits a constructor from SBF::Client::EntityEndpoint

Instance Method Details

#join_event(fundraiser_id, new_event_id) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/stbaldricks/endpoints/fundraiser.rb', line 22

def join_event(fundraiser_id, new_event_id)
  response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_event",
                                                    id: fundraiser_id, new_event_id: new_event_id)

  error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)

  SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
end

#join_team(fundraiser_id, new_team_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/stbaldricks/endpoints/fundraiser.rb', line 6

def join_team(fundraiser_id, new_team_id)
  response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: fundraiser_id, new_team_id: new_team_id)

  if ok?(response)
    data = SBF::Client::FullFundraiser.new(JSON.parse(response.body).symbolize!)
  else
    error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
  end

  SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
end

#leave_event(fundraiser_id) ⇒ Object



31
32
33
# File 'lib/stbaldricks/endpoints/fundraiser.rb', line 31

def leave_event(fundraiser_id)
  join_event(fundraiser_id, 0)
end

#leave_team(fundraiser_id) ⇒ Object



18
19
20
# File 'lib/stbaldricks/endpoints/fundraiser.rb', line 18

def leave_team(fundraiser_id)
  join_team(fundraiser_id, 0)
end