Class: FaithTeams::API::V2::Entity::Batch

Inherits:
Base
  • Object
show all
Defined in:
lib/faithteams/api/v2/entity/batch.rb

Overview

Wraps an faithteams batch object

Instance Method Summary collapse

Methods inherited from Base

#initialize, #saved?, #to_h

Constructor Details

This class inherits a constructor from FaithTeams::API::V2::Entity::Base

Instance Method Details

#batch_idInteger? Also known as: id

Returns:

  • (Integer, nil)


10
11
12
# File 'lib/faithteams/api/v2/entity/batch.rb', line 10

def batch_id
  read_attribute(:batchId)
end

#contributionsArray<FaithTeams::API::V2::Entity::Contributions>

Returns:

  • (Array<FaithTeams::API::V2::Entity::Contributions>)


16
17
18
19
20
21
22
23
# File 'lib/faithteams/api/v2/entity/batch.rb', line 16

def contributions
  records = read_attribute(:contributions)
  return [] unless records.present?

  records.group_by { |r| r["parentId"] }
    .values
    .map { FaithTeams::API::V2::Entity::Contribution.new(attributes: _1) }
end

#created_datetimeString?

Returns:

  • (String, nil)


26
27
28
# File 'lib/faithteams/api/v2/entity/batch.rb', line 26

def created_datetime
  read_attribute(:dtm).presence
end

#deleted?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/faithteams/api/v2/entity/batch.rb', line 46

def deleted?
  status == "D"
end

#open?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/faithteams/api/v2/entity/batch.rb', line 41

def open?
  status == "O"
end

#org_idInteger?

Returns:

  • (Integer, nil)


31
32
33
# File 'lib/faithteams/api/v2/entity/batch.rb', line 31

def org_id
  read_attribute(:orgId)
end

#statusString?

Returns "O" for open, "C" for closed, "D" for deleted.

Returns:

  • (String, nil)

    "O" for open, "C" for closed, "D" for deleted



36
37
38
# File 'lib/faithteams/api/v2/entity/batch.rb', line 36

def status
  read_attribute(:status).presence
end

#titleString?

Returns:

  • (String, nil)


51
52
53
# File 'lib/faithteams/api/v2/entity/batch.rb', line 51

def title
  read_attribute(:title).presence
end

#updated_datetimeString?

Returns:

  • (String, nil)


56
57
58
# File 'lib/faithteams/api/v2/entity/batch.rb', line 56

def updated_datetime
  read_attribute(:updatedDtm).presence
end

#updated_user_idInteger?

Returns:

  • (Integer, nil)


61
62
63
# File 'lib/faithteams/api/v2/entity/batch.rb', line 61

def updated_user_id
  read_attribute(:updatedUser)
end