wikidata_adaptor 1.0.0
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 +7 -0
- data/.env.test +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +45 -0
- data/.yardopts +10 -0
- data/CHANGELOG.md +106 -0
- data/CLAUDE.md +200 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/COVERAGE.md +77 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +124 -0
- data/LICENSE.txt +21 -0
- data/README.md +269 -0
- data/Rakefile +18 -0
- data/integration/.env.example +20 -0
- data/integration/README.md +58 -0
- data/integration/config/99_IntegrationTesting.php +3 -0
- data/integration/config/wikibase-php.ini +15 -0
- data/integration/docker-compose.yml +98 -0
- data/lib/wikidata_adaptor/rest_api/aliases.rb +88 -0
- data/lib/wikidata_adaptor/rest_api/descriptions.rb +138 -0
- data/lib/wikidata_adaptor/rest_api/items.rb +36 -0
- data/lib/wikidata_adaptor/rest_api/labels.rb +138 -0
- data/lib/wikidata_adaptor/rest_api/open_api_document.rb +15 -0
- data/lib/wikidata_adaptor/rest_api/properties.rb +36 -0
- data/lib/wikidata_adaptor/rest_api/property_data_types.rb +15 -0
- data/lib/wikidata_adaptor/rest_api/search_item.rb +44 -0
- data/lib/wikidata_adaptor/rest_api/search_property.rb +44 -0
- data/lib/wikidata_adaptor/rest_api/sitelinks.rb +59 -0
- data/lib/wikidata_adaptor/rest_api/statements.rb +153 -0
- data/lib/wikidata_adaptor/rest_api.rb +32 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/aliases.rb +229 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/descriptions.rb +308 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/items.rb +213 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/labels.rb +302 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/open_api_document.rb +29 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/properties.rb +233 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/property_data_types.rb +23 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/search_item.rb +118 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/search_property.rb +118 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/sitelinks.rb +143 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/statements.rb +475 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api/support/support.rb +310 -0
- data/lib/wikidata_adaptor/test_helpers/rest_api.rb +89 -0
- data/lib/wikidata_adaptor/version.rb +6 -0
- data/lib/wikidata_adaptor.rb +28 -0
- data/sig/wikidata_adaptor.rbs +4 -0
- metadata +106 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module WikidataAdaptor
|
|
4
|
+
module TestHelpers
|
|
5
|
+
module RestApi
|
|
6
|
+
# WebMock stubs for Wikibase REST API statements endpoints
|
|
7
|
+
module Statements
|
|
8
|
+
#########################################
|
|
9
|
+
# GET /v1/entities/items/:item_id/statements
|
|
10
|
+
#########################################
|
|
11
|
+
def stub_get_item_statements(item_id, response_body = nil)
|
|
12
|
+
stub_rest_api_request(
|
|
13
|
+
:get,
|
|
14
|
+
"/v1/entities/items/#{item_id}/statements",
|
|
15
|
+
response_body: response_body || {
|
|
16
|
+
additionalProp1: [
|
|
17
|
+
{
|
|
18
|
+
id: "Q11$6403c562-401a-2b26-85cc-8327801145e1",
|
|
19
|
+
rank: "normal",
|
|
20
|
+
property: { id: "P92", "data-type": "string" },
|
|
21
|
+
value: { content: "I am a goat", type: "value" },
|
|
22
|
+
qualifiers: [],
|
|
23
|
+
references: []
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
########################################################
|
|
31
|
+
# GET /v1/entities/items/:item_id/statements/:statement_id
|
|
32
|
+
########################################################
|
|
33
|
+
def stub_get_item_statement(item_id, statement_id)
|
|
34
|
+
stub_rest_api_request(
|
|
35
|
+
:get,
|
|
36
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
37
|
+
response_body: {
|
|
38
|
+
id: statement_id.to_s,
|
|
39
|
+
rank: "normal",
|
|
40
|
+
property: { id: "P92", "data-type": "string" },
|
|
41
|
+
value: { content: "I am a goat", type: "value" },
|
|
42
|
+
qualifiers: [],
|
|
43
|
+
references: []
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##########################################
|
|
49
|
+
# POST /v1/entities/items/:item_id/statements
|
|
50
|
+
##########################################
|
|
51
|
+
def stub_post_item_statement(item_id, payload, response_body: nil)
|
|
52
|
+
stub_rest_api_request(
|
|
53
|
+
:post,
|
|
54
|
+
"/v1/entities/items/#{item_id}/statements",
|
|
55
|
+
response_status: 201,
|
|
56
|
+
with: { body: payload.to_json },
|
|
57
|
+
response_body: response_body || {
|
|
58
|
+
id: "Q42$6403c562-401a-2b26-85cc-8327801145e1",
|
|
59
|
+
rank: "normal",
|
|
60
|
+
property: { id: "P92", "data-type": "string" },
|
|
61
|
+
value: { content: "I am a goat", type: "value" },
|
|
62
|
+
qualifiers: [],
|
|
63
|
+
references: []
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Stub POST item statement request returning 500 error
|
|
69
|
+
#
|
|
70
|
+
# @param item_id [String] The item ID
|
|
71
|
+
# @param payload [Hash] The request payload
|
|
72
|
+
#
|
|
73
|
+
# @return [WebMock::RequestStub]
|
|
74
|
+
def stub_post_item_statement_unexpected_error(item_id, payload)
|
|
75
|
+
stub_rest_api_request(
|
|
76
|
+
:post,
|
|
77
|
+
"/v1/entities/items/#{item_id}/statements",
|
|
78
|
+
response_status: 500,
|
|
79
|
+
with: { body: payload.to_json },
|
|
80
|
+
response_body: {
|
|
81
|
+
code: "unexpected-error",
|
|
82
|
+
message: "Unexpected Error"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
###############################
|
|
88
|
+
# GET /v1/statements/:statement_id
|
|
89
|
+
###############################
|
|
90
|
+
def stub_get_statement(statement_id)
|
|
91
|
+
stub_rest_api_request(
|
|
92
|
+
:get,
|
|
93
|
+
"/v1/statements/#{statement_id}",
|
|
94
|
+
response_body: {
|
|
95
|
+
id: statement_id.to_s,
|
|
96
|
+
rank: "normal",
|
|
97
|
+
property: { id: "P92", "data-type": "string" },
|
|
98
|
+
value: { content: "I am a goat", type: "value" },
|
|
99
|
+
qualifiers: [],
|
|
100
|
+
references: []
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
############################################
|
|
106
|
+
# GET /v1/entities/properties/:property_id/statements
|
|
107
|
+
############################################
|
|
108
|
+
def stub_get_property_statements(property_id, response_body = nil)
|
|
109
|
+
stub_rest_api_request(
|
|
110
|
+
:get,
|
|
111
|
+
"/v1/entities/properties/#{property_id}/statements",
|
|
112
|
+
response_body: response_body || {}
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
##################################################################
|
|
117
|
+
# GET /v1/entities/properties/:property_id/statements/:statement_id
|
|
118
|
+
##################################################################
|
|
119
|
+
def stub_get_property_statement(property_id, statement_id)
|
|
120
|
+
stub_rest_api_request(
|
|
121
|
+
:get,
|
|
122
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
123
|
+
response_body: {
|
|
124
|
+
id: statement_id.to_s,
|
|
125
|
+
rank: "normal",
|
|
126
|
+
property: { id: property_id.to_s, "data-type": "wikibase-item" },
|
|
127
|
+
value: { content: "Q5", type: "value" },
|
|
128
|
+
qualifiers: [],
|
|
129
|
+
references: []
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
##################################################
|
|
135
|
+
# POST /v1/entities/properties/:property_id/statements
|
|
136
|
+
##################################################
|
|
137
|
+
def stub_post_property_statement(property_id, payload, response_body: nil)
|
|
138
|
+
stub_rest_api_request(
|
|
139
|
+
:post,
|
|
140
|
+
"/v1/entities/properties/#{property_id}/statements",
|
|
141
|
+
response_status: 201,
|
|
142
|
+
with: { body: payload.to_json },
|
|
143
|
+
response_body: response_body || {
|
|
144
|
+
id: "P31$11111111-2222-3333-4444-555555555555",
|
|
145
|
+
rank: "normal",
|
|
146
|
+
property: { id: property_id.to_s, "data-type": "wikibase-item" },
|
|
147
|
+
value: { content: "Q5", type: "value" },
|
|
148
|
+
qualifiers: [],
|
|
149
|
+
references: []
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Stub POST property statement request returning 500 error
|
|
155
|
+
#
|
|
156
|
+
# @param property_id [String] The property ID
|
|
157
|
+
# @param payload [Hash] The request payload
|
|
158
|
+
#
|
|
159
|
+
# @return [WebMock::RequestStub]
|
|
160
|
+
def stub_post_property_statement_unexpected_error(property_id, payload)
|
|
161
|
+
stub_rest_api_request(
|
|
162
|
+
:post,
|
|
163
|
+
"/v1/entities/properties/#{property_id}/statements",
|
|
164
|
+
response_status: 500,
|
|
165
|
+
with: { body: payload.to_json },
|
|
166
|
+
response_body: {
|
|
167
|
+
code: "unexpected-error",
|
|
168
|
+
message: "Unexpected Error"
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
############################################################
|
|
174
|
+
# PUT /v1/entities/items/:item_id/statements/:statement_id
|
|
175
|
+
############################################################
|
|
176
|
+
def stub_put_item_statement(item_id, statement_id, payload, response_body: nil)
|
|
177
|
+
stub_rest_api_request(
|
|
178
|
+
:put,
|
|
179
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
180
|
+
with: { body: payload.to_json },
|
|
181
|
+
response_body: response_body || {
|
|
182
|
+
id: statement_id.to_s,
|
|
183
|
+
rank: "normal",
|
|
184
|
+
property: { id: "P92", "data-type": "string" },
|
|
185
|
+
value: { content: "Updated goat", type: "value" },
|
|
186
|
+
qualifiers: [],
|
|
187
|
+
references: []
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Stub PUT item statement request returning 500 error
|
|
193
|
+
#
|
|
194
|
+
# @param item_id [String] The item ID
|
|
195
|
+
# @param statement_id [String] The statement ID
|
|
196
|
+
# @param payload [Hash] The request payload
|
|
197
|
+
#
|
|
198
|
+
# @return [WebMock::RequestStub]
|
|
199
|
+
def stub_put_item_statement_unexpected_error(item_id, statement_id, payload)
|
|
200
|
+
stub_rest_api_request(
|
|
201
|
+
:put,
|
|
202
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
203
|
+
response_status: 500,
|
|
204
|
+
with: { body: payload.to_json },
|
|
205
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
206
|
+
)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
##################################################################
|
|
210
|
+
# PUT /v1/entities/properties/:property_id/statements/:statement_id
|
|
211
|
+
##################################################################
|
|
212
|
+
def stub_put_property_statement(property_id, statement_id, payload, response_body: nil)
|
|
213
|
+
stub_rest_api_request(
|
|
214
|
+
:put,
|
|
215
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
216
|
+
with: { body: payload.to_json },
|
|
217
|
+
response_body: response_body || {
|
|
218
|
+
id: statement_id.to_s,
|
|
219
|
+
rank: "normal",
|
|
220
|
+
property: { id: property_id.to_s, "data-type": "wikibase-item" },
|
|
221
|
+
value: { content: "Q42", type: "value" },
|
|
222
|
+
qualifiers: [],
|
|
223
|
+
references: []
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Stub PUT property statement request returning 500 error
|
|
229
|
+
#
|
|
230
|
+
# @param property_id [String] The property ID
|
|
231
|
+
# @param statement_id [String] The statement ID
|
|
232
|
+
# @param payload [Hash] The request payload
|
|
233
|
+
#
|
|
234
|
+
# @return [WebMock::RequestStub]
|
|
235
|
+
def stub_put_property_statement_unexpected_error(property_id, statement_id, payload)
|
|
236
|
+
stub_rest_api_request(
|
|
237
|
+
:put,
|
|
238
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
239
|
+
response_status: 500,
|
|
240
|
+
with: { body: payload.to_json },
|
|
241
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
242
|
+
)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
#####################################
|
|
246
|
+
# PUT /v1/statements/:statement_id
|
|
247
|
+
#####################################
|
|
248
|
+
def stub_put_statement(statement_id, payload, response_body: nil)
|
|
249
|
+
stub_rest_api_request(
|
|
250
|
+
:put,
|
|
251
|
+
"/v1/statements/#{statement_id}",
|
|
252
|
+
with: { body: payload.to_json },
|
|
253
|
+
response_body: response_body || {
|
|
254
|
+
id: statement_id.to_s,
|
|
255
|
+
rank: "normal",
|
|
256
|
+
property: { id: "P92", "data-type": "string" },
|
|
257
|
+
value: { content: "Updated goat", type: "value" },
|
|
258
|
+
qualifiers: [],
|
|
259
|
+
references: []
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Stub PUT statement request returning 500 error
|
|
265
|
+
#
|
|
266
|
+
# @param statement_id [String] The statement ID
|
|
267
|
+
# @param payload [Hash] The request payload
|
|
268
|
+
#
|
|
269
|
+
# @return [WebMock::RequestStub]
|
|
270
|
+
def stub_put_statement_unexpected_error(statement_id, payload)
|
|
271
|
+
stub_rest_api_request(
|
|
272
|
+
:put,
|
|
273
|
+
"/v1/statements/#{statement_id}",
|
|
274
|
+
response_status: 500,
|
|
275
|
+
with: { body: payload.to_json },
|
|
276
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
277
|
+
)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
##############################################################
|
|
281
|
+
# PATCH /v1/entities/items/:item_id/statements/:statement_id
|
|
282
|
+
##############################################################
|
|
283
|
+
def stub_patch_item_statement(item_id, statement_id, payload, response_body: nil)
|
|
284
|
+
stub_rest_api_request(
|
|
285
|
+
:patch,
|
|
286
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
287
|
+
with: { body: payload.to_json },
|
|
288
|
+
response_body: response_body || {
|
|
289
|
+
id: statement_id.to_s,
|
|
290
|
+
rank: "normal",
|
|
291
|
+
property: { id: "P92", "data-type": "string" },
|
|
292
|
+
value: { content: "Patched goat", type: "value" },
|
|
293
|
+
qualifiers: [],
|
|
294
|
+
references: []
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Stub PATCH item statement request returning 500 error
|
|
300
|
+
#
|
|
301
|
+
# @param item_id [String] The item ID
|
|
302
|
+
# @param statement_id [String] The statement ID
|
|
303
|
+
# @param payload [Hash] The request payload
|
|
304
|
+
#
|
|
305
|
+
# @return [WebMock::RequestStub]
|
|
306
|
+
def stub_patch_item_statement_unexpected_error(item_id, statement_id, payload)
|
|
307
|
+
stub_rest_api_request(
|
|
308
|
+
:patch,
|
|
309
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
310
|
+
response_status: 500,
|
|
311
|
+
with: { body: payload.to_json },
|
|
312
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
313
|
+
)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
####################################################################
|
|
317
|
+
# PATCH /v1/entities/properties/:property_id/statements/:statement_id
|
|
318
|
+
####################################################################
|
|
319
|
+
def stub_patch_property_statement(property_id, statement_id, payload, response_body: nil)
|
|
320
|
+
stub_rest_api_request(
|
|
321
|
+
:patch,
|
|
322
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
323
|
+
with: { body: payload.to_json },
|
|
324
|
+
response_body: response_body || {
|
|
325
|
+
id: statement_id.to_s,
|
|
326
|
+
rank: "normal",
|
|
327
|
+
property: { id: property_id.to_s, "data-type": "wikibase-item" },
|
|
328
|
+
value: { content: "Q99", type: "value" },
|
|
329
|
+
qualifiers: [],
|
|
330
|
+
references: []
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# Stub PATCH property statement request returning 500 error
|
|
336
|
+
#
|
|
337
|
+
# @param property_id [String] The property ID
|
|
338
|
+
# @param statement_id [String] The statement ID
|
|
339
|
+
# @param payload [Hash] The request payload
|
|
340
|
+
#
|
|
341
|
+
# @return [WebMock::RequestStub]
|
|
342
|
+
def stub_patch_property_statement_unexpected_error(property_id, statement_id, payload)
|
|
343
|
+
stub_rest_api_request(
|
|
344
|
+
:patch,
|
|
345
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
346
|
+
response_status: 500,
|
|
347
|
+
with: { body: payload.to_json },
|
|
348
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
349
|
+
)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
#####################################
|
|
353
|
+
# PATCH /v1/statements/:statement_id
|
|
354
|
+
#####################################
|
|
355
|
+
def stub_patch_statement(statement_id, payload, response_body: nil)
|
|
356
|
+
stub_rest_api_request(
|
|
357
|
+
:patch,
|
|
358
|
+
"/v1/statements/#{statement_id}",
|
|
359
|
+
with: { body: payload.to_json },
|
|
360
|
+
response_body: response_body || {
|
|
361
|
+
id: statement_id.to_s,
|
|
362
|
+
rank: "normal",
|
|
363
|
+
property: { id: "P92", "data-type": "string" },
|
|
364
|
+
value: { content: "Patched goat", type: "value" },
|
|
365
|
+
qualifiers: [],
|
|
366
|
+
references: []
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
# Stub PATCH statement request returning 500 error
|
|
372
|
+
#
|
|
373
|
+
# @param statement_id [String] The statement ID
|
|
374
|
+
# @param payload [Hash] The request payload
|
|
375
|
+
#
|
|
376
|
+
# @return [WebMock::RequestStub]
|
|
377
|
+
def stub_patch_statement_unexpected_error(statement_id, payload)
|
|
378
|
+
stub_rest_api_request(
|
|
379
|
+
:patch,
|
|
380
|
+
"/v1/statements/#{statement_id}",
|
|
381
|
+
response_status: 500,
|
|
382
|
+
with: { body: payload.to_json },
|
|
383
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
384
|
+
)
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
###############################################################
|
|
388
|
+
# DELETE /v1/entities/items/:item_id/statements/:statement_id
|
|
389
|
+
###############################################################
|
|
390
|
+
def stub_delete_item_statement(item_id, statement_id, payload, response_body: "Statement deleted")
|
|
391
|
+
stub_rest_api_request(
|
|
392
|
+
:delete,
|
|
393
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
394
|
+
with: { body: payload.to_json },
|
|
395
|
+
response_body: response_body
|
|
396
|
+
)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
# Stub DELETE item statement request returning 500 error
|
|
400
|
+
#
|
|
401
|
+
# @param item_id [String] The item ID
|
|
402
|
+
# @param statement_id [String] The statement ID
|
|
403
|
+
# @param payload [Hash] The request payload
|
|
404
|
+
#
|
|
405
|
+
# @return [WebMock::RequestStub]
|
|
406
|
+
def stub_delete_item_statement_unexpected_error(item_id, statement_id, payload)
|
|
407
|
+
stub_rest_api_request(
|
|
408
|
+
:delete,
|
|
409
|
+
"/v1/entities/items/#{item_id}/statements/#{statement_id}",
|
|
410
|
+
response_status: 500,
|
|
411
|
+
with: { body: payload.to_json },
|
|
412
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
413
|
+
)
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
#####################################################################
|
|
417
|
+
# DELETE /v1/entities/properties/:property_id/statements/:statement_id
|
|
418
|
+
#####################################################################
|
|
419
|
+
def stub_delete_property_statement(property_id, statement_id, payload, response_body: "Statement deleted")
|
|
420
|
+
stub_rest_api_request(
|
|
421
|
+
:delete,
|
|
422
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
423
|
+
with: { body: payload.to_json },
|
|
424
|
+
response_body: response_body
|
|
425
|
+
)
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Stub DELETE property statement request returning 500 error
|
|
429
|
+
#
|
|
430
|
+
# @param property_id [String] The property ID
|
|
431
|
+
# @param statement_id [String] The statement ID
|
|
432
|
+
# @param payload [Hash] The request payload
|
|
433
|
+
#
|
|
434
|
+
# @return [WebMock::RequestStub]
|
|
435
|
+
def stub_delete_property_statement_unexpected_error(property_id, statement_id, payload)
|
|
436
|
+
stub_rest_api_request(
|
|
437
|
+
:delete,
|
|
438
|
+
"/v1/entities/properties/#{property_id}/statements/#{statement_id}",
|
|
439
|
+
response_status: 500,
|
|
440
|
+
with: { body: payload.to_json },
|
|
441
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
442
|
+
)
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
########################################
|
|
446
|
+
# DELETE /v1/statements/:statement_id
|
|
447
|
+
########################################
|
|
448
|
+
def stub_delete_statement(statement_id, payload, response_body: "Statement deleted")
|
|
449
|
+
stub_rest_api_request(
|
|
450
|
+
:delete,
|
|
451
|
+
"/v1/statements/#{statement_id}",
|
|
452
|
+
with: { body: payload.to_json },
|
|
453
|
+
response_body: response_body
|
|
454
|
+
)
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
# Stub DELETE statement request returning 500 error
|
|
458
|
+
#
|
|
459
|
+
# @param statement_id [String] The statement ID
|
|
460
|
+
# @param payload [Hash] The request payload
|
|
461
|
+
#
|
|
462
|
+
# @return [WebMock::RequestStub]
|
|
463
|
+
def stub_delete_statement_unexpected_error(statement_id, payload)
|
|
464
|
+
stub_rest_api_request(
|
|
465
|
+
:delete,
|
|
466
|
+
"/v1/statements/#{statement_id}",
|
|
467
|
+
response_status: 500,
|
|
468
|
+
with: { body: payload.to_json },
|
|
469
|
+
response_body: { code: "unexpected-error", message: "Unexpected Error" }
|
|
470
|
+
)
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
end
|