kentaa-api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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 Site < Base
8
10
  include Kentaa::Api::Responses::Resource
9
11
 
10
- def initialize(response)
11
- super(response[:site] || response)
12
- end
13
-
14
12
  def host
15
13
  data[:host]
16
14
  end
@@ -32,7 +30,7 @@ module Kentaa
32
30
  end
33
31
 
34
32
  def total_amount
35
- BigDecimal.new(data[:total_amount])
33
+ BigDecimal(data[:total_amount])
36
34
  end
37
35
 
38
36
  def total_donations
@@ -63,6 +61,10 @@ module Kentaa
63
61
  data[:owner_email]
64
62
  end
65
63
 
64
+ def default_currency
65
+ data[:default_currency]
66
+ end
67
+
66
68
  def banners
67
69
  @banners ||= begin
68
70
  banners = []
@@ -76,6 +78,10 @@ module Kentaa
76
78
  banners
77
79
  end
78
80
  end
81
+
82
+ def external_reference
83
+ data[:external_reference]
84
+ end
79
85
  end
80
86
  end
81
87
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Responses
6
+ module Status
7
+ attr_accessor :response
8
+
9
+ def success?
10
+ (response.code == 200 || response.code == 201) && !message
11
+ end
12
+
13
+ def error?
14
+ !success?
15
+ end
16
+
17
+ def body
18
+ response.body
19
+ end
20
+
21
+ def message
22
+ body[:message] if body
23
+ end
24
+ end
25
+ end
26
+ end
27
+ 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 Team < Base
8
10
  include Kentaa::Api::Responses::Resource
9
11
 
10
- def initialize(response)
11
- super(response[:team] || response)
12
- end
13
-
14
12
  def slug
15
13
  data[:slug]
16
14
  end
@@ -24,7 +22,7 @@ module Kentaa
24
22
  end
25
23
 
26
24
  def owner
27
- @owner ||= Kentaa::Api::Responses::Owner.new(data[:owner])
25
+ @owner ||= Kentaa::Api::Responses::User.new(data[:owner])
28
26
  end
29
27
 
30
28
  def members
@@ -58,17 +56,33 @@ module Kentaa
58
56
  end
59
57
 
60
58
  def total_amount
61
- BigDecimal.new(data[:total_amount])
59
+ BigDecimal(data[:total_amount])
62
60
  end
63
61
 
64
62
  def total_donations
65
63
  data[:total_donations]
66
64
  end
67
65
 
66
+ def target_amount_achieved?
67
+ data[:target_amount_achieved]
68
+ end
69
+
68
70
  def visible?
69
71
  data[:visible]
70
72
  end
71
73
 
74
+ def countable?
75
+ data[:countable]
76
+ end
77
+
78
+ def closed?
79
+ data[:closed]
80
+ end
81
+
82
+ def ended?
83
+ data[:ended]
84
+ end
85
+
72
86
  def end_date
73
87
  Time.parse(data[:end_date]) if data[:end_date]
74
88
  end
@@ -122,6 +136,10 @@ module Kentaa
122
136
  questions
123
137
  end
124
138
  end
139
+
140
+ def external_reference
141
+ data[:external_reference]
142
+ end
125
143
  end
126
144
  end
127
145
  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
  teams.each(&block)
14
12
  end
@@ -19,8 +17,8 @@ module Kentaa
19
17
  @teams ||= begin
20
18
  teams = []
21
19
 
22
- if data[:teams]
23
- data[:teams].each do |team|
20
+ if data
21
+ data.each do |team|
24
22
  teams << Kentaa::Api::Responses::Team.new(team)
25
23
  end
26
24
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Kentaa
6
+ module Api
7
+ module Responses
8
+ class User < Base
9
+ include Kentaa::Api::Responses::Resource
10
+
11
+ def first_name
12
+ data[:first_name]
13
+ end
14
+
15
+ def infix
16
+ data[:infix]
17
+ end
18
+
19
+ def last_name
20
+ data[:last_name]
21
+ end
22
+
23
+ def name
24
+ [first_name, infix, last_name].compact.join(" ")
25
+ end
26
+
27
+ def email
28
+ data[:email]
29
+ end
30
+
31
+ def avatar_url
32
+ data[:avatar_url]
33
+ end
34
+
35
+ def address
36
+ data[:address]
37
+ end
38
+
39
+ def address2
40
+ data[:address2]
41
+ end
42
+
43
+ def street
44
+ data[:street]
45
+ end
46
+
47
+ def house_number
48
+ data[:house_number]
49
+ end
50
+
51
+ def house_number_addition
52
+ data[:house_number_addition]
53
+ end
54
+
55
+ def zipcode
56
+ data[:zipcode]
57
+ end
58
+
59
+ def city
60
+ data[:city]
61
+ end
62
+
63
+ def country
64
+ data[:country]
65
+ end
66
+
67
+ def phone
68
+ data[:phone]
69
+ end
70
+
71
+ def birthday
72
+ Time.parse(data[:birthday]) if data[:birthday]
73
+ end
74
+
75
+ def gender
76
+ data[:gender]
77
+ end
78
+
79
+ def locale
80
+ data[:locale]
81
+ end
82
+
83
+ def consent
84
+ @consent ||= Kentaa::Api::Responses::Consent.new(data[:consent]) if data[:consent]
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Responses
6
+ class Users < Base
7
+ include Enumerable
8
+ include Kentaa::Api::Responses::Pagination
9
+
10
+ def each(&block)
11
+ users.each(&block)
12
+ end
13
+
14
+ private
15
+
16
+ def users
17
+ @users ||= begin
18
+ users = []
19
+
20
+ if data
21
+ data.each do |user|
22
+ segments << Kentaa::Api::Responses::User.new(user)
23
+ end
24
+ end
25
+
26
+ users
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ 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 Video < Base
5
7
  include Kentaa::Api::Responses::Resource
6
8
 
7
- def initialize(response)
8
- super(response)
9
- end
10
-
11
9
  def url
12
10
  data[:url]
13
11
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kentaa
2
4
  module Api
3
- VERSION = "0.1.0".freeze
5
+ VERSION = "0.1.1"
4
6
  end
5
7
  end
data/lib/kentaa/api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "api/requests/base"
2
4
  require_relative "api/requests/all"
3
5
 
@@ -8,33 +10,41 @@ require_relative "api/requests/projects"
8
10
  require_relative "api/requests/segments"
9
11
  require_relative "api/requests/sites"
10
12
  require_relative "api/requests/teams"
13
+ require_relative "api/requests/users"
11
14
 
12
15
  require_relative "api/responses/base"
13
16
  require_relative "api/responses/pagination"
14
17
  require_relative "api/responses/resource"
18
+ require_relative "api/responses/status"
15
19
 
16
20
  require_relative "api/responses/action"
17
21
  require_relative "api/responses/actions"
22
+ require_relative "api/responses/activity"
18
23
  require_relative "api/responses/address"
19
24
  require_relative "api/responses/banner"
25
+ require_relative "api/responses/consent"
20
26
  require_relative "api/responses/donation"
21
27
  require_relative "api/responses/donations"
28
+ require_relative "api/responses/location"
22
29
  require_relative "api/responses/newsletter_subscription"
23
30
  require_relative "api/responses/newsletter_subscriptions"
24
- require_relative "api/responses/owner"
25
31
  require_relative "api/responses/photo"
26
32
  require_relative "api/responses/project"
27
33
  require_relative "api/responses/projects"
28
34
  require_relative "api/responses/question"
35
+ require_relative "api/responses/registration_fee"
29
36
  require_relative "api/responses/reward"
30
37
  require_relative "api/responses/segment"
31
38
  require_relative "api/responses/segments"
32
39
  require_relative "api/responses/site"
33
40
  require_relative "api/responses/team"
34
41
  require_relative "api/responses/teams"
42
+ require_relative "api/responses/user"
43
+ require_relative "api/responses/users"
35
44
  require_relative "api/responses/video"
36
45
 
37
46
  require_relative "api/client"
38
- require_relative "api/http"
47
+ require_relative "api/request"
48
+ require_relative "api/response"
39
49
 
40
50
  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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-19 00:00:00.000000000 Z
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,7 @@ files:
84
84
  - ".rubocop.yml"
85
85
  - ".travis.yml"
86
86
  - Gemfile
87
+ - Gemfile.lock
87
88
  - LICENSE.txt
88
89
  - README.md
89
90
  - Rakefile
@@ -92,7 +93,7 @@ files:
92
93
  - kentaa-api.gemspec
93
94
  - lib/kentaa/api.rb
94
95
  - lib/kentaa/api/client.rb
95
- - lib/kentaa/api/http.rb
96
+ - lib/kentaa/api/request.rb
96
97
  - lib/kentaa/api/requests/actions.rb
97
98
  - lib/kentaa/api/requests/all.rb
98
99
  - lib/kentaa/api/requests/base.rb
@@ -102,31 +103,39 @@ files:
102
103
  - lib/kentaa/api/requests/segments.rb
103
104
  - lib/kentaa/api/requests/sites.rb
104
105
  - lib/kentaa/api/requests/teams.rb
106
+ - lib/kentaa/api/requests/users.rb
107
+ - lib/kentaa/api/response.rb
105
108
  - lib/kentaa/api/responses/action.rb
106
109
  - lib/kentaa/api/responses/actions.rb
110
+ - lib/kentaa/api/responses/activity.rb
107
111
  - lib/kentaa/api/responses/address.rb
108
112
  - lib/kentaa/api/responses/banner.rb
109
113
  - lib/kentaa/api/responses/base.rb
114
+ - lib/kentaa/api/responses/consent.rb
110
115
  - lib/kentaa/api/responses/donation.rb
111
116
  - lib/kentaa/api/responses/donations.rb
117
+ - lib/kentaa/api/responses/location.rb
112
118
  - lib/kentaa/api/responses/newsletter_subscription.rb
113
119
  - lib/kentaa/api/responses/newsletter_subscriptions.rb
114
- - lib/kentaa/api/responses/owner.rb
115
120
  - lib/kentaa/api/responses/pagination.rb
116
121
  - lib/kentaa/api/responses/photo.rb
117
122
  - lib/kentaa/api/responses/project.rb
118
123
  - lib/kentaa/api/responses/projects.rb
119
124
  - lib/kentaa/api/responses/question.rb
125
+ - lib/kentaa/api/responses/registration_fee.rb
120
126
  - lib/kentaa/api/responses/resource.rb
121
127
  - lib/kentaa/api/responses/reward.rb
122
128
  - lib/kentaa/api/responses/segment.rb
123
129
  - lib/kentaa/api/responses/segments.rb
124
130
  - lib/kentaa/api/responses/site.rb
131
+ - lib/kentaa/api/responses/status.rb
125
132
  - lib/kentaa/api/responses/team.rb
126
133
  - lib/kentaa/api/responses/teams.rb
134
+ - lib/kentaa/api/responses/user.rb
135
+ - lib/kentaa/api/responses/users.rb
127
136
  - lib/kentaa/api/responses/video.rb
128
137
  - lib/kentaa/api/version.rb
129
- homepage: https://www.kentaa.nl
138
+ homepage: https://github.com/KentaaNL/kentaa-api
130
139
  licenses:
131
140
  - MIT
132
141
  metadata: {}
@@ -146,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
155
  version: '0'
147
156
  requirements: []
148
157
  rubyforge_project:
149
- rubygems_version: 2.5.2
158
+ rubygems_version: 2.7.9
150
159
  signing_key:
151
160
  specification_version: 4
152
161
  summary: Ruby library for communicating with the Kentaa API
@@ -1,37 +0,0 @@
1
- module Kentaa
2
- module Api
3
- module Responses
4
- class Owner < Base
5
- include Kentaa::Api::Responses::Resource
6
-
7
- def initialize(response)
8
- super(response)
9
- end
10
-
11
- def first_name
12
- data[:first_name]
13
- end
14
-
15
- def infix
16
- data[:infix]
17
- end
18
-
19
- def last_name
20
- data[:last_name]
21
- end
22
-
23
- def name
24
- [first_name, infix, last_name].compact.join(" ")
25
- end
26
-
27
- def email
28
- data[:email]
29
- end
30
-
31
- def avatar_url
32
- data[:avatar_url]
33
- end
34
- end
35
- end
36
- end
37
- end