Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CurrentSubscriptionResource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Resources\v2; |
| 4 | |
| 5 | use App\DTO\CurrentSubscriptionDTO; |
| 6 | use Illuminate\Http\Request; |
| 7 | use Illuminate\Http\Resources\Json\JsonResource; |
| 8 | |
| 9 | /** |
| 10 | * API Resource for current subscription response. |
| 11 | * |
| 12 | * Transforms CurrentSubscriptionDTO into the API response format. |
| 13 | * This resource is used by the GET /api/v2/plans/current endpoint. |
| 14 | * |
| 15 | * @property CurrentSubscriptionDTO $resource |
| 16 | * |
| 17 | * @response 200 { |
| 18 | * "result": { |
| 19 | * "id": "507f1f77bcf86cd799439011", |
| 20 | * "title": "Sales Pro", |
| 21 | * "identifier": "sales-pro-monthly", |
| 22 | * "stripe_id": "price_1234567890", |
| 23 | * "created_at": 1642521600, |
| 24 | * "updated_at": 1642521600, |
| 25 | * "currency": "usd", |
| 26 | * "interval": "month", |
| 27 | * "unit_amount": 9900, |
| 28 | * "flycuts_features": { |
| 29 | * "character_limit": { |
| 30 | * "value": -1, |
| 31 | * "description": "Determines the number of characters you can include inside of a single message." |
| 32 | * }, |
| 33 | * "categories_count": { |
| 34 | * "value": -1, |
| 35 | * "description": "Organize your messages in folder categories to streamline productivity." |
| 36 | * }, |
| 37 | * "subcategories_count": { |
| 38 | * "value": -1, |
| 39 | * "description": "Organize your messages in folder categories to streamline productivity." |
| 40 | * }, |
| 41 | * "version_history_limit": { |
| 42 | * "value": 999, |
| 43 | * "description": "Need to restore a message? Access previous versions..." |
| 44 | * }, |
| 45 | * "flyshare_enabled": { |
| 46 | * "value": true, |
| 47 | * "description": "Streamline communication by sharing your messages..." |
| 48 | * }, |
| 49 | * "font_size": { |
| 50 | * "value": [10, 11, 12], |
| 51 | * "description": "Determines the size of the font in your messages." |
| 52 | * }, |
| 53 | * "font_family": { |
| 54 | * "value": ["Arial", "Sans Serif", "Calibri"], |
| 55 | * "description": "Determines the font family of your messages." |
| 56 | * }, |
| 57 | * "bold": { |
| 58 | * "value": true, |
| 59 | * "description": "Determines if the bold is enabled in your messages." |
| 60 | * }, |
| 61 | * "emoticons": { |
| 62 | * "value": true, |
| 63 | * "description": "Make it fun by inserting emojis to any of your messages. 😀" |
| 64 | * }, |
| 65 | * "embed_videos": { |
| 66 | * "value": true, |
| 67 | * "description": "Insert media from YouTube and Vimeo into your messages." |
| 68 | * }, |
| 69 | * "images": { |
| 70 | * "value": true, |
| 71 | * "description": "Determines if the images are enabled in your messages." |
| 72 | * }, |
| 73 | * "giphys": { |
| 74 | * "value": true, |
| 75 | * "description": "Search, navigate and insert your favorite giphs into your messages." |
| 76 | * }, |
| 77 | * "italic": { |
| 78 | * "value": true, |
| 79 | * "description": "Determines if the italic is enabled in your messages." |
| 80 | * }, |
| 81 | * "underline": { |
| 82 | * "value": true, |
| 83 | * "description": "Determines if the underline is enabled in your messages." |
| 84 | * }, |
| 85 | * "strikethrough": { |
| 86 | * "value": true, |
| 87 | * "description": "Determines if the strikethrough is enabled in your messages." |
| 88 | * }, |
| 89 | * "bullet_points": { |
| 90 | * "value": true, |
| 91 | * "description": "Determines if the bullet points are enabled in your messages." |
| 92 | * }, |
| 93 | * "numbered_list": { |
| 94 | * "value": true, |
| 95 | * "description": "Determines if the numbered list is enabled in your messages." |
| 96 | * }, |
| 97 | * "background_color": { |
| 98 | * "value": false, |
| 99 | * "description": "Determines if the background color is enabled in your messages." |
| 100 | * }, |
| 101 | * "clear_formatting": { |
| 102 | * "value": false, |
| 103 | * "description": "Determines if the clear formatting is enabled in your messages." |
| 104 | * }, |
| 105 | * "blocks": { |
| 106 | * "value": false, |
| 107 | * "description": "For advanced writting: customize your messages with different text formats (heading, paragraph, etc)." |
| 108 | * }, |
| 109 | * "preview": { |
| 110 | * "value": false, |
| 111 | * "description": "Preview how your message will look for the recipient for web and mobile view." |
| 112 | * }, |
| 113 | * "hyperlink": { |
| 114 | * "value": false, |
| 115 | * "description": "Determines if the hyperlink is enabled in your messages." |
| 116 | * }, |
| 117 | * "alignment": { |
| 118 | * "value": ["left"], |
| 119 | * "description": "Determines the alignment of the text in your messages." |
| 120 | * }, |
| 121 | * "indent": { |
| 122 | * "value": false, |
| 123 | * "description": "Determines if the indent is enabled in your messages." |
| 124 | * }, |
| 125 | * "outdent": { |
| 126 | * "value": false, |
| 127 | * "description": "Determines if the outdent is enabled in your messages." |
| 128 | * }, |
| 129 | * "font_color": { |
| 130 | * "value": false, |
| 131 | * "description": "Determines if the font color is enabled in your messages." |
| 132 | * }, |
| 133 | * "storage_limits": { |
| 134 | * "value": {"image_size": "20MB", "total_storage": "5GB"}, |
| 135 | * "description": "Storage limits for images and total storage." |
| 136 | * }, |
| 137 | * "templates": { |
| 138 | * "value": -1, |
| 139 | * "description": "Shortcuts templates AKA FlyPlates." |
| 140 | * } |
| 141 | * }, |
| 142 | * "statistics": { |
| 143 | * "sub_categories": 5, |
| 144 | * "sub_categories_available": 10, |
| 145 | * "categories": 3, |
| 146 | * "categories_available": 10, |
| 147 | * "characters": -1, |
| 148 | * "templates": 50, |
| 149 | * "templates_available": -1, |
| 150 | * "shortcuts": 50, |
| 151 | * "shortcuts_available": -1 |
| 152 | * }, |
| 153 | * "referrals": null, |
| 154 | * "referral_key": "abc123def456", |
| 155 | * "used_trial": false, |
| 156 | * "on_trial": false, |
| 157 | * "plan_status": "active", |
| 158 | * "ends_at": null, |
| 159 | * "already_used_pro_trial": true, |
| 160 | * "user_details": { |
| 161 | * "id": "507f1f77bcf86cd799439011", |
| 162 | * "email": "user@example.com", |
| 163 | * "first_name": "John", |
| 164 | * "last_name": "Doe", |
| 165 | * "is_poc": false |
| 166 | * }, |
| 167 | * "has_fly_learning": true, |
| 168 | * "user_custom_prompts": 5, |
| 169 | * "user_persona_available": 3, |
| 170 | * "can_disable_flygrammar": true, |
| 171 | * "flycut_deployment": 10, |
| 172 | * "flygrammar_actions": 100, |
| 173 | * "prompts_per_day": 50, |
| 174 | * "regenerate_count": 20 |
| 175 | * } |
| 176 | * } |
| 177 | */ |
| 178 | class CurrentSubscriptionResource extends JsonResource |
| 179 | { |
| 180 | /** |
| 181 | * Indicates if the resource's collection keys should be preserved. |
| 182 | * |
| 183 | * @var bool |
| 184 | */ |
| 185 | public $preserveKeys = true; |
| 186 | |
| 187 | /** |
| 188 | * Disable wrapping since middleware handles 'result' wrapper. |
| 189 | * |
| 190 | * @var string|null |
| 191 | */ |
| 192 | public static $wrap = null; |
| 193 | |
| 194 | /** |
| 195 | * Transform the resource into an array. |
| 196 | * |
| 197 | * @return array<string, mixed> |
| 198 | */ |
| 199 | public function toArray(Request $request): array |
| 200 | { |
| 201 | return $this->resource->toArray(); |
| 202 | } |
| 203 | } |