apress-api 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/.drone.yml +30 -0
  3. data/.gitignore +15 -0
  4. data/.rspec +4 -0
  5. data/Appraisals +31 -0
  6. data/CHANGELOG.md +227 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +31 -0
  10. data/Rakefile +2 -0
  11. data/app/controllers/apress/api/deprecated_versions_controller.rb +15 -0
  12. data/app/controllers/apress/api/v1/callbacks_controller.rb +30 -0
  13. data/app/controllers/apress/api/v1/tokens_controller.rb +24 -0
  14. data/app/docs/schema/api/v1/types/apress/api/link.rb +29 -0
  15. data/app/docs/schema/api/v1/types/apress/api/links.rb +24 -0
  16. data/app/docs/swagger/v1/controllers/apress/api/tokens_controller.rb +64 -0
  17. data/app/docs/swagger/v1/default_responses/bad_request.rb +16 -0
  18. data/app/docs/swagger/v1/default_responses/not_found.rb +16 -0
  19. data/app/docs/swagger/v1/default_responses/unauthenticated.rb +16 -0
  20. data/app/docs/swagger/v1/default_responses/unauthorized.rb +16 -0
  21. data/app/docs/swagger/v1/default_responses/unprocessable.rb +16 -0
  22. data/app/docs/swagger/v1/default_responses/updates_locked.rb +13 -0
  23. data/app/docs/swagger/v1/models/apress/api/client.rb +53 -0
  24. data/app/docs/swagger/v1/models/apress/api/simple_error.rb +27 -0
  25. data/app/docs/swagger/v1/models/apress/api/unproccesable_error.rb +16 -0
  26. data/app/docs/swagger/v1/models/apress/api/unprocessable_error.rb +37 -0
  27. data/app/docs/swagger/v1/root.rb +28 -0
  28. data/app/interactors/apress/api/callbacks/base_callback.rb +42 -0
  29. data/app/interactors/apress/api/delayed_fire_callback.rb +25 -0
  30. data/app/jobs/apress/api/event_handler_enqueueing_job.rb +19 -0
  31. data/app/jobs/apress/api/fire_callback_job.rb +25 -0
  32. data/app/models/apress/api/client.rb +60 -0
  33. data/app/policies/apress/api/callback_policy.rb +15 -0
  34. data/app/services/apress/api/auth_service.rb +37 -0
  35. data/app/views/apress/api/shared/_exception.json.jbuilder +4 -0
  36. data/app/views/apress/api/shared/error.json.jbuilder +5 -0
  37. data/app/views/apress/api/shared/parameter_missing_errors.json.jbuilder +9 -0
  38. data/app/views/apress/api/shared/unprocessable_errors.json.jbuilder +9 -0
  39. data/app/views/apress/api/v1/clients/_client.json.jbuilder +2 -0
  40. data/app/views/apress/api/v1/tokens/create.json.jbuilder +4 -0
  41. data/apress-api.gemspec +46 -0
  42. data/config/routes.rb +17 -0
  43. data/db/migrate/20150716000000_create_api_clients.rb +38 -0
  44. data/dip.yml +48 -0
  45. data/docker-compose.development.yml +18 -0
  46. data/docker-compose.drone.yml +7 -0
  47. data/docker-compose.yml +20 -0
  48. data/lib/apress-api.rb +1 -0
  49. data/lib/apress/api.rb +25 -0
  50. data/lib/apress/api/api_controller/authentification.rb +33 -0
  51. data/lib/apress/api/api_controller/base.rb +63 -0
  52. data/lib/apress/api/api_controller/compatibility.rb +26 -0
  53. data/lib/apress/api/api_controller/pagination.rb +60 -0
  54. data/lib/apress/api/api_controller/pagination_helper.rb +55 -0
  55. data/lib/apress/api/api_controller/rescue.rb +89 -0
  56. data/lib/apress/api/api_controller/responds.rb +25 -0
  57. data/lib/apress/api/callbacks/config.rb +56 -0
  58. data/lib/apress/api/callbacks/fire_callback_error.rb +12 -0
  59. data/lib/apress/api/callbacks/integration.rb +28 -0
  60. data/lib/apress/api/callbacks/repeat_callback_error.rb +12 -0
  61. data/lib/apress/api/engine.rb +33 -0
  62. data/lib/apress/api/extensions/jbuilder/jbuilder_template.rb +41 -0
  63. data/lib/apress/api/rspec.rb +48 -0
  64. data/lib/apress/api/rspec/utils.rb +17 -0
  65. data/lib/apress/api/testing/json_matcher.rb +9 -0
  66. data/lib/apress/api/version.rb +5 -0
  67. data/lib/tasks/docs.rake +12 -0
  68. data/spec/controllers/api_controller/authentification_spec.rb +79 -0
  69. data/spec/controllers/api_controller/pagination_spec.rb +199 -0
  70. data/spec/controllers/api_controller/rescue_spec.rb +167 -0
  71. data/spec/controllers/deprecated_versions_controller_spec.rb +10 -0
  72. data/spec/controllers/v1/callbacks_controller_spec.rb +50 -0
  73. data/spec/controllers/v1/tokens_controller_spec.rb +53 -0
  74. data/spec/factories/client_factory.rb +4 -0
  75. data/spec/helpers/paginating_cache_spec.rb +72 -0
  76. data/spec/interactors/apress/api/delayed_fire_callback_spec.rb +43 -0
  77. data/spec/internal/app/integrations/error_client/fire_callback.rb +14 -0
  78. data/spec/internal/app/integrations/service_client/fire_callback.rb +7 -0
  79. data/spec/internal/app/jobs/handler_job.rb +5 -0
  80. data/spec/internal/app/jobs/second_handler_job.rb +5 -0
  81. data/spec/internal/app/models/dummy_model.rb +15 -0
  82. data/spec/internal/config/database.yml +5 -0
  83. data/spec/internal/config/environments/test.rb +5 -0
  84. data/spec/internal/config/initializers/api.rb +10 -0
  85. data/spec/internal/config/routes.rb +3 -0
  86. data/spec/internal/db/schema.rb +5 -0
  87. data/spec/internal/log/.gitignore +1 -0
  88. data/spec/jobs/apress/api/event_handler_equeueing_job_spec.rb +31 -0
  89. data/spec/jobs/apress/api/fire_callback_job_spec.rb +34 -0
  90. data/spec/lib/apress/api/callbacks/integration_spec.rb +24 -0
  91. data/spec/models/client_spec.rb +25 -0
  92. data/spec/services/auth_service_spec.rb +64 -0
  93. data/spec/spec_helper.rb +34 -0
  94. metadata +518 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0675e01e2bf8451ccf0aea116eb8210702f95f4a
4
+ data.tar.gz: f845d4e05146deefea5441834397d667069d3239
5
+ SHA512:
6
+ metadata.gz: b555258e9441cf634c25eeb41a918f69fdd70fe98a109a2b509c791449937bbd2eb9296c167fc167e47cbdf4831dace20835e437d38eb2e9e1f6145955288b87
7
+ data.tar.gz: 7dd2ba7675a18d8696af7f24a813493df6eb7feb40b2afbee180f890bdd26ce65c02e43b6da45a033ab0ba3fb0e7dfaffab2e5d22e0c451f1c511ebcd94cb1f1
data/.drone.yml ADDED
@@ -0,0 +1,30 @@
1
+ build:
2
+ test:
3
+ image: abakpress/dind-testing
4
+ privileged: true
5
+ pull: true
6
+ volumes:
7
+ - /home/data/drone/images:/images
8
+ - /home/data/drone/gems:/bundle
9
+ environment:
10
+ - COMPOSE_FILE_EXT=drone
11
+ - RUBY_IMAGE_TAG=2.2-latest
12
+ - POSTGRES_IMAGE_TAG=9.3-latest
13
+ commands:
14
+ - wrapdocker docker -v
15
+
16
+ - fetch-images --image abakpress/ruby-app:$RUBY_IMAGE_TAG
17
+
18
+ - dip provision
19
+ - dip rspec
20
+
21
+ release:
22
+ image: abakpress/gem-publication
23
+ pull: true
24
+ when:
25
+ event: push
26
+ branch: master
27
+ volumes:
28
+ - /home/data/drone/rubygems:/root/.gem
29
+ commands:
30
+ - release-gem --public
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ gemfiles/
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --tty
3
+ --format progress
4
+ --order random
data/Appraisals ADDED
@@ -0,0 +1,31 @@
1
+ appraise "rails3.2" do
2
+ gem "rails", "~> 3.2.0", require: false
3
+ gem "strong_parameters", ">= 0.2", require: false
4
+ end
5
+
6
+ appraise "rails4.0" do
7
+ gem "rails", "~> 4.0.0", require: false
8
+ end
9
+
10
+ appraise "rails4.1" do
11
+ gem "rails", "~> 4.1.0", require: false
12
+ end
13
+
14
+ appraise "rails4.2" do
15
+ gem "rails", "~> 4.2.0", require: false
16
+ end
17
+
18
+ appraise "rails5.0" do
19
+ gem "rails", "~> 5.0.0", require: false
20
+ gem "rails-controller-testing", require: false
21
+ end
22
+
23
+ appraise "rails5.1" do
24
+ gem "rails", "~> 5.1.0", require: false
25
+ gem "rails-controller-testing", require: false
26
+ end
27
+
28
+ appraise "rails5.2" do
29
+ gem "rails", "~> 5.2.0", require: false
30
+ gem "rails-controller-testing", require: false
31
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,227 @@
1
+ # v1.22.0
2
+
3
+ * 2018-08-22 [7bb90fa](../../commit/7bb90fa) - __(Artem Napolskih)__ chore: Add automatic publication
4
+ * 2018-08-20 [ce83eba](../../commit/ce83eba) - __(Artem Napolskih)__ feat: rails 5-x support
5
+
6
+ # v1.21.0
7
+
8
+ * 2018-07-19 [09ac671](../../commit/09ac671) - __(Zhidkov Denis)__ feat: allow to add several handlers for each service event
9
+ https://jira.railsc.ru/browse/ORDERS-1916
10
+
11
+ # v1.20.2
12
+
13
+ * 2018-05-31 [e950f34](../../commit/e950f34) - __(Denis Korobicyn)__ fix: add rescue instead of stub in tests
14
+
15
+ # v1.20.1
16
+
17
+ * 2018-05-30 [4ffdc34](../../commit/4ffdc34) - __(Denis Korobicyn)__ Version 1.20.1
18
+ * 2018-05-30 [8f0930f](../../commit/8f0930f) - __(Denis Korobicyn)__ fix: autoload for pagination headers
19
+
20
+ # v1.20.0
21
+
22
+ * 2018-05-29 [876a71c](../../commit/876a71c) - __(Denis Korobicyn)__ feature: add correct headers on json pagination cache
23
+ https://jira.railsc.ru/browse/ORDERS-1524
24
+
25
+ # v1.19.2
26
+
27
+ * 2018-04-16 [243a81f](../../commit/243a81f) - __(Denis Korobicyn)__ feature(callbacks): add inf reapet errors
28
+ https://jira.railsc.ru/browse/ORDERS-1484
29
+
30
+ * 2018-04-11 [ca1c1f2](../../commit/ca1c1f2) - __(Denis Korobicyn)__ fix(callbacks): add exponential backoff
31
+ https://jira.railsc.ru/browse/ORDERS-1484
32
+
33
+ # v1.19.1
34
+
35
+ * 2018-04-10 [bf3b4ce](../../commit/bf3b4ce) - __(Denis Korobicyn)__ chore(dorne): allow only master release
36
+ * 2018-04-06 [553c515](../../commit/553c515) - __(Denis Korobicyn)__ fix(callbacks): add fatal exeptions
37
+ https://jira.railsc.ru/browse/ORDERS-1484
38
+
39
+ # v1.19.0
40
+
41
+ * 2018-04-03 [12aa8e0](../../commit/12aa8e0) - __(Denis Korobicyn)__ feature: add callbacks logic
42
+ https://jira.railsc.ru/browse/ORDERS-1484
43
+
44
+ # v1.18.0
45
+
46
+ * 2018-01-30 [26a7884](../../commit/26a7884) - __(Dmitry Bochkarev)__ chore: restrict pg version
47
+ http://samson.railsc.ru/projects/pulscen-production/deploys/9785
48
+ https://jira.railsc.ru/browse/PC4-21470
49
+
50
+ https://github.com/abak-press/pulscen/commit/ff1e27f89c45a30bb0479383d864a15a526422fd
51
+ https://github.com/abak-press/pulscen/pull/16479
52
+
53
+ * 2017-12-22 [33d5523](../../commit/33d5523) - __(Dmitry Bochkarev)__ fix(newrelic): не реквайрим устаревший модуль
54
+ https://jira.railsc.ru/browse/PC4-19900
55
+
56
+ * 2017-12-22 [5132ad7](../../commit/5132ad7) - __(Dmitry Bochkarev)__ fix(new_relic): выпил ::NewRelic::Agent::Instrumentation::Rails3::Errors
57
+ https://jira.railsc.ru/browse/PC4-19900
58
+
59
+ модуль был удален, использвание методов в коде нет:
60
+ https://jira.railsc.ru/browse/PC4-19900?focusedCommentId=146483&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-146483
61
+
62
+ # v1.17.1
63
+
64
+ * 2017-09-07 [08c3799](../../commit/08c3799) - __(Denis Korobicyn)__ fix: api tests
65
+
66
+ # v1.17.0
67
+
68
+ * 2017-06-28 [96ff1ea](../../commit/96ff1ea) - __(Denis Korobicyn)__ fix: namespaces for default responses
69
+ https://jira.railsc.ru/browse/PC4-19812
70
+
71
+ * 2017-04-25 [0cc731e](../../commit/0cc731e) - __(Denis Korobicyn)__ feature: move swagger to apress-documentation
72
+ https://jira.railsc.ru/browse/PC4-19470
73
+
74
+ # v1.16.1
75
+
76
+ * 2017-08-02 [9f03ee6](../../commit/9f03ee6) - __(Artem Napolskih)__ fix: rails 4 New Relic support
77
+
78
+ # v1.16.0
79
+
80
+ * 2017-07-31 [2da0e08](../../commit/2da0e08) - __(Artem Napolskih)__ feature: Add tokens controller load hook
81
+
82
+ # v1.15.0
83
+
84
+ * 2017-07-28 [ee55219](../../commit/ee55219) - __(Artem Napolskih)__ feature: no find Client when access_id not given
85
+
86
+ # v1.14.0
87
+
88
+ * 2017-07-18 [df408d2](../../commit/df408d2) - __(Nikolay Kondratyev)__ feat(swagger): add type representing a links object
89
+
90
+ # v1.13.0
91
+
92
+ * 2017-07-13 [10c6c6c](../../commit/10c6c6c) - __(Dmitry Bochkarev)__ fix(drone): неверные отступы в .drone.yml
93
+ при возникновении ошибки ActionController::ParameterMissing
94
+ возвращается 400 статус, а не 404
95
+
96
+ * 2017-07-09 [8ee510c](../../commit/8ee510c) - __(Dmitry Bochkarev)__ fix: 400 статус для ActionController::ParameterMissing
97
+ * 2017-06-27 [98e02cd](../../commit/98e02cd) - __(Semyon Pupkov)__ chore: add rails 4.0 and 4.1 to Appraisals
98
+ * 2017-05-25 [4d746a4](../../commit/4d746a4) - __(JSinx)__ Release 1.12.1
99
+ * 2017-05-25 [ef793b8](../../commit/ef793b8) - __(JSinx)__ fix(client): namespace Apress::Api for model Client
100
+ * 2017-04-21 [db5ac0e](../../commit/db5ac0e) - __(Semyon Pupkov)__ chore: require only necessary files
101
+ * 2017-04-20 [d5a9c5a](../../commit/d5a9c5a) - __(Semyon Pupkov)__ chore: remove support for rails 3.1 and ruby 1.9
102
+
103
+ # v1.12.0
104
+
105
+ * 2017-02-10 [a54b723](../../commit/a54b723) - __(Nikolay Kondratyev)__ feat(gems): update swagger-core dependency
106
+ * 2017-02-21 [45b4bee](../../commit/45b4bee) - __(Andrey Shmelkov)__ feature(pagination): Link, X-Per-Page, X-Page headers
107
+ В метод #pagination_headers добавлена поддержка заголовков X-Page,
108
+ X-Per-Page и Link (RFC 5988)
109
+
110
+ https://jira.railsc.ru/browse/RAD-294
111
+
112
+ # v1.11.0
113
+
114
+ * 2017-01-10 [e7048d7](../../commit/e7048d7) - __(Semyon Pupkov)__ feature: render status in body for unproccesable error
115
+
116
+ # v1.10.2
117
+
118
+ * 2017-01-11 [6da5c9c](../../commit/6da5c9c) - __(Semyon Pupkov)__ fix: old UnproccesableError class does not work across alias
119
+ https://github.com/abak-press/apress-api/issues/34
120
+
121
+ # v1.10.1
122
+
123
+ * 2016-12-26 [7663d55](../../commit/7663d55) - __(Michail Merkushin)__ fix: Include Newrelic modules for different Rails versions
124
+ https://jira.railsc.ru/browse/PC4-18051
125
+
126
+ # v1.10.0
127
+
128
+ * 2016-12-09 [3a4459f](../../commit/3a4459f) - __(Pavel Galkin)__ fix: move UnproccesableError alias to a separate file
129
+ * 2016-12-08 [ef4ece2](../../commit/ef4ece2) - __(Nikolay Kondratyev)__ feat(gems): add swagger-core dependency
130
+ * 2016-12-08 [2f188ce](../../commit/2f188ce) - __(Nikolay Kondratyev)__ feat(rspec): add swagger schema matcher
131
+ * 2016-11-29 [12c2a02](../../commit/12c2a02) - __(Nikolay Kondratyev)__ fix: security definitions
132
+ * 2016-12-07 [eb10a20](../../commit/eb10a20) - __(Pavel Galkin)__ fix: typo in error class
133
+ Сложное слово!
134
+
135
+ # v1.9.0
136
+
137
+ * 2016-12-06 [7ea5ec2](../../commit/7ea5ec2) - __(Michail Merkushin)__ chore: Add drone and dip
138
+ * 2016-12-05 [1242c99](../../commit/1242c99) - __(Michail Merkushin)__ feature: Add newrelic tracers
139
+ https://jira.railsc.ru/browse/PC4-18051
140
+
141
+ # v1.8.3
142
+
143
+ * 2016-09-21 [c7659b1](../../commit/c7659b1) - __(Semyon Pupkov)__ refactor: remove dependency from migration_comments
144
+ * 2016-09-21 [c157718](../../commit/c157718) - __(Semyon Pupkov)__ chore: add docker-compose
145
+
146
+ # v1.8.2
147
+
148
+ * 2016-09-12 [2f52c26](../../commit/2f52c26) - __(Denis Korobicyn)__ chore: lock rails < 5.0.0
149
+ * 2016-09-12 [cbb16ec](../../commit/cbb16ec) - __(Denis Korobicyn)__ fix: remove asset_path hacks
150
+ https://jira.railsc.ru/browse/PC4-17992
151
+
152
+ # v1.8.1
153
+
154
+ * 2016-08-23 [4f83163](../../commit/4f83163) - __(Salahutdinov Dmitry)__ feature: speed up swagger load
155
+ * 2016-08-11 [0adce54](../../commit/0adce54) - __(Salahutdinov Dmitry)__ fix: minor type fix
156
+ * 2016-08-10 [93678e7](../../commit/93678e7) - __(Salahutdinov Dmitry)__ fix: try out swaggered api from any host/port, use hostless path
157
+
158
+ # v1.8.0
159
+
160
+ * 2016-07-13 [59e65ec](../../commit/59e65ec) - __(Denis Korobicyn)__ feature: swagger documentation
161
+
162
+ # v1.7.0
163
+
164
+ * 2016-07-20 [39880d3](../../commit/39880d3) - __(Sergey Kucher)__ feature: ability to handle standard error's descendants for unprocessable
165
+ https://jira.railsc.ru/browse/ORDERS-86
166
+
167
+ # v1.6.0
168
+
169
+ * 2016-06-06 [022ec6a](../../commit/022ec6a) - __(Denis Korobicyn)__ feature: unproccessable method
170
+
171
+ # v1.5.0
172
+
173
+ * 2016-05-06 [c8935c8](../../commit/c8935c8) - __(Denis Korobicyn)__ feature: paginating params preprocessing
174
+
175
+ # v1.4.0
176
+
177
+ * 2016-04-29 [1635272](../../commit/1635272) - __(Denis Korobicyn)__ feature: json paginating_cache helper
178
+ https://jira.railsc.ru/browse/PC4-17107
179
+
180
+ * 2016-04-22 [966ac22](../../commit/966ac22) - __(Denis Korobicyn)__ feature: removed cache stubs
181
+ https://jira.railsc.ru/browse/PC4-17107
182
+
183
+ # v1.3.0
184
+
185
+ * 2016-04-25 [faf3bde](../../commit/faf3bde) - __(Michail Merkushin)__ feature: Allways find current_api_client
186
+
187
+ # v1.2.0
188
+
189
+ * 2016-03-28 [20d6676](../../commit/20d6676) - __(Salahutdinov Dmitry)__ feature: пагинация в заголовках
190
+ https://jira.railsc.ru/browse/PC4-16460
191
+
192
+ # v1.1.0
193
+
194
+ * 2016-03-14 [cb8f200](../../commit/cb8f200) - __(Denis Korobitcin)__ feature: added caching module
195
+ https://jira.railsc.ru/browse/PC4-16800
196
+
197
+ # v1.0.0
198
+
199
+ * 2016-01-10 [464b9c8](../../commit/464b9c8) - __(Michail Merkushin)__ feature: not always return 200 when ajax
200
+ https://jira.railsc.ru/browse/PC4-16378
201
+
202
+ # v0.2.1
203
+
204
+ * 2015-12-16 [d5d46a6](../../commit/d5d46a6) - __(Michail Merkushin)__ feature: make AuthService#access_id as public meth
205
+ https://jira.railsc.ru/browse/PC4-16202
206
+
207
+ # v0.2.0
208
+
209
+ * 2015-11-18 [4b336ed](../../commit/4b336ed) - __(Denis Korobitcin)__ feature(api-rescue): render_json method
210
+
211
+ # v0.1.0
212
+
213
+ * 2015-09-17 [b09a647](../../commit/b09a647) - __(Sergey Kucher)__ chore: move match_json_schema from barmen pc4-15522
214
+
215
+ # v0.0.2
216
+
217
+ * 2015-08-12 [a1f5e0d](../../commit/a1f5e0d) - __(Michail Merkushin)__ feature: respond with 403 on Pundit errors
218
+ https://jira.railsc.ru/browse/PC4-15338
219
+
220
+ # v0.0.1
221
+
222
+ * 2015-08-06 [cf77643](../../commit/cf77643) - __(bibendi)__ move column device_id to gem api-application
223
+ * 2015-08-05 [eba14a6](../../commit/eba14a6) - __(bibendi)__ fix: add lazy load hook on client and small fixes
224
+ https://jira.railsc.ru/browse/PC4-15271
225
+
226
+ * 2015-07-22 [015c863](../../commit/015c863) - __(bibendi)__ Initial commit
227
+ * 2015-07-17 [dcee43c](../../commit/dcee43c) - __(Artem Napolskih)__ Initial commit
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://gems.railsc.ru"
2
+ source "https://rubygems.org"
3
+
4
+ # Specify your gem's dependencies in apress-api.gemspec
5
+ gemspec
6
+
7
+
8
+ gem "pg", "< 1.0", require: false
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 bibendi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Apress::Api
2
+
3
+ Базовый контроллер АПИ с авторизацией HMAC
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'apress-api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install apress-api
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/abak-press/apress-api/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,15 @@
1
+ module Apress
2
+ module Api
3
+ class DeprecatedVersionsController < ApiController::Base
4
+ if (Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR == 2) || Rails::VERSION::MAJOR > 4
5
+ skip_before_action :authenticate, only: :show
6
+ else
7
+ skip_before_filter :authenticate, only: :show
8
+ end
9
+
10
+ def show
11
+ render_error(410)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ module Apress
2
+ module Api
3
+ module V1
4
+ class CallbacksController < ApiController::Base
5
+ include Pundit
6
+
7
+ def create
8
+ authorize :'apress/api/callback'
9
+
10
+ event_params = params[:params] || {}
11
+
12
+ Resque.redis.multi do
13
+ Apress::Api::Callbacks::Config.handlers(
14
+ service: params.require(:service),
15
+ event: params.require(:event)
16
+ ).each { |handler| Resque.enqueue(Apress::Api::EventHandlerEnqueueingJob, handler, event_params) }
17
+ end
18
+
19
+ head 201
20
+ end
21
+
22
+ private
23
+
24
+ def pundit_user
25
+ current_api_client
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module Apress
2
+ module Api
3
+ module V1
4
+ class TokensController < ApiController::Base
5
+ if (Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR == 2) || Rails::VERSION::MAJOR > 4
6
+ skip_before_action :authenticate, only: :create
7
+ else
8
+ skip_before_filter :authenticate, only: :create
9
+ end
10
+
11
+ def create
12
+ @client = Apress::Api::Client.find_by_access_id!(params.require(:client_id))
13
+
14
+ return bad_request if @client.refresh_token != params.require(:refresh_token)
15
+ return forbidden if @client.refresh_token_expired?
16
+
17
+ @client.regenerate_tokens!
18
+ end
19
+
20
+ ActiveSupport.run_load_hooks(:"apress/api/tokens_controller", self)
21
+ end
22
+ end
23
+ end
24
+ end