Class: Endpoints::TestApi

Inherits:
NonCrudEndpoints
  • Object
show all
Defined in:
app/models/endpoints/test_api.rb

Instance Method Summary collapse

Instance Method Details

#test(params) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/endpoints/test_api.rb', line 2

def test(params)
  # Define an explain var to be used to validate and document the action behavior when using ?explain=true in query string
  explain = {
    verbs: ["GET", "POST"],
    body: {
      messages: {
        type: :array,
        optional: true,
        items: {
          type: :string,
          optional: false
        }
      },
      is_connected: {
        type: :boolean,
        optional: false
      },
      user: {
        type: :object,
        optional: true,
        properties: {
          name: {
            type: :string,
            optional: false
          },
          age: {
            type: :integer,
            optional: true
          }
        }
      }
    },
    query: {
      explain: {
        type: :boolean,
        optional: true
      }
    },
    responses: {
      200 => {
        message: :string,
        params: {},
      },
      501 => {
        error: :string,
      },
    },
  }
  return explain, 200 if params[:explain].to_s == "true" && !explain.blank?
  
  
  return { message: "Hello World From Test API Custom Action called test", params: params }, 200
end