Class: FaithTeams::API::V2::Resource::ContributionType

Inherits:
Base show all
Defined in:
lib/faithteams/api/v2/resource/contribution_type.rb

Overview

The contribution type resource

Instance Method Summary collapse

Methods inherited from Base

#create, #delete, #update

Methods inherited from GatewayBase

#initialize, #valid_connection?

Constructor Details

This class inherits a constructor from FaithTeams::API::V2::GatewayBase

Instance Method Details

#find(id:) ⇒ Entity::ContributionType

Parameters:

  • id (Integer)

Returns:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/faithteams/api/v2/resource/contribution_type.rb', line 23

def find(id:)
  return nil if id.blank?

  data = connection.get(path: "/contributiontypes/#{id}", params: {}).fetch("data")

  return nil unless data.present?

  Entity::ContributionType.new(attributes: data)
rescue Error::Request => e
  e.response.code == 404 ? nil : raise
end

#search(**args) ⇒ Entity::ContributionType

Parameters:

  • args (Hash)

    These are ignored as no filters are available for this endpoint

Returns:



11
12
13
14
15
16
17
18
19
# File 'lib/faithteams/api/v2/resource/contribution_type.rb', line 11

def search(**args)
  data = connection.get(path: "/contributiontypes", params: {}).fetch("data")

  return nil unless data.present?

  data.map do |record|
    Entity::ContributionType.new(attributes: record)
  end
end