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.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +18 -1
  4. data/.travis.yml +7 -3
  5. data/Gemfile +4 -1
  6. data/Gemfile.lock +66 -0
  7. data/README.md +15 -0
  8. data/Rakefile +2 -0
  9. data/bin/console +1 -0
  10. data/kentaa-api.gemspec +2 -2
  11. data/lib/kentaa/api/client.rb +14 -8
  12. data/lib/kentaa/api/{http.rb → request.rb} +9 -10
  13. data/lib/kentaa/api/requests/actions.rb +4 -2
  14. data/lib/kentaa/api/requests/all.rb +3 -1
  15. data/lib/kentaa/api/requests/base.rb +5 -3
  16. data/lib/kentaa/api/requests/donations.rb +4 -2
  17. data/lib/kentaa/api/requests/newsletter_subscriptions.rb +8 -1
  18. data/lib/kentaa/api/requests/projects.rb +4 -2
  19. data/lib/kentaa/api/requests/segments.rb +4 -2
  20. data/lib/kentaa/api/requests/sites.rb +3 -1
  21. data/lib/kentaa/api/requests/teams.rb +4 -2
  22. data/lib/kentaa/api/requests/users.rb +21 -0
  23. data/lib/kentaa/api/response.rb +30 -0
  24. data/lib/kentaa/api/responses/action.rb +72 -6
  25. data/lib/kentaa/api/responses/actions.rb +4 -6
  26. data/lib/kentaa/api/responses/activity.rb +15 -0
  27. data/lib/kentaa/api/responses/address.rb +14 -4
  28. data/lib/kentaa/api/responses/banner.rb +2 -4
  29. data/lib/kentaa/api/responses/base.rb +19 -7
  30. data/lib/kentaa/api/responses/consent.rb +21 -0
  31. data/lib/kentaa/api/responses/donation.rb +38 -8
  32. data/lib/kentaa/api/responses/donations.rb +4 -6
  33. data/lib/kentaa/api/responses/location.rb +29 -0
  34. data/lib/kentaa/api/responses/newsletter_subscription.rb +20 -2
  35. data/lib/kentaa/api/responses/newsletter_subscriptions.rb +4 -6
  36. data/lib/kentaa/api/responses/pagination.rb +9 -5
  37. data/lib/kentaa/api/responses/photo.rb +2 -4
  38. data/lib/kentaa/api/responses/project.rb +31 -5
  39. data/lib/kentaa/api/responses/projects.rb +4 -6
  40. data/lib/kentaa/api/responses/question.rb +2 -4
  41. data/lib/kentaa/api/responses/registration_fee.rb +17 -0
  42. data/lib/kentaa/api/responses/resource.rb +2 -0
  43. data/lib/kentaa/api/responses/reward.rb +2 -4
  44. data/lib/kentaa/api/responses/segment.rb +7 -5
  45. data/lib/kentaa/api/responses/segments.rb +4 -6
  46. data/lib/kentaa/api/responses/site.rb +11 -5
  47. data/lib/kentaa/api/responses/status.rb +27 -0
  48. data/lib/kentaa/api/responses/team.rb +24 -6
  49. data/lib/kentaa/api/responses/teams.rb +4 -6
  50. data/lib/kentaa/api/responses/user.rb +89 -0
  51. data/lib/kentaa/api/responses/users.rb +32 -0
  52. data/lib/kentaa/api/responses/video.rb +2 -4
  53. data/lib/kentaa/api/version.rb +3 -1
  54. data/lib/kentaa/api.rb +12 -2
  55. metadata +15 -6
  56. data/lib/kentaa/api/responses/owner.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b6fdaf28cb966314b02ab13f42c9c228a1ffedc3
4
- data.tar.gz: 55b33406270da3c4d00cf7bcfb5c128b7101af92
2
+ SHA256:
3
+ metadata.gz: 5c9f7ea46e68c4af626c227e7ef2bd787d181d487661f60a89c43f5ab7c3d9ac
4
+ data.tar.gz: dd3725827a82aa19ad4dfa6858e9a9d47b945a33cd8791410f2d2ce57d0c8e29
5
5
  SHA512:
6
- metadata.gz: 6065be812cc0caa5758d9e4afbcbc1fc4ceda6f7bbba77225ffd5274a71a7e33c5d4d15973e04692e08664cd367027894e60c7b1dc493db98b07e46516765594
7
- data.tar.gz: e0f51e23b4eb13700cedabebfa70ae3e99733340b3dc3ebd088bb164d1e356c6afc15ae20e05933bfea59351f0dc96ba0e3d2234d46f1879488cd8f7870858cf
6
+ metadata.gz: 4e03bd106dfab27111bdcb5ef44019b6cd7872254b22c27d91e35ba849b110c3e866a3f22ac6d9e72a7825ed8cef3f7898cfaf7691ac7f3d085a83a9dea4d4d7
7
+ data.tar.gz: be757c6cc5dd388820d05c400cdf2f59e593c82921b4c71374250ca490118315a4fbe4636bc63217fc4ebf2bbd6492c86efb298fd1d71c047c3b1fe49aaa953b
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/.rubocop.yml CHANGED
@@ -1,26 +1,43 @@
1
1
  # Kentaa-API RuboCop configuration
2
2
 
3
+ require: rubocop-rspec
4
+
3
5
  AllCops:
4
6
  TargetRubyVersion: 2.3
5
7
  DisplayCopNames: true
6
8
  DisplayStyleGuide: true
7
9
 
10
+ Gemspec/RequiredRubyVersion:
11
+ Enabled: false
12
+
8
13
  Metrics/AbcSize:
9
14
  Enabled: false
10
15
 
11
16
  Metrics/BlockLength:
12
17
  Enabled: false
13
18
 
19
+ Metrics/ClassLength:
20
+ Enabled: false
21
+
14
22
  Metrics/LineLength:
15
23
  Enabled: false
16
24
 
17
25
  Metrics/MethodLength:
18
26
  Enabled: false
19
27
 
28
+ RSpec/DescribedClass:
29
+ Enabled: false
30
+
31
+ RSpec/ExampleLength:
32
+ Enabled: false
33
+
34
+ RSpec/MultipleExpectations:
35
+ Enabled: false
36
+
20
37
  Style/Documentation:
21
38
  Enabled: false
22
39
 
23
- Style/FrozenStringLiteralComment:
40
+ Style/ExpandPathArguments:
24
41
  Enabled: false
25
42
 
26
43
  Style/SafeNavigation:
data/.travis.yml CHANGED
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
+ before_install:
5
+ - gem update --system
6
+ - gem update bundler
4
7
  rvm:
5
- - 2.2.7
6
- - 2.3.4
7
- - 2.4.1
8
+ - 2.3.8
9
+ - 2.4.6
10
+ - 2.5.5
11
+ - 2.6.3
data/Gemfile CHANGED
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in kentaa-api.gemspec
4
6
  gemspec
5
7
 
6
- gem 'rubocop', '~> 0.48.1'
8
+ gem 'rubocop', '~> 0.72.0'
9
+ gem 'rubocop-rspec', '~> 1.33.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kentaa-api (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.5.2)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ ast (2.4.0)
12
+ crack (0.4.3)
13
+ safe_yaml (~> 1.0.0)
14
+ diff-lcs (1.3)
15
+ hashdiff (0.3.7)
16
+ jaro_winkler (1.5.3)
17
+ parallel (1.17.0)
18
+ parser (2.6.3.0)
19
+ ast (~> 2.4.0)
20
+ public_suffix (3.0.3)
21
+ rainbow (3.0.0)
22
+ rake (10.5.0)
23
+ rspec (3.8.0)
24
+ rspec-core (~> 3.8.0)
25
+ rspec-expectations (~> 3.8.0)
26
+ rspec-mocks (~> 3.8.0)
27
+ rspec-core (3.8.0)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-expectations (3.8.2)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-mocks (3.8.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-support (3.8.0)
36
+ rubocop (0.72.0)
37
+ jaro_winkler (~> 1.5.1)
38
+ parallel (~> 1.10)
39
+ parser (>= 2.6)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 1.4.0, < 1.7)
43
+ rubocop-rspec (1.33.0)
44
+ rubocop (>= 0.60.0)
45
+ ruby-progressbar (1.10.1)
46
+ safe_yaml (1.0.4)
47
+ unicode-display_width (1.6.0)
48
+ webmock (2.3.2)
49
+ addressable (>= 2.3.6)
50
+ crack (>= 0.3.2)
51
+ hashdiff
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ bundler (~> 1.14)
58
+ kentaa-api!
59
+ rake (~> 10.0)
60
+ rspec (~> 3.0)
61
+ rubocop (~> 0.72.0)
62
+ rubocop-rspec (~> 1.33.0)
63
+ webmock (~> 2.3, >= 2.3.2)
64
+
65
+ BUNDLED WITH
66
+ 1.17.1
data/README.md CHANGED
@@ -96,6 +96,9 @@ See also the [Kentaa API documention](https://api.kentaa.nl/v1/doc/donations).
96
96
  ```ruby
97
97
  newsletter_subscriptions = client.newsletter_subscriptions.all # get newsletter subscriptions (paginated)
98
98
  newsletter_subscriptions = client.newsletter_subscriptions.list # get all newsletter subscriptions (non-paginated)
99
+
100
+
101
+ newsletter_subscriptions = client.newsletter_subscriptions.get(1) # query newsletter subscription by ID
99
102
  ```
100
103
 
101
104
  See also the [Kentaa API documention](https://api.kentaa.nl/v1/doc/newsletter-subscriptions).
@@ -146,6 +149,18 @@ team = client.teams.get("team") # query team by slug
146
149
  See also the [Kentaa API documention](https://api.kentaa.nl/v1/doc/teams).
147
150
 
148
151
 
152
+ #### Users
153
+
154
+ ```ruby
155
+ users = client.users.list # get users (paginated)
156
+ users = client.users.all # get all users (non-paginated)
157
+
158
+ user = client.users.get(1) # query user by ID
159
+ ```
160
+
161
+ See also the [Kentaa API documention](https://api.kentaa.nl/v1/doc/users).
162
+
163
+
149
164
  ## Development
150
165
 
151
166
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
  require "rubocop/rake_task"
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "kentaa/api"
data/kentaa-api.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  lib = File.expand_path('../lib', __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["support@kentaa.nl"]
12
12
 
13
13
  spec.summary = "Ruby library for communicating with the Kentaa API"
14
- spec.homepage = "https://www.kentaa.nl"
14
+ spec.homepage = "https://github.com/KentaaNL/kentaa-api"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -1,36 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  class Client
4
6
  def initialize(api_key, options = {})
5
- @http = Kentaa::Api::Http.new(api_key, options)
7
+ @request = Kentaa::Api::Request.new(api_key, options)
6
8
  end
7
9
 
8
10
  def actions
9
- Kentaa::Api::Requests::Actions.new(@http)
11
+ Kentaa::Api::Requests::Actions.new(@request)
10
12
  end
11
13
 
12
14
  def donations
13
- Kentaa::Api::Requests::Donations.new(@http)
15
+ Kentaa::Api::Requests::Donations.new(@request)
14
16
  end
15
17
 
16
18
  def newsletter_subscriptions
17
- Kentaa::Api::Requests::NewsletterSubscriptions.new(@http)
19
+ Kentaa::Api::Requests::NewsletterSubscriptions.new(@request)
18
20
  end
19
21
 
20
22
  def projects
21
- Kentaa::Api::Requests::Projects.new(@http)
23
+ Kentaa::Api::Requests::Projects.new(@request)
22
24
  end
23
25
 
24
26
  def segments
25
- Kentaa::Api::Requests::Segments.new(@http)
27
+ Kentaa::Api::Requests::Segments.new(@request)
26
28
  end
27
29
 
28
30
  def sites
29
- Kentaa::Api::Requests::Sites.new(@http)
31
+ Kentaa::Api::Requests::Sites.new(@request)
30
32
  end
31
33
 
32
34
  def teams
33
- Kentaa::Api::Requests::Teams.new(@http)
35
+ Kentaa::Api::Requests::Teams.new(@request)
36
+ end
37
+
38
+ def users
39
+ Kentaa::Api::Requests::Users.new(@request)
34
40
  end
35
41
  end
36
42
  end
@@ -1,12 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
  require 'net/http'
3
5
  require 'uri'
4
6
 
5
7
  module Kentaa
6
8
  module Api
7
- class Http
8
- LIVE_URL = "https://api.kentaa.nl/v1/".freeze
9
- TEST_URL = "https://api.kentaa.staatklaar.nu/v1/".freeze
9
+ class Request
10
+ LIVE_URL = "https://api.kentaa.nl/v1/"
11
+ TEST_URL = "https://api.kentaa.staatklaar.nu/v1/"
12
+ DEV_URL = "http://api.lvh.me:3000/v1"
10
13
 
11
14
  def initialize(api_key, options = {})
12
15
  @api_key = api_key
@@ -24,13 +27,7 @@ module Kentaa
24
27
  http.request(request)
25
28
  end
26
29
 
27
- begin
28
- JSON.parse(response.body, symbolize_names: true)
29
- rescue JSON::ParserError => ex
30
- {
31
- message: "Unable to parse JSON: #{ex.message}"
32
- }
33
- end
30
+ Kentaa::Api::Response.new(response)
34
31
  end
35
32
 
36
33
  private
@@ -38,6 +35,8 @@ module Kentaa
38
35
  def api_url
39
36
  if @options[:test]
40
37
  TEST_URL
38
+ elsif @options[:dev]
39
+ DEV_URL
41
40
  else
42
41
  LIVE_URL
43
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -5,12 +7,12 @@ module Kentaa
5
7
  include Kentaa::Api::Requests::All
6
8
 
7
9
  def list(options = {})
8
- response = http.get("/actions", options)
10
+ response = request.get("/actions", options)
9
11
  Kentaa::Api::Responses::Actions.new(response)
10
12
  end
11
13
 
12
14
  def get(id)
13
- response = http.get("/actions/#{id}")
15
+ response = request.get("/actions/#{id}")
14
16
  Kentaa::Api::Responses::Action.new(response)
15
17
  end
16
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -8,7 +10,7 @@ module Kentaa
8
10
 
9
11
  loop do
10
12
  response = list(options.merge(page: page))
11
- response.each { |item| yielder.yield item } unless response.error?
13
+ response.each { |item| yielder.yield item } if response.success?
12
14
 
13
15
  raise StopIteration unless response.next_page?
14
16
 
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
4
6
  class Base
5
- attr_reader :http
7
+ attr_reader :request
6
8
 
7
- def initialize(http)
8
- @http = http
9
+ def initialize(request)
10
+ @request = request
9
11
  end
10
12
  end
11
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -5,12 +7,12 @@ module Kentaa
5
7
  include Kentaa::Api::Requests::All
6
8
 
7
9
  def list(options = {})
8
- response = http.get("/donations", options)
10
+ response = request.get("/donations", options)
9
11
  Kentaa::Api::Responses::Donations.new(response)
10
12
  end
11
13
 
12
14
  def get(id)
13
- response = http.get("/donations/#{id}")
15
+ response = request.get("/donations/#{id}")
14
16
  Kentaa::Api::Responses::Donation.new(response)
15
17
  end
16
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -5,9 +7,14 @@ module Kentaa
5
7
  include Kentaa::Api::Requests::All
6
8
 
7
9
  def list(options = {})
8
- response = http.get("/newsletter-subscriptions", options)
10
+ response = request.get("/newsletter-subscriptions", options)
9
11
  Kentaa::Api::Responses::NewsletterSubscriptions.new(response)
10
12
  end
13
+
14
+ def get(id)
15
+ response = request.get("/newsletter-subscriptions/#{id}")
16
+ Kentaa::Api::Responses::NewsletterSubscription.new(response)
17
+ end
11
18
  end
12
19
  end
13
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -5,12 +7,12 @@ module Kentaa
5
7
  include Kentaa::Api::Requests::All
6
8
 
7
9
  def list(options = {})
8
- response = http.get("/projects", options)
10
+ response = request.get("/projects", options)
9
11
  Kentaa::Api::Responses::Projects.new(response)
10
12
  end
11
13
 
12
14
  def get(id)
13
- response = http.get("/projects/#{id}")
15
+ response = request.get("/projects/#{id}")
14
16
  Kentaa::Api::Responses::Project.new(response)
15
17
  end
16
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -5,12 +7,12 @@ module Kentaa
5
7
  include Kentaa::Api::Requests::All
6
8
 
7
9
  def list(options = {})
8
- response = http.get("/segments", options)
10
+ response = request.get("/segments", options)
9
11
  Kentaa::Api::Responses::Segments.new(response)
10
12
  end
11
13
 
12
14
  def get(id)
13
- response = http.get("/segments/#{id}")
15
+ response = request.get("/segments/#{id}")
14
16
  Kentaa::Api::Responses::Segment.new(response)
15
17
  end
16
18
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
4
6
  class Sites < Base
5
7
  def current
6
- response = http.get("/sites/current")
8
+ response = request.get("/sites/current")
7
9
  Kentaa::Api::Responses::Site.new(response)
8
10
  end
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
5
  module Requests
@@ -5,12 +7,12 @@ module Kentaa
5
7
  include Kentaa::Api::Requests::All
6
8
 
7
9
  def list(options = {})
8
- response = http.get("/teams", options)
10
+ response = request.get("/teams", options)
9
11
  Kentaa::Api::Responses::Teams.new(response)
10
12
  end
11
13
 
12
14
  def get(id)
13
- response = http.get("/teams/#{id}")
15
+ response = request.get("/teams/#{id}")
14
16
  Kentaa::Api::Responses::Team.new(response)
15
17
  end
16
18
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Requests
6
+ class Users < Base
7
+ include Kentaa::Api::Requests::All
8
+
9
+ def list(options = {})
10
+ response = request.get("/users", options)
11
+ Kentaa::Api::Responses::Users.new(response)
12
+ end
13
+
14
+ def get(id)
15
+ response = request.get("/users/#{id}")
16
+ Kentaa::Api::Responses::User.new(response)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Kentaa
6
+ module Api
7
+ class Response
8
+ attr_reader :response, :body
9
+
10
+ def initialize(response)
11
+ @response = response
12
+ @body = parse_body(response.body)
13
+ end
14
+
15
+ def code
16
+ response.code.to_i
17
+ end
18
+
19
+ private
20
+
21
+ def parse_body(body)
22
+ JSON.parse(body, symbolize_names: true)
23
+ rescue JSON::ParserError => e
24
+ {
25
+ message: "Unable to parse JSON: #{e.message}"
26
+ }
27
+ end
28
+ end
29
+ end
30
+ 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 Action < Base
8
10
  include Kentaa::Api::Responses::Resource
9
11
 
10
- def initialize(response)
11
- super(response[:action] || response)
12
- end
13
-
14
12
  def slug
15
13
  data[:slug]
16
14
  end
@@ -28,7 +26,35 @@ module Kentaa
28
26
  end
29
27
 
30
28
  def owner
31
- @owner ||= Kentaa::Api::Responses::Owner.new(data[:owner])
29
+ @owner ||= Kentaa::Api::Responses::User.new(data[:owner])
30
+ end
31
+
32
+ def team_captain?
33
+ data[:team_captain]
34
+ end
35
+
36
+ def first_name
37
+ data[:first_name]
38
+ end
39
+
40
+ def infix
41
+ data[:infix]
42
+ end
43
+
44
+ def last_name
45
+ data[:last_name]
46
+ end
47
+
48
+ def avatar_url
49
+ data[:avatar_url]
50
+ end
51
+
52
+ def name
53
+ [first_name, infix, last_name].compact.join(" ")
54
+ end
55
+
56
+ def fundraiser_page?
57
+ data[:fundraiser_page]
32
58
  end
33
59
 
34
60
  def title
@@ -44,21 +70,45 @@ module Kentaa
44
70
  end
45
71
 
46
72
  def total_amount
47
- BigDecimal.new(data[:total_amount])
73
+ BigDecimal(data[:total_amount])
48
74
  end
49
75
 
50
76
  def total_donations
51
77
  data[:total_donations]
52
78
  end
53
79
 
80
+ def target_amount_achieved?
81
+ data[:target_amount_achieved]
82
+ end
83
+
54
84
  def visible?
55
85
  data[:visible]
56
86
  end
57
87
 
88
+ def countable?
89
+ data[:countable]
90
+ end
91
+
92
+ def closed?
93
+ data[:closed]
94
+ end
95
+
96
+ def ended?
97
+ data[:ended]
98
+ end
99
+
58
100
  def end_date
59
101
  Time.parse(data[:end_date]) if data[:end_date]
60
102
  end
61
103
 
104
+ def activity
105
+ @activity ||= Kentaa::Api::Responses::Activity.new(data[:activity])
106
+ end
107
+
108
+ def previous_participations
109
+ data[:previous_participations]
110
+ end
111
+
62
112
  def url
63
113
  data[:url]
64
114
  end
@@ -67,6 +117,14 @@ module Kentaa
67
117
  data[:donate_url]
68
118
  end
69
119
 
120
+ def registration_fee
121
+ @registration_fee ||= Kentaa::Api::Responses::RegistrationFee.new(data[:registration_fee])
122
+ end
123
+
124
+ def location
125
+ @location ||= Kentaa::Api::Responses::Location.new(data[:location])
126
+ end
127
+
70
128
  def photos
71
129
  @photos ||= begin
72
130
  photos = []
@@ -108,6 +166,14 @@ module Kentaa
108
166
  questions
109
167
  end
110
168
  end
169
+
170
+ def consent
171
+ @consent ||= Kentaa::Api::Responses::Consent.new(data[:consent]) if data[:consent]
172
+ end
173
+
174
+ def external_reference
175
+ data[:external_reference]
176
+ end
111
177
  end
112
178
  end
113
179
  end