GetSubscriptionCollectionParams.php
10 months ago
GetSubscriptionItemSchema.php
10 months ago
GetSubscriptionSharedParamsForGetMethods.php
10 months ago
GetSubscriptionItemSchema.php
198 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\API\REST\V3\Routes\Subscriptions\Actions; |
| 4 | |
| 5 | use Give\Subscriptions\ValueObjects\SubscriptionPeriod; |
| 6 | use Give\Subscriptions\ValueObjects\SubscriptionStatus; |
| 7 | |
| 8 | /** |
| 9 | * @since 4.8.0 |
| 10 | */ |
| 11 | class GetSubscriptionItemSchema |
| 12 | { |
| 13 | /** |
| 14 | * @since 4.8.0 |
| 15 | */ |
| 16 | public function __invoke(): array |
| 17 | { |
| 18 | return [ |
| 19 | 'title' => 'givewp/subscription', |
| 20 | 'type' => 'object', |
| 21 | 'properties' => [ |
| 22 | 'id' => [ |
| 23 | 'type' => 'integer', |
| 24 | 'description' => esc_html__('Subscription ID', 'give'), |
| 25 | ], |
| 26 | 'donorId' => [ |
| 27 | 'type' => 'integer', |
| 28 | 'description' => esc_html__('Donor ID', 'give'), |
| 29 | 'required' => true, |
| 30 | ], |
| 31 | 'donationFormId' => [ |
| 32 | 'type' => 'integer', |
| 33 | 'description' => esc_html__('Donation form ID', 'give'), |
| 34 | 'required' => true, |
| 35 | ], |
| 36 | 'amount' => [ |
| 37 | 'type' => ['object', 'null'], |
| 38 | 'properties' => [ |
| 39 | 'amount' => [ |
| 40 | 'type' => 'number', |
| 41 | ], |
| 42 | 'amountInMinorUnits' => [ |
| 43 | 'type' => 'integer', |
| 44 | ], |
| 45 | 'currency' => [ |
| 46 | 'type' => 'string', |
| 47 | 'format' => 'text-field', |
| 48 | ], |
| 49 | ], |
| 50 | 'description' => esc_html__('Subscription amount', 'give'), |
| 51 | 'required' => true, |
| 52 | ], |
| 53 | 'feeAmountRecovered' => [ |
| 54 | 'type' => ['object', 'null'], |
| 55 | 'properties' => [ |
| 56 | 'amount' => [ |
| 57 | 'type' => 'number', |
| 58 | ], |
| 59 | 'amountInMinorUnits' => [ |
| 60 | 'type' => 'integer', |
| 61 | ], |
| 62 | 'currency' => [ |
| 63 | 'type' => 'string', |
| 64 | 'format' => 'text-field', |
| 65 | ], |
| 66 | ], |
| 67 | 'description' => esc_html__('Fee amount recovered', 'give'), |
| 68 | ], |
| 69 | 'status' => [ |
| 70 | 'type' => 'string', |
| 71 | 'description' => esc_html__('Subscription status', 'give'), |
| 72 | 'enum' => ['any', ...array_values(SubscriptionStatus::toArray())], |
| 73 | 'required' => true, |
| 74 | ], |
| 75 | 'period' => [ |
| 76 | 'type' => 'string', |
| 77 | 'description' => esc_html__('Subscription billing period', 'give'), |
| 78 | 'enum' => array_values(SubscriptionPeriod::toArray()), |
| 79 | 'required' => true, |
| 80 | ], |
| 81 | 'frequency' => [ |
| 82 | 'type' => 'integer', |
| 83 | 'description' => esc_html__('Billing frequency', 'give'), |
| 84 | 'required' => true, |
| 85 | ], |
| 86 | 'installments' => [ |
| 87 | 'type' => 'integer', |
| 88 | 'description' => esc_html__('Number of installments (0 for unlimited)', 'give'), |
| 89 | 'default' => 0, |
| 90 | ], |
| 91 | 'transactionId' => [ |
| 92 | 'type' => ['string', 'null'], |
| 93 | 'description' => esc_html__('Transaction ID', 'give'), |
| 94 | 'format' => 'text-field', |
| 95 | ], |
| 96 | 'gatewayId' => [ |
| 97 | 'type' => 'string', |
| 98 | 'description' => esc_html__('Payment gateway ID', 'give'), |
| 99 | 'format' => 'text-field', |
| 100 | 'required' => true, |
| 101 | ], |
| 102 | 'gatewaySubscriptionId' => [ |
| 103 | 'type' => ['string', 'null'], |
| 104 | 'description' => esc_html__('Gateway subscription ID', 'give'), |
| 105 | 'format' => 'text-field', |
| 106 | ], |
| 107 | 'mode' => [ |
| 108 | 'type' => 'string', |
| 109 | 'description' => esc_html__('Subscription mode (live or test)', 'give'), |
| 110 | 'default' => 'live', |
| 111 | 'enum' => ['live', 'test'], |
| 112 | ], |
| 113 | 'createdAt' => [ |
| 114 | 'oneOf' => [ |
| 115 | [ |
| 116 | 'type' => 'string', |
| 117 | 'description' => esc_html__('Subscription creation date as ISO string', 'give'), |
| 118 | 'format' => 'date-time', |
| 119 | ], |
| 120 | [ |
| 121 | 'type' => 'object', |
| 122 | 'properties' => [ |
| 123 | 'date' => [ |
| 124 | 'type' => 'string', |
| 125 | 'description' => esc_html__('Date', 'give'), |
| 126 | 'format' => 'date-time', |
| 127 | ], |
| 128 | 'timezone' => [ |
| 129 | 'type' => 'string', |
| 130 | 'description' => esc_html__('Timezone of the date', 'give'), |
| 131 | 'format' => 'text-field', |
| 132 | ], |
| 133 | 'timezone_type' => [ |
| 134 | 'type' => 'integer', |
| 135 | 'description' => esc_html__('Timezone type', 'give'), |
| 136 | ], |
| 137 | ], |
| 138 | 'description' => esc_html__('Subscription creation date', 'give'), |
| 139 | ], |
| 140 | [ |
| 141 | 'type' => 'null', |
| 142 | ], |
| 143 | ], |
| 144 | ], |
| 145 | 'renewsAt' => [ |
| 146 | 'oneOf' => [ |
| 147 | [ |
| 148 | 'type' => 'string', |
| 149 | 'description' => esc_html__('Next renewal date as ISO string', 'give'), |
| 150 | 'format' => 'date-time', |
| 151 | ], |
| 152 | [ |
| 153 | 'type' => 'object', |
| 154 | 'properties' => [ |
| 155 | 'date' => [ |
| 156 | 'type' => 'string', |
| 157 | 'description' => esc_html__('Date', 'give'), |
| 158 | 'format' => 'date-time', |
| 159 | ], |
| 160 | 'timezone' => [ |
| 161 | 'type' => 'string', |
| 162 | 'description' => esc_html__('Timezone of the date', 'give'), |
| 163 | 'format' => 'text-field', |
| 164 | ], |
| 165 | 'timezone_type' => [ |
| 166 | 'type' => 'integer', |
| 167 | 'description' => esc_html__('Timezone type', 'give'), |
| 168 | ], |
| 169 | ], |
| 170 | 'description' => esc_html__('Next renewal date', 'give'), |
| 171 | ], |
| 172 | [ |
| 173 | 'type' => 'null', |
| 174 | ], |
| 175 | ], |
| 176 | ], |
| 177 | 'projectedAnnualRevenue' => [ |
| 178 | 'type' => ['object', 'null'], |
| 179 | 'properties' => [ |
| 180 | 'amount' => [ |
| 181 | 'type' => 'number', |
| 182 | ], |
| 183 | 'amountInMinorUnits' => [ |
| 184 | 'type' => 'integer', |
| 185 | ], |
| 186 | 'currency' => [ |
| 187 | 'type' => 'string', |
| 188 | 'format' => 'text-field', |
| 189 | ], |
| 190 | ], |
| 191 | 'description' => esc_html__('Projected annual revenue for this subscription', 'give'), |
| 192 | 'readOnly' => true, |
| 193 | ], |
| 194 | ], |
| 195 | ]; |
| 196 | } |
| 197 | } |
| 198 |