x_api_scraper 0.1.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 +7 -0
- data/lib/crystalline/enum.rbi +17 -0
- data/lib/crystalline/metadata_fields.rb +265 -0
- data/lib/crystalline/module.rb +188 -0
- data/lib/crystalline/types.rb +170 -0
- data/lib/crystalline/utils.rb +69 -0
- data/lib/crystalline.rb +13 -0
- data/lib/x_api_scraper.rb +41 -0
- data/lib/xapi_scraper/account.rb +194 -0
- data/lib/xapi_scraper/actions.rb +2166 -0
- data/lib/xapi_scraper/analysis.rb +230 -0
- data/lib/xapi_scraper/articles.rb +410 -0
- data/lib/xapi_scraper/client.rb +133 -0
- data/lib/xapi_scraper/communities.rb +1352 -0
- data/lib/xapi_scraper/dm.rb +990 -0
- data/lib/xapi_scraper/engagement.rb +792 -0
- data/lib/xapi_scraper/followers.rb +420 -0
- data/lib/xapi_scraper/following.rb +230 -0
- data/lib/xapi_scraper/lists.rb +1156 -0
- data/lib/xapi_scraper/models/callbacks.rb +12 -0
- data/lib/xapi_scraper/models/components/accountverifymodel.rb +82 -0
- data/lib/xapi_scraper/models/components/accountverifymodel.rbi +38 -0
- data/lib/xapi_scraper/models/components/accountverifyresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/accountverifyresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/advancedsearchcursorquery.rb +51 -0
- data/lib/xapi_scraper/models/components/advancedsearchcursorquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/advancedsearchcursorresponse.rb +76 -0
- data/lib/xapi_scraper/models/components/advancedsearchcursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/articleblock.rb +50 -0
- data/lib/xapi_scraper/models/components/articleblock.rbi +26 -0
- data/lib/xapi_scraper/models/components/articleblockrange.rb +47 -0
- data/lib/xapi_scraper/models/components/articleblockrange.rbi +26 -0
- data/lib/xapi_scraper/models/components/blockuserresponse.rb +54 -0
- data/lib/xapi_scraper/models/components/blockuserresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/bookmarkbody.rb +43 -0
- data/lib/xapi_scraper/models/components/bookmarkbody.rbi +20 -0
- data/lib/xapi_scraper/models/components/cashtagsquery.rb +192 -0
- data/lib/xapi_scraper/models/components/cashtagsquery.rbi +98 -0
- data/lib/xapi_scraper/models/components/cashtagsquery_language.rb +76 -0
- data/lib/xapi_scraper/models/components/cashtagsquery_language.rbi +9 -0
- data/lib/xapi_scraper/models/components/cashtagsquery_sortby.rb +18 -0
- data/lib/xapi_scraper/models/components/cashtagsquery_sortby.rbi +9 -0
- data/lib/xapi_scraper/models/components/communitymodel.rb +164 -0
- data/lib/xapi_scraper/models/components/communitymodel.rbi +92 -0
- data/lib/xapi_scraper/models/components/communitytweetsresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/communitytweetsresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/context.rb +25 -0
- data/lib/xapi_scraper/models/components/context.rbi +9 -0
- data/lib/xapi_scraper/models/components/conversationv3model.rb +57 -0
- data/lib/xapi_scraper/models/components/conversationv3model.rbi +32 -0
- data/lib/xapi_scraper/models/components/createthreaddata.rb +35 -0
- data/lib/xapi_scraper/models/components/createthreaddata.rbi +14 -0
- data/lib/xapi_scraper/models/components/createthreadquery.rb +51 -0
- data/lib/xapi_scraper/models/components/createthreadquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/createthreadresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/createthreadresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/createthreadtweetitem.rb +31 -0
- data/lib/xapi_scraper/models/components/createthreadtweetitem.rbi +14 -0
- data/lib/xapi_scraper/models/components/deletebookmarkquery.rb +35 -0
- data/lib/xapi_scraper/models/components/deletebookmarkquery.rbi +14 -0
- data/lib/xapi_scraper/models/components/deleteretweetquery.rb +35 -0
- data/lib/xapi_scraper/models/components/deleteretweetquery.rbi +14 -0
- data/lib/xapi_scraper/models/components/deletetweetquery.rb +51 -0
- data/lib/xapi_scraper/models/components/deletetweetquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/deletetweetresponse.rb +51 -0
- data/lib/xapi_scraper/models/components/deletetweetresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/dmhistoryv3data.rb +54 -0
- data/lib/xapi_scraper/models/components/dmhistoryv3data.rbi +26 -0
- data/lib/xapi_scraper/models/components/dmstatusmodelv2.rb +122 -0
- data/lib/xapi_scraper/models/components/dmstatusmodelv2.rbi +62 -0
- data/lib/xapi_scraper/models/components/dmstatusresponsev2.rb +47 -0
- data/lib/xapi_scraper/models/components/dmstatusresponsev2.rbi +26 -0
- data/lib/xapi_scraper/models/components/followersfollowingv3query.rb +51 -0
- data/lib/xapi_scraper/models/components/followersfollowingv3query.rbi +26 -0
- data/lib/xapi_scraper/models/components/followuserquery.rb +43 -0
- data/lib/xapi_scraper/models/components/followuserquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getalltweetsrepliescursorquery.rb +43 -0
- data/lib/xapi_scraper/models/components/getalltweetsrepliescursorquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getalltweetsrepliescursorresponse.rb +76 -0
- data/lib/xapi_scraper/models/components/getalltweetsrepliescursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/getcommunitymemberscursorquery.rb +43 -0
- data/lib/xapi_scraper/models/components/getcommunitymemberscursorquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getcommunitymemberscursorresponse.rb +72 -0
- data/lib/xapi_scraper/models/components/getcommunitymemberscursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/getcommunityresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/getcommunityresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/getcommunitytweetscursorquery.rb +60 -0
- data/lib/xapi_scraper/models/components/getcommunitytweetscursorquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/getcommunitytweetscursorresponse.rb +72 -0
- data/lib/xapi_scraper/models/components/getcommunitytweetscursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/getconversationsv3query.rb +62 -0
- data/lib/xapi_scraper/models/components/getconversationsv3query.rbi +32 -0
- data/lib/xapi_scraper/models/components/getconversationsv3response.rb +47 -0
- data/lib/xapi_scraper/models/components/getconversationsv3response.rbi +26 -0
- data/lib/xapi_scraper/models/components/getdmhistoryv3query.rb +94 -0
- data/lib/xapi_scraper/models/components/getdmhistoryv3query.rbi +50 -0
- data/lib/xapi_scraper/models/components/getdmhistoryv3response.rb +47 -0
- data/lib/xapi_scraper/models/components/getdmhistoryv3response.rbi +26 -0
- data/lib/xapi_scraper/models/components/getdmmediav3data.rb +77 -0
- data/lib/xapi_scraper/models/components/getdmmediav3data.rbi +44 -0
- data/lib/xapi_scraper/models/components/getdmmediav3query.rb +112 -0
- data/lib/xapi_scraper/models/components/getdmmediav3query.rbi +56 -0
- data/lib/xapi_scraper/models/components/getdmmediav3response.rb +47 -0
- data/lib/xapi_scraper/models/components/getdmmediav3response.rbi +26 -0
- data/lib/xapi_scraper/models/components/getlistmemberscursorquery.rb +43 -0
- data/lib/xapi_scraper/models/components/getlistmemberscursorquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getlistmemberscursorresponse.rb +72 -0
- data/lib/xapi_scraper/models/components/getlistmemberscursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/getlisttweetscursorquery.rb +43 -0
- data/lib/xapi_scraper/models/components/getlisttweetscursorquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getlisttweetscursorresponse.rb +72 -0
- data/lib/xapi_scraper/models/components/getlisttweetscursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/getquotescursorquery.rb +63 -0
- data/lib/xapi_scraper/models/components/getquotescursorquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/getquotescursorquery_sort_by.rb +18 -0
- data/lib/xapi_scraper/models/components/getquotescursorquery_sort_by.rbi +9 -0
- data/lib/xapi_scraper/models/components/getquotescursorresponse.rb +72 -0
- data/lib/xapi_scraper/models/components/getquotescursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/getquotesquery.rb +59 -0
- data/lib/xapi_scraper/models/components/getquotesquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/getquotesquery_sort_by.rb +18 -0
- data/lib/xapi_scraper/models/components/getquotesquery_sort_by.rbi +9 -0
- data/lib/xapi_scraper/models/components/getquotesresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/getquotesresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/getrepliespagequery.rb +51 -0
- data/lib/xapi_scraper/models/components/getrepliespagequery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getrepliespagequery_sort_by.rb +19 -0
- data/lib/xapi_scraper/models/components/getrepliespagequery_sort_by.rbi +9 -0
- data/lib/xapi_scraper/models/components/getrepliespageresponse.rb +85 -0
- data/lib/xapi_scraper/models/components/getrepliespageresponse.rbi +44 -0
- data/lib/xapi_scraper/models/components/getretweeterscursorquery.rb +43 -0
- data/lib/xapi_scraper/models/components/getretweeterscursorquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/getretweeterscursorresponse.rb +72 -0
- data/lib/xapi_scraper/models/components/getretweeterscursorresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/gettweetsbyidresponse.rb +58 -0
- data/lib/xapi_scraper/models/components/gettweetsbyidresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/hashtagsquery.rb +192 -0
- data/lib/xapi_scraper/models/components/hashtagsquery.rbi +98 -0
- data/lib/xapi_scraper/models/components/hashtagsquery_language.rb +76 -0
- data/lib/xapi_scraper/models/components/hashtagsquery_language.rbi +9 -0
- data/lib/xapi_scraper/models/components/hashtagsquery_sortby.rb +18 -0
- data/lib/xapi_scraper/models/components/hashtagsquery_sortby.rbi +9 -0
- data/lib/xapi_scraper/models/components/likeactionbody.rb +43 -0
- data/lib/xapi_scraper/models/components/likeactionbody.rbi +20 -0
- data/lib/xapi_scraper/models/components/listmembersresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/listmembersresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/listmodel.rb +77 -0
- data/lib/xapi_scraper/models/components/listmodel.rbi +44 -0
- data/lib/xapi_scraper/models/components/listsubscribersresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/listsubscribersresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/listtweetsresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/listtweetsresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/loc.rb +25 -0
- data/lib/xapi_scraper/models/components/loc.rbi +9 -0
- data/lib/xapi_scraper/models/components/mediamodel.rb +194 -0
- data/lib/xapi_scraper/models/components/mediamodel.rbi +110 -0
- data/lib/xapi_scraper/models/components/messagemodel.rb +100 -0
- data/lib/xapi_scraper/models/components/messagemodel.rbi +56 -0
- data/lib/xapi_scraper/models/components/posttweetdata.rb +51 -0
- data/lib/xapi_scraper/models/components/posttweetdata.rbi +26 -0
- data/lib/xapi_scraper/models/components/posttweetquery.rb +122 -0
- data/lib/xapi_scraper/models/components/posttweetquery.rbi +62 -0
- data/lib/xapi_scraper/models/components/posttweetresponse.rb +58 -0
- data/lib/xapi_scraper/models/components/posttweetresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/posttweetwithoutcookiequery.rb +102 -0
- data/lib/xapi_scraper/models/components/posttweetwithoutcookiequery.rbi +50 -0
- data/lib/xapi_scraper/models/components/quotetweetquery.rb +112 -0
- data/lib/xapi_scraper/models/components/quotetweetquery.rbi +56 -0
- data/lib/xapi_scraper/models/components/retweetactionbody.rb +43 -0
- data/lib/xapi_scraper/models/components/retweetactionbody.rbi +20 -0
- data/lib/xapi_scraper/models/components/searchcommunityquery.rb +43 -0
- data/lib/xapi_scraper/models/components/searchcommunityquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/searchcommunityresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/searchcommunityresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/searchcommunitytweetsquery.rb +51 -0
- data/lib/xapi_scraper/models/components/searchcommunitytweetsquery.rbi +26 -0
- data/lib/xapi_scraper/models/components/searchlistquery.rb +43 -0
- data/lib/xapi_scraper/models/components/searchlistquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/searchlistresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/searchlistresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/searchresponse.rb +54 -0
- data/lib/xapi_scraper/models/components/searchresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/searchuserresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/searchuserresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/security.rb +34 -0
- data/lib/xapi_scraper/models/components/security.rbi +14 -0
- data/lib/xapi_scraper/models/components/senddmresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/senddmresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/senddmv3query.rb +90 -0
- data/lib/xapi_scraper/models/components/senddmv3query.rbi +50 -0
- data/lib/xapi_scraper/models/components/sentimentanalysismodel.rb +43 -0
- data/lib/xapi_scraper/models/components/sentimentanalysismodel.rbi +20 -0
- data/lib/xapi_scraper/models/components/sentimentanalysisquery.rb +31 -0
- data/lib/xapi_scraper/models/components/sentimentanalysisquery.rbi +14 -0
- data/lib/xapi_scraper/models/components/sentimentanalysisresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/sentimentanalysisresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/standardresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/standardresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/streammodel.rb +51 -0
- data/lib/xapi_scraper/models/components/streammodel.rbi +26 -0
- data/lib/xapi_scraper/models/components/tweet_type.rb +19 -0
- data/lib/xapi_scraper/models/components/tweet_type.rbi +9 -0
- data/lib/xapi_scraper/models/components/tweetactionresponse.rb +51 -0
- data/lib/xapi_scraper/models/components/tweetactionresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/tweetmodel.rb +518 -0
- data/lib/xapi_scraper/models/components/tweetmodel.rbi +302 -0
- data/lib/xapi_scraper/models/components/tweetthreadbyidbody.rb +53 -0
- data/lib/xapi_scraper/models/components/tweetthreadbyidbody.rbi +26 -0
- data/lib/xapi_scraper/models/components/twitteraccountbasedstandardresponse.rb +58 -0
- data/lib/xapi_scraper/models/components/twitteraccountbasedstandardresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/twitteruseraboutresponse.rb +208 -0
- data/lib/xapi_scraper/models/components/twitteruseraboutresponse.rbi +116 -0
- data/lib/xapi_scraper/models/components/twitteruseraboutstandardresponse.rb +58 -0
- data/lib/xapi_scraper/models/components/twitteruseraboutstandardresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/unfavoritetweetquery.rb +35 -0
- data/lib/xapi_scraper/models/components/unfavoritetweetquery.rbi +14 -0
- data/lib/xapi_scraper/models/components/unfollowuserquery.rb +43 -0
- data/lib/xapi_scraper/models/components/unfollowuserquery.rbi +20 -0
- data/lib/xapi_scraper/models/components/unfollowuserresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/unfollowuserresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/urlmodel.rb +47 -0
- data/lib/xapi_scraper/models/components/urlmodel.rbi +26 -0
- data/lib/xapi_scraper/models/components/userinfo.rb +348 -0
- data/lib/xapi_scraper/models/components/userinfo.rbi +200 -0
- data/lib/xapi_scraper/models/components/usermodel.rb +344 -0
- data/lib/xapi_scraper/models/components/usermodel.rbi +200 -0
- data/lib/xapi_scraper/models/components/usersdetailsresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/usersdetailsresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/usertimelinefillquery.rb +35 -0
- data/lib/xapi_scraper/models/components/usertimelinefillquery.rbi +14 -0
- data/lib/xapi_scraper/models/components/usertimelinepagequery.rb +43 -0
- data/lib/xapi_scraper/models/components/usertimelinepagequery.rbi +20 -0
- data/lib/xapi_scraper/models/components/usertimelinepageresponse.rb +112 -0
- data/lib/xapi_scraper/models/components/usertimelinepageresponse.rbi +56 -0
- data/lib/xapi_scraper/models/components/usertimelineresponse.rb +76 -0
- data/lib/xapi_scraper/models/components/usertimelineresponse.rbi +38 -0
- data/lib/xapi_scraper/models/components/usertweetitem.rb +225 -0
- data/lib/xapi_scraper/models/components/usertweetitem.rbi +122 -0
- data/lib/xapi_scraper/models/components/validationerror.rb +67 -0
- data/lib/xapi_scraper/models/components/validationerror.rbi +38 -0
- data/lib/xapi_scraper/models/components/verifiedfollowersdata.rb +58 -0
- data/lib/xapi_scraper/models/components/verifiedfollowersdata.rbi +26 -0
- data/lib/xapi_scraper/models/components/verifiedfollowersresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/verifiedfollowersresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components/xarticlemodel.rb +305 -0
- data/lib/xapi_scraper/models/components/xarticlemodel.rbi +170 -0
- data/lib/xapi_scraper/models/components/xarticleresponse.rb +47 -0
- data/lib/xapi_scraper/models/components/xarticleresponse.rbi +26 -0
- data/lib/xapi_scraper/models/components.rb +128 -0
- data/lib/xapi_scraper/models/errors/apierror.rb +39 -0
- data/lib/xapi_scraper/models/errors/apierror.rbi +27 -0
- data/lib/xapi_scraper/models/errors/httpvalidationerror.rb +48 -0
- data/lib/xapi_scraper/models/errors/httpvalidationerror.rbi +20 -0
- data/lib/xapi_scraper/models/errors.rb +13 -0
- data/lib/xapi_scraper/models/operations/accountgetbalance_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/accountgetbalance_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/analysissentiment_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/analysissentiment_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/articlesfetch_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/articlesfetch_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/articlesmarkdown_request.rb +31 -0
- data/lib/xapi_scraper/models/operations/articlesmarkdown_request.rbi +14 -0
- data/lib/xapi_scraper/models/operations/articlesmarkdown_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/articlesmarkdown_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiesget_request.rb +34 -0
- data/lib/xapi_scraper/models/operations/communitiesget_request.rbi +14 -0
- data/lib/xapi_scraper/models/operations/communitiesget_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/communitiesget_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiesmembers_request.rb +42 -0
- data/lib/xapi_scraper/models/operations/communitiesmembers_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/communitiesmembers_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/communitiesmembers_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiesmemberspage_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/communitiesmemberspage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiessearch_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/communitiessearch_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiessearchtweets_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/communitiessearchtweets_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiestweets_request.rb +50 -0
- data/lib/xapi_scraper/models/operations/communitiestweets_request.rbi +26 -0
- data/lib/xapi_scraper/models/operations/communitiestweets_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/communitiestweets_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/communitiestweetspage_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/communitiestweetspage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/country.rb +79 -0
- data/lib/xapi_scraper/models/operations/country.rbi +9 -0
- data/lib/xapi_scraper/models/operations/dmconversations_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/dmconversations_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/dmhistory_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/dmhistory_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/dmmedia_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/dmmedia_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/dmsend_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/dmsend_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/dmstatus_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/dmstatus_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/listsmembers_request.rb +38 -0
- data/lib/xapi_scraper/models/operations/listsmembers_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/listsmembers_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/listsmembers_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/listsmemberspage_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/listsmemberspage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/listssearch_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/listssearch_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/listssubscribers_request.rb +38 -0
- data/lib/xapi_scraper/models/operations/listssubscribers_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/listssubscribers_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/listssubscribers_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/liststweets_request.rb +38 -0
- data/lib/xapi_scraper/models/operations/liststweets_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/liststweets_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/liststweets_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/liststweetspage_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/liststweetspage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/searchadvanced_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/searchadvanced_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/searchcashtags_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/searchcashtags_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/searchhashtags_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/searchhashtags_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/timelinestweetsandrepliespage_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/timelinestweetsandrepliespage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/timelinesuser_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/timelinesuser_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/timelinesuser_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/timelinesuser_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/timelinesuserpage_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/timelinesuserpage_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/timelinesuserpage_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/timelinesuserpage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/trendingbycountry_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/trendingbycountry_request.rbi +14 -0
- data/lib/xapi_scraper/models/operations/trendingbycountry_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/trendingbycountry_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/trendingcontents_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/trendingcontents_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/trendingcontents_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/trendingcontents_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/trendingcountries_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/trendingcountries_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/trendingtopics_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/trendingtopics_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/trendingtweets_request.rb +63 -0
- data/lib/xapi_scraper/models/operations/trendingtweets_request.rbi +32 -0
- data/lib/xapi_scraper/models/operations/trendingtweets_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/trendingtweets_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweet_type.rb +19 -0
- data/lib/xapi_scraper/models/operations/tweet_type.rbi +9 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionscreate_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionscreate_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionscreatethread_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionscreatethread_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionscreatewithoutcookie_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionscreatewithoutcookie_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsdeletebatch_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsdeletebatch_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionslike_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsactionslike_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsactionslike_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionslike_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsquote_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsquote_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsretweet_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsretweet_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsretweet_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsretweet_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunlike_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunlike_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunlike_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunlike_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsdetail_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsdetail_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementquotes_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementquotes_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementquotespage_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementquotespage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_request.rb +39 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementretweeterspage_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsengagementretweeterspage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetslookup_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetslookup_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsrepliespage_request.rb +35 -0
- data/lib/xapi_scraper/models/operations/tweetsrepliespage_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/tweetsrepliespage_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsrepliespage_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetssimilar_request.rb +30 -0
- data/lib/xapi_scraper/models/operations/tweetssimilar_request.rbi +14 -0
- data/lib/xapi_scraper/models/operations/tweetssimilar_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetssimilar_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/tweetsthread_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/tweetsthread_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersfollow_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersfollow_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersfollowerslist_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersfollowerslist_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersfollowersverified_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersfollowersverified_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersfollowinglist_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersfollowinglist_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersgetabout_request.rb +31 -0
- data/lib/xapi_scraper/models/operations/usersgetabout_request.rbi +14 -0
- data/lib/xapi_scraper/models/operations/usersgetabout_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/usersgetabout_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersgetaccountbased_response.rb +54 -0
- data/lib/xapi_scraper/models/operations/usersgetaccountbased_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersgetbyids_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersgetbyids_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersgetbyusernames_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersgetbyusernames_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersgetstatuses_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersgetstatuses_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/userssearch_request.rb +39 -0
- data/lib/xapi_scraper/models/operations/userssearch_request.rbi +20 -0
- data/lib/xapi_scraper/models/operations/userssearch_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/userssearch_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersunfollow_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersunfollow_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations/usersverifyaccount_response.rb +51 -0
- data/lib/xapi_scraper/models/operations/usersverifyaccount_response.rbi +32 -0
- data/lib/xapi_scraper/models/operations.rb +127 -0
- data/lib/xapi_scraper/replies.rb +235 -0
- data/lib/xapi_scraper/sdk_hooks/hooks.rb +99 -0
- data/lib/xapi_scraper/sdk_hooks/registration.rb +34 -0
- data/lib/xapi_scraper/sdk_hooks/types.rb +180 -0
- data/lib/xapi_scraper/sdkconfiguration.rb +107 -0
- data/lib/xapi_scraper/sdkconfiguration.rbi +83 -0
- data/lib/xapi_scraper/search.rb +610 -0
- data/lib/xapi_scraper/timelines.rb +805 -0
- data/lib/xapi_scraper/trending.rb +888 -0
- data/lib/xapi_scraper/tweets.rb +801 -0
- data/lib/xapi_scraper/users.rb +1748 -0
- data/lib/xapi_scraper/utils/forms.rb +232 -0
- data/lib/xapi_scraper/utils/headers.rb +82 -0
- data/lib/xapi_scraper/utils/query_params.rb +167 -0
- data/lib/xapi_scraper/utils/request_bodies.rb +79 -0
- data/lib/xapi_scraper/utils/retries.rb +139 -0
- data/lib/xapi_scraper/utils/security.rb +158 -0
- data/lib/xapi_scraper/utils/url.rb +124 -0
- data/lib/xapi_scraper/utils/utils.rb +241 -0
- metadata +720 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 924ea3a4a6d4240c3696c32224aa6196ef1b439e5c9ec01aa85fd98e246bcc08
|
|
4
|
+
data.tar.gz: 29f921c2233d149f330559ad02939397a59b80dc73a95769707070ef8e9df3cf
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 27ab198aa7082a6a3ec4171920fa3f0a6f43040736ff55f4cf43364cf9c1ad94334ce343fa709527f3cf93f6a34198242a17422e4e41b0433e83f566837c4ded
|
|
7
|
+
data.tar.gz: 807da824f554ee1e5b6cddfc3561e0f82dbc8c5785172fbb043ede8b2c7b9e2aec4e7a9f6d8b5d04df08d39196eeee35781887f1415e9dbcee562494488f02c5
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
module Crystalline
|
|
4
|
+
module Enum
|
|
5
|
+
mixes_in_class_methods(ClassMethods)
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
def enums(&blk); end
|
|
9
|
+
def open!; end
|
|
10
|
+
def open?; end
|
|
11
|
+
def deserialize(val); end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def serialize; end
|
|
15
|
+
def known?; end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Crystalline
|
|
7
|
+
module MetadataFields
|
|
8
|
+
|
|
9
|
+
class Field
|
|
10
|
+
attr_accessor :name, :type, :metadata
|
|
11
|
+
|
|
12
|
+
def initialize(name, type, metadata)
|
|
13
|
+
@name = name
|
|
14
|
+
@type = type
|
|
15
|
+
@metadata = metadata
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module ClassMethods
|
|
20
|
+
|
|
21
|
+
def fields
|
|
22
|
+
@__fields__ = [] if @__fields__.nil?
|
|
23
|
+
|
|
24
|
+
@__fields__
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def field(field_name, type, metadata = {})
|
|
28
|
+
attr_accessor field_name
|
|
29
|
+
|
|
30
|
+
fields << Field.new(field_name, type, metadata)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def field_augmented?
|
|
34
|
+
true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def unmarshal_single(field_type, value, format_metadata = nil)
|
|
38
|
+
decoder = format_metadata.fetch(:decoder, nil)
|
|
39
|
+
|
|
40
|
+
# Delegate complex Crystalline types to unmarshal_json
|
|
41
|
+
if field_type.is_a?(Crystalline::DiscriminatedUnion) ||
|
|
42
|
+
Crystalline::Utils.arr?(field_type) ||
|
|
43
|
+
Crystalline::Utils.hash?(field_type) ||
|
|
44
|
+
Crystalline::Utils.union?(field_type)
|
|
45
|
+
return Crystalline.unmarshal_json(value, field_type)
|
|
46
|
+
elsif field_type.instance_of?(Class) && field_type.include?(::Crystalline::MetadataFields)
|
|
47
|
+
return field_type.from_dict(value)
|
|
48
|
+
elsif field_type.to_s == 'Date'
|
|
49
|
+
return Date.parse(value)
|
|
50
|
+
elsif field_type.to_s == 'DateTime'
|
|
51
|
+
return DateTime.parse(value)
|
|
52
|
+
elsif field_type.to_s == 'Object'
|
|
53
|
+
if value.is_a?(::String)
|
|
54
|
+
trimmed = value.lstrip
|
|
55
|
+
if trimmed.start_with?('{') || trimmed.start_with?('[')
|
|
56
|
+
# rubocop:disable Lint/SuppressedException
|
|
57
|
+
begin
|
|
58
|
+
value = JSON.parse(value)
|
|
59
|
+
rescue TypeError, JSON::ParserError
|
|
60
|
+
end
|
|
61
|
+
# rubocop:enable Lint/SuppressedException
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
return value
|
|
65
|
+
elsif field_type.to_s == 'Float'
|
|
66
|
+
return value.to_f
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
if decoder.nil?
|
|
70
|
+
value
|
|
71
|
+
else
|
|
72
|
+
decoder.call(value)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def from_dict(d)
|
|
77
|
+
to_build = {}
|
|
78
|
+
|
|
79
|
+
# Collect lookup keys for regular fields so we can identify additional properties later
|
|
80
|
+
known_keys = {}
|
|
81
|
+
additional_props_fields = []
|
|
82
|
+
fields.each do |field|
|
|
83
|
+
format_metadata = field.metadata.fetch(:format_json, {})
|
|
84
|
+
if format_metadata.fetch(:additional_properties, false)
|
|
85
|
+
additional_props_fields << field
|
|
86
|
+
else
|
|
87
|
+
lookup = format_metadata.fetch(:letter_case, nil).call
|
|
88
|
+
known_keys[lookup] = true
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Process regular fields
|
|
93
|
+
(fields - additional_props_fields).each do |field|
|
|
94
|
+
key = field.name
|
|
95
|
+
format_metadata = field.metadata.fetch(:format_json, {})
|
|
96
|
+
field_type = field.type
|
|
97
|
+
|
|
98
|
+
lookup = format_metadata.fetch(:letter_case, nil).call
|
|
99
|
+
value = d[lookup]
|
|
100
|
+
if ::Crystalline::Utils.nilable? field_type
|
|
101
|
+
if value == 'null'
|
|
102
|
+
to_build[key] = nil
|
|
103
|
+
next
|
|
104
|
+
end
|
|
105
|
+
field_type = ::Crystalline::Utils.nilable_of(field_type)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# If field is not nilable, and the value is not in the dict, raise a KeyError
|
|
109
|
+
raise KeyError, "key #{lookup} not found in hash" if value.nil? && !::Crystalline::Utils.nilable?(field.type)
|
|
110
|
+
# If field is nilable, and the value is not in the dict, just move to the next field
|
|
111
|
+
next if value.nil?
|
|
112
|
+
|
|
113
|
+
if field_type.is_a?(Crystalline::DiscriminatedUnion)
|
|
114
|
+
to_build[key] = field_type.parse(value)
|
|
115
|
+
elsif Crystalline::Utils.arr? field_type
|
|
116
|
+
inner_type = Crystalline::Utils.arr_of(field_type)
|
|
117
|
+
unmarshalled_array = value.map { |f| unmarshal_single(inner_type, f, format_metadata) }
|
|
118
|
+
to_build[key] = unmarshalled_array
|
|
119
|
+
elsif Crystalline::Utils.hash? field_type
|
|
120
|
+
val_type = Crystalline::Utils.hash_of(field_type)
|
|
121
|
+
|
|
122
|
+
# rubocop:disable Style/HashTransformValues
|
|
123
|
+
unmarshalled_hash = value.map { |k, v| [k, unmarshal_single(val_type, v, format_metadata)] }.to_h
|
|
124
|
+
# rubocop:enable Style/HashTransformValues
|
|
125
|
+
to_build[key] = unmarshalled_hash
|
|
126
|
+
elsif Crystalline::Utils.union? field_type
|
|
127
|
+
discriminator = field.metadata.fetch(:discriminator, nil)
|
|
128
|
+
discriminator_mapping = field.metadata.fetch(:discriminator_mapping, nil)
|
|
129
|
+
if !discriminator.nil?
|
|
130
|
+
discriminator_value = value.fetch(discriminator)
|
|
131
|
+
if !discriminator_mapping.nil?
|
|
132
|
+
# Use explicit mapping from discriminator value to type
|
|
133
|
+
type_to_deserialize = discriminator_mapping[discriminator_value]
|
|
134
|
+
else
|
|
135
|
+
# Fallback: try to match discriminator value against type name
|
|
136
|
+
type_to_deserialize = Crystalline::Utils.get_union_types(field_type).find { |t| t.name.split('::').last == discriminator_value }
|
|
137
|
+
end
|
|
138
|
+
to_build[key] = Crystalline.unmarshal_json(value, type_to_deserialize)
|
|
139
|
+
else
|
|
140
|
+
union_types = Crystalline::Utils.get_union_types(field_type)
|
|
141
|
+
union_types = union_types.sort_by { |klass| Crystalline.non_nilable_attr_count(klass) }
|
|
142
|
+
|
|
143
|
+
if Crystalline.union_strategy == :populated_fields
|
|
144
|
+
to_build[key] = Crystalline.unmarshal_union_populated_fields(value, union_types)
|
|
145
|
+
else
|
|
146
|
+
union_types.each do |union_type|
|
|
147
|
+
begin
|
|
148
|
+
to_build[key] = Crystalline.unmarshal_json(value, union_type)
|
|
149
|
+
rescue TypeError
|
|
150
|
+
next
|
|
151
|
+
rescue NoMethodError
|
|
152
|
+
next
|
|
153
|
+
rescue KeyError
|
|
154
|
+
next
|
|
155
|
+
end
|
|
156
|
+
break
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
elsif field_type.instance_of?(Class) && field_type.include?(::Crystalline::MetadataFields)
|
|
161
|
+
to_build[key] = Crystalline.unmarshal_json(value, field_type)
|
|
162
|
+
else
|
|
163
|
+
to_build[key] = unmarshal_single(field_type, value, format_metadata)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Process additional properties fields: collect remaining keys from the dict
|
|
168
|
+
additional_props_fields.each do |field|
|
|
169
|
+
key = field.name
|
|
170
|
+
format_metadata = field.metadata.fetch(:format_json, {})
|
|
171
|
+
field_type = field.type
|
|
172
|
+
|
|
173
|
+
remaining = d.reject { |k, _| known_keys.key?(k) }
|
|
174
|
+
if remaining.empty?
|
|
175
|
+
next if ::Crystalline::Utils.nilable?(field.type)
|
|
176
|
+
|
|
177
|
+
raise KeyError, 'no additional properties found in hash'
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
inner_field_type = field_type
|
|
181
|
+
inner_field_type = ::Crystalline::Utils.nilable_of(inner_field_type) if ::Crystalline::Utils.nilable?(inner_field_type)
|
|
182
|
+
if Crystalline::Utils.hash?(inner_field_type)
|
|
183
|
+
val_type = Crystalline::Utils.hash_of(inner_field_type)
|
|
184
|
+
# rubocop:disable Style/HashTransformValues
|
|
185
|
+
to_build[key] = remaining.map { |k, v| [k, unmarshal_single(val_type, v, format_metadata)] }.to_h
|
|
186
|
+
# rubocop:enable Style/HashTransformValues
|
|
187
|
+
else
|
|
188
|
+
to_build[key] = remaining
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
new(**to_build)
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def initialize
|
|
197
|
+
instance = allocate
|
|
198
|
+
fields.each { |mod| instance.singleton_class.include(mod) }
|
|
199
|
+
instance.send(:initialize)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def self.included(base)
|
|
203
|
+
base.extend(ClassMethods)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def fields
|
|
207
|
+
self.class.fields
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def field(field_name)
|
|
211
|
+
fields.each do |f|
|
|
212
|
+
return f if f.name == field_name
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def marshal_single(field)
|
|
217
|
+
if field.class.include? ::Crystalline::MetadataFields
|
|
218
|
+
field.to_dict
|
|
219
|
+
else
|
|
220
|
+
if ::Crystalline.needs_string_conversion field
|
|
221
|
+
::Crystalline.json_encode field
|
|
222
|
+
else
|
|
223
|
+
field
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def to_dict
|
|
229
|
+
result = {}
|
|
230
|
+
fields.sort_by(&:name).each do |field|
|
|
231
|
+
format_json_meta = field.metadata[:format_json]
|
|
232
|
+
required = !format_json_meta.nil? && format_json_meta.include?(:required)
|
|
233
|
+
is_additional_props = !format_json_meta.nil? && format_json_meta.fetch(:additional_properties, false)
|
|
234
|
+
|
|
235
|
+
if !format_json_meta.nil? && format_json_meta.include?(:letter_case)
|
|
236
|
+
key = format_json_meta[:letter_case].call(field.name)
|
|
237
|
+
else
|
|
238
|
+
key = field.name
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
f = send(field.name)
|
|
242
|
+
next if f.nil? && !required
|
|
243
|
+
result[key] = nil if f.nil? && required
|
|
244
|
+
|
|
245
|
+
# Flatten additional properties into the parent object
|
|
246
|
+
if is_additional_props && f.is_a?(::Hash)
|
|
247
|
+
f.each { |k, v| result[k] = marshal_single(v) }
|
|
248
|
+
elsif f.is_a? ::Array
|
|
249
|
+
result[key] = f.map { |o| marshal_single(o) }
|
|
250
|
+
elsif f.is_a? ::Hash
|
|
251
|
+
result[key] = f.transform_values { |v| marshal_single(v) }
|
|
252
|
+
else
|
|
253
|
+
result[key] = marshal_single(f)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
result
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def to_json(*args)
|
|
260
|
+
JSON.generate(to_dict, *args)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Crystalline
|
|
7
|
+
@union_strategy = :populated_fields
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
attr_accessor :union_strategy
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.to_dict(complex)
|
|
14
|
+
if complex.is_a?(::Array)
|
|
15
|
+
complex.map { |v| Crystalline.to_dict(v) }
|
|
16
|
+
elsif complex.is_a?(::Hash)
|
|
17
|
+
complex.transform_values { |v| Crystalline.to_dict(v) }
|
|
18
|
+
elsif complex.respond_to?(:class) && complex.class.include?(::Crystalline::MetadataFields)
|
|
19
|
+
complex.to_dict
|
|
20
|
+
else
|
|
21
|
+
json_encode(complex, primitives: false)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.needs_string_conversion(val)
|
|
26
|
+
val.class.respond_to?(:enums) || val.is_a?(DateTime) || val.nil?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.to_json(complex)
|
|
30
|
+
JSON.dump(to_dict(complex))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.unmarshal_json(data, type)
|
|
34
|
+
if Crystalline::Utils.nilable?(type)
|
|
35
|
+
type = Crystalline::Utils.nilable_of(type)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if type.is_a?(Crystalline::DiscriminatedUnion)
|
|
39
|
+
type.parse(data)
|
|
40
|
+
elsif type.instance_of?(Class) && type.include?(::Crystalline::MetadataFields)
|
|
41
|
+
type.from_dict(data)
|
|
42
|
+
elsif Crystalline::Utils.union?(type)
|
|
43
|
+
union_types = Crystalline::Utils.get_union_types(type)
|
|
44
|
+
union_types = union_types.sort_by { |klass| Crystalline.non_nilable_attr_count(klass) }
|
|
45
|
+
|
|
46
|
+
if Crystalline.union_strategy == :populated_fields
|
|
47
|
+
Crystalline.unmarshal_union_populated_fields(data, union_types)
|
|
48
|
+
else
|
|
49
|
+
Crystalline.unmarshal_union_left_to_right(data, union_types)
|
|
50
|
+
end
|
|
51
|
+
elsif Crystalline::Utils.arr?(type)
|
|
52
|
+
data.map { |v| Crystalline.unmarshal_json(v, Crystalline::Utils.arr_of(type)) }
|
|
53
|
+
elsif Crystalline::Utils.hash?(type)
|
|
54
|
+
data.transform_values { |v| Crystalline.unmarshal_json(v, Crystalline::Utils.hash_of(type)) }
|
|
55
|
+
elsif Crystalline::Utils.nilable?(type) && data == "null"
|
|
56
|
+
nil
|
|
57
|
+
elsif Crystalline::Utils.boolean?(type)
|
|
58
|
+
Crystalline::Utils.to_boolean(data)
|
|
59
|
+
elsif type.is_a?(Class) && type < T::Enum
|
|
60
|
+
type.deserialize(data)
|
|
61
|
+
elsif type.is_a?(Class) && type.respond_to?(:enums) && type.respond_to?(:deserialize)
|
|
62
|
+
type.deserialize(data)
|
|
63
|
+
else
|
|
64
|
+
data
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.json_encode(val, primitives: true)
|
|
69
|
+
if val.class.respond_to?(:enums)
|
|
70
|
+
val.serialize
|
|
71
|
+
elsif val.is_a?(DateTime)
|
|
72
|
+
val.strftime("%Y-%m-%dT%H:%M:%S.%NZ").sub(/(\.\d*[1-9])0+Z\z/, "\\1Z").sub(/\.0+Z\z/, "Z")
|
|
73
|
+
elsif val.nil?
|
|
74
|
+
nil
|
|
75
|
+
elsif primitives
|
|
76
|
+
val.to_s
|
|
77
|
+
else
|
|
78
|
+
val
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def self.unmarshal_union_left_to_right(data, union_types)
|
|
83
|
+
union_types.each do |union_type|
|
|
84
|
+
return Crystalline.unmarshal_json(data, union_type)
|
|
85
|
+
rescue TypeError
|
|
86
|
+
next
|
|
87
|
+
rescue NoMethodError
|
|
88
|
+
next
|
|
89
|
+
rescue KeyError
|
|
90
|
+
next
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
nil
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.unmarshal_union_populated_fields(data, union_types)
|
|
97
|
+
best_value = nil
|
|
98
|
+
best_matched = -1
|
|
99
|
+
best_inexact = 0
|
|
100
|
+
best_unmatched = 0
|
|
101
|
+
|
|
102
|
+
union_types.each do |union_type|
|
|
103
|
+
value = Crystalline.unmarshal_json(data, union_type)
|
|
104
|
+
matched, inexact, unmatched = count_matched_fields(value, data)
|
|
105
|
+
|
|
106
|
+
if best_value.nil? ||
|
|
107
|
+
matched > best_matched ||
|
|
108
|
+
(matched == best_matched && inexact < best_inexact) ||
|
|
109
|
+
(matched == best_matched && inexact == best_inexact && unmatched < best_unmatched)
|
|
110
|
+
best_value = value
|
|
111
|
+
best_matched = matched
|
|
112
|
+
best_inexact = inexact
|
|
113
|
+
best_unmatched = unmatched
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
rescue TypeError
|
|
117
|
+
next
|
|
118
|
+
rescue NoMethodError
|
|
119
|
+
next
|
|
120
|
+
rescue KeyError
|
|
121
|
+
next
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
best_value
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def self.count_matched_fields(value, raw_data)
|
|
128
|
+
matched = 0
|
|
129
|
+
inexact = 0
|
|
130
|
+
unmatched = 0
|
|
131
|
+
|
|
132
|
+
if value.is_a?(Crystalline::Unknown)
|
|
133
|
+
return [0, 0, 0]
|
|
134
|
+
elsif value.class.include?(::Crystalline::MetadataFields)
|
|
135
|
+
value.fields.each do |field|
|
|
136
|
+
format_metadata = field.metadata.fetch(:format_json, {})
|
|
137
|
+
lookup = format_metadata.fetch(:letter_case, nil)&.call
|
|
138
|
+
field_val = value.send(field.name)
|
|
139
|
+
|
|
140
|
+
if raw_data.is_a?(::Hash) && lookup && raw_data.key?(lookup)
|
|
141
|
+
if field_val.class.include?(::Crystalline::MetadataFields) && raw_data[lookup].is_a?(::Hash)
|
|
142
|
+
nested_matched, nested_inexact, nested_unmatched = count_matched_fields(field_val, raw_data[lookup])
|
|
143
|
+
matched += nested_matched
|
|
144
|
+
inexact += nested_inexact
|
|
145
|
+
unmatched += nested_unmatched
|
|
146
|
+
else
|
|
147
|
+
matched += 1
|
|
148
|
+
if field_val.respond_to?(:known?) && !field_val.known?
|
|
149
|
+
inexact += 1
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
elsif !::Crystalline::Utils.nilable?(field.type)
|
|
153
|
+
unmatched += 1
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
elsif value.is_a?(::Array)
|
|
157
|
+
matched = value.length
|
|
158
|
+
elsif value.is_a?(::Hash)
|
|
159
|
+
matched = value.length
|
|
160
|
+
else
|
|
161
|
+
matched = 1
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
[matched, inexact, unmatched]
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def self.non_nilable_attr_count(klass)
|
|
168
|
+
# somewhat sane sort ordering for Union deserialization.
|
|
169
|
+
# All Crystalline objects return the number of non-nilable fields
|
|
170
|
+
# All non-string primitives return 2
|
|
171
|
+
# All arrays and hashes return 1
|
|
172
|
+
# Strings return 0 (since any data can deserialize to a string, it should be our last attempt)
|
|
173
|
+
if klass.respond_to?(:fields)
|
|
174
|
+
return -1 *
|
|
175
|
+
klass.fields.count do |field|
|
|
176
|
+
!::Crystalline::Utils.nilable?(field.type)
|
|
177
|
+
end
|
|
178
|
+
else
|
|
179
|
+
if klass == String
|
|
180
|
+
return 0
|
|
181
|
+
elsif klass.is_a?(T::Types::TypedArray) || klass.is_a?(T::Types::TypedHash)
|
|
182
|
+
return 1
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
return 2
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Crystalline
|
|
7
|
+
class Array
|
|
8
|
+
attr_accessor :inner_type
|
|
9
|
+
|
|
10
|
+
def initialize(inner_type)
|
|
11
|
+
@inner_type = inner_type
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Hash
|
|
16
|
+
attr_accessor :key_type, :value_type
|
|
17
|
+
|
|
18
|
+
def initialize(key_type, value_type)
|
|
19
|
+
@key_type = key_type
|
|
20
|
+
@value_type = value_type
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Union
|
|
25
|
+
attr_accessor :types
|
|
26
|
+
|
|
27
|
+
def initialize(*types)
|
|
28
|
+
@types = types
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class Nilable
|
|
33
|
+
attr_accessor :inner_type
|
|
34
|
+
|
|
35
|
+
def initialize(inner_type)
|
|
36
|
+
@inner_type = inner_type
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Boolean
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Wraps an unrecognized payload from an open discriminated union.
|
|
44
|
+
# Produced when the discriminator value is missing, unknown, or schema validation fails.
|
|
45
|
+
class Unknown
|
|
46
|
+
attr_reader :raw
|
|
47
|
+
|
|
48
|
+
def initialize(raw:)
|
|
49
|
+
@raw = raw
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def unknown?
|
|
53
|
+
true
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Forward-compatible discriminated union parser.
|
|
58
|
+
# Known discriminator values are deserialized to their mapped types.
|
|
59
|
+
# Unknown or invalid payloads are captured as Crystalline::Unknown.
|
|
60
|
+
class DiscriminatedUnion
|
|
61
|
+
attr_reader :discriminator, :variants
|
|
62
|
+
|
|
63
|
+
def initialize(discriminator, variants)
|
|
64
|
+
@discriminator = discriminator
|
|
65
|
+
@variants = variants
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def parse(payload)
|
|
69
|
+
unless payload.is_a?(::Hash)
|
|
70
|
+
return Unknown.new(raw: payload)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
disc_value = payload[@discriminator]
|
|
74
|
+
unless disc_value.is_a?(::String)
|
|
75
|
+
return Unknown.new(raw: payload)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
variant_type = @variants[disc_value]
|
|
79
|
+
unless variant_type
|
|
80
|
+
return Unknown.new(raw: payload)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
begin
|
|
84
|
+
Crystalline.unmarshal_json(payload, variant_type)
|
|
85
|
+
rescue StandardError
|
|
86
|
+
Unknown.new(raw: payload)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def self.unknown?(value)
|
|
92
|
+
value.is_a?(Unknown)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
module Enum
|
|
96
|
+
def self.included(base)
|
|
97
|
+
base.extend(ClassMethods)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def initialize(val)
|
|
101
|
+
if self.class.instance_methods(false).include?(:initialize)
|
|
102
|
+
super(val)
|
|
103
|
+
else
|
|
104
|
+
@val = val
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
module ClassMethods
|
|
109
|
+
def enums(&blk)
|
|
110
|
+
@mapping = {}
|
|
111
|
+
|
|
112
|
+
yield
|
|
113
|
+
constants(false).each do |const_name|
|
|
114
|
+
instance = const_get(const_name, false)
|
|
115
|
+
unless instance.is_a? self
|
|
116
|
+
raise 'Enum constants must be instances of the Enum class (e.g. `Foo = new`)'
|
|
117
|
+
end
|
|
118
|
+
@mapping[instance.serialize] = instance
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def open!
|
|
123
|
+
@open = true
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def open?
|
|
127
|
+
@open == true
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def deserialize(val)
|
|
131
|
+
if @mapping.include? val
|
|
132
|
+
@mapping[val]
|
|
133
|
+
elsif open?
|
|
134
|
+
new(val)
|
|
135
|
+
else
|
|
136
|
+
raise "Invalid value for enum: #{val}"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def serialize
|
|
142
|
+
@val
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def to_s
|
|
146
|
+
serialize.to_s
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def inspect
|
|
150
|
+
"#<#{self.class} #{serialize.inspect}>"
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def known?
|
|
154
|
+
self.class.instance_variable_get(:@mapping)&.value?(self) || false
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def ==(other)
|
|
158
|
+
other = other.serialize if other.is_a?(self.class)
|
|
159
|
+
@val == other
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def eql?(other)
|
|
163
|
+
self == other
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def hash
|
|
167
|
+
@val.hash
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: false
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Crystalline
|
|
7
|
+
module Utils
|
|
8
|
+
def self.arr?(t)
|
|
9
|
+
if t.instance_of? Crystalline::Array
|
|
10
|
+
return true
|
|
11
|
+
end
|
|
12
|
+
false
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.arr_of(t)
|
|
16
|
+
t.inner_type
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.hash?(t)
|
|
20
|
+
if t.instance_of? Crystalline::Hash
|
|
21
|
+
return true
|
|
22
|
+
end
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.hash_of(t)
|
|
27
|
+
t.value_type
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.nilable?(t)
|
|
31
|
+
if t.instance_of? Crystalline::Nilable
|
|
32
|
+
return true
|
|
33
|
+
end
|
|
34
|
+
if t.instance_of? Crystalline::Union
|
|
35
|
+
return t.types.any? { |tt| tt.instance_of? Crystalline::Nilable }
|
|
36
|
+
end
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.nilable_of(t)
|
|
41
|
+
|
|
42
|
+
if nilable? t
|
|
43
|
+
return t.inner_type
|
|
44
|
+
end
|
|
45
|
+
nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.union?(t)
|
|
49
|
+
return t.instance_of? Crystalline::Union
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.get_union_types(t)
|
|
53
|
+
t.types
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.boolean?(t)
|
|
57
|
+
t.instance_of? Crystalline::Boolean
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.to_boolean(value)
|
|
61
|
+
case value
|
|
62
|
+
when true, false
|
|
63
|
+
value
|
|
64
|
+
else
|
|
65
|
+
raise TypeError, "Cannot convert #{value.inspect} to boolean. The value is of type #{value.class}"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|