kentaa-api 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +18 -1
- data/.travis.yml +7 -3
- data/Gemfile +4 -1
- data/Gemfile.lock +66 -0
- data/README.md +15 -0
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/kentaa-api.gemspec +2 -2
- data/lib/kentaa/api/client.rb +14 -8
- data/lib/kentaa/api/{http.rb → request.rb} +9 -10
- data/lib/kentaa/api/requests/actions.rb +4 -2
- data/lib/kentaa/api/requests/all.rb +3 -1
- data/lib/kentaa/api/requests/base.rb +5 -3
- data/lib/kentaa/api/requests/donations.rb +4 -2
- data/lib/kentaa/api/requests/newsletter_subscriptions.rb +8 -1
- data/lib/kentaa/api/requests/projects.rb +4 -2
- data/lib/kentaa/api/requests/segments.rb +4 -2
- data/lib/kentaa/api/requests/sites.rb +3 -1
- data/lib/kentaa/api/requests/teams.rb +4 -2
- data/lib/kentaa/api/requests/users.rb +21 -0
- data/lib/kentaa/api/response.rb +30 -0
- data/lib/kentaa/api/responses/action.rb +72 -6
- data/lib/kentaa/api/responses/actions.rb +4 -6
- data/lib/kentaa/api/responses/activity.rb +15 -0
- data/lib/kentaa/api/responses/address.rb +14 -4
- data/lib/kentaa/api/responses/banner.rb +2 -4
- data/lib/kentaa/api/responses/base.rb +19 -7
- data/lib/kentaa/api/responses/consent.rb +21 -0
- data/lib/kentaa/api/responses/donation.rb +38 -8
- data/lib/kentaa/api/responses/donations.rb +4 -6
- data/lib/kentaa/api/responses/location.rb +29 -0
- data/lib/kentaa/api/responses/newsletter_subscription.rb +20 -2
- data/lib/kentaa/api/responses/newsletter_subscriptions.rb +4 -6
- data/lib/kentaa/api/responses/pagination.rb +9 -5
- data/lib/kentaa/api/responses/photo.rb +2 -4
- data/lib/kentaa/api/responses/project.rb +31 -5
- data/lib/kentaa/api/responses/projects.rb +4 -6
- data/lib/kentaa/api/responses/question.rb +2 -4
- data/lib/kentaa/api/responses/registration_fee.rb +17 -0
- data/lib/kentaa/api/responses/resource.rb +2 -0
- data/lib/kentaa/api/responses/reward.rb +2 -4
- data/lib/kentaa/api/responses/segment.rb +7 -5
- data/lib/kentaa/api/responses/segments.rb +4 -6
- data/lib/kentaa/api/responses/site.rb +11 -5
- data/lib/kentaa/api/responses/status.rb +27 -0
- data/lib/kentaa/api/responses/team.rb +24 -6
- data/lib/kentaa/api/responses/teams.rb +4 -6
- data/lib/kentaa/api/responses/user.rb +89 -0
- data/lib/kentaa/api/responses/users.rb +32 -0
- data/lib/kentaa/api/responses/video.rb +2 -4
- data/lib/kentaa/api/version.rb +3 -1
- data/lib/kentaa/api.rb +12 -2
- metadata +15 -6
- data/lib/kentaa/api/responses/owner.rb +0 -37
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
@@ -5,10 +7,6 @@ module Kentaa
|
|
5
7
|
include Enumerable
|
6
8
|
include Kentaa::Api::Responses::Pagination
|
7
9
|
|
8
|
-
def initialize(response)
|
9
|
-
super(response)
|
10
|
-
end
|
11
|
-
|
12
10
|
def each(&block)
|
13
11
|
actions.each(&block)
|
14
12
|
end
|
@@ -19,8 +17,8 @@ module Kentaa
|
|
19
17
|
@actions ||= begin
|
20
18
|
actions = []
|
21
19
|
|
22
|
-
if data
|
23
|
-
data
|
20
|
+
if data
|
21
|
+
data.each do |action|
|
24
22
|
actions << Kentaa::Api::Responses::Action.new(action)
|
25
23
|
end
|
26
24
|
end
|
@@ -1,13 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
4
6
|
class Address < Base
|
5
7
|
include Kentaa::Api::Responses::Resource
|
6
8
|
|
7
|
-
def initialize(response)
|
8
|
-
super(response)
|
9
|
-
end
|
10
|
-
|
11
9
|
def address
|
12
10
|
data[:address]
|
13
11
|
end
|
@@ -16,6 +14,18 @@ module Kentaa
|
|
16
14
|
data[:address2]
|
17
15
|
end
|
18
16
|
|
17
|
+
def street
|
18
|
+
data[:street]
|
19
|
+
end
|
20
|
+
|
21
|
+
def house_number
|
22
|
+
data[:house_number]
|
23
|
+
end
|
24
|
+
|
25
|
+
def house_number_addition
|
26
|
+
data[:house_number_addition]
|
27
|
+
end
|
28
|
+
|
19
29
|
def zipcode
|
20
30
|
data[:zipcode]
|
21
31
|
end
|
@@ -1,19 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
1
5
|
module Kentaa
|
2
6
|
module Api
|
3
7
|
module Responses
|
4
8
|
class Base
|
5
9
|
attr_reader :data
|
6
10
|
|
7
|
-
def initialize(
|
8
|
-
|
9
|
-
|
11
|
+
def initialize(response)
|
12
|
+
if response.respond_to?(:body)
|
13
|
+
extend Kentaa::Api::Responses::Status
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
@response = response
|
16
|
+
@data = response.body[attribute_key]
|
17
|
+
else
|
18
|
+
@data = response
|
19
|
+
end
|
20
|
+
|
21
|
+
@data ||= {}
|
13
22
|
end
|
14
23
|
|
15
|
-
|
16
|
-
|
24
|
+
private
|
25
|
+
|
26
|
+
def attribute_key
|
27
|
+
class_name = self.class.name.split("::").last
|
28
|
+
class_name.gsub(/([^\^])([A-Z])/, '\1_\2').downcase.to_sym
|
17
29
|
end
|
18
30
|
end
|
19
31
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Responses
|
6
|
+
class Consent < Base
|
7
|
+
def url
|
8
|
+
data[:url]
|
9
|
+
end
|
10
|
+
|
11
|
+
def text
|
12
|
+
data[:text]
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
data[:version]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bigdecimal'
|
2
4
|
require 'time'
|
3
5
|
|
@@ -7,10 +9,6 @@ module Kentaa
|
|
7
9
|
class Donation < Base
|
8
10
|
include Kentaa::Api::Responses::Resource
|
9
11
|
|
10
|
-
def initialize(response)
|
11
|
-
super(response[:donation] || response)
|
12
|
-
end
|
13
|
-
|
14
12
|
def segment_id
|
15
13
|
data[:segment_id]
|
16
14
|
end
|
@@ -47,6 +45,10 @@ module Kentaa
|
|
47
45
|
data[:company]
|
48
46
|
end
|
49
47
|
|
48
|
+
def anonymous?
|
49
|
+
data[:anonymous]
|
50
|
+
end
|
51
|
+
|
50
52
|
def email
|
51
53
|
data[:email]
|
52
54
|
end
|
@@ -67,12 +69,16 @@ module Kentaa
|
|
67
69
|
data[:locale]
|
68
70
|
end
|
69
71
|
|
72
|
+
def currency
|
73
|
+
data[:currency]
|
74
|
+
end
|
75
|
+
|
70
76
|
def amount
|
71
|
-
BigDecimal
|
77
|
+
BigDecimal(data[:amount])
|
72
78
|
end
|
73
79
|
|
74
80
|
def transaction_costs
|
75
|
-
BigDecimal
|
81
|
+
BigDecimal(data[:transaction_costs]) if data[:transaction_costs]
|
76
82
|
end
|
77
83
|
|
78
84
|
def registration_fee?
|
@@ -80,11 +86,15 @@ module Kentaa
|
|
80
86
|
end
|
81
87
|
|
82
88
|
def registration_fee_amount
|
83
|
-
BigDecimal
|
89
|
+
BigDecimal(data[:registration_fee_amount]) if data[:registration_fee_amount]
|
84
90
|
end
|
85
91
|
|
86
92
|
def total_amount
|
87
|
-
BigDecimal
|
93
|
+
BigDecimal(data[:total_amount])
|
94
|
+
end
|
95
|
+
|
96
|
+
def countable?
|
97
|
+
data[:countable]
|
88
98
|
end
|
89
99
|
|
90
100
|
def invoicenumber
|
@@ -111,6 +121,10 @@ module Kentaa
|
|
111
121
|
data[:payment_id]
|
112
122
|
end
|
113
123
|
|
124
|
+
def payment_description
|
125
|
+
data[:payment_description]
|
126
|
+
end
|
127
|
+
|
114
128
|
def target_url
|
115
129
|
data[:target_url]
|
116
130
|
end
|
@@ -136,6 +150,22 @@ module Kentaa
|
|
136
150
|
def address
|
137
151
|
@address ||= Kentaa::Api::Responses::Address.new(data[:address]) if data[:address]
|
138
152
|
end
|
153
|
+
|
154
|
+
def birthday
|
155
|
+
Time.parse(data[:birthday]) if data[:birthday]
|
156
|
+
end
|
157
|
+
|
158
|
+
def gender
|
159
|
+
data[:gender]
|
160
|
+
end
|
161
|
+
|
162
|
+
def phone
|
163
|
+
data[:phone]
|
164
|
+
end
|
165
|
+
|
166
|
+
def consent
|
167
|
+
@consent ||= Kentaa::Api::Responses::Consent.new(data[:consent]) if data[:consent]
|
168
|
+
end
|
139
169
|
end
|
140
170
|
end
|
141
171
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
@@ -5,10 +7,6 @@ module Kentaa
|
|
5
7
|
include Enumerable
|
6
8
|
include Kentaa::Api::Responses::Pagination
|
7
9
|
|
8
|
-
def initialize(response)
|
9
|
-
super(response)
|
10
|
-
end
|
11
|
-
|
12
10
|
def each(&block)
|
13
11
|
donations.each(&block)
|
14
12
|
end
|
@@ -19,8 +17,8 @@ module Kentaa
|
|
19
17
|
@donations ||= begin
|
20
18
|
donations = []
|
21
19
|
|
22
|
-
if data
|
23
|
-
data
|
20
|
+
if data
|
21
|
+
data.each do |donation|
|
24
22
|
donations << Kentaa::Api::Responses::Donation.new(donation)
|
25
23
|
end
|
26
24
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Responses
|
6
|
+
class Location < Base
|
7
|
+
def zip_code
|
8
|
+
data[:zip_code]
|
9
|
+
end
|
10
|
+
|
11
|
+
def street
|
12
|
+
data[:street]
|
13
|
+
end
|
14
|
+
|
15
|
+
def city
|
16
|
+
data[:city]
|
17
|
+
end
|
18
|
+
|
19
|
+
def latitude
|
20
|
+
data[:latitude]
|
21
|
+
end
|
22
|
+
|
23
|
+
def longitude
|
24
|
+
data[:longitude]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,11 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
4
6
|
class NewsletterSubscription < Base
|
5
7
|
include Kentaa::Api::Responses::Resource
|
6
8
|
|
7
|
-
def
|
8
|
-
|
9
|
+
def first_name
|
10
|
+
data[:first_name]
|
11
|
+
end
|
12
|
+
|
13
|
+
def infix
|
14
|
+
data[:infix]
|
15
|
+
end
|
16
|
+
|
17
|
+
def last_name
|
18
|
+
data[:last_name]
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
[first_name, infix, last_name].compact.join(" ")
|
9
23
|
end
|
10
24
|
|
11
25
|
def segment_id
|
@@ -27,6 +41,10 @@ module Kentaa
|
|
27
41
|
def subscription_url
|
28
42
|
data[:subscription_url]
|
29
43
|
end
|
44
|
+
|
45
|
+
def consent
|
46
|
+
@consent ||= Kentaa::Api::Responses::Consent.new(data[:consent]) if data[:consent]
|
47
|
+
end
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
@@ -5,10 +7,6 @@ module Kentaa
|
|
5
7
|
include Enumerable
|
6
8
|
include Kentaa::Api::Responses::Pagination
|
7
9
|
|
8
|
-
def initialize(response)
|
9
|
-
super(response)
|
10
|
-
end
|
11
|
-
|
12
10
|
def each(&block)
|
13
11
|
newsletter_subscriptions.each(&block)
|
14
12
|
end
|
@@ -19,8 +17,8 @@ module Kentaa
|
|
19
17
|
@newsletter_subscriptions ||= begin
|
20
18
|
newsletter_subscriptions = []
|
21
19
|
|
22
|
-
if data
|
23
|
-
data
|
20
|
+
if data
|
21
|
+
data.each do |newsletter_subscription|
|
24
22
|
newsletter_subscriptions << Kentaa::Api::Responses::NewsletterSubscription.new(newsletter_subscription)
|
25
23
|
end
|
26
24
|
end
|
@@ -1,9 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
4
6
|
module Pagination
|
7
|
+
attr_accessor :body
|
8
|
+
|
5
9
|
def links
|
6
|
-
|
10
|
+
body[:links]
|
7
11
|
end
|
8
12
|
|
9
13
|
def pages
|
@@ -11,19 +15,19 @@ module Kentaa
|
|
11
15
|
end
|
12
16
|
|
13
17
|
def total_entries
|
14
|
-
|
18
|
+
body[:total_entries]
|
15
19
|
end
|
16
20
|
|
17
21
|
def total_pages
|
18
|
-
|
22
|
+
body[:total_pages]
|
19
23
|
end
|
20
24
|
|
21
25
|
def per_page
|
22
|
-
|
26
|
+
body[:per_page]
|
23
27
|
end
|
24
28
|
|
25
29
|
def current_page
|
26
|
-
|
30
|
+
body[:current_page]
|
27
31
|
end
|
28
32
|
|
29
33
|
def next_page
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bigdecimal'
|
2
4
|
require 'time'
|
3
5
|
|
@@ -7,10 +9,6 @@ module Kentaa
|
|
7
9
|
class Project < Base
|
8
10
|
include Kentaa::Api::Responses::Resource
|
9
11
|
|
10
|
-
def initialize(response)
|
11
|
-
super(response[:project] || response)
|
12
|
-
end
|
13
|
-
|
14
12
|
def slug
|
15
13
|
data[:slug]
|
16
14
|
end
|
@@ -32,17 +30,33 @@ module Kentaa
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def total_amount
|
35
|
-
BigDecimal
|
33
|
+
BigDecimal(data[:total_amount])
|
36
34
|
end
|
37
35
|
|
38
36
|
def total_donations
|
39
37
|
data[:total_donations]
|
40
38
|
end
|
41
39
|
|
40
|
+
def target_amount_achieved?
|
41
|
+
data[:target_amount_achieved]
|
42
|
+
end
|
43
|
+
|
42
44
|
def visible?
|
43
45
|
data[:visible]
|
44
46
|
end
|
45
47
|
|
48
|
+
def countable?
|
49
|
+
data[:countable]
|
50
|
+
end
|
51
|
+
|
52
|
+
def closed?
|
53
|
+
data[:closed]
|
54
|
+
end
|
55
|
+
|
56
|
+
def ended?
|
57
|
+
data[:ended]
|
58
|
+
end
|
59
|
+
|
46
60
|
def end_date
|
47
61
|
Time.parse(data[:end_date]) if data[:end_date]
|
48
62
|
end
|
@@ -55,6 +69,10 @@ module Kentaa
|
|
55
69
|
data[:donate_url]
|
56
70
|
end
|
57
71
|
|
72
|
+
def location
|
73
|
+
@location ||= Kentaa::Api::Responses::Location.new(data[:location])
|
74
|
+
end
|
75
|
+
|
58
76
|
def photos
|
59
77
|
@photos ||= begin
|
60
78
|
photos = []
|
@@ -96,6 +114,14 @@ module Kentaa
|
|
96
114
|
questions
|
97
115
|
end
|
98
116
|
end
|
117
|
+
|
118
|
+
def consent
|
119
|
+
@consent ||= Kentaa::Api::Responses::Consent.new(data[:consent]) if data[:consent]
|
120
|
+
end
|
121
|
+
|
122
|
+
def external_reference
|
123
|
+
data[:external_reference]
|
124
|
+
end
|
99
125
|
end
|
100
126
|
end
|
101
127
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
@@ -5,10 +7,6 @@ module Kentaa
|
|
5
7
|
include Enumerable
|
6
8
|
include Kentaa::Api::Responses::Pagination
|
7
9
|
|
8
|
-
def initialize(response)
|
9
|
-
super(response)
|
10
|
-
end
|
11
|
-
|
12
10
|
def each(&block)
|
13
11
|
projects.each(&block)
|
14
12
|
end
|
@@ -19,8 +17,8 @@ module Kentaa
|
|
19
17
|
@projects ||= begin
|
20
18
|
projects = []
|
21
19
|
|
22
|
-
if data
|
23
|
-
data
|
20
|
+
if data
|
21
|
+
data.each do |project|
|
24
22
|
projects << Kentaa::Api::Responses::Project.new(project)
|
25
23
|
end
|
26
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bigdecimal'
|
2
4
|
require 'time'
|
3
5
|
|
@@ -7,10 +9,6 @@ module Kentaa
|
|
7
9
|
class Segment < Base
|
8
10
|
include Kentaa::Api::Responses::Resource
|
9
11
|
|
10
|
-
def initialize(response)
|
11
|
-
super(response[:segment] || response)
|
12
|
-
end
|
13
|
-
|
14
12
|
def subdomain
|
15
13
|
data[:subdomain]
|
16
14
|
end
|
@@ -32,7 +30,7 @@ module Kentaa
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def total_amount
|
35
|
-
BigDecimal
|
33
|
+
BigDecimal(data[:total_amount])
|
36
34
|
end
|
37
35
|
|
38
36
|
def total_donations
|
@@ -64,6 +62,10 @@ module Kentaa
|
|
64
62
|
banners
|
65
63
|
end
|
66
64
|
end
|
65
|
+
|
66
|
+
def external_reference
|
67
|
+
data[:external_reference]
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kentaa
|
2
4
|
module Api
|
3
5
|
module Responses
|
@@ -5,10 +7,6 @@ module Kentaa
|
|
5
7
|
include Enumerable
|
6
8
|
include Kentaa::Api::Responses::Pagination
|
7
9
|
|
8
|
-
def initialize(response)
|
9
|
-
super(response)
|
10
|
-
end
|
11
|
-
|
12
10
|
def each(&block)
|
13
11
|
segments.each(&block)
|
14
12
|
end
|
@@ -19,8 +17,8 @@ module Kentaa
|
|
19
17
|
@segments ||= begin
|
20
18
|
segments = []
|
21
19
|
|
22
|
-
if data
|
23
|
-
data
|
20
|
+
if data
|
21
|
+
data.each do |segment|
|
24
22
|
segments << Kentaa::Api::Responses::Segment.new(segment)
|
25
23
|
end
|
26
24
|
end
|