kentaa-api 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +13 -12
  5. data/lib/kentaa/api.rb +42 -39
  6. data/lib/kentaa/api/client.rb +10 -10
  7. data/lib/kentaa/api/{requests → clients}/actions.rb +4 -4
  8. data/lib/kentaa/api/{requests → clients}/all.rb +1 -1
  9. data/lib/kentaa/api/clients/base.rb +19 -0
  10. data/lib/kentaa/api/{requests → clients}/donations.rb +4 -4
  11. data/lib/kentaa/api/{requests → clients}/newsletter_subscriptions.rb +4 -4
  12. data/lib/kentaa/api/{requests → clients}/projects.rb +4 -4
  13. data/lib/kentaa/api/{requests → clients}/segments.rb +4 -4
  14. data/lib/kentaa/api/{requests → clients}/sites.rb +2 -2
  15. data/lib/kentaa/api/{requests → clients}/teams.rb +4 -4
  16. data/lib/kentaa/api/{requests → clients}/users.rb +4 -4
  17. data/lib/kentaa/api/config.rb +39 -0
  18. data/lib/kentaa/api/exception.rb +8 -0
  19. data/lib/kentaa/api/finder.rb +35 -0
  20. data/lib/kentaa/api/request.rb +15 -24
  21. data/lib/kentaa/api/{responses → resources}/action.rb +34 -10
  22. data/lib/kentaa/api/{responses → resources}/actions.rb +3 -3
  23. data/lib/kentaa/api/{responses → resources}/activity.rb +2 -2
  24. data/lib/kentaa/api/{responses → resources}/address.rb +2 -2
  25. data/lib/kentaa/api/{responses → resources}/banner.rb +2 -2
  26. data/lib/kentaa/api/{responses → resources}/base.rb +6 -6
  27. data/lib/kentaa/api/{responses → resources}/consent.rb +1 -1
  28. data/lib/kentaa/api/{responses → resources}/donation.rb +45 -6
  29. data/lib/kentaa/api/{responses → resources}/donations.rb +3 -3
  30. data/lib/kentaa/api/{responses → resources}/location.rb +1 -1
  31. data/lib/kentaa/api/{responses → resources}/newsletter_subscription.rb +24 -3
  32. data/lib/kentaa/api/{responses → resources}/newsletter_subscriptions.rb +3 -3
  33. data/lib/kentaa/api/{responses → resources}/pagination.rb +1 -1
  34. data/lib/kentaa/api/{responses → resources}/photo.rb +2 -2
  35. data/lib/kentaa/api/{responses → resources}/project.rb +25 -7
  36. data/lib/kentaa/api/{responses → resources}/projects.rb +3 -3
  37. data/lib/kentaa/api/{responses → resources}/question.rb +2 -2
  38. data/lib/kentaa/api/{responses → resources}/registration_fee.rb +1 -1
  39. data/lib/kentaa/api/{responses → resources}/resource.rb +1 -1
  40. data/lib/kentaa/api/{responses → resources}/reward.rb +2 -2
  41. data/lib/kentaa/api/{responses → resources}/segment.rb +11 -3
  42. data/lib/kentaa/api/{responses → resources}/segments.rb +3 -3
  43. data/lib/kentaa/api/{responses → resources}/site.rb +7 -3
  44. data/lib/kentaa/api/{responses → resources}/status.rb +4 -4
  45. data/lib/kentaa/api/{responses → resources}/team.rb +28 -7
  46. data/lib/kentaa/api/{responses → resources}/teams.rb +3 -3
  47. data/lib/kentaa/api/{responses → resources}/user.rb +11 -3
  48. data/lib/kentaa/api/{responses → resources}/users.rb +3 -3
  49. data/lib/kentaa/api/{responses → resources}/video.rb +2 -2
  50. data/lib/kentaa/api/response.rb +12 -0
  51. data/lib/kentaa/api/version.rb +1 -1
  52. metadata +44 -41
  53. data/lib/kentaa/api/requests/base.rb +0 -15
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- module Responses
5
+ module Resources
6
6
  class Teams < Base
7
7
  include Enumerable
8
- include Kentaa::Api::Responses::Pagination
8
+ include Kentaa::Api::Resources::Pagination
9
9
 
10
10
  def each(&block)
11
11
  teams.each(&block)
@@ -19,7 +19,7 @@ module Kentaa
19
19
 
20
20
  if data
21
21
  data.each do |team|
22
- teams << Kentaa::Api::Responses::Team.new(team)
22
+ teams << Kentaa::Api::Resources::Team.new(config, team)
23
23
  end
24
24
  end
25
25
 
@@ -4,9 +4,17 @@ require 'time'
4
4
 
5
5
  module Kentaa
6
6
  module Api
7
- module Responses
7
+ module Resources
8
8
  class User < Base
9
- include Kentaa::Api::Responses::Resource
9
+ include Kentaa::Api::Resources::Resource
10
+
11
+ def object_key
12
+ "User_#{id}"
13
+ end
14
+
15
+ def site_id
16
+ data[:site_id]
17
+ end
10
18
 
11
19
  def first_name
12
20
  data[:first_name]
@@ -81,7 +89,7 @@ module Kentaa
81
89
  end
82
90
 
83
91
  def consent
84
- @consent ||= Kentaa::Api::Responses::Consent.new(data[:consent]) if data[:consent]
92
+ @consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent]
85
93
  end
86
94
  end
87
95
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- module Responses
5
+ module Resources
6
6
  class Users < Base
7
7
  include Enumerable
8
- include Kentaa::Api::Responses::Pagination
8
+ include Kentaa::Api::Resources::Pagination
9
9
 
10
10
  def each(&block)
11
11
  users.each(&block)
@@ -19,7 +19,7 @@ module Kentaa
19
19
 
20
20
  if data
21
21
  data.each do |user|
22
- segments << Kentaa::Api::Responses::User.new(user)
22
+ users << Kentaa::Api::Resources::User.new(config, user)
23
23
  end
24
24
  end
25
25
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- module Responses
5
+ module Resources
6
6
  class Video < Base
7
- include Kentaa::Api::Responses::Resource
7
+ include Kentaa::Api::Resources::Resource
8
8
 
9
9
  def url
10
10
  data[:url]
@@ -12,10 +12,22 @@ module Kentaa
12
12
  @body = parse_body(response.body)
13
13
  end
14
14
 
15
+ def success?
16
+ (code == 200 || code == 201) && !message
17
+ end
18
+
19
+ def error?
20
+ !success?
21
+ end
22
+
15
23
  def code
16
24
  response.code.to_i
17
25
  end
18
26
 
27
+ def message
28
+ body[:message]
29
+ end
30
+
19
31
  private
20
32
 
21
33
  def parse_body(body)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,47 +93,50 @@ files:
93
93
  - kentaa-api.gemspec
94
94
  - lib/kentaa/api.rb
95
95
  - lib/kentaa/api/client.rb
96
+ - lib/kentaa/api/clients/actions.rb
97
+ - lib/kentaa/api/clients/all.rb
98
+ - lib/kentaa/api/clients/base.rb
99
+ - lib/kentaa/api/clients/donations.rb
100
+ - lib/kentaa/api/clients/newsletter_subscriptions.rb
101
+ - lib/kentaa/api/clients/projects.rb
102
+ - lib/kentaa/api/clients/segments.rb
103
+ - lib/kentaa/api/clients/sites.rb
104
+ - lib/kentaa/api/clients/teams.rb
105
+ - lib/kentaa/api/clients/users.rb
106
+ - lib/kentaa/api/config.rb
107
+ - lib/kentaa/api/exception.rb
108
+ - lib/kentaa/api/finder.rb
96
109
  - lib/kentaa/api/request.rb
97
- - lib/kentaa/api/requests/actions.rb
98
- - lib/kentaa/api/requests/all.rb
99
- - lib/kentaa/api/requests/base.rb
100
- - lib/kentaa/api/requests/donations.rb
101
- - lib/kentaa/api/requests/newsletter_subscriptions.rb
102
- - lib/kentaa/api/requests/projects.rb
103
- - lib/kentaa/api/requests/segments.rb
104
- - lib/kentaa/api/requests/sites.rb
105
- - lib/kentaa/api/requests/teams.rb
106
- - lib/kentaa/api/requests/users.rb
110
+ - lib/kentaa/api/resources/action.rb
111
+ - lib/kentaa/api/resources/actions.rb
112
+ - lib/kentaa/api/resources/activity.rb
113
+ - lib/kentaa/api/resources/address.rb
114
+ - lib/kentaa/api/resources/banner.rb
115
+ - lib/kentaa/api/resources/base.rb
116
+ - lib/kentaa/api/resources/consent.rb
117
+ - lib/kentaa/api/resources/donation.rb
118
+ - lib/kentaa/api/resources/donations.rb
119
+ - lib/kentaa/api/resources/location.rb
120
+ - lib/kentaa/api/resources/newsletter_subscription.rb
121
+ - lib/kentaa/api/resources/newsletter_subscriptions.rb
122
+ - lib/kentaa/api/resources/pagination.rb
123
+ - lib/kentaa/api/resources/photo.rb
124
+ - lib/kentaa/api/resources/project.rb
125
+ - lib/kentaa/api/resources/projects.rb
126
+ - lib/kentaa/api/resources/question.rb
127
+ - lib/kentaa/api/resources/registration_fee.rb
128
+ - lib/kentaa/api/resources/resource.rb
129
+ - lib/kentaa/api/resources/reward.rb
130
+ - lib/kentaa/api/resources/segment.rb
131
+ - lib/kentaa/api/resources/segments.rb
132
+ - lib/kentaa/api/resources/site.rb
133
+ - lib/kentaa/api/resources/status.rb
134
+ - lib/kentaa/api/resources/team.rb
135
+ - lib/kentaa/api/resources/teams.rb
136
+ - lib/kentaa/api/resources/user.rb
137
+ - lib/kentaa/api/resources/users.rb
138
+ - lib/kentaa/api/resources/video.rb
107
139
  - lib/kentaa/api/response.rb
108
- - lib/kentaa/api/responses/action.rb
109
- - lib/kentaa/api/responses/actions.rb
110
- - lib/kentaa/api/responses/activity.rb
111
- - lib/kentaa/api/responses/address.rb
112
- - lib/kentaa/api/responses/banner.rb
113
- - lib/kentaa/api/responses/base.rb
114
- - lib/kentaa/api/responses/consent.rb
115
- - lib/kentaa/api/responses/donation.rb
116
- - lib/kentaa/api/responses/donations.rb
117
- - lib/kentaa/api/responses/location.rb
118
- - lib/kentaa/api/responses/newsletter_subscription.rb
119
- - lib/kentaa/api/responses/newsletter_subscriptions.rb
120
- - lib/kentaa/api/responses/pagination.rb
121
- - lib/kentaa/api/responses/photo.rb
122
- - lib/kentaa/api/responses/project.rb
123
- - lib/kentaa/api/responses/projects.rb
124
- - lib/kentaa/api/responses/question.rb
125
- - lib/kentaa/api/responses/registration_fee.rb
126
- - lib/kentaa/api/responses/resource.rb
127
- - lib/kentaa/api/responses/reward.rb
128
- - lib/kentaa/api/responses/segment.rb
129
- - lib/kentaa/api/responses/segments.rb
130
- - lib/kentaa/api/responses/site.rb
131
- - lib/kentaa/api/responses/status.rb
132
- - lib/kentaa/api/responses/team.rb
133
- - lib/kentaa/api/responses/teams.rb
134
- - lib/kentaa/api/responses/user.rb
135
- - lib/kentaa/api/responses/users.rb
136
- - lib/kentaa/api/responses/video.rb
137
140
  - lib/kentaa/api/version.rb
138
141
  homepage: https://github.com/KentaaNL/kentaa-api
139
142
  licenses:
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Kentaa
4
- module Api
5
- module Requests
6
- class Base
7
- attr_reader :request
8
-
9
- def initialize(request)
10
- @request = request
11
- end
12
- end
13
- end
14
- end
15
- end