Class: CypressTestApi::APIController
- Inherits:
-
BaseController
- Object
- BaseController
- CypressTestApi::APIController
- Defined in:
- lib/cypress_test_api/controllers/api_controller.rb
Overview
APIController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_o_auth_token(body: nil) ⇒ void
Generates a new OAuth token with the specified scopes.
-
#createanitem(status, body: nil) ⇒ Object
Creates a new resource in the system.
-
#getanitemby_id(id, value) ⇒ Item
TODO: type endpoint description here retrieve.
-
#test_endpointwith_arrays(body: nil) ⇒ void
This endpoint accepts a complex structure with multiple arrays.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from CypressTestApi::BaseController
Instance Method Details
#create_o_auth_token(body: nil) ⇒ void
This method returns an undefined value.
Generates a new OAuth token with the specified scopes. here
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cypress_test_api/controllers/api_controller.rb', line 66 def create_o_auth_token(body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/tokens', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .is_response_void(true) .local_error('400', 'Bad request', APIException)) .execute end |
#createanitem(status, body: nil) ⇒ Object
Creates a new resource in the system. to filter by. properties
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cypress_test_api/controllers/api_controller.rb', line 15 def createanitem(status, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/items/{status}', Server::DEFAULT) .template_param(new_parameter(status, key: 'status') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .local_error('400', 'Bad Syntax', APIException) .local_error('401', 'Unauthorized', APIException) .local_error('403', 'Permission Denied', APIException)) .execute end |
#getanitemby_id(id, value) ⇒ Item
TODO: type endpoint description here retrieve
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cypress_test_api/controllers/api_controller.rb', line 46 def getanitemby_id(id, value) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/items/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .query_param(new_parameter(value, key: 'value')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Item.method(:from_hash))) .execute end |
#test_endpointwith_arrays(body: nil) ⇒ void
This method returns an undefined value.
This endpoint accepts a complex structure with multiple arrays. description here
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cypress_test_api/controllers/api_controller.rb', line 86 def test_endpointwith_arrays(body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/multiple-arrays', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .is_response_void(true) .local_error('400', 'Bad request', APIException)) .execute end |