-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual_donation.rb
128 lines (101 loc) · 2.76 KB
/
manual_donation.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# frozen_string_literal: true
require 'bigdecimal'
require 'time'
module Kentaa
module Api
module Resources
class ManualDonation < Resource
def object_key
"Donation_#{id}"
end
def entity
if action_id
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
elsif team_id
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
elsif company_id
Kentaa::Api::Resources::Company.new(config, id: company_id, options: options)
elsif project_id
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
elsif segment_id
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
elsif donation_form_id
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
else
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end
end
def site
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end
def site_id
data[:site_id]
end
def donation_form_id
data[:donation_form_id]
end
def segment_id
data[:segment_id]
end
def company_id
data[:company_id]
end
def project_id
data[:project_id]
end
def team_id
data[:team_id]
end
def action_id
data[:action_id]
end
def first_name
data[:first_name]
end
def infix
data[:infix]
end
def last_name
data[:last_name]
end
def name
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
end
def anonymous?
data[:anonymous]
end
def email
data[:email]
end
def message
data[:message]
end
def currency
data[:currency]
end
def amount
BigDecimal(data[:amount])
end
def countable?
data[:countable]
end
def target_url
data[:target_url]
end
private
def load_resource
request.get("/manual-donations/#{id}", options)
end
def create_resource(attributes)
request.post('/manual-donations', options, attributes)
end
def update_resource(attributes)
request.patch("/manual-donations/#{id}", options, attributes)
end
def delete_resource
request.delete("/manual-donations/#{id}", options)
end
end
end
end
end