Sha256: 930530d605c8e5c2f1baac8e40f95abab7a70f93d3a75564290745d6f1e141fc

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module FaithTeams
  module API
    module V2
      module Resource
        # The contribution type resource
        class ContributionType < Base
          # @param args [Hash] These are ignored as no filters are available for this endpoint
          # @return [Entity::ContributionType]
          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

          # @param id [Integer]
          # @return [Entity::ContributionType]
          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
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
faithteams-api-4.2.0 lib/faithteams/api/v2/resource/contribution_type.rb
faithteams-api-4.1.1 lib/faithteams/api/v2/resource/contribution_type.rb
faithteams-api-4.0.1 lib/faithteams/api/v2/resource/contribution_type.rb
faithteams-api-2.0.2 lib/faithteams/api/v2/resource/contribution_type.rb
faithteams-api-2.0.1 lib/faithteams/api/v2/resource/contribution_type.rb