kentaa-api 0.2.0 → 0.4.0

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +14 -3
  4. data/.travis.yml +5 -4
  5. data/Gemfile +3 -2
  6. data/Gemfile.lock +19 -14
  7. data/README.md +12 -12
  8. data/kentaa-api.gemspec +2 -2
  9. data/lib/kentaa/api.rb +6 -4
  10. data/lib/kentaa/api/client.rb +4 -0
  11. data/lib/kentaa/api/clients/actions.rb +19 -6
  12. data/lib/kentaa/api/clients/base.rb +0 -4
  13. data/lib/kentaa/api/clients/donations.rb +9 -6
  14. data/lib/kentaa/api/clients/manual_donations.rb +39 -0
  15. data/lib/kentaa/api/clients/newsletter_subscriptions.rb +9 -6
  16. data/lib/kentaa/api/clients/projects.rb +9 -6
  17. data/lib/kentaa/api/clients/segments.rb +9 -6
  18. data/lib/kentaa/api/clients/sites.rb +3 -3
  19. data/lib/kentaa/api/clients/teams.rb +9 -6
  20. data/lib/kentaa/api/clients/users.rb +19 -6
  21. data/lib/kentaa/api/exception.rb +18 -0
  22. data/lib/kentaa/api/finder.rb +9 -0
  23. data/lib/kentaa/api/request.rb +46 -5
  24. data/lib/kentaa/api/resources/action.rb +36 -20
  25. data/lib/kentaa/api/resources/actions.rb +11 -3
  26. data/lib/kentaa/api/resources/activity.rb +10 -2
  27. data/lib/kentaa/api/resources/address.rb +6 -2
  28. data/lib/kentaa/api/resources/banner.rb +20 -2
  29. data/lib/kentaa/api/resources/base.rb +35 -11
  30. data/lib/kentaa/api/resources/consent.rb +7 -1
  31. data/lib/kentaa/api/resources/contact.rb +83 -0
  32. data/lib/kentaa/api/resources/donation.rb +25 -18
  33. data/lib/kentaa/api/resources/donations.rb +6 -3
  34. data/lib/kentaa/api/resources/error.rb +23 -0
  35. data/lib/kentaa/api/resources/{pagination.rb → list.rb} +26 -3
  36. data/lib/kentaa/api/resources/location.rb +7 -1
  37. data/lib/kentaa/api/resources/manual_donation.rb +112 -0
  38. data/lib/kentaa/api/resources/manual_donations.rb +40 -0
  39. data/lib/kentaa/api/resources/newsletter_subscription.rb +12 -11
  40. data/lib/kentaa/api/resources/newsletter_subscriptions.rb +6 -3
  41. data/lib/kentaa/api/resources/photo.rb +20 -2
  42. data/lib/kentaa/api/resources/project.rb +26 -12
  43. data/lib/kentaa/api/resources/projects.rb +6 -3
  44. data/lib/kentaa/api/resources/question.rb +10 -2
  45. data/lib/kentaa/api/resources/registration_fee.rb +1 -1
  46. data/lib/kentaa/api/resources/resource.rb +50 -3
  47. data/lib/kentaa/api/resources/reward.rb +10 -2
  48. data/lib/kentaa/api/resources/segment.rb +16 -4
  49. data/lib/kentaa/api/resources/segments.rb +6 -3
  50. data/lib/kentaa/api/resources/site.rb +16 -4
  51. data/lib/kentaa/api/resources/team.rb +23 -14
  52. data/lib/kentaa/api/resources/teams.rb +6 -3
  53. data/lib/kentaa/api/resources/user.rb +17 -5
  54. data/lib/kentaa/api/resources/users.rb +11 -3
  55. data/lib/kentaa/api/resources/video.rb +20 -2
  56. data/lib/kentaa/api/response.rb +21 -3
  57. data/lib/kentaa/api/version.rb +1 -1
  58. metadata +16 -14
  59. data/lib/kentaa/api/clients/all.rb +0 -26
  60. data/lib/kentaa/api/resources/status.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c62a6f7a4458cfe09d6ae1c9afc27460f05c58c8e23d59462a03ef2d59f16cc
4
- data.tar.gz: f9b555b9a83ae084ca35ca3690f7dd4c85119bcb4aa7984fee0e32ab9e9eadf9
3
+ metadata.gz: 4ebca7b73a3ae49b7d9948211b21638e7131340fe58f6b34551260853dd4b6fb
4
+ data.tar.gz: cc9a8b5450c1b4068867a2bf0eada220174e3d107ae2369ddbc5080bcf785257
5
5
  SHA512:
6
- metadata.gz: 0cdf39593639b4e11f13006bc602f084daa45c4fda1770c6a6b827d66bad3f587cafe82cb1f4cea7b8e3a76d4d4aa1afacc39d6fce9fb85c3434efaf69c27131
7
- data.tar.gz: c7b0cb509e5ab3215dbdddfb671e6127b3897470edc794e728ca32d21f436e2636afaad21b8d1256b6015b020d1b6af54d31f0ef80cad9622dcb09edb65635dd
6
+ metadata.gz: 2815897919718da19a9ed6ddb05589523b492639427fced920168bb469c794a83c5cc4477f9dc3403e7a932f6d88d657035a741f5cb3a44c075807b88b3ccf0f
7
+ data.tar.gz: 696d64f0bf684fafcbf1c38c24f3f1b03c97312f2c6b666054464b85b58b0907eb27e8a42bffd4e886d035475daaab8e22354af9a39ce9ea9a54943fbd225962
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.idea
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
@@ -6,6 +7,7 @@
6
7
  /pkg/
7
8
  /spec/reports/
8
9
  /tmp/
10
+ .rakeTasks
9
11
 
10
12
  # rspec failure tracking
11
13
  .rspec_status
@@ -1,13 +1,15 @@
1
1
  # Kentaa-API RuboCop configuration
2
2
 
3
- require: rubocop-rspec
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rspec
4
6
 
5
7
  AllCops:
6
8
  TargetRubyVersion: 2.3
7
9
  DisplayCopNames: true
8
10
  DisplayStyleGuide: true
9
11
 
10
- Gemspec/RequiredRubyVersion:
12
+ Layout/LineLength:
11
13
  Enabled: false
12
14
 
13
15
  Metrics/AbcSize:
@@ -19,7 +21,7 @@ Metrics/BlockLength:
19
21
  Metrics/ClassLength:
20
22
  Enabled: false
21
23
 
22
- Metrics/LineLength:
24
+ Metrics/CyclomaticComplexity:
23
25
  Enabled: false
24
26
 
25
27
  Metrics/MethodLength:
@@ -40,6 +42,15 @@ Style/Documentation:
40
42
  Style/ExpandPathArguments:
41
43
  Enabled: false
42
44
 
45
+ Style/HashEachMethods:
46
+ Enabled: true
47
+
48
+ Style/HashTransformKeys:
49
+ Enabled: true
50
+
51
+ Style/HashTransformValues:
52
+ Enabled: true
53
+
43
54
  Style/IfUnlessModifier:
44
55
  Enabled: false
45
56
 
@@ -3,9 +3,10 @@ sudo: false
3
3
  cache: bundler
4
4
  before_install:
5
5
  - gem update --system
6
- - gem update bundler
6
+ - gem install bundler -v '< 2'
7
7
  rvm:
8
8
  - 2.3.8
9
- - 2.4.6
10
- - 2.5.5
11
- - 2.6.3
9
+ - 2.4.9
10
+ - 2.5.7
11
+ - 2.6.5
12
+ - 2.7.0
data/Gemfile CHANGED
@@ -5,5 +5,6 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in kentaa-api.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rubocop', '~> 0.72.0'
9
- gem 'rubocop-rspec', '~> 1.33.0'
8
+ gem 'rubocop', '~> 0.80.1'
9
+ gem 'rubocop-performance', '~> 1.5.2'
10
+ gem 'rubocop-rspec', '~> 1.38.1'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kentaa-api (0.2.0)
4
+ kentaa-api (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -13,13 +13,14 @@ GEM
13
13
  safe_yaml (~> 1.0.0)
14
14
  diff-lcs (1.3)
15
15
  hashdiff (0.3.7)
16
- jaro_winkler (1.5.3)
17
- parallel (1.17.0)
18
- parser (2.6.3.0)
16
+ jaro_winkler (1.5.4)
17
+ parallel (1.19.1)
18
+ parser (2.7.0.4)
19
19
  ast (~> 2.4.0)
20
20
  public_suffix (3.0.3)
21
21
  rainbow (3.0.0)
22
- rake (10.5.0)
22
+ rake (12.3.3)
23
+ rexml (3.2.4)
23
24
  rspec (3.8.0)
24
25
  rspec-core (~> 3.8.0)
25
26
  rspec-expectations (~> 3.8.0)
@@ -33,18 +34,21 @@ GEM
33
34
  diff-lcs (>= 1.2.0, < 2.0)
34
35
  rspec-support (~> 3.8.0)
35
36
  rspec-support (3.8.0)
36
- rubocop (0.72.0)
37
+ rubocop (0.80.1)
37
38
  jaro_winkler (~> 1.5.1)
38
39
  parallel (~> 1.10)
39
- parser (>= 2.6)
40
+ parser (>= 2.7.0.1)
40
41
  rainbow (>= 2.2.2, < 4.0)
42
+ rexml
41
43
  ruby-progressbar (~> 1.7)
42
44
  unicode-display_width (>= 1.4.0, < 1.7)
43
- rubocop-rspec (1.33.0)
44
- rubocop (>= 0.60.0)
45
+ rubocop-performance (1.5.2)
46
+ rubocop (>= 0.71.0)
47
+ rubocop-rspec (1.38.1)
48
+ rubocop (>= 0.68.1)
45
49
  ruby-progressbar (1.10.1)
46
50
  safe_yaml (1.0.4)
47
- unicode-display_width (1.6.0)
51
+ unicode-display_width (1.6.1)
48
52
  webmock (2.3.2)
49
53
  addressable (>= 2.3.6)
50
54
  crack (>= 0.3.2)
@@ -56,11 +60,12 @@ PLATFORMS
56
60
  DEPENDENCIES
57
61
  bundler (~> 1.14)
58
62
  kentaa-api!
59
- rake (~> 10.0)
63
+ rake (~> 12.3)
60
64
  rspec (~> 3.0)
61
- rubocop (~> 0.72.0)
62
- rubocop-rspec (~> 1.33.0)
65
+ rubocop (~> 0.80.1)
66
+ rubocop-performance (~> 1.5.2)
67
+ rubocop-rspec (~> 1.38.1)
63
68
  webmock (~> 2.3, >= 2.3.2)
64
69
 
65
70
  BUNDLED WITH
66
- 1.17.1
71
+ 1.17.3
data/README.md CHANGED
@@ -37,7 +37,7 @@ client = Kentaa::Api::Client.new(config)
37
37
 
38
38
  ### Retrieving data
39
39
 
40
- All endpoints use the same convention for retrieving data. The methods `list` and `all` are used for retrieving multiple resources. The method `get` is used for retrieving a single resource.
40
+ All endpoints use the same convention for retrieving data. The method `list` is for retrieving multiple resources. The method `get` is used for retrieving a single resource.
41
41
 
42
42
  The `list` method on the endpoint returns an [Enumerable](https://ruby-doc.org/core/Enumerable.html) object:
43
43
 
@@ -51,10 +51,10 @@ actions.first
51
51
  The results might be part of a paginated set. You can query the next page by doing:
52
52
 
53
53
  ```ruby
54
- actions = client.actions.list(page: actions.next_page) if actions.next_page?
54
+ actions = actions.next if actions.next_page?
55
55
  ```
56
56
 
57
- See also `Kentaa::Api::Resources::Pagination` for the available methods for pagination.
57
+ See also `Kentaa::Api::Resources::List` for the available methods for pagination.
58
58
 
59
59
  The `all` method on the endpoint returns an [Enumerator](https://ruby-doc.org/core/Enumerator.html) and will iterate automatically through all pages to retrieve the requested data.
60
60
 
@@ -84,10 +84,10 @@ See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/actions).
84
84
  #### Donations
85
85
 
86
86
  ```ruby
87
- donations = client.donations.list # get donations (paginated)
88
- donations = client.donations.all # get all donations (non-paginated)
87
+ donations = client.donations.list # get donations (paginated)
88
+ donations = client.donations.all # get all donations (non-paginated)
89
89
 
90
- donation = client.donations.get(1) # query donation by ID
90
+ donation = client.donations.get(1) # query donation by ID
91
91
  ```
92
92
 
93
93
  See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/donations).
@@ -95,11 +95,11 @@ See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/donations).
95
95
  #### Newsletter subscriptions
96
96
 
97
97
  ```ruby
98
- newsletter_subscriptions = client.newsletter_subscriptions.all # get newsletter subscriptions (paginated)
99
- newsletter_subscriptions = client.newsletter_subscriptions.list # get all newsletter subscriptions (non-paginated)
98
+ newsletter_subscriptions = client.newsletter_subscriptions.list # get newsletter subscriptions (paginated)
99
+ newsletter_subscriptions = client.newsletter_subscriptions.all # get all newsletter subscriptions (non-paginated)
100
100
 
101
101
 
102
- newsletter_subscriptions = client.newsletter_subscriptions.get(1) # query newsletter subscription by ID
102
+ newsletter_subscriptions = client.newsletter_subscriptions.get(1) # query newsletter subscription by ID
103
103
  ```
104
104
 
105
105
  See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/newsletter-subscriptions).
@@ -119,10 +119,10 @@ See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/projects).
119
119
  #### Segments
120
120
 
121
121
  ```ruby
122
- segments = client.segments.list # get segments (paginated)
123
- segments = client.segments.all # get all segments (non-paginated)
122
+ segments = client.segments.list # get segments (paginated)
123
+ segments = client.segments.all # get all segments (non-paginated)
124
124
 
125
- segment = client.segments.get(1) # query segment by ID
125
+ segment = client.segments.get(1) # query segment by ID
126
126
  ```
127
127
 
128
128
  See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/segments).
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.required_ruby_version = ">= 2.0.0"
24
+ spec.required_ruby_version = ">= 2.3.0"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.14"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake", "~> 12.3"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
  spec.add_development_dependency "webmock", "~> 2.3", ">= 2.3.2"
30
30
  end
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "api/clients/base"
4
- require_relative "api/clients/all"
5
-
6
4
  require_relative "api/clients/actions"
7
5
  require_relative "api/clients/donations"
6
+ require_relative "api/clients/manual_donations"
8
7
  require_relative "api/clients/newsletter_subscriptions"
9
8
  require_relative "api/clients/projects"
10
9
  require_relative "api/clients/segments"
@@ -13,9 +12,9 @@ require_relative "api/clients/teams"
13
12
  require_relative "api/clients/users"
14
13
 
15
14
  require_relative "api/resources/base"
16
- require_relative "api/resources/pagination"
15
+ require_relative "api/resources/error"
16
+ require_relative "api/resources/list"
17
17
  require_relative "api/resources/resource"
18
- require_relative "api/resources/status"
19
18
 
20
19
  require_relative "api/resources/action"
21
20
  require_relative "api/resources/actions"
@@ -23,9 +22,12 @@ require_relative "api/resources/activity"
23
22
  require_relative "api/resources/address"
24
23
  require_relative "api/resources/banner"
25
24
  require_relative "api/resources/consent"
25
+ require_relative "api/resources/contact"
26
26
  require_relative "api/resources/donation"
27
27
  require_relative "api/resources/donations"
28
28
  require_relative "api/resources/location"
29
+ require_relative "api/resources/manual_donation"
30
+ require_relative "api/resources/manual_donations"
29
31
  require_relative "api/resources/newsletter_subscription"
30
32
  require_relative "api/resources/newsletter_subscriptions"
31
33
  require_relative "api/resources/photo"
@@ -15,6 +15,10 @@ module Kentaa
15
15
  Kentaa::Api::Clients::Donations.new(@config)
16
16
  end
17
17
 
18
+ def manual_donations
19
+ Kentaa::Api::Clients::ManualDonations.new(@config)
20
+ end
21
+
18
22
  def newsletter_subscriptions
19
23
  Kentaa::Api::Clients::NewsletterSubscriptions.new(@config)
20
24
  end
@@ -4,16 +4,29 @@ module Kentaa
4
4
  module Api
5
5
  module Clients
6
6
  class Actions < Base
7
- include Kentaa::Api::Clients::All
7
+ def all(options = {})
8
+ actions = Kentaa::Api::Resources::Actions.new(config, options)
9
+ actions.all
10
+ end
8
11
 
9
12
  def list(options = {})
10
- response = request.get("/actions", options)
11
- Kentaa::Api::Resources::Actions.new(config, response)
13
+ actions = Kentaa::Api::Resources::Actions.new(config, options)
14
+ actions.load
15
+ end
16
+
17
+ def get(id, options = {})
18
+ action = Kentaa::Api::Resources::Action.new(config, options.merge(id: id))
19
+ action.load
20
+ end
21
+
22
+ def create(attributes = {}, options = {})
23
+ action = Kentaa::Api::Resources::Actions.new(config, options)
24
+ action.create(attributes)
12
25
  end
13
26
 
14
- def get(id)
15
- response = request.get("/actions/#{id}")
16
- Kentaa::Api::Resources::Action.new(config, response)
27
+ def update(id, attributes = {}, options = {})
28
+ action = Kentaa::Api::Resources::Action.new(config, options.merge(id: id))
29
+ action.save(attributes)
17
30
  end
18
31
  end
19
32
  end
@@ -9,10 +9,6 @@ module Kentaa
9
9
  def initialize(config)
10
10
  @config = config
11
11
  end
12
-
13
- def request
14
- @request ||= Kentaa::Api::Request.new(config)
15
- end
16
12
  end
17
13
  end
18
14
  end
@@ -4,16 +4,19 @@ module Kentaa
4
4
  module Api
5
5
  module Clients
6
6
  class Donations < Base
7
- include Kentaa::Api::Clients::All
7
+ def all(options = {})
8
+ donations = Kentaa::Api::Resources::Donations.new(config, options)
9
+ donations.all
10
+ end
8
11
 
9
12
  def list(options = {})
10
- response = request.get("/donations", options)
11
- Kentaa::Api::Resources::Donations.new(config, response)
13
+ donations = Kentaa::Api::Resources::Donations.new(config, options)
14
+ donations.load
12
15
  end
13
16
 
14
- def get(id)
15
- response = request.get("/donations/#{id}")
16
- Kentaa::Api::Resources::Donation.new(config, response)
17
+ def get(id, options = {})
18
+ donation = Kentaa::Api::Resources::Donation.new(config, options.merge(id: id))
19
+ donation.load
17
20
  end
18
21
  end
19
22
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Clients
6
+ class ManualDonations < Base
7
+ def all(options = {})
8
+ donations = Kentaa::Api::Resources::ManualDonations.new(config, options)
9
+ donations.all
10
+ end
11
+
12
+ def list(options = {})
13
+ donations = Kentaa::Api::Resources::ManualDonations.new(config, options)
14
+ donations.load
15
+ end
16
+
17
+ def get(id, options = {})
18
+ donation = Kentaa::Api::Resources::ManualDonation.new(config, options.merge(id: id))
19
+ donation.load
20
+ end
21
+
22
+ def create(attributes = {}, options = {})
23
+ donation = Kentaa::Api::Resources::ManualDonation.new(config, options)
24
+ donation.save(attributes)
25
+ end
26
+
27
+ def update(id, attributes = {}, options = {})
28
+ donation = Kentaa::Api::Resources::ManualDonation.new(config, options.merge(id: id))
29
+ donation.save(attributes)
30
+ end
31
+
32
+ def delete(id, options = {})
33
+ donation = Kentaa::Api::Resources::ManualDonation.new(config, options.merge(id: id))
34
+ donation.delete
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,16 +4,19 @@ module Kentaa
4
4
  module Api
5
5
  module Clients
6
6
  class NewsletterSubscriptions < Base
7
- include Kentaa::Api::Clients::All
7
+ def all(options = {})
8
+ newsletter_subscriptions = Kentaa::Api::Resources::NewsletterSubscriptions.new(config, options)
9
+ newsletter_subscriptions.all
10
+ end
8
11
 
9
12
  def list(options = {})
10
- response = request.get("/newsletter-subscriptions", options)
11
- Kentaa::Api::Resources::NewsletterSubscriptions.new(config, response)
13
+ newsletter_subscriptions = Kentaa::Api::Resources::NewsletterSubscriptions.new(config, options)
14
+ newsletter_subscriptions.load
12
15
  end
13
16
 
14
- def get(id)
15
- response = request.get("/newsletter-subscriptions/#{id}")
16
- Kentaa::Api::Resources::NewsletterSubscription.new(config, response)
17
+ def get(id, options = {})
18
+ newsletter_subscription = Kentaa::Api::Resources::NewsletterSubscription.new(config, options.merge(id: id))
19
+ newsletter_subscription.load
17
20
  end
18
21
  end
19
22
  end
@@ -4,16 +4,19 @@ module Kentaa
4
4
  module Api
5
5
  module Clients
6
6
  class Projects < Base
7
- include Kentaa::Api::Clients::All
7
+ def all(options = {})
8
+ projects = Kentaa::Api::Resources::Projects.new(config, options)
9
+ projects.all
10
+ end
8
11
 
9
12
  def list(options = {})
10
- response = request.get("/projects", options)
11
- Kentaa::Api::Resources::Projects.new(config, response)
13
+ projects = Kentaa::Api::Resources::Projects.new(config, options)
14
+ projects.load
12
15
  end
13
16
 
14
- def get(id)
15
- response = request.get("/projects/#{id}")
16
- Kentaa::Api::Resources::Project.new(config, response)
17
+ def get(id, options = {})
18
+ project = Kentaa::Api::Resources::Project.new(config, options.merge(id: id))
19
+ project.load
17
20
  end
18
21
  end
19
22
  end