terminal-shop 2.1.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ignore +2 -0
- data/CHANGELOG.md +674 -0
- data/README.md +88 -28
- data/SECURITY.md +27 -0
- data/lib/{terminal-shop → terminal_shop}/client.rb +19 -24
- data/lib/terminal_shop/errors.rb +192 -0
- data/lib/terminal_shop/file_part.rb +55 -0
- data/lib/terminal_shop/internal/transport/base_client.rb +486 -0
- data/lib/terminal_shop/internal/transport/pooled_net_requester.rb +193 -0
- data/lib/terminal_shop/internal/type/array_of.rb +154 -0
- data/lib/terminal_shop/internal/type/base_model.rb +443 -0
- data/lib/terminal_shop/internal/type/base_page.rb +55 -0
- data/lib/terminal_shop/internal/type/boolean.rb +64 -0
- data/lib/terminal_shop/internal/type/converter.rb +274 -0
- data/lib/terminal_shop/internal/type/enum.rb +133 -0
- data/lib/terminal_shop/internal/type/file_input.rb +96 -0
- data/lib/terminal_shop/internal/type/hash_of.rb +174 -0
- data/lib/terminal_shop/internal/type/request_parameters.rb +48 -0
- data/lib/terminal_shop/internal/type/union.rb +220 -0
- data/lib/terminal_shop/internal/type/unknown.rb +68 -0
- data/lib/terminal_shop/internal/util.rb +790 -0
- data/lib/terminal_shop/internal.rb +11 -0
- data/lib/terminal_shop/models/address.rb +93 -0
- data/lib/terminal_shop/models/address_create_params.rb +78 -0
- data/lib/terminal_shop/models/address_create_response.rb +17 -0
- data/lib/terminal_shop/models/address_delete_params.rb +14 -0
- data/lib/terminal_shop/models/address_delete_response.rb +16 -0
- data/lib/terminal_shop/models/address_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/address_get_response.rb +4 -7
- data/lib/terminal_shop/models/address_list_params.rb +14 -0
- data/lib/terminal_shop/models/address_list_response.rb +17 -0
- data/lib/{terminal-shop → terminal_shop}/models/app.rb +14 -12
- data/lib/terminal_shop/models/app_create_params.rb +26 -0
- data/lib/{terminal-shop → terminal_shop}/models/app_create_response.rb +10 -15
- data/lib/terminal_shop/models/app_delete_params.rb +14 -0
- data/lib/terminal_shop/models/app_delete_response.rb +16 -0
- data/lib/terminal_shop/models/app_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/app_get_response.rb +4 -7
- data/lib/terminal_shop/models/app_list_params.rb +14 -0
- data/lib/terminal_shop/models/app_list_response.rb +17 -0
- data/lib/terminal_shop/models/card.rb +75 -0
- data/lib/terminal_shop/models/card_collect_params.rb +14 -0
- data/lib/terminal_shop/models/card_collect_response.rb +36 -0
- data/lib/terminal_shop/models/card_create_params.rb +27 -0
- data/lib/terminal_shop/models/card_create_response.rb +17 -0
- data/lib/terminal_shop/models/card_delete_params.rb +14 -0
- data/lib/terminal_shop/models/card_delete_response.rb +16 -0
- data/lib/terminal_shop/models/card_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/card_get_response.rb +4 -7
- data/lib/terminal_shop/models/card_list_params.rb +14 -0
- data/lib/terminal_shop/models/card_list_response.rb +17 -0
- data/lib/terminal_shop/models/cart.rb +150 -0
- data/lib/terminal_shop/models/cart_clear_params.rb +14 -0
- data/lib/terminal_shop/models/cart_clear_response.rb +16 -0
- data/lib/terminal_shop/models/cart_convert_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/cart_convert_response.rb +4 -7
- data/lib/terminal_shop/models/cart_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/cart_get_response.rb +4 -7
- data/lib/terminal_shop/models/cart_set_address_params.rb +22 -0
- data/lib/terminal_shop/models/cart_set_address_response.rb +16 -0
- data/lib/terminal_shop/models/cart_set_card_params.rb +22 -0
- data/lib/terminal_shop/models/cart_set_card_response.rb +16 -0
- data/lib/terminal_shop/models/cart_set_item_params.rb +30 -0
- data/lib/{terminal-shop → terminal_shop}/models/cart_set_item_response.rb +4 -7
- data/lib/terminal_shop/models/email_create_params.rb +22 -0
- data/lib/terminal_shop/models/email_create_response.rb +16 -0
- data/lib/terminal_shop/models/order.rb +278 -0
- data/lib/terminal_shop/models/order_create_params.rb +38 -0
- data/lib/terminal_shop/models/order_create_response.rb +17 -0
- data/lib/terminal_shop/models/order_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/order_get_response.rb +4 -7
- data/lib/terminal_shop/models/order_list_params.rb +14 -0
- data/lib/terminal_shop/models/order_list_response.rb +17 -0
- data/lib/terminal_shop/models/product.rb +125 -0
- data/lib/terminal_shop/models/product_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/product_get_response.rb +4 -7
- data/lib/terminal_shop/models/product_list_params.rb +14 -0
- data/lib/terminal_shop/models/product_list_response.rb +17 -0
- data/lib/terminal_shop/models/product_variant.rb +84 -0
- data/lib/{terminal-shop → terminal_shop}/models/profile.rb +22 -22
- data/lib/terminal_shop/models/profile_me_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/profile_me_response.rb +4 -7
- data/lib/terminal_shop/models/profile_update_params.rb +26 -0
- data/lib/{terminal-shop → terminal_shop}/models/profile_update_response.rb +4 -7
- data/lib/{terminal-shop → terminal_shop}/models/region.rb +4 -6
- data/lib/terminal_shop/models/subscription.rb +125 -0
- data/lib/terminal_shop/models/subscription_create_params.rb +14 -0
- data/lib/terminal_shop/models/subscription_create_response.rb +16 -0
- data/lib/terminal_shop/models/subscription_delete_params.rb +14 -0
- data/lib/terminal_shop/models/subscription_delete_response.rb +16 -0
- data/lib/terminal_shop/models/subscription_get_params.rb +14 -0
- data/lib/{terminal-shop → terminal_shop}/models/subscription_get_response.rb +4 -7
- data/lib/terminal_shop/models/subscription_list_params.rb +14 -0
- data/lib/terminal_shop/models/subscription_list_response.rb +17 -0
- data/lib/terminal_shop/models/subscription_update_params.rb +76 -0
- data/lib/terminal_shop/models/subscription_update_response.rb +17 -0
- data/lib/terminal_shop/models/token.rb +38 -0
- data/lib/terminal_shop/models/token_create_params.rb +14 -0
- data/lib/terminal_shop/models/token_create_response.rb +41 -0
- data/lib/terminal_shop/models/token_delete_params.rb +14 -0
- data/lib/terminal_shop/models/token_delete_response.rb +16 -0
- data/lib/terminal_shop/models/token_get_params.rb +14 -0
- data/lib/terminal_shop/models/token_get_response.rb +22 -0
- data/lib/terminal_shop/models/token_list_params.rb +14 -0
- data/lib/terminal_shop/models/token_list_response.rb +17 -0
- data/lib/terminal_shop/models/view_init_params.rb +14 -0
- data/lib/terminal_shop/models/view_init_response.rb +97 -0
- data/lib/{terminal-shop → terminal_shop}/request_options.rb +14 -15
- data/lib/{terminal-shop → terminal_shop}/resources/address.rb +28 -18
- data/lib/{terminal-shop → terminal_shop}/resources/app.rb +22 -14
- data/lib/{terminal-shop → terminal_shop}/resources/card.rb +30 -15
- data/lib/{terminal-shop → terminal_shop}/resources/cart.rb +30 -16
- data/lib/{terminal-shop → terminal_shop}/resources/email.rb +7 -3
- data/lib/{terminal-shop → terminal_shop}/resources/order.rb +18 -10
- data/lib/{terminal-shop → terminal_shop}/resources/product.rb +11 -5
- data/lib/{terminal-shop → terminal_shop}/resources/profile.rb +12 -8
- data/lib/terminal_shop/resources/subscription.rb +141 -0
- data/lib/{terminal-shop → terminal_shop}/resources/token.rb +20 -10
- data/lib/{terminal-shop → terminal_shop}/resources/view.rb +7 -3
- data/lib/{terminal-shop → terminal_shop}/version.rb +1 -1
- data/lib/terminal_shop.rb +144 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/client.rbi +18 -19
- data/rbi/lib/terminal_shop/errors.rbi +143 -0
- data/rbi/lib/terminal_shop/file_part.rbi +34 -0
- data/rbi/lib/terminal_shop/internal/transport/base_client.rbi +213 -0
- data/rbi/lib/terminal_shop/internal/transport/pooled_net_requester.rbi +60 -0
- data/rbi/lib/terminal_shop/internal/type/array_of.rbi +88 -0
- data/rbi/lib/terminal_shop/internal/type/base_model.rbi +220 -0
- data/rbi/lib/terminal_shop/internal/type/base_page.rbi +38 -0
- data/rbi/lib/terminal_shop/internal/type/boolean.rbi +48 -0
- data/rbi/lib/terminal_shop/internal/type/converter.rbi +120 -0
- data/rbi/lib/terminal_shop/internal/type/enum.rbi +66 -0
- data/rbi/lib/terminal_shop/internal/type/file_input.rbi +50 -0
- data/rbi/lib/terminal_shop/internal/type/hash_of.rbi +88 -0
- data/rbi/lib/terminal_shop/internal/type/request_parameters.rbi +21 -0
- data/rbi/lib/terminal_shop/internal/type/union.rbi +80 -0
- data/rbi/lib/terminal_shop/internal/type/unknown.rbi +40 -0
- data/rbi/lib/terminal_shop/internal/util.rbi +302 -0
- data/rbi/lib/terminal_shop/internal.rbi +11 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/address.rbi +30 -6
- data/rbi/lib/{terminal-shop → terminal_shop}/models/address_create_params.rbi +14 -9
- data/rbi/lib/{terminal-shop → terminal_shop}/models/address_create_response.rbi +6 -6
- data/rbi/lib/terminal_shop/models/address_delete_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/address_delete_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/address_get_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/address_get_response.rbi +8 -8
- data/rbi/lib/terminal_shop/models/address_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/address_list_response.rbi +7 -7
- data/rbi/lib/{terminal-shop → terminal_shop}/models/app.rbi +12 -6
- data/rbi/lib/{terminal-shop → terminal_shop}/models/app_create_params.rbi +6 -8
- data/rbi/lib/{terminal-shop → terminal_shop}/models/app_create_response.rbi +13 -13
- data/rbi/lib/terminal_shop/models/app_delete_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/app_delete_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/app_get_params.rbi +19 -0
- data/rbi/lib/terminal_shop/models/app_get_response.rbi +25 -0
- data/rbi/lib/terminal_shop/models/app_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/app_list_response.rbi +7 -7
- data/rbi/lib/{terminal-shop → terminal_shop}/models/card.rbi +32 -15
- data/rbi/lib/terminal_shop/models/card_collect_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/card_collect_response.rbi +16 -15
- data/rbi/lib/terminal_shop/models/card_create_params.rbi +31 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/card_create_response.rbi +6 -6
- data/rbi/lib/terminal_shop/models/card_delete_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/card_delete_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/card_get_params.rbi +19 -0
- data/rbi/lib/terminal_shop/models/card_get_response.rbi +25 -0
- data/rbi/lib/terminal_shop/models/card_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/card_list_response.rbi +7 -7
- data/rbi/lib/{terminal-shop → terminal_shop}/models/cart.rbi +51 -29
- data/rbi/lib/terminal_shop/models/cart_clear_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/cart_clear_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/cart_convert_params.rbi +19 -0
- data/rbi/lib/terminal_shop/models/cart_convert_response.rbi +25 -0
- data/rbi/lib/terminal_shop/models/cart_get_params.rbi +19 -0
- data/rbi/lib/terminal_shop/models/cart_get_response.rbi +25 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/cart_set_address_params.rbi +10 -9
- data/rbi/lib/{terminal-shop → terminal_shop}/models/cart_set_address_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/cart_set_card_params.rbi +29 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/cart_set_card_response.rbi +3 -5
- data/rbi/lib/{terminal-shop → terminal_shop}/models/cart_set_item_params.rbi +12 -9
- data/rbi/lib/terminal_shop/models/cart_set_item_response.rbi +25 -0
- data/rbi/lib/terminal_shop/models/email_create_params.rbi +29 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/email_create_response.rbi +3 -5
- data/rbi/lib/{terminal-shop → terminal_shop}/models/order.rbi +149 -36
- data/rbi/lib/{terminal-shop → terminal_shop}/models/order_create_params.rbi +14 -9
- data/rbi/lib/{terminal-shop → terminal_shop}/models/order_create_response.rbi +6 -6
- data/rbi/lib/terminal_shop/models/order_get_params.rbi +19 -0
- data/rbi/lib/terminal_shop/models/order_get_response.rbi +25 -0
- data/rbi/lib/terminal_shop/models/order_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/order_list_response.rbi +7 -7
- data/rbi/lib/{terminal-shop → terminal_shop}/models/product.rbi +44 -24
- data/rbi/lib/terminal_shop/models/product_get_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/product_get_response.rbi +8 -8
- data/rbi/lib/terminal_shop/models/product_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/product_list_response.rbi +7 -7
- data/rbi/lib/terminal_shop/models/product_variant.rbi +109 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/profile.rbi +22 -14
- data/rbi/lib/terminal_shop/models/profile_me_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/profile_me_response.rbi +8 -8
- data/rbi/lib/{terminal-shop → terminal_shop}/models/profile_update_params.rbi +6 -8
- data/rbi/lib/{terminal-shop → terminal_shop}/models/profile_update_response.rbi +8 -8
- data/rbi/lib/{terminal-shop → terminal_shop}/models/region.rbi +4 -4
- data/rbi/lib/{terminal-shop → terminal_shop}/models/subscription.rbi +44 -21
- data/rbi/lib/{terminal-shop → terminal_shop}/models/subscription_create_params.rbi +5 -7
- data/rbi/lib/{terminal-shop → terminal_shop}/models/subscription_create_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/subscription_delete_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/subscription_delete_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/subscription_get_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/subscription_get_response.rbi +8 -8
- data/rbi/lib/terminal_shop/models/subscription_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/subscription_list_response.rbi +7 -7
- data/rbi/lib/terminal_shop/models/subscription_update_params.rbi +125 -0
- data/rbi/lib/terminal_shop/models/subscription_update_response.rbi +25 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/token.rbi +11 -7
- data/rbi/lib/terminal_shop/models/token_create_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/token_create_response.rbi +15 -14
- data/rbi/lib/terminal_shop/models/token_delete_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/token_delete_response.rbi +3 -5
- data/rbi/lib/terminal_shop/models/token_get_params.rbi +19 -0
- data/rbi/lib/terminal_shop/models/token_get_response.rbi +27 -0
- data/rbi/lib/terminal_shop/models/token_list_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/token_list_response.rbi +7 -7
- data/rbi/lib/terminal_shop/models/view_init_params.rbi +19 -0
- data/rbi/lib/{terminal-shop → terminal_shop}/models/view_init_response.rbi +25 -25
- data/rbi/lib/{terminal-shop → terminal_shop}/request_options.rbi +11 -13
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/address.rbi +17 -17
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/app.rbi +17 -16
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/card.rbi +28 -22
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/cart.rbi +35 -23
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/email.rbi +4 -6
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/order.rbi +15 -13
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/product.rbi +13 -9
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/profile.rbi +13 -8
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/subscription.rbi +49 -17
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/token.rbi +24 -16
- data/rbi/lib/{terminal-shop → terminal_shop}/resources/view.rbi +12 -6
- data/rbi/lib/{terminal-shop → terminal_shop}/version.rbi +1 -1
- data/sig/{terminal-shop → terminal_shop}/client.rbs +3 -3
- data/sig/terminal_shop/errors.rbs +101 -0
- data/sig/terminal_shop/file_part.rbs +21 -0
- data/sig/terminal_shop/internal/transport/base_client.rbs +116 -0
- data/sig/terminal_shop/internal/transport/pooled_net_requester.rbs +41 -0
- data/sig/terminal_shop/internal/type/array_of.rbs +45 -0
- data/sig/terminal_shop/internal/type/base_model.rbs +96 -0
- data/sig/terminal_shop/internal/type/base_page.rbs +24 -0
- data/sig/terminal_shop/internal/type/boolean.rbs +23 -0
- data/sig/terminal_shop/internal/type/converter.rbs +54 -0
- data/sig/terminal_shop/internal/type/enum.rbs +29 -0
- data/sig/terminal_shop/internal/type/file_input.rbs +23 -0
- data/sig/terminal_shop/internal/type/hash_of.rbs +45 -0
- data/sig/terminal_shop/internal/type/request_parameters.rbs +15 -0
- data/sig/terminal_shop/internal/type/union.rbs +49 -0
- data/sig/terminal_shop/internal/type/unknown.rbs +23 -0
- data/sig/terminal_shop/internal/util.rbs +158 -0
- data/sig/terminal_shop/internal.rbs +5 -0
- data/sig/{terminal-shop → terminal_shop}/models/address.rbs +5 -1
- data/sig/{terminal-shop → terminal_shop}/models/address_create_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/address_create_response.rbs +1 -1
- data/sig/terminal_shop/models/address_delete_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/address_delete_response.rbs +1 -1
- data/sig/terminal_shop/models/address_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/address_get_response.rbs +1 -1
- data/sig/terminal_shop/models/address_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/address_list_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/app.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/app_create_params.rbs +5 -4
- data/sig/{terminal-shop → terminal_shop}/models/app_create_response.rbs +2 -2
- data/sig/terminal_shop/models/app_delete_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/app_delete_response.rbs +1 -1
- data/sig/terminal_shop/models/app_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/app_get_response.rbs +1 -1
- data/sig/terminal_shop/models/app_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/app_list_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/card.rbs +6 -2
- data/sig/terminal_shop/models/card_collect_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/card_collect_response.rbs +2 -2
- data/sig/{terminal-shop → terminal_shop}/models/card_create_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/card_create_response.rbs +1 -1
- data/sig/terminal_shop/models/card_delete_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/card_delete_response.rbs +1 -1
- data/sig/terminal_shop/models/card_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/card_get_response.rbs +1 -1
- data/sig/terminal_shop/models/card_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/card_list_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/cart.rbs +4 -4
- data/sig/terminal_shop/models/cart_clear_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/cart_clear_response.rbs +1 -1
- data/sig/terminal_shop/models/cart_convert_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/cart_convert_response.rbs +1 -1
- data/sig/terminal_shop/models/cart_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/cart_get_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/cart_set_address_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/cart_set_address_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/cart_set_card_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/cart_set_card_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/cart_set_item_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/cart_set_item_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/email_create_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/email_create_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/order.rbs +51 -6
- data/sig/{terminal-shop → terminal_shop}/models/order_create_params.rbs +4 -4
- data/sig/{terminal-shop → terminal_shop}/models/order_create_response.rbs +1 -1
- data/sig/terminal_shop/models/order_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/order_get_response.rbs +1 -1
- data/sig/terminal_shop/models/order_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/order_list_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/product.rbs +9 -3
- data/sig/terminal_shop/models/product_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/product_get_response.rbs +1 -1
- data/sig/terminal_shop/models/product_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/product_list_response.rbs +1 -1
- data/sig/terminal_shop/models/product_variant.rbs +70 -0
- data/sig/{terminal-shop → terminal_shop}/models/profile.rbs +2 -2
- data/sig/terminal_shop/models/profile_me_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/profile_me_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/profile_update_params.rbs +5 -4
- data/sig/{terminal-shop → terminal_shop}/models/profile_update_response.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/models/region.rbs +3 -2
- data/sig/{terminal-shop → terminal_shop}/models/subscription.rbs +12 -4
- data/sig/{terminal-shop → terminal_shop}/models/subscription_create_params.rbs +4 -3
- data/sig/{terminal-shop → terminal_shop}/models/subscription_create_response.rbs +1 -1
- data/sig/terminal_shop/models/subscription_delete_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/subscription_delete_response.rbs +1 -1
- data/sig/terminal_shop/models/subscription_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/subscription_get_response.rbs +1 -1
- data/sig/terminal_shop/models/subscription_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/subscription_list_response.rbs +1 -1
- data/sig/terminal_shop/models/subscription_update_params.rbs +71 -0
- data/sig/terminal_shop/models/subscription_update_response.rbs +14 -0
- data/sig/{terminal-shop → terminal_shop}/models/token.rbs +1 -1
- data/sig/terminal_shop/models/token_create_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/token_create_response.rbs +2 -2
- data/sig/terminal_shop/models/token_delete_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/token_delete_response.rbs +1 -1
- data/sig/terminal_shop/models/token_get_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/token_get_response.rbs +1 -1
- data/sig/terminal_shop/models/token_list_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/token_list_response.rbs +1 -1
- data/sig/terminal_shop/models/view_init_params.rbs +15 -0
- data/sig/{terminal-shop → terminal_shop}/models/view_init_response.rbs +2 -2
- data/sig/{terminal-shop → terminal_shop}/request_options.rbs +1 -1
- data/sig/{terminal-shop → terminal_shop}/resources/subscription.rbs +10 -0
- data/sig/{terminal-shop → terminal_shop}/version.rbs +1 -1
- metadata +354 -339
- data/lib/terminal-shop/errors.rb +0 -183
- data/lib/terminal-shop/models/address.rb +0 -90
- data/lib/terminal-shop/models/address_create_params.rb +0 -86
- data/lib/terminal-shop/models/address_create_response.rb +0 -20
- data/lib/terminal-shop/models/address_delete_params.rb +0 -18
- data/lib/terminal-shop/models/address_delete_response.rb +0 -19
- data/lib/terminal-shop/models/address_get_params.rb +0 -18
- data/lib/terminal-shop/models/address_list_params.rb +0 -18
- data/lib/terminal-shop/models/address_list_response.rb +0 -20
- data/lib/terminal-shop/models/app_create_params.rb +0 -30
- data/lib/terminal-shop/models/app_delete_params.rb +0 -18
- data/lib/terminal-shop/models/app_delete_response.rb +0 -19
- data/lib/terminal-shop/models/app_get_params.rb +0 -18
- data/lib/terminal-shop/models/app_list_params.rb +0 -18
- data/lib/terminal-shop/models/app_list_response.rb +0 -20
- data/lib/terminal-shop/models/card.rb +0 -67
- data/lib/terminal-shop/models/card_collect_params.rb +0 -18
- data/lib/terminal-shop/models/card_collect_response.rb +0 -38
- data/lib/terminal-shop/models/card_create_params.rb +0 -26
- data/lib/terminal-shop/models/card_create_response.rb +0 -20
- data/lib/terminal-shop/models/card_delete_params.rb +0 -18
- data/lib/terminal-shop/models/card_delete_response.rb +0 -19
- data/lib/terminal-shop/models/card_get_params.rb +0 -18
- data/lib/terminal-shop/models/card_list_params.rb +0 -18
- data/lib/terminal-shop/models/card_list_response.rb +0 -20
- data/lib/terminal-shop/models/cart.rb +0 -178
- data/lib/terminal-shop/models/cart_clear_params.rb +0 -18
- data/lib/terminal-shop/models/cart_clear_response.rb +0 -19
- data/lib/terminal-shop/models/cart_convert_params.rb +0 -18
- data/lib/terminal-shop/models/cart_get_params.rb +0 -18
- data/lib/terminal-shop/models/cart_set_address_params.rb +0 -25
- data/lib/terminal-shop/models/cart_set_address_response.rb +0 -19
- data/lib/terminal-shop/models/cart_set_card_params.rb +0 -25
- data/lib/terminal-shop/models/cart_set_card_response.rb +0 -19
- data/lib/terminal-shop/models/cart_set_item_params.rb +0 -32
- data/lib/terminal-shop/models/email_create_params.rb +0 -25
- data/lib/terminal-shop/models/email_create_response.rb +0 -19
- data/lib/terminal-shop/models/order.rb +0 -257
- data/lib/terminal-shop/models/order_create_params.rb +0 -39
- data/lib/terminal-shop/models/order_create_response.rb +0 -20
- data/lib/terminal-shop/models/order_get_params.rb +0 -18
- data/lib/terminal-shop/models/order_list_params.rb +0 -18
- data/lib/terminal-shop/models/order_list_response.rb +0 -20
- data/lib/terminal-shop/models/product.rb +0 -150
- data/lib/terminal-shop/models/product_get_params.rb +0 -18
- data/lib/terminal-shop/models/product_list_params.rb +0 -18
- data/lib/terminal-shop/models/product_list_response.rb +0 -20
- data/lib/terminal-shop/models/product_variant.rb +0 -36
- data/lib/terminal-shop/models/profile_me_params.rb +0 -18
- data/lib/terminal-shop/models/profile_update_params.rb +0 -30
- data/lib/terminal-shop/models/subscription.rb +0 -119
- data/lib/terminal-shop/models/subscription_create_params.rb +0 -18
- data/lib/terminal-shop/models/subscription_create_response.rb +0 -19
- data/lib/terminal-shop/models/subscription_delete_params.rb +0 -18
- data/lib/terminal-shop/models/subscription_delete_response.rb +0 -19
- data/lib/terminal-shop/models/subscription_get_params.rb +0 -18
- data/lib/terminal-shop/models/subscription_list_params.rb +0 -18
- data/lib/terminal-shop/models/subscription_list_response.rb +0 -20
- data/lib/terminal-shop/models/token.rb +0 -37
- data/lib/terminal-shop/models/token_create_params.rb +0 -18
- data/lib/terminal-shop/models/token_create_response.rb +0 -42
- data/lib/terminal-shop/models/token_delete_params.rb +0 -18
- data/lib/terminal-shop/models/token_delete_response.rb +0 -19
- data/lib/terminal-shop/models/token_get_params.rb +0 -18
- data/lib/terminal-shop/models/token_get_response.rb +0 -21
- data/lib/terminal-shop/models/token_list_params.rb +0 -18
- data/lib/terminal-shop/models/token_list_response.rb +0 -20
- data/lib/terminal-shop/models/view_init_params.rb +0 -18
- data/lib/terminal-shop/models/view_init_response.rb +0 -93
- data/lib/terminal-shop/resources/subscription.rb +0 -96
- data/lib/terminal-shop/transport/base_client.rb +0 -459
- data/lib/terminal-shop/transport/pooled_net_requester.rb +0 -182
- data/lib/terminal-shop/type/array_of.rb +0 -112
- data/lib/terminal-shop/type/base_model.rb +0 -364
- data/lib/terminal-shop/type/base_page.rb +0 -61
- data/lib/terminal-shop/type/boolean_model.rb +0 -52
- data/lib/terminal-shop/type/converter.rb +0 -217
- data/lib/terminal-shop/type/enum.rb +0 -101
- data/lib/terminal-shop/type/hash_of.rb +0 -138
- data/lib/terminal-shop/type/request_parameters.rb +0 -38
- data/lib/terminal-shop/type/union.rb +0 -185
- data/lib/terminal-shop/type/unknown.rb +0 -56
- data/lib/terminal-shop/type.rb +0 -23
- data/lib/terminal-shop/util.rb +0 -726
- data/lib/terminal-shop.rb +0 -149
- data/rbi/lib/terminal-shop/errors.rbi +0 -144
- data/rbi/lib/terminal-shop/models/address_delete_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/address_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/address_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/app_delete_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/app_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/app_get_response.rbi +0 -22
- data/rbi/lib/terminal-shop/models/app_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/card_collect_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/card_create_params.rbi +0 -32
- data/rbi/lib/terminal-shop/models/card_delete_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/card_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/card_get_response.rbi +0 -22
- data/rbi/lib/terminal-shop/models/card_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/cart_clear_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/cart_convert_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/cart_convert_response.rbi +0 -22
- data/rbi/lib/terminal-shop/models/cart_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/cart_get_response.rbi +0 -22
- data/rbi/lib/terminal-shop/models/cart_set_card_params.rbi +0 -31
- data/rbi/lib/terminal-shop/models/cart_set_item_response.rbi +0 -22
- data/rbi/lib/terminal-shop/models/email_create_params.rbi +0 -31
- data/rbi/lib/terminal-shop/models/order_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/order_get_response.rbi +0 -22
- data/rbi/lib/terminal-shop/models/order_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/product_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/product_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/product_variant.rbi +0 -28
- data/rbi/lib/terminal-shop/models/profile_me_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/subscription_delete_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/subscription_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/subscription_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/token_create_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/token_delete_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/token_get_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/token_get_response.rbi +0 -23
- data/rbi/lib/terminal-shop/models/token_list_params.rbi +0 -21
- data/rbi/lib/terminal-shop/models/view_init_params.rbi +0 -21
- data/rbi/lib/terminal-shop/transport/base_client.rbi +0 -208
- data/rbi/lib/terminal-shop/transport/pooled_net_requester.rbi +0 -64
- data/rbi/lib/terminal-shop/type/array_of.rbi +0 -82
- data/rbi/lib/terminal-shop/type/base_model.rbi +0 -194
- data/rbi/lib/terminal-shop/type/base_page.rbi +0 -38
- data/rbi/lib/terminal-shop/type/boolean_model.rbi +0 -41
- data/rbi/lib/terminal-shop/type/converter.rbi +0 -101
- data/rbi/lib/terminal-shop/type/enum.rbi +0 -58
- data/rbi/lib/terminal-shop/type/hash_of.rbi +0 -85
- data/rbi/lib/terminal-shop/type/request_parameters.rbi +0 -20
- data/rbi/lib/terminal-shop/type/union.rbi +0 -68
- data/rbi/lib/terminal-shop/type/unknown.rbi +0 -37
- data/rbi/lib/terminal-shop/type.rbi +0 -23
- data/rbi/lib/terminal-shop/util.rbi +0 -281
- data/sig/terminal-shop/errors.rbs +0 -99
- data/sig/terminal-shop/models/address_delete_params.rbs +0 -14
- data/sig/terminal-shop/models/address_get_params.rbs +0 -14
- data/sig/terminal-shop/models/address_list_params.rbs +0 -14
- data/sig/terminal-shop/models/app_delete_params.rbs +0 -14
- data/sig/terminal-shop/models/app_get_params.rbs +0 -14
- data/sig/terminal-shop/models/app_list_params.rbs +0 -14
- data/sig/terminal-shop/models/card_collect_params.rbs +0 -14
- data/sig/terminal-shop/models/card_delete_params.rbs +0 -14
- data/sig/terminal-shop/models/card_get_params.rbs +0 -14
- data/sig/terminal-shop/models/card_list_params.rbs +0 -14
- data/sig/terminal-shop/models/cart_clear_params.rbs +0 -14
- data/sig/terminal-shop/models/cart_convert_params.rbs +0 -14
- data/sig/terminal-shop/models/cart_get_params.rbs +0 -14
- data/sig/terminal-shop/models/order_get_params.rbs +0 -14
- data/sig/terminal-shop/models/order_list_params.rbs +0 -14
- data/sig/terminal-shop/models/product_get_params.rbs +0 -14
- data/sig/terminal-shop/models/product_list_params.rbs +0 -14
- data/sig/terminal-shop/models/product_variant.rbs +0 -17
- data/sig/terminal-shop/models/profile_me_params.rbs +0 -14
- data/sig/terminal-shop/models/subscription_delete_params.rbs +0 -14
- data/sig/terminal-shop/models/subscription_get_params.rbs +0 -14
- data/sig/terminal-shop/models/subscription_list_params.rbs +0 -14
- data/sig/terminal-shop/models/token_create_params.rbs +0 -14
- data/sig/terminal-shop/models/token_delete_params.rbs +0 -14
- data/sig/terminal-shop/models/token_get_params.rbs +0 -14
- data/sig/terminal-shop/models/token_list_params.rbs +0 -14
- data/sig/terminal-shop/models/view_init_params.rbs +0 -14
- data/sig/terminal-shop/transport/base_client.rbs +0 -110
- data/sig/terminal-shop/transport/pooled_net_requester.rbs +0 -39
- data/sig/terminal-shop/type/array_of.rbs +0 -36
- data/sig/terminal-shop/type/base_model.rbs +0 -73
- data/sig/terminal-shop/type/base_page.rbs +0 -22
- data/sig/terminal-shop/type/boolean_model.rbs +0 -18
- data/sig/terminal-shop/type/converter.rbs +0 -42
- data/sig/terminal-shop/type/enum.rbs +0 -22
- data/sig/terminal-shop/type/hash_of.rbs +0 -36
- data/sig/terminal-shop/type/request_parameters.rbs +0 -13
- data/sig/terminal-shop/type/union.rbs +0 -40
- data/sig/terminal-shop/type/unknown.rbs +0 -18
- data/sig/terminal-shop/type.rbs +0 -22
- data/sig/terminal-shop/util.rbs +0 -136
- /data/sig/{terminal-shop → terminal_shop}/resources/address.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/app.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/card.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/cart.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/email.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/order.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/product.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/profile.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/token.rbs +0 -0
- /data/sig/{terminal-shop → terminal_shop}/resources/view.rbs +0 -0
@@ -0,0 +1,274 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
module Converter
|
8
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
#
|
12
|
+
# @param value [Object]
|
13
|
+
#
|
14
|
+
# @param state [Hash{Symbol=>Object}] .
|
15
|
+
#
|
16
|
+
# @option state [Boolean, :strong] :strictness
|
17
|
+
#
|
18
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
19
|
+
#
|
20
|
+
# @option state [Integer] :branched
|
21
|
+
#
|
22
|
+
# @return [Object]
|
23
|
+
def coerce(value, state:) = (raise NotImplementedError)
|
24
|
+
|
25
|
+
# @api private
|
26
|
+
#
|
27
|
+
# @param value [Object]
|
28
|
+
#
|
29
|
+
# @param state [Hash{Symbol=>Object}] .
|
30
|
+
#
|
31
|
+
# @option state [Boolean] :can_retry
|
32
|
+
#
|
33
|
+
# @return [Object]
|
34
|
+
def dump(value, state:)
|
35
|
+
case value
|
36
|
+
in Array
|
37
|
+
value.map { TerminalShop::Internal::Type::Unknown.dump(_1, state: state) }
|
38
|
+
in Hash
|
39
|
+
value.transform_values { TerminalShop::Internal::Type::Unknown.dump(_1, state: state) }
|
40
|
+
in TerminalShop::Internal::Type::BaseModel
|
41
|
+
value.class.dump(value, state: state)
|
42
|
+
in StringIO
|
43
|
+
value.string
|
44
|
+
in Pathname | IO
|
45
|
+
state[:can_retry] = false if value.is_a?(IO)
|
46
|
+
TerminalShop::FilePart.new(value)
|
47
|
+
in TerminalShop::FilePart
|
48
|
+
state[:can_retry] = false if value.content.is_a?(IO)
|
49
|
+
value
|
50
|
+
else
|
51
|
+
value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# @api private
|
56
|
+
#
|
57
|
+
# @param depth [Integer]
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
def inspect(depth: 0)
|
61
|
+
super()
|
62
|
+
end
|
63
|
+
|
64
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
65
|
+
|
66
|
+
class << self
|
67
|
+
# @api private
|
68
|
+
#
|
69
|
+
# @param spec [Hash{Symbol=>Object}, Proc, TerminalShop::Internal::Type::Converter, Class] .
|
70
|
+
#
|
71
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
72
|
+
#
|
73
|
+
# @option spec [Proc] :enum
|
74
|
+
#
|
75
|
+
# @option spec [Proc] :union
|
76
|
+
#
|
77
|
+
# @option spec [Boolean] :"nil?"
|
78
|
+
#
|
79
|
+
# @return [Proc]
|
80
|
+
def type_info(spec)
|
81
|
+
case spec
|
82
|
+
in Proc
|
83
|
+
spec
|
84
|
+
in Hash
|
85
|
+
type_info(spec.slice(:const, :enum, :union).first&.last)
|
86
|
+
in true | false
|
87
|
+
-> { TerminalShop::Internal::Type::Boolean }
|
88
|
+
in TerminalShop::Internal::Type::Converter | Class | Symbol
|
89
|
+
-> { spec }
|
90
|
+
in NilClass | Integer | Float
|
91
|
+
-> { spec.class }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# @api private
|
96
|
+
#
|
97
|
+
# Based on `target`, transform `value` into `target`, to the extent possible:
|
98
|
+
#
|
99
|
+
# 1. if the given `value` conforms to `target` already, return the given `value`
|
100
|
+
# 2. if it's possible and safe to convert the given `value` to `target`, then the
|
101
|
+
# converted value
|
102
|
+
# 3. otherwise, the given `value` unaltered
|
103
|
+
#
|
104
|
+
# The coercion process is subject to improvement between minor release versions.
|
105
|
+
# See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
|
106
|
+
#
|
107
|
+
# @param target [TerminalShop::Internal::Type::Converter, Class]
|
108
|
+
#
|
109
|
+
# @param value [Object]
|
110
|
+
#
|
111
|
+
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`, or `:strong`. This informs the
|
112
|
+
# coercion strategy when we have to decide between multiple possible conversion
|
113
|
+
# targets:
|
114
|
+
#
|
115
|
+
# - `true`: the conversion must be exact, with minimum coercion.
|
116
|
+
# - `false`: the conversion can be approximate, with some coercion.
|
117
|
+
# - `:strong`: the conversion must be exact, with no coercion, and raise an error
|
118
|
+
# if not possible.
|
119
|
+
#
|
120
|
+
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
|
121
|
+
# any given conversion attempt, the exactness will be updated based on how closely
|
122
|
+
# the value recursively matches the target type:
|
123
|
+
#
|
124
|
+
# - `yes`: the value can be converted to the target type with minimum coercion.
|
125
|
+
# - `maybe`: the value can be converted to the target type with some reasonable
|
126
|
+
# coercion.
|
127
|
+
# - `no`: the value cannot be converted to the target type.
|
128
|
+
#
|
129
|
+
# See implementation below for more details.
|
130
|
+
#
|
131
|
+
# @option state [Boolean, :strong] :strictness
|
132
|
+
#
|
133
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
134
|
+
#
|
135
|
+
# @option state [Integer] :branched
|
136
|
+
#
|
137
|
+
# @return [Object]
|
138
|
+
def coerce(
|
139
|
+
target,
|
140
|
+
value,
|
141
|
+
state: {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0}
|
142
|
+
)
|
143
|
+
# rubocop:disable Lint/SuppressedException
|
144
|
+
# rubocop:disable Metrics/BlockNesting
|
145
|
+
strictness, exactness = state.fetch_values(:strictness, :exactness)
|
146
|
+
|
147
|
+
case target
|
148
|
+
in TerminalShop::Internal::Type::Converter
|
149
|
+
return target.coerce(value, state: state)
|
150
|
+
in Class
|
151
|
+
if value.is_a?(target)
|
152
|
+
exactness[:yes] += 1
|
153
|
+
return value
|
154
|
+
end
|
155
|
+
|
156
|
+
case target
|
157
|
+
in -> { _1 <= NilClass }
|
158
|
+
exactness[value.nil? ? :yes : :maybe] += 1
|
159
|
+
return nil
|
160
|
+
in -> { _1 <= Integer }
|
161
|
+
if value.is_a?(Integer)
|
162
|
+
exactness[:yes] += 1
|
163
|
+
return value
|
164
|
+
elsif strictness == :strong && Integer(value, exception: false) != value
|
165
|
+
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
166
|
+
raise value.is_a?(Numeric) ? ArgumentError.new(message) : TypeError.new(message)
|
167
|
+
else
|
168
|
+
Kernel.then do
|
169
|
+
return Integer(value).tap { exactness[:maybe] += 1 }
|
170
|
+
rescue ArgumentError, TypeError
|
171
|
+
end
|
172
|
+
end
|
173
|
+
in -> { _1 <= Float }
|
174
|
+
if value.is_a?(Numeric)
|
175
|
+
exactness[:yes] += 1
|
176
|
+
return Float(value)
|
177
|
+
elsif strictness == :strong
|
178
|
+
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
179
|
+
raise TypeError.new(message)
|
180
|
+
else
|
181
|
+
Kernel.then do
|
182
|
+
return Float(value).tap { exactness[:maybe] += 1 }
|
183
|
+
rescue ArgumentError, TypeError
|
184
|
+
end
|
185
|
+
end
|
186
|
+
in -> { _1 <= String }
|
187
|
+
case value
|
188
|
+
in String | Symbol | Numeric
|
189
|
+
exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1
|
190
|
+
return value.to_s
|
191
|
+
in StringIO
|
192
|
+
exactness[:yes] += 1
|
193
|
+
return value.string
|
194
|
+
else
|
195
|
+
if strictness == :strong
|
196
|
+
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
197
|
+
raise TypeError.new(message)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
in -> { _1 <= Date || _1 <= Time }
|
201
|
+
Kernel.then do
|
202
|
+
return target.parse(value).tap { exactness[:yes] += 1 }
|
203
|
+
rescue ArgumentError, TypeError => e
|
204
|
+
raise e if strictness == :strong
|
205
|
+
end
|
206
|
+
in -> { _1 <= StringIO } if value.is_a?(String)
|
207
|
+
exactness[:yes] += 1
|
208
|
+
return StringIO.new(value.b)
|
209
|
+
else
|
210
|
+
end
|
211
|
+
in Symbol
|
212
|
+
case value
|
213
|
+
in Symbol | String
|
214
|
+
if value.to_sym == target
|
215
|
+
exactness[:yes] += 1
|
216
|
+
return target
|
217
|
+
else
|
218
|
+
exactness[:maybe] += 1
|
219
|
+
return value
|
220
|
+
end
|
221
|
+
else
|
222
|
+
if strictness == :strong
|
223
|
+
message = "cannot convert non-matching #{value.class} into #{target.inspect}"
|
224
|
+
raise ArgumentError.new(message)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
else
|
228
|
+
end
|
229
|
+
|
230
|
+
exactness[:no] += 1
|
231
|
+
value
|
232
|
+
# rubocop:enable Metrics/BlockNesting
|
233
|
+
# rubocop:enable Lint/SuppressedException
|
234
|
+
end
|
235
|
+
|
236
|
+
# @api private
|
237
|
+
#
|
238
|
+
# @param target [TerminalShop::Internal::Type::Converter, Class]
|
239
|
+
#
|
240
|
+
# @param value [Object]
|
241
|
+
#
|
242
|
+
# @param state [Hash{Symbol=>Object}] .
|
243
|
+
#
|
244
|
+
# @option state [Boolean] :can_retry
|
245
|
+
#
|
246
|
+
# @return [Object]
|
247
|
+
def dump(target, value, state: {can_retry: true})
|
248
|
+
case target
|
249
|
+
in TerminalShop::Internal::Type::Converter
|
250
|
+
target.dump(value, state: state)
|
251
|
+
else
|
252
|
+
TerminalShop::Internal::Type::Unknown.dump(value, state: state)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# @api private
|
257
|
+
#
|
258
|
+
# @param target [Object]
|
259
|
+
# @param depth [Integer]
|
260
|
+
#
|
261
|
+
# @return [String]
|
262
|
+
def inspect(target, depth:)
|
263
|
+
case target
|
264
|
+
in TerminalShop::Internal::Type::Converter
|
265
|
+
target.inspect(depth: depth.succ)
|
266
|
+
else
|
267
|
+
target.inspect
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# A value from among a specified list of options. OpenAPI enum values map to Ruby
|
9
|
+
# values in the SDK as follows:
|
10
|
+
#
|
11
|
+
# 1. boolean => true | false
|
12
|
+
# 2. integer => Integer
|
13
|
+
# 3. float => Float
|
14
|
+
# 4. string => Symbol
|
15
|
+
#
|
16
|
+
# We can therefore convert string values to Symbols, but can't convert other
|
17
|
+
# values safely.
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# # `region` is a `TerminalShop::Models::Region`
|
21
|
+
# case region
|
22
|
+
# when TerminalShop::Models::Region::EU
|
23
|
+
# # ...
|
24
|
+
# when TerminalShop::Models::Region::NA
|
25
|
+
# # ...
|
26
|
+
# when TerminalShop::Models::Region::GLOBAL
|
27
|
+
# # ...
|
28
|
+
# else
|
29
|
+
# puts(region)
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# case region
|
34
|
+
# in :eu
|
35
|
+
# # ...
|
36
|
+
# in :na
|
37
|
+
# # ...
|
38
|
+
# in :global
|
39
|
+
# # ...
|
40
|
+
# else
|
41
|
+
# puts(region)
|
42
|
+
# end
|
43
|
+
module Enum
|
44
|
+
include TerminalShop::Internal::Type::Converter
|
45
|
+
|
46
|
+
# All of the valid Symbol values for this enum.
|
47
|
+
#
|
48
|
+
# @return [Array<NilClass, Boolean, Integer, Float, Symbol>]
|
49
|
+
def values = constants.map { const_get(_1) }
|
50
|
+
|
51
|
+
# @api public
|
52
|
+
#
|
53
|
+
# @param other [Object]
|
54
|
+
#
|
55
|
+
# @return [Boolean]
|
56
|
+
def ===(other) = values.include?(other)
|
57
|
+
|
58
|
+
# @api public
|
59
|
+
#
|
60
|
+
# @param other [Object]
|
61
|
+
#
|
62
|
+
# @return [Boolean]
|
63
|
+
def ==(other)
|
64
|
+
# rubocop:disable Style/CaseEquality
|
65
|
+
TerminalShop::Internal::Type::Enum === other && other.values.to_set == values.to_set
|
66
|
+
# rubocop:enable Style/CaseEquality
|
67
|
+
end
|
68
|
+
|
69
|
+
# @api public
|
70
|
+
#
|
71
|
+
# @return [Integer]
|
72
|
+
def hash = values.to_set.hash
|
73
|
+
|
74
|
+
# @api private
|
75
|
+
#
|
76
|
+
# Unlike with primitives, `Enum` additionally validates that the value is a member
|
77
|
+
# of the enum.
|
78
|
+
#
|
79
|
+
# @param value [String, Symbol, Object]
|
80
|
+
#
|
81
|
+
# @param state [Hash{Symbol=>Object}] .
|
82
|
+
#
|
83
|
+
# @option state [Boolean, :strong] :strictness
|
84
|
+
#
|
85
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
86
|
+
#
|
87
|
+
# @option state [Integer] :branched
|
88
|
+
#
|
89
|
+
# @return [Symbol, Object]
|
90
|
+
def coerce(value, state:)
|
91
|
+
exactness = state.fetch(:exactness)
|
92
|
+
val = value.is_a?(String) ? value.to_sym : value
|
93
|
+
|
94
|
+
if values.include?(val)
|
95
|
+
exactness[:yes] += 1
|
96
|
+
val
|
97
|
+
else
|
98
|
+
exactness[values.first&.class == val.class ? :maybe : :no] += 1
|
99
|
+
value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# @!parse
|
104
|
+
# # @api private
|
105
|
+
# #
|
106
|
+
# # @param value [Symbol, Object]
|
107
|
+
# #
|
108
|
+
# # @param state [Hash{Symbol=>Object}] .
|
109
|
+
# #
|
110
|
+
# # @option state [Boolean] :can_retry
|
111
|
+
# #
|
112
|
+
# # @return [Symbol, Object]
|
113
|
+
# def dump(value, state:) = super
|
114
|
+
|
115
|
+
# @api private
|
116
|
+
#
|
117
|
+
# @param depth [Integer]
|
118
|
+
#
|
119
|
+
# @return [String]
|
120
|
+
def inspect(depth: 0)
|
121
|
+
if depth.positive?
|
122
|
+
return is_a?(Module) ? super() : self.class.name
|
123
|
+
end
|
124
|
+
|
125
|
+
members = values.map { TerminalShop::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
|
126
|
+
prefix = is_a?(Module) ? name : self.class.name
|
127
|
+
|
128
|
+
"#{prefix}[#{members.join(' | ')}]"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# @abstract
|
9
|
+
#
|
10
|
+
# Either `Pathname` or `StringIO`, or `IO`, or
|
11
|
+
# `TerminalShop::Internal::Type::FileInput`.
|
12
|
+
#
|
13
|
+
# Note: when `IO` is used, all retries are disabled, since many IO` streams are
|
14
|
+
# not rewindable.
|
15
|
+
class FileInput
|
16
|
+
extend TerminalShop::Internal::Type::Converter
|
17
|
+
|
18
|
+
private_class_method :new
|
19
|
+
|
20
|
+
# @api public
|
21
|
+
#
|
22
|
+
# @param other [Object]
|
23
|
+
#
|
24
|
+
# @return [Boolean]
|
25
|
+
def self.===(other)
|
26
|
+
case other
|
27
|
+
in Pathname | StringIO | IO | String | TerminalShop::FilePart
|
28
|
+
true
|
29
|
+
else
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @api public
|
35
|
+
#
|
36
|
+
# @param other [Object]
|
37
|
+
#
|
38
|
+
# @return [Boolean]
|
39
|
+
def self.==(other) = other.is_a?(Class) && other <= TerminalShop::Internal::Type::FileInput
|
40
|
+
|
41
|
+
class << self
|
42
|
+
# @api private
|
43
|
+
#
|
44
|
+
# @param value [StringIO, String, Object]
|
45
|
+
#
|
46
|
+
# @param state [Hash{Symbol=>Object}] .
|
47
|
+
#
|
48
|
+
# @option state [Boolean, :strong] :strictness
|
49
|
+
#
|
50
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
51
|
+
#
|
52
|
+
# @option state [Integer] :branched
|
53
|
+
#
|
54
|
+
# @return [StringIO, Object]
|
55
|
+
def coerce(value, state:)
|
56
|
+
exactness = state.fetch(:exactness)
|
57
|
+
case value
|
58
|
+
in String
|
59
|
+
exactness[:yes] += 1
|
60
|
+
StringIO.new(value)
|
61
|
+
in StringIO
|
62
|
+
exactness[:yes] += 1
|
63
|
+
value
|
64
|
+
else
|
65
|
+
exactness[:no] += 1
|
66
|
+
value
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# @api private
|
71
|
+
#
|
72
|
+
# @param value [Pathname, StringIO, IO, String, Object]
|
73
|
+
#
|
74
|
+
# @param state [Hash{Symbol=>Object}] .
|
75
|
+
#
|
76
|
+
# @option state [Boolean] :can_retry
|
77
|
+
#
|
78
|
+
# @return [Pathname, StringIO, IO, String, Object]
|
79
|
+
def dump(value, state:)
|
80
|
+
# rubocop:disable Lint/DuplicateBranch
|
81
|
+
case value
|
82
|
+
in IO
|
83
|
+
state[:can_retry] = false
|
84
|
+
in TerminalShop::FilePart if value.content.is_a?(IO)
|
85
|
+
state[:can_retry] = false
|
86
|
+
else
|
87
|
+
end
|
88
|
+
# rubocop:enable Lint/DuplicateBranch
|
89
|
+
|
90
|
+
value
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# @abstract
|
9
|
+
#
|
10
|
+
# @generic Elem
|
11
|
+
#
|
12
|
+
# Hash of items of a given type.
|
13
|
+
class HashOf
|
14
|
+
include TerminalShop::Internal::Type::Converter
|
15
|
+
|
16
|
+
private_class_method :new
|
17
|
+
|
18
|
+
# @overload [](type_info, spec = {})
|
19
|
+
#
|
20
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, TerminalShop::Internal::Type::Converter, Class]
|
21
|
+
#
|
22
|
+
# @param spec [Hash{Symbol=>Object}] .
|
23
|
+
#
|
24
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
25
|
+
#
|
26
|
+
# @option spec [Proc] :enum
|
27
|
+
#
|
28
|
+
# @option spec [Proc] :union
|
29
|
+
#
|
30
|
+
# @option spec [Boolean] :"nil?"
|
31
|
+
#
|
32
|
+
# @return [TerminalShop::Internal::Type::HashOf]
|
33
|
+
def self.[](...) = new(...)
|
34
|
+
|
35
|
+
# @api public
|
36
|
+
#
|
37
|
+
# @param other [Object]
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
def ===(other)
|
41
|
+
type = item_type
|
42
|
+
case other
|
43
|
+
in Hash
|
44
|
+
other.all? do |key, val|
|
45
|
+
case [key, val]
|
46
|
+
in [Symbol | String, ^type]
|
47
|
+
true
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# @api public
|
58
|
+
#
|
59
|
+
# @param other [Object]
|
60
|
+
#
|
61
|
+
# @return [Boolean]
|
62
|
+
def ==(other)
|
63
|
+
# rubocop:disable Layout/LineLength
|
64
|
+
other.is_a?(TerminalShop::Internal::Type::HashOf) && other.nilable? == nilable? && other.item_type == item_type
|
65
|
+
# rubocop:enable Layout/LineLength
|
66
|
+
end
|
67
|
+
|
68
|
+
# @api public
|
69
|
+
#
|
70
|
+
# @return [Integer]
|
71
|
+
def hash = [self.class, item_type].hash
|
72
|
+
|
73
|
+
# @api private
|
74
|
+
#
|
75
|
+
# @param value [Hash{Object=>Object}, Object]
|
76
|
+
#
|
77
|
+
# @param state [Hash{Symbol=>Object}] .
|
78
|
+
#
|
79
|
+
# @option state [Boolean, :strong] :strictness
|
80
|
+
#
|
81
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
82
|
+
#
|
83
|
+
# @option state [Integer] :branched
|
84
|
+
#
|
85
|
+
# @return [Hash{Symbol=>Object}, Object]
|
86
|
+
def coerce(value, state:)
|
87
|
+
exactness = state.fetch(:exactness)
|
88
|
+
|
89
|
+
unless value.is_a?(Hash)
|
90
|
+
exactness[:no] += 1
|
91
|
+
return value
|
92
|
+
end
|
93
|
+
|
94
|
+
target = item_type
|
95
|
+
exactness[:yes] += 1
|
96
|
+
value
|
97
|
+
.to_h do |key, val|
|
98
|
+
k = key.is_a?(String) ? key.to_sym : key
|
99
|
+
v =
|
100
|
+
case [nilable?, val]
|
101
|
+
in [true, nil]
|
102
|
+
exactness[:yes] += 1
|
103
|
+
nil
|
104
|
+
else
|
105
|
+
TerminalShop::Internal::Type::Converter.coerce(target, val, state: state)
|
106
|
+
end
|
107
|
+
|
108
|
+
exactness[:no] += 1 unless k.is_a?(Symbol)
|
109
|
+
[k, v]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# @api private
|
114
|
+
#
|
115
|
+
# @param value [Hash{Object=>Object}, Object]
|
116
|
+
#
|
117
|
+
# @param state [Hash{Symbol=>Object}] .
|
118
|
+
#
|
119
|
+
# @option state [Boolean] :can_retry
|
120
|
+
#
|
121
|
+
# @return [Hash{Symbol=>Object}, Object]
|
122
|
+
def dump(value, state:)
|
123
|
+
target = item_type
|
124
|
+
if value.is_a?(Hash)
|
125
|
+
value.transform_values do
|
126
|
+
TerminalShop::Internal::Type::Converter.dump(target, _1, state: state)
|
127
|
+
end
|
128
|
+
else
|
129
|
+
super
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# @api private
|
134
|
+
#
|
135
|
+
# @return [generic<Elem>]
|
136
|
+
protected def item_type = @item_type_fn.call
|
137
|
+
|
138
|
+
# @api private
|
139
|
+
#
|
140
|
+
# @return [Boolean]
|
141
|
+
protected def nilable? = @nilable
|
142
|
+
|
143
|
+
# @api private
|
144
|
+
#
|
145
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, TerminalShop::Internal::Type::Converter, Class]
|
146
|
+
#
|
147
|
+
# @param spec [Hash{Symbol=>Object}] .
|
148
|
+
#
|
149
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
150
|
+
#
|
151
|
+
# @option spec [Proc] :enum
|
152
|
+
#
|
153
|
+
# @option spec [Proc] :union
|
154
|
+
#
|
155
|
+
# @option spec [Boolean] :"nil?"
|
156
|
+
def initialize(type_info, spec = {})
|
157
|
+
@item_type_fn = TerminalShop::Internal::Type::Converter.type_info(type_info || spec)
|
158
|
+
@nilable = spec.fetch(:nil?, false)
|
159
|
+
end
|
160
|
+
|
161
|
+
# @api private
|
162
|
+
#
|
163
|
+
# @param depth [Integer]
|
164
|
+
#
|
165
|
+
# @return [String]
|
166
|
+
def inspect(depth: 0)
|
167
|
+
items = TerminalShop::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
|
168
|
+
|
169
|
+
"#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|