-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtester.rb
65 lines (52 loc) · 2.26 KB
/
tester.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
token = ""
secret = ""
church_code = ""
@client ||= FellowshipOne::Client.new(token, secret, church_code)
find_or_create_fellowship_person
contribution = build_fellowship_contribution
@donation.refs = {"f1_id" => contribution.id}
raise
@donation.save
def find_or_create_fellowship_person
people = @client.search_for_person({name: "taylor", email: "tbrooks@gmail"})
if people.count == 0
@donor = build_fellowship_person
build_fellowship_email
else
@donor = people.first
end
end
def build_fellowship_person
household = @client.new_household
household.household_name = "Taylor Brooks"
@client.save_household(household)
donor = @client.new_person
donor.household_id = household.id.to_s
donor.id = ''
donor.household_member_type['@id'] = '1'
donor.status['@id'] = '6' # Contributor Only
donor.first_name = "Taylor"
donor.last_name = "Brooks"
@client.create_person(donor)
end
def build_fellowship_email
communication = @client.new_communication(@donor.id)
communication.communication_type['@id'] = '4'
communication.communication_type['name'] = 'Email'
communication.communication_general_type = 'Email'
communication.preferred = 'true'
communication.communication_value = @customer.email
communication.search_communication_value = @customer.email
@client.create_communicate(@donor.id, communication.id, communication)
end
def build_fellowship_contribution
contribution = @client.new_contribution
contribution.amount = @donation.gross_amount/100.00
contribution.fund['@id'] = @donation.fund.settings['fellowship_fund_id']
contribution.household['@id'] = @donor.household_id
contribution.received_date = @donation.created_at.iso8601 # Needs to be this format
contribution.contribution_type['@id'] = @donation.payment_type == 'bank account' ? 5 : 3 # 3 - Credit Card, 5 - ACH
contribution.memo = "Simple Donation - #{@donation.id}"
contribution.address_verification = false
@client.create_contribution(contribution)
end