kentaa-api 0.2.1 → 0.5.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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +22 -4
  4. data/.travis.yml +5 -5
  5. data/Gemfile +4 -2
  6. data/Gemfile.lock +33 -20
  7. data/README.md +320 -66
  8. data/kentaa-api.gemspec +3 -3
  9. data/lib/kentaa/api.rb +12 -4
  10. data/lib/kentaa/api/client.rb +12 -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/donation_forms.rb +24 -0
  14. data/lib/kentaa/api/clients/donations.rb +9 -6
  15. data/lib/kentaa/api/clients/manual_donations.rb +39 -0
  16. data/lib/kentaa/api/clients/newsletter_subscriptions.rb +9 -6
  17. data/lib/kentaa/api/clients/projects.rb +9 -6
  18. data/lib/kentaa/api/clients/recurring_donors.rb +24 -0
  19. data/lib/kentaa/api/clients/segments.rb +9 -6
  20. data/lib/kentaa/api/clients/sites.rb +3 -3
  21. data/lib/kentaa/api/clients/teams.rb +9 -6
  22. data/lib/kentaa/api/clients/users.rb +24 -6
  23. data/lib/kentaa/api/config.rb +4 -0
  24. data/lib/kentaa/api/exception.rb +21 -0
  25. data/lib/kentaa/api/finder.rb +9 -0
  26. data/lib/kentaa/api/request.rb +55 -5
  27. data/lib/kentaa/api/resources/action.rb +40 -20
  28. data/lib/kentaa/api/resources/actions.rb +11 -3
  29. data/lib/kentaa/api/resources/activity.rb +10 -2
  30. data/lib/kentaa/api/resources/address.rb +6 -2
  31. data/lib/kentaa/api/resources/banner.rb +20 -2
  32. data/lib/kentaa/api/resources/base.rb +35 -11
  33. data/lib/kentaa/api/resources/consent.rb +7 -1
  34. data/lib/kentaa/api/resources/contact.rb +83 -0
  35. data/lib/kentaa/api/resources/donation.rb +35 -18
  36. data/lib/kentaa/api/resources/donation_form.rb +100 -0
  37. data/lib/kentaa/api/resources/donation_forms.rb +35 -0
  38. data/lib/kentaa/api/resources/donations.rb +6 -3
  39. data/lib/kentaa/api/resources/error.rb +23 -0
  40. data/lib/kentaa/api/resources/{pagination.rb → list.rb} +26 -3
  41. data/lib/kentaa/api/resources/location.rb +7 -1
  42. data/lib/kentaa/api/resources/manual_donation.rb +122 -0
  43. data/lib/kentaa/api/resources/manual_donations.rb +40 -0
  44. data/lib/kentaa/api/resources/newsletter_subscription.rb +21 -10
  45. data/lib/kentaa/api/resources/newsletter_subscriptions.rb +6 -3
  46. data/lib/kentaa/api/resources/photo.rb +20 -2
  47. data/lib/kentaa/api/resources/project.rb +34 -12
  48. data/lib/kentaa/api/resources/projects.rb +6 -3
  49. data/lib/kentaa/api/resources/question.rb +18 -2
  50. data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
  51. data/lib/kentaa/api/resources/recurring_donors.rb +35 -0
  52. data/lib/kentaa/api/resources/registration_fee.rb +1 -1
  53. data/lib/kentaa/api/resources/resource.rb +50 -3
  54. data/lib/kentaa/api/resources/reward.rb +10 -2
  55. data/lib/kentaa/api/resources/segment.rb +28 -4
  56. data/lib/kentaa/api/resources/segments.rb +6 -3
  57. data/lib/kentaa/api/resources/site.rb +20 -4
  58. data/lib/kentaa/api/resources/team.rb +27 -14
  59. data/lib/kentaa/api/resources/teams.rb +6 -3
  60. data/lib/kentaa/api/resources/user.rb +27 -5
  61. data/lib/kentaa/api/resources/users.rb +16 -3
  62. data/lib/kentaa/api/resources/video.rb +20 -2
  63. data/lib/kentaa/api/response.rb +21 -3
  64. data/lib/kentaa/api/version.rb +1 -1
  65. metadata +24 -16
  66. data/lib/kentaa/api/clients/all.rb +0 -26
  67. data/lib/kentaa/api/resources/status.rb +0 -27
@@ -1,10 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'time'
4
+
3
5
  module Kentaa
4
6
  module Api
5
7
  module Resources
6
- class Video < Base
7
- include Kentaa::Api::Resources::Resource
8
+ class Video
9
+ attr_reader :data
10
+
11
+ def initialize(data)
12
+ @data = data
13
+ end
14
+
15
+ def id
16
+ data[:id]
17
+ end
18
+
19
+ def created_at
20
+ Time.parse(data[:created_at]) if data[:created_at]
21
+ end
22
+
23
+ def updated_at
24
+ Time.parse(data[:updated_at]) if data[:updated_at]
25
+ end
8
26
 
9
27
  def url
10
28
  data[:url]
@@ -9,25 +9,43 @@ module Kentaa
9
9
 
10
10
  def initialize(response)
11
11
  @response = response
12
- @body = parse_body(response.body)
12
+ @body = response.body ? parse_body(response.body) : {}
13
13
  end
14
14
 
15
15
  def success?
16
- (code == 200 || code == 201) && !message
16
+ (http_code == 200 || http_code == 201 || http_code == 204) && !message
17
17
  end
18
18
 
19
19
  def error?
20
20
  !success?
21
21
  end
22
22
 
23
- def code
23
+ def http_code
24
24
  response.code.to_i
25
25
  end
26
26
 
27
+ def request_uri
28
+ response.uri
29
+ end
30
+
27
31
  def message
28
32
  body[:message]
29
33
  end
30
34
 
35
+ def errors
36
+ @errors ||= begin
37
+ errors = []
38
+
39
+ if body[:errors]
40
+ body[:errors].each do |error|
41
+ errors << Kentaa::Api::Resources::Error.new(error)
42
+ end
43
+ end
44
+
45
+ errors
46
+ end
47
+ end
48
+
31
49
  private
32
50
 
33
51
  def parse_body(body)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- VERSION = "0.2.1"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kentaa-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 2.3.2
75
- description:
75
+ description:
76
76
  email:
77
77
  - support@kentaa.nl
78
78
  executables: []
@@ -94,11 +94,13 @@ files:
94
94
  - lib/kentaa/api.rb
95
95
  - lib/kentaa/api/client.rb
96
96
  - lib/kentaa/api/clients/actions.rb
97
- - lib/kentaa/api/clients/all.rb
98
97
  - lib/kentaa/api/clients/base.rb
98
+ - lib/kentaa/api/clients/donation_forms.rb
99
99
  - lib/kentaa/api/clients/donations.rb
100
+ - lib/kentaa/api/clients/manual_donations.rb
100
101
  - lib/kentaa/api/clients/newsletter_subscriptions.rb
101
102
  - lib/kentaa/api/clients/projects.rb
103
+ - lib/kentaa/api/clients/recurring_donors.rb
102
104
  - lib/kentaa/api/clients/segments.rb
103
105
  - lib/kentaa/api/clients/sites.rb
104
106
  - lib/kentaa/api/clients/teams.rb
@@ -114,23 +116,30 @@ files:
114
116
  - lib/kentaa/api/resources/banner.rb
115
117
  - lib/kentaa/api/resources/base.rb
116
118
  - lib/kentaa/api/resources/consent.rb
119
+ - lib/kentaa/api/resources/contact.rb
117
120
  - lib/kentaa/api/resources/donation.rb
121
+ - lib/kentaa/api/resources/donation_form.rb
122
+ - lib/kentaa/api/resources/donation_forms.rb
118
123
  - lib/kentaa/api/resources/donations.rb
124
+ - lib/kentaa/api/resources/error.rb
125
+ - lib/kentaa/api/resources/list.rb
119
126
  - lib/kentaa/api/resources/location.rb
127
+ - lib/kentaa/api/resources/manual_donation.rb
128
+ - lib/kentaa/api/resources/manual_donations.rb
120
129
  - lib/kentaa/api/resources/newsletter_subscription.rb
121
130
  - lib/kentaa/api/resources/newsletter_subscriptions.rb
122
- - lib/kentaa/api/resources/pagination.rb
123
131
  - lib/kentaa/api/resources/photo.rb
124
132
  - lib/kentaa/api/resources/project.rb
125
133
  - lib/kentaa/api/resources/projects.rb
126
134
  - lib/kentaa/api/resources/question.rb
135
+ - lib/kentaa/api/resources/recurring_donor.rb
136
+ - lib/kentaa/api/resources/recurring_donors.rb
127
137
  - lib/kentaa/api/resources/registration_fee.rb
128
138
  - lib/kentaa/api/resources/resource.rb
129
139
  - lib/kentaa/api/resources/reward.rb
130
140
  - lib/kentaa/api/resources/segment.rb
131
141
  - lib/kentaa/api/resources/segments.rb
132
142
  - lib/kentaa/api/resources/site.rb
133
- - lib/kentaa/api/resources/status.rb
134
143
  - lib/kentaa/api/resources/team.rb
135
144
  - lib/kentaa/api/resources/teams.rb
136
145
  - lib/kentaa/api/resources/user.rb
@@ -142,7 +151,7 @@ homepage: https://github.com/KentaaNL/kentaa-api
142
151
  licenses:
143
152
  - MIT
144
153
  metadata: {}
145
- post_install_message:
154
+ post_install_message:
146
155
  rdoc_options: []
147
156
  require_paths:
148
157
  - lib
@@ -150,16 +159,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
159
  requirements:
151
160
  - - ">="
152
161
  - !ruby/object:Gem::Version
153
- version: 2.0.0
162
+ version: 2.4.0
154
163
  required_rubygems_version: !ruby/object:Gem::Requirement
155
164
  requirements:
156
165
  - - ">="
157
166
  - !ruby/object:Gem::Version
158
167
  version: '0'
159
168
  requirements: []
160
- rubyforge_project:
161
- rubygems_version: 2.7.9
162
- signing_key:
169
+ rubygems_version: 3.2.3
170
+ signing_key:
163
171
  specification_version: 4
164
172
  summary: Ruby library for communicating with the Kentaa API
165
173
  test_files: []
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Kentaa
4
- module Api
5
- module Clients
6
- module All
7
- def all(options = {})
8
- enumerator = Enumerator.new do |yielder|
9
- page = 1
10
-
11
- loop do
12
- response = list(options.merge(page: page))
13
- response.each { |item| yielder.yield item } if response.success?
14
-
15
- raise StopIteration unless response.next_page?
16
-
17
- page = response.next_page
18
- end
19
- end
20
-
21
- enumerator.lazy
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Kentaa
4
- module Api
5
- module Resources
6
- module Status
7
- attr_accessor :response
8
-
9
- def success?
10
- response.success?
11
- end
12
-
13
- def error?
14
- response.error?
15
- end
16
-
17
- def body
18
- response.body
19
- end
20
-
21
- def message
22
- response.message
23
- end
24
- end
25
- end
26
- end
27
- end