Class: SBF::Client::FundEndpoint

Inherits:
EntityEndpoint show all
Defined in:
lib/stbaldricks/endpoints/fund.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

#allowed_entities(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/stbaldricks/endpoints/fund.rb', line 6

def allowed_entities(params)
  response = SBF::Client::Api::Request.post_request("#{base_uri}/allowed_entities", params)
  parsed_response_body = JSON.parse(response.body).symbolize!

  if ok?(response)
    data = parsed_response_body
    model_type = SBF::Client::ModelType.list[params[:dest_model_type]].capitalize
    entity_class = "SBF::Client::Full#{model_type}".to_class
    data[:results].map! { |entity| entity_class.new(entity) }
  else
    error = SBF::Client::ErrorEntity.new(parsed_response_body)
    data = nil
  end

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

#direct_donation_years(params) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/stbaldricks/endpoints/fund.rb', line 23

def direct_donation_years(params)
  response = SBF::Client::Api::Request.post_request("#{base_uri}/direct_donation_years", params)
  data = JSON.parse(response.body).symbolize!

  unless ok?(response)
    error = SBF::Client::ErrorEntity.new(data)
    data = nil
  end

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