kentaa-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +33 -0
  5. data/.travis.yml +7 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +163 -0
  9. data/Rakefile +8 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/kentaa-api.gemspec +30 -0
  13. data/lib/kentaa/api/client.rb +37 -0
  14. data/lib/kentaa/api/http.rb +47 -0
  15. data/lib/kentaa/api/requests/actions.rb +19 -0
  16. data/lib/kentaa/api/requests/all.rb +24 -0
  17. data/lib/kentaa/api/requests/base.rb +13 -0
  18. data/lib/kentaa/api/requests/donations.rb +19 -0
  19. data/lib/kentaa/api/requests/newsletter_subscriptions.rb +14 -0
  20. data/lib/kentaa/api/requests/projects.rb +19 -0
  21. data/lib/kentaa/api/requests/segments.rb +19 -0
  22. data/lib/kentaa/api/requests/sites.rb +12 -0
  23. data/lib/kentaa/api/requests/teams.rb +19 -0
  24. data/lib/kentaa/api/responses/action.rb +114 -0
  25. data/lib/kentaa/api/responses/actions.rb +34 -0
  26. data/lib/kentaa/api/responses/address.rb +33 -0
  27. data/lib/kentaa/api/responses/banner.rb +29 -0
  28. data/lib/kentaa/api/responses/base.rb +21 -0
  29. data/lib/kentaa/api/responses/donation.rb +142 -0
  30. data/lib/kentaa/api/responses/donations.rb +34 -0
  31. data/lib/kentaa/api/responses/newsletter_subscription.rb +33 -0
  32. data/lib/kentaa/api/responses/newsletter_subscriptions.rb +34 -0
  33. data/lib/kentaa/api/responses/owner.rb +37 -0
  34. data/lib/kentaa/api/responses/pagination.rb +47 -0
  35. data/lib/kentaa/api/responses/photo.rb +17 -0
  36. data/lib/kentaa/api/responses/project.rb +102 -0
  37. data/lib/kentaa/api/responses/projects.rb +34 -0
  38. data/lib/kentaa/api/responses/question.rb +21 -0
  39. data/lib/kentaa/api/responses/resource.rb +21 -0
  40. data/lib/kentaa/api/responses/reward.rb +29 -0
  41. data/lib/kentaa/api/responses/segment.rb +70 -0
  42. data/lib/kentaa/api/responses/segments.rb +34 -0
  43. data/lib/kentaa/api/responses/site.rb +82 -0
  44. data/lib/kentaa/api/responses/team.rb +128 -0
  45. data/lib/kentaa/api/responses/teams.rb +34 -0
  46. data/lib/kentaa/api/responses/video.rb +17 -0
  47. data/lib/kentaa/api/version.rb +5 -0
  48. data/lib/kentaa/api.rb +40 -0
  49. metadata +153 -0
@@ -0,0 +1,21 @@
1
+ module Kentaa
2
+ module Api
3
+ module Responses
4
+ class Question < Base
5
+ include Kentaa::Api::Responses::Resource
6
+
7
+ def initialize(response)
8
+ super(response)
9
+ end
10
+
11
+ def question
12
+ data[:question]
13
+ end
14
+
15
+ def answer
16
+ data[:answer]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'time'
2
+
3
+ module Kentaa
4
+ module Api
5
+ module Responses
6
+ module Resource
7
+ def id
8
+ data[:id]
9
+ end
10
+
11
+ def created_at
12
+ Time.parse(data[:created_at]) if data[:created_at]
13
+ end
14
+
15
+ def updated_at
16
+ Time.parse(data[:updated_at]) if data[:updated_at]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module Kentaa
2
+ module Api
3
+ module Responses
4
+ class Reward < Base
5
+ include Kentaa::Api::Responses::Resource
6
+
7
+ def initialize(response)
8
+ super(response)
9
+ end
10
+
11
+ def type
12
+ data[:type]
13
+ end
14
+
15
+ def title
16
+ data[:title]
17
+ end
18
+
19
+ def description
20
+ data[:description]
21
+ end
22
+
23
+ def ask_for_address?
24
+ data[:ask_for_address]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,70 @@
1
+ require 'bigdecimal'
2
+ require 'time'
3
+
4
+ module Kentaa
5
+ module Api
6
+ module Responses
7
+ class Segment < Base
8
+ include Kentaa::Api::Responses::Resource
9
+
10
+ def initialize(response)
11
+ super(response[:segment] || response)
12
+ end
13
+
14
+ def subdomain
15
+ data[:subdomain]
16
+ end
17
+
18
+ def name
19
+ data[:name]
20
+ end
21
+
22
+ def title
23
+ data[:title]
24
+ end
25
+
26
+ def description
27
+ data[:description]
28
+ end
29
+
30
+ def target_amount
31
+ data[:target_amount]
32
+ end
33
+
34
+ def total_amount
35
+ BigDecimal.new(data[:total_amount])
36
+ end
37
+
38
+ def total_donations
39
+ data[:total_donations]
40
+ end
41
+
42
+ def end_date
43
+ Time.parse(data[:end_date]) if data[:end_date]
44
+ end
45
+
46
+ def url
47
+ data[:url]
48
+ end
49
+
50
+ def donate_url
51
+ data[:donate_url]
52
+ end
53
+
54
+ def banners
55
+ @banners ||= begin
56
+ banners = []
57
+
58
+ if data[:banners]
59
+ data[:banners].each do |banner|
60
+ banners << Kentaa::Api::Responses::Banner.new(banner)
61
+ end
62
+ end
63
+
64
+ banners
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,34 @@
1
+ module Kentaa
2
+ module Api
3
+ module Responses
4
+ class Segments < Base
5
+ include Enumerable
6
+ include Kentaa::Api::Responses::Pagination
7
+
8
+ def initialize(response)
9
+ super(response)
10
+ end
11
+
12
+ def each(&block)
13
+ segments.each(&block)
14
+ end
15
+
16
+ private
17
+
18
+ def segments
19
+ @segments ||= begin
20
+ segments = []
21
+
22
+ if data[:segments]
23
+ data[:segments].each do |segment|
24
+ segments << Kentaa::Api::Responses::Segment.new(segment)
25
+ end
26
+ end
27
+
28
+ segments
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,82 @@
1
+ require 'bigdecimal'
2
+ require 'time'
3
+
4
+ module Kentaa
5
+ module Api
6
+ module Responses
7
+ class Site < Base
8
+ include Kentaa::Api::Responses::Resource
9
+
10
+ def initialize(response)
11
+ super(response[:site] || response)
12
+ end
13
+
14
+ def host
15
+ data[:host]
16
+ end
17
+
18
+ def name
19
+ data[:name]
20
+ end
21
+
22
+ def title
23
+ data[:title]
24
+ end
25
+
26
+ def description
27
+ data[:description]
28
+ end
29
+
30
+ def target_amount
31
+ data[:target_amount]
32
+ end
33
+
34
+ def total_amount
35
+ BigDecimal.new(data[:total_amount])
36
+ end
37
+
38
+ def total_donations
39
+ data[:total_donations]
40
+ end
41
+
42
+ def end_date
43
+ Time.parse(data[:end_date]) if data[:end_date]
44
+ end
45
+
46
+ def url
47
+ data[:url]
48
+ end
49
+
50
+ def donate_url
51
+ data[:donate_url]
52
+ end
53
+
54
+ def video_url
55
+ data[:video_url]
56
+ end
57
+
58
+ def owner_name
59
+ data[:owner_name]
60
+ end
61
+
62
+ def owner_email
63
+ data[:owner_email]
64
+ end
65
+
66
+ def banners
67
+ @banners ||= begin
68
+ banners = []
69
+
70
+ if data[:banners]
71
+ data[:banners].each do |banner|
72
+ banners << Kentaa::Api::Responses::Banner.new(banner)
73
+ end
74
+ end
75
+
76
+ banners
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,128 @@
1
+ require 'bigdecimal'
2
+ require 'time'
3
+
4
+ module Kentaa
5
+ module Api
6
+ module Responses
7
+ class Team < Base
8
+ include Kentaa::Api::Responses::Resource
9
+
10
+ def initialize(response)
11
+ super(response[:team] || response)
12
+ end
13
+
14
+ def slug
15
+ data[:slug]
16
+ end
17
+
18
+ def segment_id
19
+ data[:segment_id]
20
+ end
21
+
22
+ def project_id
23
+ data[:project_id]
24
+ end
25
+
26
+ def owner
27
+ @owner ||= Kentaa::Api::Responses::Owner.new(data[:owner])
28
+ end
29
+
30
+ def members
31
+ @members ||= begin
32
+ members = []
33
+
34
+ if data[:members]
35
+ data[:members].each do |member|
36
+ members << Kentaa::Api::Responses::Action.new(member)
37
+ end
38
+ end
39
+
40
+ members
41
+ end
42
+ end
43
+
44
+ def name
45
+ data[:name]
46
+ end
47
+
48
+ def title
49
+ data[:title]
50
+ end
51
+
52
+ def description
53
+ data[:description]
54
+ end
55
+
56
+ def target_amount
57
+ data[:target_amount]
58
+ end
59
+
60
+ def total_amount
61
+ BigDecimal.new(data[:total_amount])
62
+ end
63
+
64
+ def total_donations
65
+ data[:total_donations]
66
+ end
67
+
68
+ def visible?
69
+ data[:visible]
70
+ end
71
+
72
+ def end_date
73
+ Time.parse(data[:end_date]) if data[:end_date]
74
+ end
75
+
76
+ def url
77
+ data[:url]
78
+ end
79
+
80
+ def donate_url
81
+ data[:donate_url]
82
+ end
83
+
84
+ def photos
85
+ @photos ||= begin
86
+ photos = []
87
+
88
+ if data[:photos]
89
+ data[:photos].each do |photo|
90
+ photos << Kentaa::Api::Responses::Photo.new(photo)
91
+ end
92
+ end
93
+
94
+ photos
95
+ end
96
+ end
97
+
98
+ def videos
99
+ @videos ||= begin
100
+ videos = []
101
+
102
+ if data[:videos]
103
+ data[:videos].each do |video|
104
+ videos << Kentaa::Api::Responses::Video.new(video)
105
+ end
106
+ end
107
+
108
+ videos
109
+ end
110
+ end
111
+
112
+ def questions
113
+ @questions ||= begin
114
+ questions = []
115
+
116
+ if data[:questions]
117
+ data[:questions].each do |question|
118
+ questions << Kentaa::Api::Responses::Question.new(question)
119
+ end
120
+ end
121
+
122
+ questions
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,34 @@
1
+ module Kentaa
2
+ module Api
3
+ module Responses
4
+ class Teams < Base
5
+ include Enumerable
6
+ include Kentaa::Api::Responses::Pagination
7
+
8
+ def initialize(response)
9
+ super(response)
10
+ end
11
+
12
+ def each(&block)
13
+ teams.each(&block)
14
+ end
15
+
16
+ private
17
+
18
+ def teams
19
+ @teams ||= begin
20
+ teams = []
21
+
22
+ if data[:teams]
23
+ data[:teams].each do |team|
24
+ teams << Kentaa::Api::Responses::Team.new(team)
25
+ end
26
+ end
27
+
28
+ teams
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ module Kentaa
2
+ module Api
3
+ module Responses
4
+ class Video < Base
5
+ include Kentaa::Api::Responses::Resource
6
+
7
+ def initialize(response)
8
+ super(response)
9
+ end
10
+
11
+ def url
12
+ data[:url]
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Kentaa
2
+ module Api
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
data/lib/kentaa/api.rb ADDED
@@ -0,0 +1,40 @@
1
+ require_relative "api/requests/base"
2
+ require_relative "api/requests/all"
3
+
4
+ require_relative "api/requests/actions"
5
+ require_relative "api/requests/donations"
6
+ require_relative "api/requests/newsletter_subscriptions"
7
+ require_relative "api/requests/projects"
8
+ require_relative "api/requests/segments"
9
+ require_relative "api/requests/sites"
10
+ require_relative "api/requests/teams"
11
+
12
+ require_relative "api/responses/base"
13
+ require_relative "api/responses/pagination"
14
+ require_relative "api/responses/resource"
15
+
16
+ require_relative "api/responses/action"
17
+ require_relative "api/responses/actions"
18
+ require_relative "api/responses/address"
19
+ require_relative "api/responses/banner"
20
+ require_relative "api/responses/donation"
21
+ require_relative "api/responses/donations"
22
+ require_relative "api/responses/newsletter_subscription"
23
+ require_relative "api/responses/newsletter_subscriptions"
24
+ require_relative "api/responses/owner"
25
+ require_relative "api/responses/photo"
26
+ require_relative "api/responses/project"
27
+ require_relative "api/responses/projects"
28
+ require_relative "api/responses/question"
29
+ require_relative "api/responses/reward"
30
+ require_relative "api/responses/segment"
31
+ require_relative "api/responses/segments"
32
+ require_relative "api/responses/site"
33
+ require_relative "api/responses/team"
34
+ require_relative "api/responses/teams"
35
+ require_relative "api/responses/video"
36
+
37
+ require_relative "api/client"
38
+ require_relative "api/http"
39
+
40
+ require_relative "api/version"
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kentaa-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kentaa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.3.2
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.3'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.3.2
75
+ description:
76
+ email:
77
+ - support@kentaa.nl
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - ".rubocop.yml"
85
+ - ".travis.yml"
86
+ - Gemfile
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - bin/console
91
+ - bin/setup
92
+ - kentaa-api.gemspec
93
+ - lib/kentaa/api.rb
94
+ - lib/kentaa/api/client.rb
95
+ - lib/kentaa/api/http.rb
96
+ - lib/kentaa/api/requests/actions.rb
97
+ - lib/kentaa/api/requests/all.rb
98
+ - lib/kentaa/api/requests/base.rb
99
+ - lib/kentaa/api/requests/donations.rb
100
+ - lib/kentaa/api/requests/newsletter_subscriptions.rb
101
+ - lib/kentaa/api/requests/projects.rb
102
+ - lib/kentaa/api/requests/segments.rb
103
+ - lib/kentaa/api/requests/sites.rb
104
+ - lib/kentaa/api/requests/teams.rb
105
+ - lib/kentaa/api/responses/action.rb
106
+ - lib/kentaa/api/responses/actions.rb
107
+ - lib/kentaa/api/responses/address.rb
108
+ - lib/kentaa/api/responses/banner.rb
109
+ - lib/kentaa/api/responses/base.rb
110
+ - lib/kentaa/api/responses/donation.rb
111
+ - lib/kentaa/api/responses/donations.rb
112
+ - lib/kentaa/api/responses/newsletter_subscription.rb
113
+ - lib/kentaa/api/responses/newsletter_subscriptions.rb
114
+ - lib/kentaa/api/responses/owner.rb
115
+ - lib/kentaa/api/responses/pagination.rb
116
+ - lib/kentaa/api/responses/photo.rb
117
+ - lib/kentaa/api/responses/project.rb
118
+ - lib/kentaa/api/responses/projects.rb
119
+ - lib/kentaa/api/responses/question.rb
120
+ - lib/kentaa/api/responses/resource.rb
121
+ - lib/kentaa/api/responses/reward.rb
122
+ - lib/kentaa/api/responses/segment.rb
123
+ - lib/kentaa/api/responses/segments.rb
124
+ - lib/kentaa/api/responses/site.rb
125
+ - lib/kentaa/api/responses/team.rb
126
+ - lib/kentaa/api/responses/teams.rb
127
+ - lib/kentaa/api/responses/video.rb
128
+ - lib/kentaa/api/version.rb
129
+ homepage: https://www.kentaa.nl
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: 2.0.0
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.5.2
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Ruby library for communicating with the Kentaa API
153
+ test_files: []