Ticket_Definition_Provider.php
167 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Pods\REST\V1\Documentation; |
| 4 | |
| 5 | use Tribe__Documentation__Swagger__Provider_Interface as Provider_Interface; |
| 6 | |
| 7 | /** |
| 8 | * Class Ticket_Definition_Provider |
| 9 | * |
| 10 | * @since 2.8.0 |
| 11 | */ |
| 12 | class Ticket_Definition_Provider implements Provider_Interface { |
| 13 | |
| 14 | /** |
| 15 | * {@inheritdoc} |
| 16 | * |
| 17 | * @since 2.8.0 |
| 18 | */ |
| 19 | public function get_documentation() { |
| 20 | $documentation = [ |
| 21 | 'type' => 'object', |
| 22 | 'properties' => [ |
| 23 | 'id' => [ |
| 24 | 'type' => 'integer', |
| 25 | 'description' => __( 'The ticket WordPress post ID', 'pods' ), |
| 26 | ], |
| 27 | 'post_id' => [ |
| 28 | 'type' => 'integer', |
| 29 | 'description' => __( 'The ID of the post the ticket is associated to', 'pods' ), |
| 30 | ], |
| 31 | 'global_id' => [ |
| 32 | 'type' => 'string', |
| 33 | 'description' => __( 'The ticket global ID', 'pods' ), |
| 34 | ], |
| 35 | 'global_id_lineage' => [ |
| 36 | 'type' => 'array', |
| 37 | 'items' => [ |
| 38 | 'type' => 'string', |
| 39 | ], |
| 40 | 'description' => __( 'The ticket global ID lineage', 'pods' ), |
| 41 | ], |
| 42 | 'author' => [ |
| 43 | 'type' => 'integer', |
| 44 | 'description' => __( 'The ticket post author ID', 'pods' ), |
| 45 | ], |
| 46 | 'status' => [ |
| 47 | 'type' => 'string', |
| 48 | 'description' => __( 'The ticket post status', 'pods' ), |
| 49 | ], |
| 50 | 'date' => [ |
| 51 | 'type' => 'string', |
| 52 | 'format' => 'date', |
| 53 | 'description' => __( 'The ticket creation date', 'pods' ), |
| 54 | ], |
| 55 | 'date_utc' => [ |
| 56 | 'type' => 'string', |
| 57 | 'format' => 'date', |
| 58 | 'description' => __( 'The ticket creation UTC date', 'pods' ), |
| 59 | ], |
| 60 | 'modified' => [ |
| 61 | 'type' => 'string', |
| 62 | 'format' => 'date', |
| 63 | 'description' => __( 'The ticket modification date', 'pods' ), |
| 64 | ], |
| 65 | 'modified_utc' => [ |
| 66 | 'type' => 'string', |
| 67 | 'format' => 'date', |
| 68 | 'description' => __( 'The ticket modification UTC date', 'pods' ), |
| 69 | ], |
| 70 | 'rest_url' => [ |
| 71 | 'type' => 'string', |
| 72 | 'format' => 'uri', |
| 73 | 'description' => __( 'The ticket ET REST API URL', 'pods' ), |
| 74 | ], |
| 75 | 'provider' => [ |
| 76 | 'type' => 'string', |
| 77 | 'description' => __( 'The ticket commerce provider', 'pods' ), |
| 78 | 'enum' => [ 'rsvp', 'tribe-commerce', 'woo', 'edd' ], |
| 79 | ], |
| 80 | 'title' => [ |
| 81 | 'type' => 'string', |
| 82 | 'description' => __( 'The ticket title', 'pods' ), |
| 83 | ], |
| 84 | 'description' => [ |
| 85 | 'type' => 'string', |
| 86 | 'description' => __( 'The ticket description', 'pods' ), |
| 87 | ], |
| 88 | 'image' => [ |
| 89 | '$ref' => '#/components/schemas/Image', |
| 90 | ], |
| 91 | 'available_from' => [ |
| 92 | 'type' => 'string', |
| 93 | 'format' => 'date', |
| 94 | 'description' => __( 'The date the ticket will be available', 'pods' ), |
| 95 | ], |
| 96 | 'available_from_details' => [ |
| 97 | '$ref' => '#/components/schemas/DateDetails', |
| 98 | ], |
| 99 | 'available_until' => [ |
| 100 | 'type' => 'string', |
| 101 | 'format' => 'date', |
| 102 | 'description' => __( 'The date the ticket will be available', 'pods' ), |
| 103 | ], |
| 104 | 'available_until_details' => [ |
| 105 | '$ref' => '#/components/schemas/DateDetails', |
| 106 | ], |
| 107 | 'capacity' => [ |
| 108 | 'type' => 'integer', |
| 109 | 'description' => __( 'The formatted ticket current capacity', 'pods' ), |
| 110 | ], |
| 111 | 'capacity_details' => [ |
| 112 | '$ref' => '#/components/schemas/CapacityDetails', |
| 113 | ], |
| 114 | 'is_available' => [ |
| 115 | 'type' => 'boolean', |
| 116 | 'description' => __( 'Whether the ticket is currently available or not due to capacity or date constraints', 'pods' ), |
| 117 | ], |
| 118 | 'cost' => [ |
| 119 | 'type' => 'integer', |
| 120 | 'description' => __( 'The formatted cost string', 'pods' ), |
| 121 | ], |
| 122 | 'cost_details' => [ |
| 123 | '$ref' => '#/components/schemas/CostDetails', |
| 124 | ], |
| 125 | 'attendees' => [ |
| 126 | 'type' => 'array', |
| 127 | 'items' => [ |
| 128 | '$ref' => '#/components/schemas/Attendee', |
| 129 | ], |
| 130 | 'description' => __( 'A list of attendees for the ticket, ', 'pods' ), |
| 131 | ], |
| 132 | 'supports_attendee_information' => [ |
| 133 | 'type' => 'boolean', |
| 134 | 'description' => __( 'Whether the ticket supports at least one attendee information field, ET+ required', 'pods' ), |
| 135 | ], |
| 136 | 'requires_attendee_information' => [ |
| 137 | 'type' => 'boolean', |
| 138 | 'description' => __( 'Whether the ticket requires at least one attendee information field, ET+ required', 'pods' ), |
| 139 | ], |
| 140 | 'attendee_information_fields' => [ |
| 141 | 'type' => 'object', |
| 142 | 'description' => __( 'A list of attendee information fields supported/required by the ticket in the format [ <field-slug>: label, required, type, extra ]', 'pods' ), |
| 143 | ], |
| 144 | 'rsvp' => [ |
| 145 | '$ref' => '#/components/schemas/RSVPReport', |
| 146 | ], |
| 147 | 'checkin' => [ |
| 148 | '$ref' => '#/components/schemas/CheckinReport', |
| 149 | ], |
| 150 | ], |
| 151 | ]; |
| 152 | |
| 153 | /** |
| 154 | * Filters the Swagger documentation generated in the REST API. |
| 155 | * |
| 156 | * @since 2.8.0 |
| 157 | * |
| 158 | * @param array $documentation An associative PHP array in the format supported by Swagger. |
| 159 | * |
| 160 | * @link http://swagger.io/ |
| 161 | */ |
| 162 | $documentation = apply_filters( 'pods_rest_swagger_ticket_documentation', $documentation ); |
| 163 | |
| 164 | return $documentation; |
| 165 | } |
| 166 | } |
| 167 |