kentaa-api 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Resources
6
+ class CompanyPackage
7
+ attr_reader :data
8
+
9
+ def initialize(data)
10
+ @data = data
11
+ end
12
+
13
+ def id
14
+ data[:id]
15
+ end
16
+
17
+ def created_at
18
+ Time.parse(data[:created_at]) if data[:created_at]
19
+ end
20
+
21
+ def updated_at
22
+ Time.parse(data[:updated_at]) if data[:updated_at]
23
+ end
24
+
25
+ def amount
26
+ data[:amount]
27
+ end
28
+
29
+ def title
30
+ data[:title]
31
+ end
32
+
33
+ def description
34
+ data[:description]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,25 +1,98 @@
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
8
  class Consent
9
+ STATUS_GRANTED = 'granted'
10
+ STATUS_REVOKED = 'revoked'
11
+
12
+ TYPE_TERMS_CONDITIONS = 'terms_conditions'
13
+ TYPE_PROCESSING_PERSONAL_DATA = 'processing_personal_data'
14
+ TYPE_PROCESSING_PERSONAL_SENSITIVE_DATA = 'processing_personal_sensitive_data'
15
+ TYPE_NEWSLETTER_SUBSCRIPTION = 'newsletter_subscription'
16
+ TYPE_NEWS_ITEM_SUBSCRIPTION = 'news_item_subscription'
17
+ TYPE_CONTACT_PHONE = 'contact_phone'
18
+ TYPE_CONTACT_PHONE_COMMERCIAL = 'contact_phone_commercial'
19
+
7
20
  attr_reader :data
8
21
 
9
22
  def initialize(data)
10
23
  @data = data
11
24
  end
12
25
 
13
- def url
14
- data[:url]
26
+ def consent_type
27
+ data[:consent_type]
28
+ end
29
+
30
+ def terms_conditions?
31
+ consent_type == TYPE_TERMS_CONDITIONS
32
+ end
33
+
34
+ def processing_personal_data?
35
+ consent_type == TYPE_PROCESSING_PERSONAL_DATA
36
+ end
37
+
38
+ def processing_personal_sensitive_data?
39
+ consent_type == TYPE_PROCESSING_PERSONAL_SENSITIVE_DATA
40
+ end
41
+
42
+ def newsletter_subscription?
43
+ consent_type == TYPE_NEWSLETTER_SUBSCRIPTION
44
+ end
45
+
46
+ def news_item_subscription?
47
+ consent_type == TYPE_NEWS_ITEM_SUBSCRIPTION
48
+ end
49
+
50
+ def contact_phone?
51
+ consent_type == TYPE_CONTACT_PHONE
52
+ end
53
+
54
+ def contact_phone_commercial?
55
+ consent_type == TYPE_CONTACT_PHONE_COMMERCIAL
56
+ end
57
+
58
+ def consent_status
59
+ data[:consent_status]
60
+ end
61
+
62
+ def granted?
63
+ consent_status == STATUS_GRANTED
64
+ end
65
+
66
+ def revoked?
67
+ consent_status == STATUS_REVOKED
68
+ end
69
+
70
+ def granted_at
71
+ Time.parse(data[:granted_at])
72
+ end
73
+
74
+ def revoked_at
75
+ Time.parse(data[:revoked_at]) if data[:revoked_at]
76
+ end
77
+
78
+ def consent_text
79
+ data[:consent_text]
15
80
  end
16
81
 
17
82
  def text
18
- data[:text]
83
+ data[:text] || data[:consent_text]
84
+ end
85
+
86
+ def url
87
+ data[:url]
19
88
  end
20
89
 
21
90
  def version
22
- data[:version]
91
+ data[:version] || data[:terms_conditions_version]
92
+ end
93
+
94
+ def terms_conditions_version
95
+ data[:terms_conditions_version]
23
96
  end
24
97
  end
25
98
  end
@@ -23,7 +23,7 @@ module Kentaa
23
23
  end
24
24
 
25
25
  def name
26
- [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
26
+ [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
27
27
  end
28
28
 
29
29
  def email
@@ -27,6 +27,10 @@ module Kentaa
27
27
  end
28
28
  end
29
29
 
30
+ def recurring_donor
31
+ Kentaa::Api::Resources::RecurringDonor.new(config, id: recurring_donor_id, options: options) if recurring_donor_id
32
+ end
33
+
30
34
  def site
31
35
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
32
36
  end
@@ -55,6 +59,10 @@ module Kentaa
55
59
  data[:action_id]
56
60
  end
57
61
 
62
+ def recurring_donor_id
63
+ data[:recurring_donor_id]
64
+ end
65
+
58
66
  def first_name
59
67
  data[:first_name]
60
68
  end
@@ -68,7 +76,7 @@ module Kentaa
68
76
  end
69
77
 
70
78
  def name
71
- [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
79
+ [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
72
80
  end
73
81
 
74
82
  def company
@@ -99,6 +107,10 @@ module Kentaa
99
107
  data[:locale]
100
108
  end
101
109
 
110
+ def frequency_type
111
+ data[:frequency_type]
112
+ end
113
+
102
114
  def currency
103
115
  data[:currency]
104
116
  end
@@ -214,9 +226,25 @@ module Kentaa
214
226
  end
215
227
 
216
228
  def consent
229
+ Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
230
+
217
231
  @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
218
232
  end
219
233
 
234
+ def consents
235
+ @consents ||= begin
236
+ consents = []
237
+
238
+ if data[:consents]
239
+ data[:consents].each do |consent|
240
+ consents << Kentaa::Api::Resources::Consent.new(consent)
241
+ end
242
+ end
243
+
244
+ consents
245
+ end
246
+ end
247
+
220
248
  private
221
249
 
222
250
  def load_resource
@@ -68,7 +68,7 @@ module Kentaa
68
68
  end
69
69
 
70
70
  def name
71
- [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
71
+ [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
72
72
  end
73
73
 
74
74
  def anonymous?
@@ -106,7 +106,7 @@ module Kentaa
106
106
  end
107
107
 
108
108
  def create_resource(attributes)
109
- request.post("/manual-donations", options, attributes)
109
+ request.post('/manual-donations', options, attributes)
110
110
  end
111
111
 
112
112
  def update_resource(attributes)
@@ -37,7 +37,7 @@ module Kentaa
37
37
  end
38
38
 
39
39
  def name
40
- [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
40
+ [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
41
41
  end
42
42
 
43
43
  def site_id
@@ -69,9 +69,25 @@ module Kentaa
69
69
  end
70
70
 
71
71
  def consent
72
+ Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
73
+
72
74
  @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
73
75
  end
74
76
 
77
+ def consents
78
+ @consents ||= begin
79
+ consents = []
80
+
81
+ if data[:consents]
82
+ data[:consents].each do |consent|
83
+ consents << Kentaa::Api::Resources::Consent.new(consent)
84
+ end
85
+ end
86
+
87
+ consents
88
+ end
89
+ end
90
+
75
91
  private
76
92
 
77
93
  def load_resource
@@ -23,6 +23,10 @@ module Kentaa
23
23
  data[:title]
24
24
  end
25
25
 
26
+ def description
27
+ data[:description]
28
+ end
29
+
26
30
  def performance_type
27
31
  data[:performance_type]
28
32
  end
@@ -39,6 +43,10 @@ module Kentaa
39
43
  data[:unit]
40
44
  end
41
45
 
46
+ def photos(options = {})
47
+ @photos ||= Kentaa::Api::Resources::List.new(config, options.merge(resource_class: Kentaa::Api::Resources::PerformancePhoto, endpoint_path: "/actions/#{action_id}/performances/#{id}/photos"))
48
+ end
49
+
42
50
  private
43
51
 
44
52
  def load_resource
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Resources
6
+ class PerformancePhoto < Resource
7
+ class << self
8
+ def attribute_key
9
+ 'photo'
10
+ end
11
+ end
12
+
13
+ def object_key
14
+ "ActionPerformancePhoto_#{id}"
15
+ end
16
+
17
+ def image_url
18
+ data[:image_url]
19
+ end
20
+
21
+ private
22
+
23
+ def load_resource
24
+ request.get("#{endpoint_path}/#{id}", options)
25
+ end
26
+
27
+ def create_resource(attributes)
28
+ io = attributes.fetch(:io)
29
+ content_type = attributes.fetch(:content_type)
30
+
31
+ request.post(endpoint_path, options, io, content_type: content_type)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -134,9 +134,25 @@ module Kentaa
134
134
  end
135
135
 
136
136
  def consent
137
+ Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
138
+
137
139
  @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
138
140
  end
139
141
 
142
+ def consents
143
+ @consents ||= begin
144
+ consents = []
145
+
146
+ if data[:consents]
147
+ data[:consents].each do |consent|
148
+ consents << Kentaa::Api::Resources::Consent.new(consent)
149
+ end
150
+ end
151
+
152
+ consents
153
+ end
154
+ end
155
+
140
156
  def contact
141
157
  @contact ||= Kentaa::Api::Resources::Contact.new(data[:contact]) if data[:contact]
142
158
  end
@@ -44,7 +44,7 @@ module Kentaa
44
44
  end
45
45
 
46
46
  def name
47
- [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
47
+ [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
48
48
  end
49
49
 
50
50
  def company
@@ -86,21 +86,21 @@ module Kentaa
86
86
  end
87
87
 
88
88
  def donations
89
- @donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: "/donations")
89
+ @donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: '/donations')
90
90
  end
91
91
 
92
92
  def manual_donations
93
- @manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/manual-donations")
93
+ @manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: '/manual-donations')
94
94
  end
95
95
 
96
96
  def newsletter_subscriptions
97
- @newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: "/newsletter-subscriptions")
97
+ @newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: '/newsletter-subscriptions')
98
98
  end
99
99
 
100
100
  private
101
101
 
102
102
  def load_resource
103
- request.get("/sites/current", options)
103
+ request.get('/sites/current', options)
104
104
  end
105
105
  end
106
106
  end
@@ -31,7 +31,7 @@ module Kentaa
31
31
  end
32
32
 
33
33
  def name
34
- [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
34
+ [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
35
35
  end
36
36
 
37
37
  def email
@@ -91,9 +91,29 @@ module Kentaa
91
91
  end
92
92
 
93
93
  def consent
94
+ Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
95
+
94
96
  @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
95
97
  end
96
98
 
99
+ def consents
100
+ @consents ||= begin
101
+ consents = []
102
+
103
+ if data[:consents]
104
+ data[:consents].each do |consent|
105
+ consents << Kentaa::Api::Resources::Consent.new(consent)
106
+ end
107
+ end
108
+
109
+ consents
110
+ end
111
+ end
112
+
113
+ def actions
114
+ @actions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Action, endpoint_path: "/users/#{id}/actions")
115
+ end
116
+
97
117
  private
98
118
 
99
119
  def load_resource
@@ -101,7 +121,7 @@ module Kentaa
101
121
  end
102
122
 
103
123
  def create_resource(attributes)
104
- request.post("/users", options, attributes)
124
+ request.post('/users', options, attributes)
105
125
  end
106
126
 
107
127
  def update_resource(attributes)
@@ -5,7 +5,7 @@ module Kentaa
5
5
  module Resources
6
6
  class Users < List
7
7
  def initialize(config, options = {})
8
- super(config, options.merge(resource_class: Kentaa::Api::Resources::User, endpoint_path: "/users"))
8
+ super(config, options.merge(resource_class: Kentaa::Api::Resources::User, endpoint_path: '/users'))
9
9
  end
10
10
 
11
11
  def auth(attributes, options = {})
@@ -6,7 +6,11 @@ module Kentaa
6
6
  module_function
7
7
 
8
8
  def pluralize(string)
9
- "#{string}s"
9
+ if string[-1] == 'y'
10
+ "#{string.chop}ies"
11
+ else
12
+ "#{string}s"
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- VERSION = "0.6.0"
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
data/lib/kentaa/api.rb CHANGED
@@ -1,41 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "api/resources/base"
4
- require_relative "api/resources/error"
5
- require_relative "api/resources/list"
6
- require_relative "api/resources/resource"
3
+ require_relative 'api/resources/base'
4
+ require_relative 'api/resources/error'
5
+ require_relative 'api/resources/list'
6
+ require_relative 'api/resources/resource'
7
7
 
8
- require_relative "api/resources/action"
9
- require_relative "api/resources/activity"
10
- require_relative "api/resources/address"
11
- require_relative "api/resources/banner"
12
- require_relative "api/resources/consent"
13
- require_relative "api/resources/contact"
14
- require_relative "api/resources/donation_form"
15
- require_relative "api/resources/donation"
16
- require_relative "api/resources/location"
17
- require_relative "api/resources/manual_donation"
18
- require_relative "api/resources/newsletter_subscription"
19
- require_relative "api/resources/performance"
20
- require_relative "api/resources/photo"
21
- require_relative "api/resources/project"
22
- require_relative "api/resources/recurring_donor"
23
- require_relative "api/resources/registration_fee"
24
- require_relative "api/resources/reward"
25
- require_relative "api/resources/question"
26
- require_relative "api/resources/segment"
27
- require_relative "api/resources/site"
28
- require_relative "api/resources/sites"
29
- require_relative "api/resources/team"
30
- require_relative "api/resources/user"
31
- require_relative "api/resources/users"
32
- require_relative "api/resources/video"
8
+ require_relative 'api/resources/action'
9
+ require_relative 'api/resources/activity'
10
+ require_relative 'api/resources/address'
11
+ require_relative 'api/resources/banner'
12
+ require_relative 'api/resources/billing'
13
+ require_relative 'api/resources/company'
14
+ require_relative 'api/resources/company_package'
15
+ require_relative 'api/resources/consent'
16
+ require_relative 'api/resources/contact'
17
+ require_relative 'api/resources/donation_form'
18
+ require_relative 'api/resources/donation'
19
+ require_relative 'api/resources/location'
20
+ require_relative 'api/resources/manual_donation'
21
+ require_relative 'api/resources/newsletter_subscription'
22
+ require_relative 'api/resources/performance'
23
+ require_relative 'api/resources/performance_photo'
24
+ require_relative 'api/resources/photo'
25
+ require_relative 'api/resources/project'
26
+ require_relative 'api/resources/recurring_donor'
27
+ require_relative 'api/resources/registration_fee'
28
+ require_relative 'api/resources/reward'
29
+ require_relative 'api/resources/question'
30
+ require_relative 'api/resources/segment'
31
+ require_relative 'api/resources/site'
32
+ require_relative 'api/resources/sites'
33
+ require_relative 'api/resources/team'
34
+ require_relative 'api/resources/user'
35
+ require_relative 'api/resources/users'
36
+ require_relative 'api/resources/video'
33
37
 
34
- require_relative "api/client"
35
- require_relative "api/config"
36
- require_relative "api/exception"
37
- require_relative "api/request"
38
- require_relative "api/response"
39
- require_relative "api/util"
38
+ require_relative 'api/client'
39
+ require_relative 'api/config'
40
+ require_relative 'api/deprecation'
41
+ require_relative 'api/exception'
42
+ require_relative 'api/request'
43
+ require_relative 'api/response'
44
+ require_relative 'api/util'
40
45
 
41
- require_relative "api/version"
46
+ require_relative 'api/version'
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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,42 +58,27 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.3'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 2.3.2
61
+ version: '3.0'
65
62
  type: :development
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
66
  - - "~>"
70
67
  - !ruby/object:Gem::Version
71
- version: '2.3'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 2.3.2
68
+ version: '3.0'
75
69
  description:
76
70
  email:
77
- - support@kentaa.nl
71
+ - developers@kentaa.nl
78
72
  executables: []
79
73
  extensions: []
80
74
  extra_rdoc_files: []
81
75
  files:
82
- - ".github/workflows/test.yml"
83
- - ".gitignore"
84
- - ".rspec"
85
- - ".rubocop.yml"
86
- - Gemfile
87
- - Gemfile.lock
88
76
  - LICENSE.txt
89
77
  - README.md
90
- - Rakefile
91
- - bin/console
92
- - bin/setup
93
- - kentaa-api.gemspec
94
78
  - lib/kentaa/api.rb
95
79
  - lib/kentaa/api/client.rb
96
80
  - lib/kentaa/api/config.rb
81
+ - lib/kentaa/api/deprecation.rb
97
82
  - lib/kentaa/api/exception.rb
98
83
  - lib/kentaa/api/request.rb
99
84
  - lib/kentaa/api/resources/action.rb
@@ -101,6 +86,9 @@ files:
101
86
  - lib/kentaa/api/resources/address.rb
102
87
  - lib/kentaa/api/resources/banner.rb
103
88
  - lib/kentaa/api/resources/base.rb
89
+ - lib/kentaa/api/resources/billing.rb
90
+ - lib/kentaa/api/resources/company.rb
91
+ - lib/kentaa/api/resources/company_package.rb
104
92
  - lib/kentaa/api/resources/consent.rb
105
93
  - lib/kentaa/api/resources/contact.rb
106
94
  - lib/kentaa/api/resources/donation.rb
@@ -111,6 +99,7 @@ files:
111
99
  - lib/kentaa/api/resources/manual_donation.rb
112
100
  - lib/kentaa/api/resources/newsletter_subscription.rb
113
101
  - lib/kentaa/api/resources/performance.rb
102
+ - lib/kentaa/api/resources/performance_photo.rb
114
103
  - lib/kentaa/api/resources/photo.rb
115
104
  - lib/kentaa/api/resources/project.rb
116
105
  - lib/kentaa/api/resources/question.rb
@@ -131,7 +120,8 @@ files:
131
120
  homepage: https://github.com/KentaaNL/kentaa-api
132
121
  licenses:
133
122
  - MIT
134
- metadata: {}
123
+ metadata:
124
+ rubygems_mfa_required: 'true'
135
125
  post_install_message:
136
126
  rdoc_options: []
137
127
  require_paths:
@@ -140,14 +130,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
130
  requirements:
141
131
  - - ">="
142
132
  - !ruby/object:Gem::Version
143
- version: 2.4.0
133
+ version: 2.5.0
144
134
  required_rubygems_version: !ruby/object:Gem::Requirement
145
135
  requirements:
146
136
  - - ">="
147
137
  - !ruby/object:Gem::Version
148
138
  version: '0'
149
139
  requirements: []
150
- rubygems_version: 3.2.3
140
+ rubygems_version: 3.0.9
151
141
  signing_key:
152
142
  specification_version: 4
153
143
  summary: Ruby library for communicating with the Kentaa API