openstax_api 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/openstax/api/roar.rb +11 -14
- data/lib/openstax/api/rspec_helpers.rb +4 -3
- data/lib/openstax/api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f83c98026dbc9d84ffd602fc06cf65de6b88ee89fe05c72ec01e974d82bf7cef
|
4
|
+
data.tar.gz: 7fa22ec461b66dfd46bf5e73348b33154bf272e68ff38c365cc7c37b26bd657d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b6a34c6c049c3e52a86bd91adb9f9b2275eae3409730af74090ca7bdef314bfafcc58923cd61dcd4f56ecb8ea8b5ec9a543205988acb9706b187a50af05b21
|
7
|
+
data.tar.gz: c967f69e3c85fe37c387ad145156dcc6317545606981fd019c882e22fa0ae231fdc14f2a99bf51a279b172f486b57229c05b3b289980506351b52af1480fef70
|
data/lib/openstax/api/roar.rb
CHANGED
@@ -13,7 +13,7 @@ module OpenStax
|
|
13
13
|
model_klass = relation.base_class
|
14
14
|
OSU::AccessPolicy.require_action_allowed!(:index, current_api_user, model_klass)
|
15
15
|
|
16
|
-
represent_with_options = { user_options: options
|
16
|
+
represent_with_options = { user_options: options, represent_with: represent_with }
|
17
17
|
|
18
18
|
relation.each do |item|
|
19
19
|
# Must be able to read each record
|
@@ -24,11 +24,10 @@ module OpenStax
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def standard_search(klass, routine, represent_with, options={})
|
27
|
-
search_options = { location: nil }
|
28
27
|
user = current_api_user
|
29
28
|
OSU::AccessPolicy.require_action_allowed!(:search, user, klass)
|
30
29
|
|
31
|
-
represent_with_options = { user_options: options
|
30
|
+
represent_with_options = { user_options: options, represent_with: represent_with }
|
32
31
|
|
33
32
|
result = routine.call(params, options)
|
34
33
|
return render_api_errors(result.errors) if result.errors.any?
|
@@ -38,12 +37,11 @@ module OpenStax
|
|
38
37
|
OSU::AccessPolicy.require_action_allowed!(:read, user, item)
|
39
38
|
end
|
40
39
|
|
41
|
-
respond_with outputs,
|
40
|
+
respond_with outputs, { status: :ok, location: nil }.merge(represent_with_options)
|
42
41
|
end
|
43
42
|
|
44
43
|
def standard_create(model, represent_with=nil, options={})
|
45
|
-
|
46
|
-
represent_with_options = { user_options: options }.merge(represent_with: represent_with)
|
44
|
+
represent_with_options = { user_options: options, represent_with: represent_with }
|
47
45
|
|
48
46
|
model.class.transaction do
|
49
47
|
consume!(model, represent_with_options.dup)
|
@@ -51,7 +49,7 @@ module OpenStax
|
|
51
49
|
OSU::AccessPolicy.require_action_allowed!(:create, current_api_user, model)
|
52
50
|
|
53
51
|
if model.save
|
54
|
-
respond_with model,
|
52
|
+
respond_with model, { status: :created, location: nil }.merge(represent_with_options)
|
55
53
|
else
|
56
54
|
render_api_errors(model.errors)
|
57
55
|
end
|
@@ -71,9 +69,7 @@ module OpenStax
|
|
71
69
|
def standard_read(model, represent_with=nil, use_timestamp_for_cache=false, options={})
|
72
70
|
OSU::AccessPolicy.require_action_allowed!(:read, current_api_user, model)
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
respond_with model, represent_with_options \
|
72
|
+
respond_with(model, { user_options: options, represent_with: represent_with }) \
|
77
73
|
if !use_timestamp_for_cache || stale?(model, template: false)
|
78
74
|
end
|
79
75
|
|
@@ -82,7 +78,7 @@ module OpenStax
|
|
82
78
|
OSU::AccessPolicy.require_action_allowed!(:update, current_api_user, model)
|
83
79
|
|
84
80
|
responder_options = { responder: ResponderWithPutPatchDeleteContent }
|
85
|
-
represent_with_options = { user_options: options
|
81
|
+
represent_with_options = { user_options: options, represent_with: represent_with }
|
86
82
|
|
87
83
|
model.with_lock do
|
88
84
|
consume!(model, represent_with_options.dup)
|
@@ -106,7 +102,7 @@ module OpenStax
|
|
106
102
|
if model.respond_to?(:deleted?) && model.deleted?
|
107
103
|
|
108
104
|
responder_options = { responder: ResponderWithPutPatchDeleteContent }
|
109
|
-
represent_with_options = { user_options: options
|
105
|
+
represent_with_options = { user_options: options, represent_with: represent_with }
|
110
106
|
|
111
107
|
model.with_lock do
|
112
108
|
if model.destroy
|
@@ -128,8 +124,9 @@ module OpenStax
|
|
128
124
|
recursive = options.has_key?(:recursive) ? options[:recursive] : true
|
129
125
|
|
130
126
|
responder_options = { responder: ResponderWithPutPatchDeleteContent }
|
131
|
-
represent_with_options = {
|
132
|
-
|
127
|
+
represent_with_options = {
|
128
|
+
user_options: options.except(:recursive), represent_with: represent_with
|
129
|
+
}
|
133
130
|
|
134
131
|
model.with_lock do
|
135
132
|
if model.restore(recursive: recursive)
|
@@ -71,9 +71,10 @@ module OpenStax
|
|
71
71
|
# be a URL fragment string -- in such a case, prepend "/api"
|
72
72
|
# to the front of the URL as a convenience to callers
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
action = "
|
74
|
+
action = action.to_s unless is_a_controller_spec?
|
75
|
+
if action.is_a?(String) && !action.include?('://')
|
76
|
+
action = "/#{action}" if !action.starts_with?('/')
|
77
|
+
action = "/api#{action}" if !action.starts_with?('/api/')
|
77
78
|
end
|
78
79
|
|
79
80
|
send type, action, args
|
data/lib/openstax/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.
|
4
|
+
version: 9.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dante Soares
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
- !ruby/object:Gem::Version
|
275
275
|
version: '0'
|
276
276
|
requirements: []
|
277
|
-
rubygems_version: 3.0.
|
277
|
+
rubygems_version: 3.0.4
|
278
278
|
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: API utilities for OpenStax products and tools.
|