kentaa-api 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -1
- data/.travis.yml +5 -6
- data/Gemfile +4 -3
- data/Gemfile.lock +31 -23
- data/README.md +320 -66
- data/kentaa-api.gemspec +3 -3
- data/lib/kentaa/api.rb +6 -0
- data/lib/kentaa/api/client.rb +8 -0
- data/lib/kentaa/api/clients/actions.rb +2 -2
- data/lib/kentaa/api/clients/donation_forms.rb +24 -0
- data/lib/kentaa/api/clients/donations.rb +1 -1
- data/lib/kentaa/api/clients/manual_donations.rb +5 -5
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +1 -1
- data/lib/kentaa/api/clients/projects.rb +1 -1
- data/lib/kentaa/api/clients/recurring_donors.rb +24 -0
- data/lib/kentaa/api/clients/segments.rb +1 -1
- data/lib/kentaa/api/clients/sites.rb +1 -1
- data/lib/kentaa/api/clients/teams.rb +1 -1
- data/lib/kentaa/api/clients/users.rb +7 -2
- data/lib/kentaa/api/config.rb +4 -0
- data/lib/kentaa/api/exception.rb +5 -2
- data/lib/kentaa/api/request.rb +9 -0
- data/lib/kentaa/api/resources/action.rb +10 -6
- data/lib/kentaa/api/resources/actions.rb +2 -2
- data/lib/kentaa/api/resources/contact.rb +1 -1
- data/lib/kentaa/api/resources/donation.rb +16 -6
- data/lib/kentaa/api/resources/donation_form.rb +100 -0
- data/lib/kentaa/api/resources/donation_forms.rb +35 -0
- data/lib/kentaa/api/resources/donations.rb +1 -1
- data/lib/kentaa/api/resources/manual_donation.rb +15 -5
- data/lib/kentaa/api/resources/manual_donations.rb +2 -2
- data/lib/kentaa/api/resources/newsletter_subscription.rb +13 -3
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +1 -1
- data/lib/kentaa/api/resources/project.rb +10 -2
- data/lib/kentaa/api/resources/projects.rb +1 -1
- data/lib/kentaa/api/resources/question.rb +8 -0
- data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
- data/lib/kentaa/api/resources/recurring_donors.rb +35 -0
- data/lib/kentaa/api/resources/resource.rb +6 -6
- data/lib/kentaa/api/resources/segment.rb +12 -0
- data/lib/kentaa/api/resources/segments.rb +1 -1
- data/lib/kentaa/api/resources/site.rb +4 -0
- data/lib/kentaa/api/resources/team.rb +9 -5
- data/lib/kentaa/api/resources/teams.rb +1 -1
- data/lib/kentaa/api/resources/user.rb +11 -1
- data/lib/kentaa/api/resources/users.rb +7 -2
- data/lib/kentaa/api/version.rb +1 -1
- metadata +14 -8
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class DonationForms < List
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def each(&block)
|
10
|
+
donation_forms.each(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def load_resource
|
16
|
+
request.get("/donation-forms", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def donation_forms
|
20
|
+
@donation_forms ||= begin
|
21
|
+
donation_forms = []
|
22
|
+
|
23
|
+
if data
|
24
|
+
data.each do |donation_form|
|
25
|
+
donation_forms << Kentaa::Api::Resources::DonationForm.new(config, data: donation_form, options: options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
donation_forms
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -13,22 +13,32 @@ module Kentaa
|
|
13
13
|
|
14
14
|
def entity
|
15
15
|
if action_id
|
16
|
-
Kentaa::Api::Resources::Action.new(config, id: action_id)
|
16
|
+
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
|
17
17
|
elsif team_id
|
18
|
-
Kentaa::Api::Resources::Team.new(config, id: team_id)
|
18
|
+
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
|
19
19
|
elsif project_id
|
20
|
-
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
20
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
21
21
|
elsif segment_id
|
22
|
-
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
22
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
23
|
+
elsif donation_form_id
|
24
|
+
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
|
23
25
|
else
|
24
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
26
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def site
|
31
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
32
|
+
end
|
33
|
+
|
28
34
|
def site_id
|
29
35
|
data[:site_id]
|
30
36
|
end
|
31
37
|
|
38
|
+
def donation_form_id
|
39
|
+
data[:donation_form_id]
|
40
|
+
end
|
41
|
+
|
32
42
|
def segment_id
|
33
43
|
data[:segment_id]
|
34
44
|
end
|
@@ -11,7 +11,7 @@ module Kentaa
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create(attributes = {})
|
14
|
-
donation = Kentaa::Api::Resources::ManualDonation.new(config, options)
|
14
|
+
donation = Kentaa::Api::Resources::ManualDonation.new(config, options: options)
|
15
15
|
donation.save(attributes)
|
16
16
|
end
|
17
17
|
|
@@ -27,7 +27,7 @@ module Kentaa
|
|
27
27
|
|
28
28
|
if data
|
29
29
|
data.each do |manual_donation|
|
30
|
-
manual_donations << Kentaa::Api::Resources::ManualDonation.new(config, data: manual_donation)
|
30
|
+
manual_donations << Kentaa::Api::Resources::ManualDonation.new(config, data: manual_donation, options: options)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -10,14 +10,20 @@ module Kentaa
|
|
10
10
|
|
11
11
|
def entity
|
12
12
|
if project_id
|
13
|
-
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
13
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
14
14
|
elsif segment_id
|
15
|
-
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
15
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
16
|
+
elsif donation_form_id
|
17
|
+
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
|
16
18
|
else
|
17
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
19
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
23
|
+
def site
|
24
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
25
|
+
end
|
26
|
+
|
21
27
|
def first_name
|
22
28
|
data[:first_name]
|
23
29
|
end
|
@@ -38,6 +44,10 @@ module Kentaa
|
|
38
44
|
data[:site_id]
|
39
45
|
end
|
40
46
|
|
47
|
+
def donation_form_id
|
48
|
+
data[:donation_form_id]
|
49
|
+
end
|
50
|
+
|
41
51
|
def segment_id
|
42
52
|
data[:segment_id]
|
43
53
|
end
|
@@ -22,7 +22,7 @@ module Kentaa
|
|
22
22
|
|
23
23
|
if data
|
24
24
|
data.each do |newsletter_subscription|
|
25
|
-
newsletter_subscriptions << Kentaa::Api::Resources::NewsletterSubscription.new(config, data: newsletter_subscription)
|
25
|
+
newsletter_subscriptions << Kentaa::Api::Resources::NewsletterSubscription.new(config, data: newsletter_subscription, options: options)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -13,12 +13,16 @@ module Kentaa
|
|
13
13
|
|
14
14
|
def parent
|
15
15
|
if segment_id
|
16
|
-
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
16
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
17
17
|
else
|
18
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
18
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def site
|
23
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
24
|
+
end
|
25
|
+
|
22
26
|
def slug
|
23
27
|
data[:slug]
|
24
28
|
end
|
@@ -149,6 +153,10 @@ module Kentaa
|
|
149
153
|
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, project_id: id)
|
150
154
|
end
|
151
155
|
|
156
|
+
def newsletter_subscriptions
|
157
|
+
@newsletter_subscriptions ||= Kentaa::Api::Resources::NewsletterSubscriptions.new(config, project_id: id)
|
158
|
+
end
|
159
|
+
|
152
160
|
private
|
153
161
|
|
154
162
|
def load_resource
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class RecurringDonor < Resource
|
10
|
+
def object_key
|
11
|
+
"RecurringDonor_#{id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def entity
|
15
|
+
if donation_form_id
|
16
|
+
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
|
17
|
+
else
|
18
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def site
|
23
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def site_id
|
27
|
+
data[:site_id]
|
28
|
+
end
|
29
|
+
|
30
|
+
def donation_form_id
|
31
|
+
data[:donation_form_id]
|
32
|
+
end
|
33
|
+
|
34
|
+
def first_name
|
35
|
+
data[:first_name]
|
36
|
+
end
|
37
|
+
|
38
|
+
def infix
|
39
|
+
data[:infix]
|
40
|
+
end
|
41
|
+
|
42
|
+
def last_name
|
43
|
+
data[:last_name]
|
44
|
+
end
|
45
|
+
|
46
|
+
def name
|
47
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
|
48
|
+
end
|
49
|
+
|
50
|
+
def company
|
51
|
+
data[:company]
|
52
|
+
end
|
53
|
+
|
54
|
+
def anonymous?
|
55
|
+
data[:anonymous]
|
56
|
+
end
|
57
|
+
|
58
|
+
def email
|
59
|
+
data[:email]
|
60
|
+
end
|
61
|
+
|
62
|
+
def locale
|
63
|
+
data[:locale]
|
64
|
+
end
|
65
|
+
|
66
|
+
def frequency_type
|
67
|
+
data[:frequency_type]
|
68
|
+
end
|
69
|
+
|
70
|
+
def start_date
|
71
|
+
Date.parse(data[:start_date])
|
72
|
+
end
|
73
|
+
|
74
|
+
def end_date
|
75
|
+
Date.parse(data[:end_date]) if data[:end_date]
|
76
|
+
end
|
77
|
+
|
78
|
+
def active?
|
79
|
+
data[:active]
|
80
|
+
end
|
81
|
+
|
82
|
+
def currency
|
83
|
+
data[:currency]
|
84
|
+
end
|
85
|
+
|
86
|
+
def amount
|
87
|
+
BigDecimal(data[:amount])
|
88
|
+
end
|
89
|
+
|
90
|
+
def transaction_costs
|
91
|
+
BigDecimal(data[:transaction_costs]) if data[:transaction_costs]
|
92
|
+
end
|
93
|
+
|
94
|
+
def total_amount
|
95
|
+
BigDecimal(data[:total_amount])
|
96
|
+
end
|
97
|
+
|
98
|
+
def donations
|
99
|
+
@donations ||= Kentaa::Api::Resources::Donations.new(config, recurring_donor_id: id)
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def load_resource
|
105
|
+
request.get("/recurring-donors/#{id}", options)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class RecurringDonors < List
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def each(&block)
|
10
|
+
recurring_donors.each(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def load_resource
|
16
|
+
request.get("/recurring-donors", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def recurring_donors
|
20
|
+
@recurring_donors ||= begin
|
21
|
+
recurring_donors = []
|
22
|
+
|
23
|
+
if data
|
24
|
+
data.each do |recurring_donor|
|
25
|
+
recurring_donors << Kentaa::Api::Resources::RecurringDonor.new(config, data: recurring_donor, options: options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
recurring_donors
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -8,14 +8,14 @@ module Kentaa
|
|
8
8
|
class Resource < Base
|
9
9
|
attr_accessor :id
|
10
10
|
|
11
|
-
def initialize(config, options
|
11
|
+
def initialize(config, id: nil, data: nil, options: {})
|
12
12
|
super(config, options)
|
13
13
|
|
14
|
-
if
|
15
|
-
@data =
|
14
|
+
if data
|
15
|
+
@data = data || {}
|
16
16
|
@id = @data.fetch(:id) if @data.key?(:id)
|
17
|
-
elsif
|
18
|
-
@id =
|
17
|
+
elsif id
|
18
|
+
@id = id
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -40,7 +40,7 @@ module Kentaa
|
|
40
40
|
def delete
|
41
41
|
delete_resource
|
42
42
|
|
43
|
-
|
43
|
+
nil
|
44
44
|
end
|
45
45
|
|
46
46
|
def created_at
|
@@ -11,6 +11,14 @@ module Kentaa
|
|
11
11
|
"Segment_#{id}"
|
12
12
|
end
|
13
13
|
|
14
|
+
def parent
|
15
|
+
site
|
16
|
+
end
|
17
|
+
|
18
|
+
def site
|
19
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
20
|
+
end
|
21
|
+
|
14
22
|
def site_id
|
15
23
|
data[:site_id]
|
16
24
|
end
|
@@ -81,6 +89,10 @@ module Kentaa
|
|
81
89
|
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, segment_id: id)
|
82
90
|
end
|
83
91
|
|
92
|
+
def newsletter_subscriptions
|
93
|
+
@newsletter_subscriptions ||= Kentaa::Api::Resources::NewsletterSubscriptions.new(config, segment_id: id)
|
94
|
+
end
|
95
|
+
|
84
96
|
private
|
85
97
|
|
86
98
|
def load_resource
|
@@ -93,6 +93,10 @@ module Kentaa
|
|
93
93
|
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config)
|
94
94
|
end
|
95
95
|
|
96
|
+
def newsletter_subscriptions
|
97
|
+
@newsletter_subscriptions ||= Kentaa::Api::Resources::NewsletterSubscriptions.new(config)
|
98
|
+
end
|
99
|
+
|
96
100
|
private
|
97
101
|
|
98
102
|
def load_resource
|
@@ -13,14 +13,18 @@ module Kentaa
|
|
13
13
|
|
14
14
|
def parent
|
15
15
|
if project_id
|
16
|
-
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
16
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
17
17
|
elsif segment_id
|
18
|
-
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
18
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
19
19
|
else
|
20
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
20
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def site
|
25
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
26
|
+
end
|
27
|
+
|
24
28
|
def slug
|
25
29
|
data[:slug]
|
26
30
|
end
|
@@ -38,7 +42,7 @@ module Kentaa
|
|
38
42
|
end
|
39
43
|
|
40
44
|
def owner
|
41
|
-
@owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner])
|
45
|
+
@owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner], options: options)
|
42
46
|
end
|
43
47
|
|
44
48
|
def members
|
@@ -47,7 +51,7 @@ module Kentaa
|
|
47
51
|
|
48
52
|
if data[:members]
|
49
53
|
data[:members].each do |member|
|
50
|
-
members << Kentaa::Api::Resources::Action.new(config, data: member)
|
54
|
+
members << Kentaa::Api::Resources::Action.new(config, data: member, options: options)
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|